Skip to content
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

ADR for Scorecard metrics aggregation and stack quality scoring #439

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/adr/0007-scorecard-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Aggregating OpenSSF Scorecard metrics to compute software stack quality scores

* Status: proposed
* Date: 2022-August-1

Technical Story: Aggregate OpenSSF Scorecard metrics on a package release update to compute software stack quality scores.

## Context and Problem Statement

As part of advise output improvements mentioned in [](https://github.com/thoth-station/core/issues/434), we would like to aggregate Security Scorecards data on a new package release to provide software stack quality metrics with regards to the global quality of packages that can be found in Thoth's Database. These metrics would inform the user about the health of a project dependencies and provide a software stack score (on a 0-100 scale or A,B,C...) based on Scorecard data.

**Note:** The architecture diagram below supposes that the OSSF Scorecards dataset available on BigQuery will expose metrics by package release instead of repository head commit SHA as it is currently the case. However if this feature is not going to be implemented on the Scorecards project side, we will need to handle the head commit SHA to release association logic by ourselves and thus revisit the diagram to include appropriate calls to the GitHub API and additional computations.

The data aggregation and score computation logic would be implemented as follows:

* With each `package-releases-job` run, aggregate data about the latest package release and corresponding Scorecards data retrieved from BigQuery
Copy link
Member

Choose a reason for hiding this comment

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

Can e use the scorecard command line Utility for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we want to aggregate data about packages we do not have yet into the prescriptions database, I don't think this will work unless we modify the scorecards handler logic. Another alternative to this architecture would be to compute prescriptions from new releases aggregated on package-release-job without storing this data in the DB, which will (if I'm not mistaken) greatly increase the number of prescriptions we already have. The global quality metrics could then be derived from prescriptions directly and stored in the DB on a regular job run for example.

* Update a new database table `package_scorecard_metrics` with columns for the package name and version and Scorecards Check (1 if the check passed, 0 otherwise). Eventually add a column for a global confidence computed from all Scorecards confidence for a project
* Schedule a job to compute a global package quality score from the previously aggregated data and store this score in the database
* Make this data available in prescriptions: update existing Scorecard prescriptions with the package version and create new prescriptions for other packages via `prescriptions-refresh-job`
* Implement the scoring logic available for relevant Thoth endpoints
* When a request is made to the relevant endpoint or a parameter is passed to ask for software stack scoring when computing an advise, output the computed metrics about the user's software stack quality

## Architectural diagram

![Scorecard metrics aggregation logic diagram](/images/Scorecards_metrics_ADR.png)
Binary file added docs/adr/images/Scorecards_metrics_ADR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.