Skip to content

Commit

Permalink
Compress default rules payload before sending
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklongsd committed Aug 30, 2022
1 parent 83cdcfe commit 405c966
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sdcclient/secure/_falco_rules_files_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil

import yaml
import zlib

from sdcclient._common import _SdcCommon

Expand Down Expand Up @@ -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()]
Expand Down

0 comments on commit 405c966

Please sign in to comment.