-
Notifications
You must be signed in to change notification settings - Fork 110
Add compliance support based on OpenSSF Scorecard score #1800
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
Conversation
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
You can now merge |
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
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.
Looks good, see various comments before the merge.
Also, could you add an entry in the CHANGELOG?
@@ -497,6 +497,22 @@ def license_clarity_compliance(self, request, *args, **kwargs): | |||
clarity_alert = project.get_license_clarity_compliance_alert() | |||
return Response({"license_clarity_compliance_alert": clarity_alert}) | |||
|
|||
@action(detail=True, methods=["get"]) | |||
def scorecard_compliance(self, request, *args, **kwargs): |
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.
This needs a new entry in the REST API documentation, see _rest_api_license_clarity_compliance
scanpipe/pipelines/fetch_scores.py
Outdated
if scorecard_policy and scorecard_data.score is not None: | ||
try: | ||
score = float(scorecard_data.score) | ||
alert = scorecard_policy.get_alert_for_score(score) | ||
except Exception: | ||
alert = "error" | ||
|
||
order = {"ok": 0, "warning": 1, "error": 2} | ||
if worst_alert is None or order[alert] > order.get(worst_alert, -1): | ||
worst_alert = alert | ||
|
||
if worst_alert is not None: | ||
self.project.update_extra_data({"scorecard_compliance_alert": worst_alert}) |
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.
All this new logic should be moved to a pipe function. We want to keep the pipeline method a simple as possible. This would also make it easier to test (make sure to add one).
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Signed-off-by: NucleonGodX <racerpro41@gmail.com>
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.
Looks good! Merging.
@@ -3,6 +3,13 @@ Changelog | |||
|
|||
v35.2.0 (2025-08-01) | |||
-------------------- | |||
- Enhanced scorecard compliance support with: |
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.
This should not be inside the v35.2.0 section since it is already released.
Fixes #1794
This PR adds support for scorecard based compliance using the new refactored architecture created in #1799
The scorecard compliance alert is stored in project's extra data and fetched from there to be visible in UI and during check-compliance command, The alert is computed during the fetch_score pipeline.
Once #1799 is merged, I will rebase this PR to main to remove the previous commits.