-
Notifications
You must be signed in to change notification settings - Fork 728
feat: expose security contacts via api [CM-1297] #4304
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
Changes from all commits
04a44fd
966ffdb
3f9a77e
4eb9186
0b72429
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -595,6 +595,16 @@ export async function listPackagesForApi( | |
| return { rows, total } | ||
| } | ||
|
|
||
| export type SecurityContactConfidence = 'PRIMARY' | 'SECONDARY' | 'FALLBACK' | 'NONE' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is also a duplication |
||
|
|
||
| export interface SecurityContactRow { | ||
| channel: string | ||
| value: string | ||
| role: string | ||
| confidence: SecurityContactConfidence | ||
| score: number | ||
| } | ||
|
|
||
| export interface PackageDetailRow { | ||
| id: string | ||
| purl: string | ||
|
|
@@ -625,6 +635,12 @@ export interface PackageDetailRow { | |
| hasSecurityFile: boolean | null | ||
| hasSecurityPolicy: boolean | null | ||
| branchProtectionEnabled: boolean | null | ||
| pvrEnabled: boolean | null | ||
| securityPolicyUrl: string | null | ||
| vulnerabilityReportingUrl: string | null | ||
| bugBountyUrl: string | null | ||
| contactsLastRefreshed: Date | null | ||
| securityContacts: SecurityContactRow[] | null | ||
| // from downloads_last_30d | ||
| downloadsLast30d: string | null | ||
| maintainerCount: number | ||
|
|
@@ -639,6 +655,13 @@ export interface PackageDetailRow { | |
| signalCoverageHealth: Record<string, unknown> | null | ||
| } | ||
|
|
||
| export function securityContactConfidenceBand(score: number): SecurityContactConfidence { | ||
| if (score >= 0.8) return 'PRIMARY' | ||
| if (score >= 0.55) return 'SECONDARY' | ||
| if (score >= 0.3) return 'FALLBACK' | ||
| return 'NONE' | ||
| } | ||
|
mbani01 marked this conversation as resolved.
Comment on lines
+658
to
+663
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a reason why we are rewriting this function ? can we use the existing one ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which existing one are you referring to? |
||
|
|
||
| export interface AdvisoryRow { | ||
| osvId: string | ||
| severity: string | ||
|
|
@@ -682,6 +705,21 @@ export async function getPackageDetailByPurl( | |
| r.security_file_enabled AS "hasSecurityFile", | ||
| r.security_policy_enabled AS "hasSecurityPolicy", | ||
| r.branch_protection_enabled AS "branchProtectionEnabled", | ||
| r.pvr_enabled AS "pvrEnabled", | ||
| r.security_policy_url AS "securityPolicyUrl", | ||
| r.vulnerability_reporting_url AS "vulnerabilityReportingUrl", | ||
| r.bug_bounty_url AS "bugBountyUrl", | ||
| r.contacts_last_refreshed AS "contactsLastRefreshed", | ||
| ( | ||
| SELECT json_agg(sc ORDER BY sc.score DESC) | ||
| FROM ( | ||
| SELECT channel, value, role, confidence, score | ||
| FROM security_contacts | ||
| WHERE repo_id = pr.repo_id AND deleted_at IS NULL | ||
| ORDER BY score DESC | ||
| LIMIT 5 | ||
| ) sc | ||
| ) AS "securityContacts", | ||
| -- latest 30-day download count | ||
| ( | ||
| SELECT d.count::text | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed sweep shows empty contacts
Medium Severity
securityContactsis derived only from whethercontactsLastRefreshedis set, but the worker also sets that timestamp on failed extractor or repo runs viamarkRepoAttemptedwithout persisting contacts. Clients then get an empty array, which the OpenAPI text describes as a successful sweep with no contacts, not a failed attempt.Reviewed by Cursor Bugbot for commit 0b72429. Configure here.