Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScanYara Safe Key Collection #412

Merged
merged 5 commits into from
Dec 1, 2023
Merged

ScanYara Safe Key Collection #412

merged 5 commits into from
Dec 1, 2023

Conversation

phutelmyer
Copy link
Contributor

@phutelmyer phutelmyer commented Nov 13, 2023

Describe the change
This PR makes a couple changes that assists in YARA loading issues:

  1. Ensures that if a backend.yml exists without a specific key (e.g., yara.compiled), a default is used to prevent an unhandled exception.

YARA failure prior to fix:

strelka-backend-1      | 2023-11-13 18:08:22 - [ERROR] root [strelka.scan_wrapper]: ScanYara: unhandled exception while scanning uid a197de79-b500-4cb0-ae4f-64a14f7c54e6 (see traceback below)
strelka-backend-1      | Traceback (most recent call last):
strelka-backend-1      |   File "/usr/local/lib/python3.10/dist-packages/strelka-0.0.0-py3.10.egg/strelka/strelka.py", line 779, in scan_wrapper
strelka-backend-1      |     self.scan(data, file, options, expire_at)
strelka-backend-1      |   File "/usr/local/lib/python3.10/dist-packages/strelka-0.0.0-py3.10.egg/strelka/scanners/scan_yara.py", line 58, in scan
strelka-backend-1      |     self.load_yara_rules(options)
strelka-backend-1      |   File "/usr/local/lib/python3.10/dist-packages/strelka-0.0.0-py3.10.egg/strelka/scanners/scan_yara.py", line 130, in load_yara_rules
strelka-backend-1      |     if compiled.get("enabled", False):
strelka-backend-1      | AttributeError: 'NoneType' object has no attribute 'get'
  1. A warning is provided to the user if an issue loading YARA rules is observed. This prevents the user from needing prior knowledge of needing to look at yara.flags for potential exceptions.
backend-1      | *************************************************
backend-1      | * WARNING: YARA File Loading Issue Detected     *
backend-1      | *************************************************
backend-1      | There was an issue loading the compiled YARA file. Please check that all YARA rules can be
backend-1      | successfully compiled. Additionally, verify the 'ScanYara' configuration in Backend.yaml to
backend-1      | ensure the targeted path is correct. This issue needs to be resolved for proper scanning
backend-1      | functionality.
backend-1      | 
backend-1      | Error: /etc/strelka/yara/rules.yara(38): undefined identifier "is__elf"
backend-1      | *************************************************
  1. Added a recommendation to the README which recommends users precompile their YARA rules prior to Strelka start.

Describe testing procedures

No unexpected errors / warnings were thrown and files were successfully scanned.

Sample output
N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of and tested my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@phutelmyer phutelmyer merged commit 6d60844 into master Dec 1, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant