Skip to content

Commit

Permalink
Update yara_analyzer.py - Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nusantara-self authored Feb 28, 2025
1 parent 102ce4a commit b2760a4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions analyzers/Yara/yara_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,15 @@ def download_rules_from_github_url(self, url, token):
def __init__(self):
Analyzer.__init__(self)

self.rulepaths = self.get_param('config.rules', None, 'No paths for rules provided.')
self.rulepaths = self.get_param('config.rules', [], 'No paths for rules provided.')
if not self.rulepaths:
self.rulepaths = [] # Ensure it's a list even if nothing was provided
elif isinstance(self.rulepaths, str):
self.rulepaths = [self.rulepaths]

# Filter out any None values from the list
self.rulepaths = [rp for rp in self.rulepaths if rp is not None and rp != '']

self.github_urls = self.get_param('config.github_urls', None, 'No GitHub URLs provided.')
self.github_token = self.get_param('config.github_token', None, 'No GitHub PAT provided.')

Expand Down Expand Up @@ -238,7 +241,7 @@ def check(self, file_path):
decoded_strings = []
for s in match.strings:
try:
matched_text = s[2].decode(errors='ignore')
matched_text = s.data.decode(errors='ignore')
except Exception as e:
matched_text = f"<decoding error: {str(e)}>"

Expand Down Expand Up @@ -324,4 +327,4 @@ def run(self):


if __name__ == '__main__':
YaraAnalyzer().run()
YaraAnalyzer().run()

0 comments on commit b2760a4

Please sign in to comment.