feat: add security contacts api (CM-1336)#4354
Conversation
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
PR SummaryHigh Risk Overview Auth & exposure: Endpoints require Data & mapping: New DAL OpenAPI documents the Contacts tag, schemas, and both paths. Unit tests cover the mapper; integration tests cover the DAL query (DB env–gated). Reviewed by Cursor Bugbot for commit e4d63f0. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Adds authenticated Akrites endpoints for retrieving package security-contact details.
Changes:
- Adds single and batch contact-detail endpoints with scope checks and validation.
- Adds DAL queries, schema-aligned types, and response mapping.
- Adds OpenAPI documentation and automated tests.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
services/libs/types/src/db/security-contacts.ts |
Defines security-contact row types. |
services/libs/types/src/db/repos.ts |
Defines repository row type. |
services/libs/types/src/db/index.ts |
Exports new row types. |
services/libs/data-access-layer/src/osspckgs/sqlFragments.ts |
Extracts contact aggregation SQL. |
services/libs/data-access-layer/src/osspckgs/getPackageDetailsByPurls.integration.test.ts |
Updates package fixtures. |
services/libs/data-access-layer/src/osspckgs/getContactDetailsByPurls.integration.test.ts |
Tests contact lookup queries. |
services/libs/data-access-layer/src/osspckgs/api.ts |
Adds contact-detail DAL query and types. |
backend/src/api/public/v1/packages/getAkritesExternalContactDetailBatch.ts |
Implements batch endpoint. |
backend/src/api/public/v1/packages/getAkritesExternalContactDetail.ts |
Implements single endpoint. |
backend/src/api/public/v1/packages/akritesExternalContactDetail.ts |
Maps DAL rows to API responses. |
backend/src/api/public/v1/packages/akritesExternalContactDetail.test.ts |
Tests response mapping. |
backend/src/api/public/v1/akrites-external/openapi.yaml |
Documents contact APIs. |
backend/src/api/public/v1/akrites-external/index.ts |
Registers scoped routes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Summary
Adds two new read-only Akrites-external endpoints —
GET /akrites-external/contacts/detailandPOST /akrites-external/contacts/detail:batch— exposing per-package security-contact info (reporting channels, confidence, repo security-policy/PVR/bug-bounty URLs) so external Akrites consumers can look up how to report a vulnerability for a given package.Changes
contactsinakrites-external/index.ts, gated behindREAD_MAINTAINER_ROLES(interim stand-in for the not-yet-issuedcdp:maintainers:readAuth0 scope — flagged with aTODOto swap once available). Deliberately not reachable via the existing packages scope, since these rows carry contact PII (e.g. reporter emails).getContactDetailsByPurls(services/libs/data-access-layer/src/osspckgs/api.ts) joiningpackages→ best-linkedrepos→ aggregatedsecurity_contacts.AkritesExternalContactDetailRowtype composed viaPick<PackageDbRow, ...> & Pick<RepoDbRow, ...>(ADR-0006: DB schema row types as source of truth, no hand-declared shapes).@crowd/types/src/db/:RepoDbRow(fullrepostable, including allALTER TABLEcolumns added by later migrations) andSecurityContactDbRow/SecurityContactConfidence(moved out of the DAL, where they previously lived ad hoc).toAkritesExternalContactDetailtranslating internal shapes to the public contract:PRIMARY/SECONDARY/FALLBACK/NONEscale verbatim.overallConfidenceBanduses a different contract-mandated scale (HIGH/MEDIUM/LOW/NONE); the crosswalk between the two is a straightforward 4→4 rename but is flaggedUNCONFIRMEDpending sign-off from Akrites/product (seeakrites-api-questions-for-joana.md).targetOrganizationName,bugBountyProgramFlag,reportingMethods,reportingGuidelines,integrationHints) are reserved but not yet backed by stored data — typed asnullso a future non-null shape requires an explicit, reviewed change.GET .../detailandPOST .../detail:batchhandlers following the same shape as the existing packages/advisories endpoints (Zod-validated purl(s), 404 on no match for the single-detail route, found/not-found entries for the batch route).getContactDetailsByPurls(new) seeded via raw SQL against a real packages-db,describe.skipIf'd whenCROWD_PACKAGES_DB_*env vars aren't set — matching the existing sibling suites' convention. Minor fixture additions to the neighboringgetPackageDetailsByPurlsintegration test (repos.url-only insert simplified) with no behavior change.akritesExternalContactDetail.test.ts).Type of change
JIRA ticket
CM-1336