Skip to content

Commit 11fa261

Browse files
committed
fix: use data from tb
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent b319c4e commit 11fa261

2 files changed

Lines changed: 35 additions & 19 deletions

File tree

backend/src/api/public/v1/packages/getPackage.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,23 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
4040
const scorecardScore = pkg.scorecardScore != null ? Number(pkg.scorecardScore) : null
4141
const mappingConfidence =
4242
pkg.repoMappingConfidence != null ? Number(pkg.repoMappingConfidence) : null
43-
const healthScoreTotal =
44-
pkg.healthScore ?? (scorecardScore !== null ? Math.round(scorecardScore * 10) : null)
43+
const healthBandScore = pkg.healthScore !== null ? pkg.healthScore / 10 : scorecardScore
4544

4645
ok(res, {
4746
purl: pkg.purl,
4847
name: pkg.name,
4948
ecosystem: pkg.ecosystem,
5049
latestVersion: pkg.latestVersion ?? null,
5150
general: {
52-
healthScore: healthScoreTotal,
51+
healthScore: pkg.healthScore,
5352
healthScoreDetails: {
54-
total: healthScoreTotal,
53+
total: pkg.healthScore,
5554
label: pkg.healthLabel,
5655
maintainerHealth: pkg.maintainerHealthScore,
5756
securitySupplyChain: pkg.securitySupplyChainScore,
5857
developmentActivity: pkg.developmentActivityScore,
5958
},
60-
healthBand: computeHealthBand(scorecardScore),
59+
healthBand: computeHealthBand(healthBandScore),
6160
impact: {
6261
impactScore:
6362
pkg.criticalityScore != null ? Math.round(Number(pkg.criticalityScore) * 100) : null,
@@ -67,7 +66,7 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
6766
transitiveReach: pkg.transitiveReach,
6867
},
6968
riskSignals: {
70-
lifecycle: pkg.lifecycleLabel ?? null,
69+
lifecycle: pkg.lifecycleLabel,
7170
maintainerBusFactor: pkg.maintainerCount,
7271
lastRelease: pkg.latestReleaseAt ? pkg.latestReleaseAt.toISOString() : null,
7372
hasSecurityFile: pkg.hasSecurityFile,
@@ -76,7 +75,7 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
7675
openSSFScorecard: scorecardScore,
7776
},
7877
},
79-
signalCoverageHealth: pkg.signalCoverageHealth ?? null,
78+
signalCoverageHealth: pkg.signalCoverageHealth,
8079
assessment: null,
8180
security: {
8281
securityContacts: null,

backend/src/api/public/v1/packages/openapi.yaml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,27 @@ components:
267267
type: object
268268
properties:
269269
healthScore:
270+
type:
271+
- integer
272+
- 'null'
273+
description: Composite health score (0–100). Tinybird-enriched when available, null otherwise.
274+
example: 18
275+
healthScoreDetails:
270276
type:
271277
- object
272278
- 'null'
279+
description: Breakdown of the composite health score. Null until Tinybird enrichment runs.
273280
properties:
281+
total:
282+
type:
283+
- integer
284+
- 'null'
285+
example: 18
286+
label:
287+
type:
288+
- string
289+
- 'null'
290+
example: Good
274291
maintainerHealth:
275292
type:
276293
- integer
@@ -286,16 +303,13 @@ components:
286303
- integer
287304
- 'null'
288305
example: 6
289-
total:
290-
type:
291-
- integer
292-
- 'null'
293-
example: 18
294-
label:
295-
type:
296-
- string
297-
- 'null'
298-
example: Good
306+
healthBand:
307+
type:
308+
- string
309+
- 'null'
310+
enum: [healthy, fair, concerning, critical, null]
311+
description: Derived from Tinybird health score when available, OpenSSF Scorecard otherwise.
312+
example: concerning
299313
impact:
300314
type:
301315
- object
@@ -683,11 +697,14 @@ paths:
683697
name: lodash
684698
ecosystem: npm
685699
general:
686-
healthScore:
700+
healthScore: 18
701+
healthScoreDetails:
702+
total: 18
703+
label: critical
687704
maintainerHealth: 4
688705
securitySupplyChain: 8
689706
developmentActivity: 6
690-
total: 18
707+
healthBand: critical
691708
impact:
692709
impactScore: 71
693710
downloadsLastMonth: 52142891

0 commit comments

Comments
 (0)