Skip to content

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

Merged
merged 11 commits into from
Aug 11, 2025

Conversation

NucleonGodX
Copy link
Contributor

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.

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>
@tdruez
Copy link
Contributor

tdruez commented Aug 4, 2025

Once #1799 is merged, I will rebase this PR to main to remove the previous commits.

You can now merge main ;)

Signed-off-by: NucleonGodX <racerpro41@gmail.com>
Copy link
Contributor

@tdruez tdruez left a 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):
Copy link
Contributor

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

Comment on lines 72 to 84
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})
Copy link
Contributor

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>
Copy link
Contributor

@tdruez tdruez left a 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:
Copy link
Contributor

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.

@tdruez tdruez merged commit 7a98ebc into aboutcode-org:main Aug 11, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add scorecard based compliance support
2 participants