Integrate signatures from unprotect.it
extract Yara and Capa rules from here periodically and add to the respective tools: https://unprotect.it/api/detection_rules/
This issue has been marked as stale because it has had no activity for 10 days. If you are still working on this, please provide some updates.
This is a simple task, we need to integrate this in the already existing Capa and Yara analyzers
Hi @mlodic,
Thanks for clarifying that this is a simple task.
Before starting implementation, I’d like to first study how the existing Capa and Yara analyzers currently load and manage rules, and then propose a minimal and safe way to integrate rules from unprotect.it without affecting existing behavior.
My plan is:
- Inspect current Capa and Yara analyzers to understand rule loading flow
- Review the unprotect.it detection_rules API structure
- Propose where and how the integration should happen (initially without scheduling, if acceptable)
- Share the approach before writing the full implementation
If this approach sounds good, I’d be happy to work on it.
Please let me know if you’d like me to focus on Yara or Capa first.
Thanks! — Gaganpreet Kaur
feel free to proceed with whatever you prefer
@mlodic Thanks! I’ll start by reviewing the existing Yara and Capa analyzers to understand how rules are currently loaded, and then begin with a minimal integration approach. I’ll share updates as I make progress.
— Gaganpreet Kaur
Hi, sorry for the delayed update. I spent the last few days understanding how IntelOwl’s existing YARA and CAPA analyzers consume rules and validating different integration approaches. Through testing, I confirmed that Unprotect.it provides detection rules via an API and cannot be directly added as a YARA repository.
The correct approach seems to be implementing a rule ingestion layer that periodically fetches rules from the Unprotect.it API, classifies them by engine, converts them into YARA (.yar) and CAPA (.yml) formats, and places them into the existing analyzer rule directories so the current analyzers can consume them without changes. I’m now working on the implementation plan for this ingestion and conversion pipeline and will start with the API fetching and rule classification logic next.
Thanks for your patience, and please let me know if this direction aligns with your expectations or if you’d like me to prioritize a specific part first. Thanks! -Gaganpreet kaur
Hi @mlodic
I’ve opened a PR for Unprotect.it YARA rule ingestion: PR: #3209
Summary:
- Added a separate rule_ingestion module
- Fetches detection rules from unprotect.it API
- Classifies and writes valid YARA rules to IntelOwl storage
- No analyzer logic was modified
CI checks are passing . Please let me know if you’d like any changes or if I should proceed with CAPA ingestion next.
-Gaganpreet Kaur Thanks!
Hii @mlodic
Earlier, I had submitted a PR but it didn’t fully follow the contribution guidelines.
I’ve now updated my work and submitted this PR following all the required guidelines properly.
PR link: https://github.com/intelowlproject/IntelOwl/pull/3211#issue-3826915261
Whenever you have time, could you please review it and let me know if any changes are needed?
Thank you for your guidance and patience.
-Gaganpreet Kaur
Thanks but the PR is not solving the issue at all.
Here we need to modify the "update" method of the already existing YaraRepo class in the yara_scan.py file. That's the place where to do this change. We need to customize it for this specific kind of signatures that are not available through github or through a downloadable zip file.
Please let me know if you want to retry it again in the next days, otherwise I'll reassign this issue within end of this week
Hi @mlodic Thank you for the clarification. It seems I misunderstood the issue earlier. I now realize that the solution involves modifying the update method of the YaraRepo class in the yara_scan.py file, rather than implementing a new ingestion pipeline for external rules. I will focus on customizing the update method to handle signatures from Unprotect.it API, ensuring that the signatures are properly fetched and added to the existing YARA repository. I’ll take another shot at the implementation and update the PR accordingly. Please let me know if there are any additional details I should keep in mind for the next steps.
Additionally, I wanted to clarify whether you’d prefer separate pull requests for the YARA and CAPA rules, or if I can combine them into a single PR..
Thanks for your patience and guidance! -Gaganpreet Kaur
Hii @mlodic @fgibertoni I have submitted a PR for the integration of YARA rules from the Unprotect.it API into IntelOwl, addressing #1711. The PR includes modifications to the .update() method in yara_scan.py to handle the YARA rules.
Please note that this PR is only for the YARA-related changes. The CAPA-related changes will be handled in a separate PR.
However, I would like to clarify if this approach is correct. Should the CAPA changes also be included in this PR, or is it better to keep them in a separate PR ?
However, based on your feedback, it seems this approach does not fully resolve the issue. I will be focusing on making the necessary changes to the .update() method as you suggested. Here is the link to the PR: https://github.com/intelowlproject/IntelOwl/pull/3229#issue-3847902239
Thanks for your Guidance. Let me know if any changes needed. -Gaganpreet Kaur
Hi @mlodic, I see this issue is currently assigned and has an active PR. If helpful, I can test the PR locally (especially the YaraRepo.update changes and unprotect.it fetch flow) and share feedback or edge cases I find.
you can help figuring out the issue, it has been on development for quite some time already.
Thanks! I’ll review the YaraRepo.update() implementation and test the current PR locally to understand where the integration with the unprotect.it API is failing. I’ll share my findings soon.
Hi @AshwinGajbhiye,
I’ve been debugging the backend CI failure for some time now. From the logs, it appears the failure happens during the CI startup phase (./start ci up -- --build -d) while pulling/starting services, rather than during test execution itself.
Locally, the stack starts correctly after clearing cache and resetting volumes, so I suspect this may be related to the CI environment or image pull timing rather than the backend logic.
Could you please try running the PR branch locally to see if the CI startup step behaves differently in your environment? Any insights would be really helpful.
Thank you.
Hi @Gagan144-blip,
I pulled down your PR branch and did some local testing. I think I found what's causing the CI failures and why the integration isn't working:
First issue - there's a Python indentation error on line 206 in yara_scan.py
The logger.info("Unprotect.it API update completed") line is sitting at the class level when it should be inside the _update_unprotect_api() method. This is probably why Python can't even parse the file during CI startup. Just needs to be indented 8 more spaces to match the method body.
Second issue - the migration doesn't actually add the unprotect.it URL
I noticed the migration file 0171_add_unprotect_yara_rules.py is adding the yaraify URL instead of the unprotect.it one. The migration should probably have something like:
if "https://unprotect.it/api/detection_rules/" not in pc.value:
pc.value.append("https://unprotect.it/api/detection_rules/")
Hi @AshwinGajbhiye,
Thank you so much for pulling the branch and testing it locally — I really appreciate the detailed feedback.
You're absolutely right about the indentation issue in yara_scan.py. I checked line 206 and the logger.info("Unprotect.it API update completed") statement is indeed incorrectly placed at the class level. I will fix the indentation so it stays properly inside the _update_unprotect_api() method.
Regarding the migration file 0171_add_unprotect_yara_rules.py, thank you for catching that as well. It seems I mistakenly added the yaraify URL instead of the unprotect.it endpoint. I will correct the migration to properly append:
https://unprotect.it/api/detection_rules/
I’ll push an updated commit shortly with both fixes.
Thanks again for taking the time to review and test this! -Gaganpreet Kaur
Hi @mlodic ,
I've been reviewing the progress on #1711 and the related PR #3442 by @Gagan144-blip . Since the PR currently has a failing backend test in CI and some automated review comments regarding migrations and URL handling, I set up a local IntelOwl environment to try reproducing the issue.
My plan is to: Reproduce the backend CI failure locally Investigate the migration conflict around 0171_* that was flagged in the automated review Review the URL construction logic for the Unprotect API integration (requests.get(..., params=...))
Share my findings here so we can help move the integration forward
Since I'm particularly interested in the Integration Ecosystem / connector-related work, I’d be happy to assist in debugging or validating this PR.
I'll post updates once I have reproducible results from my local environment.
Hi @mlodic
I have updated the PR to resolve the previous CI/CD failures and static analysis issues. Specifically: Refactored _update_unprotect_api: Split the logic into smaller helper methods (_write_rule_to_temp and _finalize_rules) to reduce cyclomatic complexity and improve readability.
Exception Handling: Fixed redundant exception catching (ValueError/JSONDecodeError) in the API ingestion logic.
YARA Compilation: Added directory creation logic in the compile method to prevent path-related errors during rule compilation.
Testing & Style: Verified that all 3 YARA unit tests pass locally. Also ran black, ruff, and isort to ensure compliance with the project's linting standards.
PR Link: https://github.com/intelowlproject/IntelOwl/pull/3442#issuecomment-4056889946
All GitHub Action checks are now passing. Ready for your review!" Please let me know if any further changes are needed.
Thanks for your patience and guidance. -Gaganpreet Kaur
Hi @mlodic
I'm interested in working on this issue. I've gone through the discussion and understand the goal -> integrating signature fetching from unprotect.it into the existing Yara and Capa analyzers.
i'll:
- Study how the existing Yara/Capa analyzers load and manage rules
- Implement the
update()method inyara_scan.pyto fetch signatures from the Unprotect.it API - Handle CAPA-related changes in a separate PR as suggested
Could you assign this issue to me? I'll make sure to follow the contribution guidelines and keep you updated on progress.
Thank you!