Add docs, implement warning behavior

This commit is contained in:
Justin Hutchings
2024-03-08 01:29:53 +00:00
parent 59d4782b76
commit 296bf3ab1b
2 changed files with 20 additions and 0 deletions
+18
View File
@@ -154,6 +154,7 @@ async function run(): Promise<void> {
const scorecard = await getScorecardLevels(filteredChanges)
summary.addScorecardToSummary(scorecard, config)
printScorecardBlock(scorecard, config)
createScorecardWarnings(scorecard, config)
}
summary.addScannedDependencies(changes)
@@ -354,4 +355,21 @@ function printDeniedDependencies(
})
}
function createScorecardWarnings(
scorecards: Scorecard,
config: ConfigurationOptions
): void {
// Iterate through the list of scorecards, and if the score is less than the threshold, send a warning
for (const dependency of scorecards.dependencies) {
if (
dependency.scorecard?.score &&
dependency.scorecard?.score < config.warn_on_openssf_scorecard_level
) {
core.warning(
`${dependency.ecosystem}/${dependency.packageName} has an OpenSSF Scorecard of ${dependency.scorecard?.score} is less than this repository's threshold of ${config.warn_on_openssf_scorecard_level}.`
)
}
}
}
run()