feat: implement generic mitigation-aware rule evaluation (fixes #21)#31
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements a generic, mitigation-aware rule evaluation layer inside Anchor's governance engine. Previously, rules defining
min_mitigationswere ignored during scan evaluation. With this change, the evaluation pipeline checks for active inline mitigations in the source code to determine compliance before registering findings.Acceptance Criteria
min_mitigations.Changes
anchor/core/engine.py): Added a generic mitigation-aware evaluation stage inevaluate_candidates. The engine parses comments matching# anchor: (mitigate|mitigation|mitigated) <rule_id>and discards candidate violations if the count of mitigations matches or exceedsmin_mitigations.anchor/core/loader.py&anchor/cli.py): Updated loaders to read and propagatemin_mitigationsfrom federated domain policy files to the active ruleset.tests/unit/test_mitigations.py): Added unit tests coverage for:min_mitigations: 2).DOCS/research/mitigation_evaluation.md): Created documentation detailing the evaluation workflow, code syntax, and config parameters.benchmarks/bench_anchor.py): Disabled remote ledger and relay environment variables to prevent HTTP blockages/timeouts during test runs.Related Issues
Fixes #21