-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: add exclude and include check in ini config #254
Conversation
eddf950
to
1fbdcab
Compare
19f6679
to
952db85
Compare
952db85
to
c06dbd9
Compare
7556972
to
d8758d0
Compare
d8758d0
to
8ea5a24
Compare
1e6c61d
to
e0cc4b2
Compare
…and factor out the get successors logic, minor fixes in test_registry.py for sort usages
I'm not sure if this is in-scope of this PR, but I am seeing some issues with the attributes These attributes serve the purpose of working out the correct execution order of checks. I think the class scope is too wide of a scope for them: they are only needed once we start executing the checks, and not needed when the If we need to I realized this issue when I looked at the unit tests that involve Furthermore, now that we have incorporated the include and exclude checks feature, the topological sorter can be created after the set of checks to be run has been worked out, which means it can just take these checks instead of all registered checks. However, I consider this to be not as relevant as an improvement compared to removing |
I agree that the The 3 phases are: when checks are being registered (the check graph is mutable, checks referenced may not yet exist, not safe to invoke operations that need a stable, complete graph), after check registration is finished, but topological sorting has not been done, and finally after topological sorting is done (not safe to repeat topological sorting). An improvement would be to refactor these phases into 3 separate classes, maybe something like This is a general improvement suggestion, this doesn't have to be done as part of this PR. |
…ifier to scorecard and exclude the mcn_provenance_level_three_1 check for e2e output of slsa-verifier integration test
…the prepare method
…lsa-verifier test case in integration_test_docker
Thanks @nicallen @nathanwn for the feedback regarding the current state of our |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for working on this PR.
tests/e2e/expected_results/slsa-verifier/slsa-verifier_provenance_checks_excluded.json
Outdated
Show resolved
Hide resolved
tests/e2e/expected_results/slsa-verifier/slsa-verifier_provenance_checks_excluded.json
Outdated
Show resolved
Hide resolved
Signed-off-by: Trong Nhan Mai <[email protected]>
Close #133.
Feature description
Configuring exclude/include in Ini config.
We want to allow the users to:
Because checks in Macaron depend on each other (using the
depends_on
attribute). Therefore, when we want to disable a check (from users' exclude/include configuration), we also need to handle its transitive parents and children.The user should define the list of str with each element as an ID of a check or a glob pattern (similar to patterns used in glob) which will be used to match multiple check IDs. This configuration is located in the
defaults.ini
file.Example on glob patterns:
mcn_*
would match all checks with IDs start withmcn_
.*
would match all checks registered in Macaron.mcn_boo_1
would match a single check with IDmcn_boo_1
Displaying the run checks
For example, this could be what we display in the HTML reports given that mcn_build_as_code_1 is excluded.
Implementation
Background
When a check is registered in Macaron, we update the 3 following attribute of the
Registry
class:_all_checks_mapping
: this is the dictionary that maps between the check id (typestr
) and the instance of a check (inherit fromBaseCheck
)._check_relationships_mapping
:dict[str, dict[str, CheckResultType]]
:str
): the ID of the parent checkdict[str, CheckResultType]
): the mapping between the children that depend on the parent check to the check status that each of them depend on (e.gCheckResultType.PASSED
):str
): the id of a child checkCheckResultType
): the status that this child check depends on._graph
: this is the final graph where we traverse to get the next available check in the correct topological order when we run the analysis.To describe those attributes conceptually:
_all_checks_mapping
: includes the nodes in the check relationship tree._check_relationships_mapping
: it is sort of anadjacency list
that described the edges in the check relationship tree._graph
: is built from the 2 above attributes and is used for getting the topological order of the checks.Solution
registry.prepare()
is run. This list will be stored in this attribute._all_checks_mapping
,_check_relationships_mapping
and_graph
still contain all of the registered checks.registry.scan()
method (which still goes through the check tree will all registered checks), checks which are not included in this list will not be run. Therefore, the result for those checks will not be included in the reports and the database.