Repository navigation
fix(engine): describe the rules of plugins given as instances - #277
Merged
Merged
Conversation
A check gathered the rule descriptions of the plugins it loaded from plugin roots only. A plugin given to analyze_project as an instance reported its findings, but its rules reached the report by id alone. The descriptions now come from every plugin of the check, loaded ones first, then those given as instances, the first declaration of an id kept.
… describes too A plugin given as an instance that describes command-injection again does not replace the description of the bundled plugin, loaded before it.
Merged
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.
Summary
Follow-up to #274. With
Plugin.rules, a plugin describes the rules it reports, and the SARIF report passes the descriptions to its consumers. A check, however, gathered them only from the plugins it loaded from plugin roots. A plugin given toanalyze_projectas an instance (plugins=[...]) still reported its findings, but its rules reached the report by id alone.The descriptions now come from every plugin of the check, in this order: the engine's own rules, then the loaded plugins', then those of the plugins given as instances. When several declare the same id, the first declaration is kept.
fix(engine): describe the rules of plugins given as instancesrule_descriptionstakes the plugins of the check instead of the registry; the test of an instance's ruletest(rules): keep a loaded plugin's description of a rule an instance describes tooTests
The new file
tests/test_rule_descriptions_of_given_plugins.pyholds 2 tests. Before the fix:KeyError: 'quiet-rule';No existing test changes.
Compatibility
engine.rule_descriptionsnow takes plugins instead of aPluginRegistry. Nothing calls it outsideengine.py, in this repository or in the Enterprise plugins.Plugin.rulesis not released yet, so the changelog entry of #274 covers this.Verification
Python 3.12, on
mainat8e9e944:ruff check .andmypy: clean on each commit;