-
Notifications
You must be signed in to change notification settings - Fork 358
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
Adds DependsOnTags field to Rule #533
Merged
Merged
Conversation
This file contains 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
After processing of rules DependsOnTags will be checked and then matches whose matching rule have required tags which are not all present in the UniqueTags will be removed before returning results. Adds tests for new functionality and rule verifier will check to make sure all tags which are depended on are present in the rule set. SemVer changes. Public properties in the Rule object have been changed to IList from a combination of Array and List.
daalcant
approved these changes
Mar 2, 2023
jacobmsft
approved these changes
Mar 3, 2023
Change a few more List to IList. Improve edge case in verification where if two rules shared the same id they would both receive the error message about depends_on_tags.
👍
Get Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: Gabe Stocco ***@***.***>
Sent: Friday, March 3, 2023 3:30:18 PM
To: microsoft/ApplicationInspector ***@***.***>
Cc: Suraj Jacob ***@***.***>; Mention ***@***.***>
Subject: Re: [microsoft/ApplicationInspector] Adds DependsOnTags field to Rule (PR #533)
@gfs commented on this pull request.
________________________________
In AppInspector/Commands/AnalyzeCommand.cs<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FApplicationInspector%2Fpull%2F533%23discussion_r1125132757&data=05%7C01%7Csujacob%40microsoft.com%7Ca2bc5cec38ba4a34103108db1c3f3fe9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638134830227211180%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=64rLjF7iwq47VhjmdZJkAD%2FqgWBLSAXNeGreHZ7XMPY%3D&reserved=0>:
@@ -335,6 +335,17 @@ void VerifyFile(string filename)
}
}
+ // Remove match records that don't have the matching depends on tags
+ List<MatchRecord> filteredMatchRecords = _metaDataHelper.Matches.Where(x => x.Rule?.DependsOnTags?.All(tag => _metaDataHelper.UniqueTags.ContainsKey(tag)) ?? true).ToList();
I did discover an edge case, but its actually from the Overrides not the ID.
Overrides are removed on a per file basis as each file is scanned.
DependsOnTags must be checked after all files are scanned, because it cares about tags in other files.
Lets say Rule A matches and does not have a DependsOnTags. Rule B also matches and overrides Rule A, however it has a DependsOnTags for "TagC".
At the end of the run, if TagC isn't present, Rule B will be removed from the matches set, but Rule A will not currently be restored. We do not keep track of the rules which were overridden and when, so this information is not available at the time we check DependsOnTags to remove rules with missing dependent tags.
The easiest way to fix this might be in the verifier, to require that a rule which is targetted with an override must depend on at least all of the tags which the overrider depends on.
—
Reply to this email directly, view it on GitHub<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FApplicationInspector%2Fpull%2F533%23discussion_r1125132757&data=05%7C01%7Csujacob%40microsoft.com%7Ca2bc5cec38ba4a34103108db1c3f3fe9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638134830227366979%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3eCwzJ9EySiXuzlda4DpKoPevgTF5KFKd3drVbu5wtk%3D&reserved=0>, or unsubscribe<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAG3WFL6UXNUXSYW6QOOQE5DW2J5IVANCNFSM6AAAAAAVMXCKIY&data=05%7C01%7Csujacob%40microsoft.com%7Ca2bc5cec38ba4a34103108db1c3f3fe9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638134830227366979%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DRY2AaUmn7ksb0804fHrgBWf9vslmLKZx0u2xJxhQ9Q%3D&reserved=0>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
… the depends on of its overrider This verification step prevents a potential issue if a ruleset contains Rule A, which is Overridden by Rule B which depends on TagX. If RuleA and RuleB match, but TagX is not present, no results would be returned. This is because overrides are performed on a file by file basis, as the last step in processing each file. Depends on tags are checked after all files have been processed, and so the overridden matches are no longer tracked.
And tests for same.
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.
Fix #531.
After processing of rules DependsOnTags will be checked, at that time, all matches whose rule have
depends_on_tags
which are not all present in the total set of UniqueTags gathered during the full run will be removed in iterative batches until no more rules have missing depends on tags.Adds tests for new functionality and rule verifier will check to make sure all tags which are depended on are present in the rule set, and that any overridden rules have at least all the
depends_on_tags
of their overrider, since overridden rules are not tracked, and thus cannot be restored during the depends checking step, resulting in a potentially confusing interaction.SemVer changes. Public properties in the some objects have been changed to IList from various Array or List.
Sample rules with new syntax (pulled from the new test cases)
One Rule Depends on tags from another rule
Two Rules Depend on each other
You can also chain depends on