Fix OpenSSF Scorecard Score retrieval

This commit is contained in:
Justin Hutchings
2024-03-03 05:59:37 +00:00
parent 43286afc54
commit 6bcbf042ff
5 changed files with 60 additions and 47 deletions
+1 -1
View File
@@ -278,7 +278,7 @@ function printScorecardBlock(
if (scorecard) {
for (const dependency of scorecard.dependencies) {
core.info(
`${dependency.ecosystem}/${dependency.packageName}: OpenSSF Scorecard Score: ${dependency.depsDevData.scorecard.overallScore}`
`${dependency.ecosystem}/${dependency.packageName}: OpenSSF Scorecard Score: ${dependency?.depsDevData?.scorecard?.overallScore}`
)
}
}
+40 -36
View File
@@ -100,47 +100,51 @@ export const ComparisonResponseSchema = z.object({
snapshot_warnings: z.string()
})
export const DepsDevProjectSchema = z.object({
projectKey: z.object({
id: z.string({})
}),
openIssuesCount: z.string(),
starsCount: z.string(),
forksCount: z.string(),
license: z.string(),
description: z.string(),
homepage: z.string(),
scorecard: z.object({
date: z.string(),
repository: z.object({
name: z.string(),
commit: z.string()
export const DepsDevProjectSchema = z
.object({
projectKey: z.object({
id: z.string({})
}),
openIssuesCount: z.string(),
starsCount: z.string(),
forksCount: z.string(),
license: z.string(),
description: z.string(),
homepage: z.string(),
scorecard: z.object({
version: z.string(),
commit: z.string()
}),
checks: z.array(
z.object({
date: z.string(),
repository: z.object({
name: z.string(),
documentation: z.object({
shortDescription: z.string(),
url: z.string()
}),
score: z.string(),
reason: z.string(),
details: z.array(z.string())
commit: z.string()
}),
scorecard: z.object({
version: z.string(),
commit: z.string()
}),
checks: z.array(
z.object({
name: z.string(),
documentation: z.object({
shortDescription: z.string(),
url: z.string()
}),
score: z.string(),
reason: z.string(),
details: z.array(z.string())
})
),
overallScore: z.number()
}),
ossFuzz: z
.object({
lineCount: z.string(),
lineCoverCount: z.string(),
date: z.string(),
configUrl: z.string()
})
),
overallScore: z.number()
}),
ossFuzz: z.object({
lineCount: z.string(),
lineCoverCount: z.string(),
date: z.string(),
configUrl: z.string()
.nullish()
})
})
.nullish()
export const ScorecardSchema = z.object({
dependencies: z.array(
+1 -1
View File
@@ -75,7 +75,7 @@ async function getDepsDevProjectData(
const response = await fetch(url)
if (response.ok) {
const data = await response.json()
core.debug(`Got deps.dev project data: ${JSON.stringify(data)}`)
//core.debug(`Got deps.dev project data: ${JSON.stringify(data)}`)
return DepsDevProjectSchema.parse(data)
} else {
throw new Error(