From 405c9666e4d9b4630e8caab51e6695172435fb5e Mon Sep 17 00:00:00 2001 From: Jack Long Date: Tue, 30 Aug 2022 09:47:50 -0400 Subject: [PATCH] Compress default rules payload before sending --- sdcclient/secure/_falco_rules_files_old.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sdcclient/secure/_falco_rules_files_old.py b/sdcclient/secure/_falco_rules_files_old.py index a6da3ac1..57fa9e81 100644 --- a/sdcclient/secure/_falco_rules_files_old.py +++ b/sdcclient/secure/_falco_rules_files_old.py @@ -3,6 +3,7 @@ import shutil import yaml +import zlib from sdcclient._common import _SdcCommon @@ -309,8 +310,12 @@ def _set_falco_rules_files(self, kind, rules_files): if "defaultPolicies" in rules_files: obj["defaultPolicies"] = rules_files["defaultPolicies"] - res = self.http.put(self.url + '/api/settings/falco/{}RulesFiles'.format(kind), headers=self.hdrs, - data=json.dumps(payload[1]), verify=self.ssl_verify) + headers = self.hdrs + headers['content-encoding'] = 'gzip' + data = zlib.compress(json.dumps(payload[1])) + + res = self.http.put(self.url + '/api/settings/falco/{}RulesFiles'.format(kind), headers, + data, verify=self.ssl_verify) if not self._checkResponse(res): return [False, self.lasterr] return [True, res.json()]