Skip to content

refactor: remove depends_on fields from heuristics and handle skips in problog #1133

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

art1f1c3R
Copy link
Member

@art1f1c3R art1f1c3R commented Jul 22, 2025

Summary

The purpose of this PR is to address #1052, and implement appropriate skip and error handling in all existing heuristics. This PR removes the depends_on field from heuristics and makes it a responsibility of the heuristic code to determine if it should be skipped or not. All skip handling is then done my the ProbLog logic.

Description of changes

The BaseHeuristicAnalyzer no longer has the depends_on field, and this has propagated to all other analyzers. The description for a SKIP result has been updated in line with issue #1052, and HeuristicAnalyzerValueErrors have replaced some SKIP results previously used when malformed data was encountered. Unit tests have been updated accordingly.

Some refactoring to the test_pypi_sourcecode_analyzer.py unit tests have also been done in this PR to address #1108, adding in temporary .ini config files to the unit tests as opposed to the existing mock objects.

Related issues

Closes #1052 and #1108.

Checklist

  • I have reviewed the contribution guide.
  • My PR title and commits follow the Conventional Commits convention.
  • My commits include the "Signed-off-by" line.
  • I have signed my commits following the instructions provided by GitHub. Note that we run GitHub's commit verification tool to check the commit signatures. A green verified label should appear next to all of your commits on GitHub.
  • I have updated the relevant documentation, if applicable.
  • I have tested my changes and verified they work as expected.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 22, 2025
@art1f1c3R art1f1c3R force-pushed the art1f1c3R/malware-dependencies-cleanup branch from 15a0c52 to 24d224e Compare July 31, 2025 01:34
mock_defaults.__getitem__.side_effect = lambda section: (
MagicMock(get=lambda _: None) if section == "heuristic.pypi" else None
)
defaults["heuristic.pypi"].clear()
Copy link
Member

@tromai tromai Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the scenario where this case happen? For instance, what would be the values in the user provided defaults.ini (if any).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our defaults.ini usually looks like this:

disabled_default_rulesets = exfiltration
disabled_rules =
custom_semgrep_rules_path =
disabled_custom_rulesets =

The reason I used .clear() here is to make sure that the rules that are being tested aren't disabled. Particularly here, by default our exfiltration ruleset is disabled, but it is tested in this unit test, so the test would fail if I didn't remove that setting.

@art1f1c3R art1f1c3R force-pushed the art1f1c3R/malware-dependencies-cleanup branch from 0c5b3b7 to 08bcd50 Compare August 8, 2025 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
2 participants