Skip to content

Add compliance support based on OpenSSF Scorecard score - #1800

Merged
tdruez merged 11 commits into
aboutcode-org:mainfrom
NucleonGodX:scorecard-compliance
Aug 11, 2025
Merged

tdruez merged 11 commits into
aboutcode-org:mainfrom
NucleonGodX:scorecard-compliance

Conversation

@NucleonGodX

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

tdruez commented Aug 4, 2025

Copy link
Copy Markdown
Contributor

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>

@tdruez tdruez left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread scanpipe/api/views.py
return Response({"license_clarity_compliance_alert": clarity_alert})

@action(detail=True, methods=["get"])
def scorecard_compliance(self, request, *args, **kwargs):

Copy link
Copy Markdown
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 thread scanpipe/pipelines/fetch_scores.py Outdated
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
Copy Markdown
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>

@tdruez tdruez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Merging.

Comment thread CHANGELOG.rst

v35.2.0 (2025-08-01)
--------------------
- Enhanced scorecard compliance support with:

Copy link
Copy Markdown
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
aayushkdev pushed a commit to aayushkdev/scancode.io that referenced this pull request Aug 28, 2025
aayushkdev added a commit to aayushkdev/scancode.io that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Add scorecard based compliance support

2 participants