Skip to content

Commit

Permalink
Rename downloaded temp malware rules file (#3602)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Huth <mhuth@redhat.com>
  • Loading branch information
mhuth committed Nov 23, 2022
1 parent 04ddde3 commit 0fe2a26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions insights/client/apps/malware_detection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def _get_rules(self):
# malware-detection client exits.
# However it can happen that the rules file isn't removed for some reason, so remove any existing
# rules files before beginning a new scan, otherwise they may show up as matches in the scan results.
old_rules_files = glob('/tmp/tmp_malware-detection-client_rules.*')
old_rules_files = glob('/tmp/.tmpsigs*')
for old_rules_file in old_rules_files:
logger.debug("Removing old rules file %s", old_rules_file)
os.remove(old_rules_file)
Expand Down Expand Up @@ -680,7 +680,7 @@ def _get_rules(self):
logger.error("Unable to download rules from %s: %s", self.rules_location, str(e))
exit(constants.sig_kill_bad)

self.temp_rules_file = NamedTemporaryFile(prefix='tmp_malware-detection-client_rules.', mode='wb', delete=True)
self.temp_rules_file = NamedTemporaryFile(prefix='.tmpsigs', mode='wb', delete=True)
self.temp_rules_file.write(response.content)
self.temp_rules_file.flush()
return self.temp_rules_file.name
Expand Down
2 changes: 1 addition & 1 deletion insights/tests/client/apps/test_malware_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
TEMP_TEST_DIR = "/tmp/malware-detection_test_dir_%s" % RANDOM_STRING

YARA = '/bin/yara' # Fake yara executable
RULES_FILE = os.path.join(TEMP_TEST_DIR, 'rules.yar')
RULES_FILE = os.path.join(TEMP_TEST_DIR, '.tmpsigs.yar')
TEST_RULE_FILE = os.path.join(TEMP_TEST_DIR, 'test-rule.yar')
TEST_RULE_SCRIPT = os.path.join(TEMP_TEST_DIR, 'test-rule_process_match.sh')
CONFIG = yaml.safe_load(DEFAULT_MALWARE_CONFIG) # Config 'returned' from _load_config
Expand Down

0 comments on commit 0fe2a26

Please sign in to comment.