feat(scorecard): Implement exclude metrics annotation #2393
feat(scorecard): Implement exclude metrics annotation #2393
Conversation
…nd simplied the usage of the openssf client by fetching scorecards only using a baseUrl
…interface, refactored tests
Missing ChangesetsThe following package(s) are changed by this PR but do not have a changeset:
See CONTRIBUTING.md for more information about how to add changesets. Changed Packages
|
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Latest suggestions up to 84b2172
Previous suggestions✅ Suggestions up to commit aea0d64
|
|||||||||||||||||||||||
|
@alizard0 to make this work, I think it makes sense to implement this for all metrics. You can update code in It would be nice to allow administrators to be able to define exclude checks also in |
dzemanov
left a comment
There was a problem hiding this comment.
Hi @alizard0,
I have added some comments.
Thinking about our scorecard work yesterday, and how users will eventually create their own via UI or YAML, I am wondering if the metric exclusion feature might become unnecessary then. However, the timeline for scorecard creation hasn't been defined yet, so it could make sense to implement this.
workspaces/scorecard/plugins/scorecard-backend/src/scheduler/tasks/PullMetricsByProviderTask.ts
Outdated
Show resolved
Hide resolved
|
dzemanov
left a comment
There was a problem hiding this comment.
@alizard0, can you please fix CI?
You will need to update scorecard backend config.d.ts with the new schema. Also, I am not sure if this is working, but I haven't looked into it closely:
plugins:
openssf:
enabled: true
I was thinking about what the best syntax for this feature would be. For annotations, usually - is used as a separator. In app-config, we usually use lower camel case.
For app-config.yaml, not sure if key include_metrics clearly shows that it actually means users can not override excluding metrics by entity annotations.
I suggest we can use something like this, so it can be consistent once we add disabling thresholds overrides:
scorecard:
entityOverrides:
thresholds:
enabled: true
except:
- openssf.packaging
disabledMetrics:
enabled: false
except:
- openssf.packaging
Then, for syntax for disabling some metric runs, I was thinking disable might be clearer, since exclude might mean check results are just filtered out instead of not run at all. It would also mean admins can define it this way:
scorecard:
disabledMetrics:
- openssf.packaging
Annotation will then be:
scorecard.io/disabled-metrics: openssf.maintained,openssf.code_review
This is of course up for debate. @imykhno, @PatAKnight WDYT?







User description
Hey, I just made a Pull Request!
It adds an annotation that allows the developer to exclude any scorecard metric.
More details: https://issues.redhat.com/browse/RHIDP-12183
✔️ Checklist
PR Type
Enhancement
Description
Add support for excluding OpenSSF checks via annotation
Implement check filtering in OpenSSFClient based on exclude-checks annotation
Inject LoggerService dependency into client and metric provider classes
Update module initialization to pass logger to metric provider factory
Enhance test coverage with exclude checks functionality
Diagram Walkthrough
File Walkthrough
OpenSSFClient.ts
Add check exclusion filtering with loggingworkspaces/scorecard/plugins/scorecard-backend-module-openssf/src/clients/OpenSSFClient.ts
openssf/exclude-checksannotation
returning
OpenSSFMetricProvider.ts
Inject logger into metric providerworkspaces/scorecard/plugins/scorecard-backend-module-openssf/src/metricProviders/OpenSSFMetricProvider.ts
logger
OpenSSFClient.test.ts
Add tests for check exclusion functionalityworkspaces/scorecard/plugins/scorecard-backend-module-openssf/src/clients/OpenSSFClient.test.ts
OpenSSFMetricProvider.test.ts
Update tests with logger dependencyworkspaces/scorecard/plugins/scorecard-backend-module-openssf/src/metricProviders/OpenSSFMetricProvider.test.ts
module.ts
Wire logger dependency in module initializationworkspaces/scorecard/plugins/scorecard-backend-module-openssf/src/module.ts
openssf-scorecard-only.yaml
Add exclude-checks annotation exampleworkspaces/scorecard/examples/openssf-scorecard-only.yaml
openssf/exclude-checksannotation with example values