Repository navigation
feat(badges): add compliance badge server and update README - #405
alenmalhas wants to merge 1 commit into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
Hi @alenmalhas, sorry for the late reply! As we discussed on our last call, this approach raises security concerns once we consider the whole CCF user base. Instead, I propose the following. On API repo 1 - Opt in per saved evidence filter, not ad-hoc label queries. Make the badge a setting on the filter, set via POST/PUT /api/filters, e.g. "badge": {"enabled": true, "label": "compliance", "slug": "payments-service"}. A per-filter opt-in makes disclosure an explicit choice on one object that can be reviewed and turned off. Slugs are human-readable, unique across filters (a partial unique index on non-null slugs) and format-validated. Changing or clearing a slug revokes every embed using it. Saved filters are cheap to create and already carry SSP scope and control/component links. 3- The API renders the SVG.
4 - Both expose only the aggregate state, never individual evidence. The aggregation already exists in GET /api/evidence/compliance-by-filter/:id, so this is a thin wrapper plus a small SVG template: one grouped query, rendered at the source, with cache headers set there. READMEs can embed it directly, with no third-party badge service (shields.io etc.) and no extra runtime. Note that badges only render where the API is reachable; on github.com that means the public route must be exposed to the internet. This UI PR 1 - Drop the Node service and repurpose the PR for the UI side: 2- the badge toggle and slug field on the dashboard, with a note that published badges are visible to anyone with the URL;
Would you be up for doing the API side along those lines? Happy to help shape it. |
Hi @gusfcarvalho , thanks for your details response and proposal. Have you agreed with Doug-Read about above approach please? The reason that I am asking is that for API repo pr#557 Doug stated his concerns about generating SVG in API project. I don't mind following above proposal as long as it's agreed with Foug and anyone who is interested in API project. What do you think? |
|
Yes, this is shared understanding between ourselves :) Please note the closed PR you linked would still pose a risk, so it would still be unacceptable. (as it's not really implementing the above) |
Thanks for confirming @gusfcarvalho ; much appreciated. Is below spec captures the details you want us to implement in API project please? If all good I will start implementing, else I will wait for your feedback. |
SVG compliance badges
Summary
Add an optional server-side endpoint that generates SVG compliance badges from evidence selected by label names and values.
Motivation
Provide embeddable compliance indicators for repository READMEs and other documentation without requiring viewers to open CCF or authenticate. Ad hoc label queries avoid creating and maintaining saved evidence filters for each badge.
Implementation
badgestarget, and npm commands for running and testing it.POST /api/evidence/search, using 50-record pages sorted bylastSeenAtdescending.status.statevalues.not-satisfiedresult, otherwise green for anysatisfiedresult, or grey for empty/unknown results.Why This Repository?
This approach treats badges as an optional presentation adapter over an existing API. It allows independent deployment without changing the evidence-search contract or coordinating an API release.
This is a delivery tradeoff, not a requirement that badges remain outside the API. An API-native implementation would avoid fetching evidence over HTTP and could remove the service’s session-cookie dependency. It would also require an explicit API-side policy for anonymous access to aggregate compliance results.
Authentication And Security
Badge viewers do not authenticate, but upstream evidence searches still do. The service requires
CCF_BADGE_API_URLandCCF_BADGE_API_COOKIE_FILE; it does not bypass API authentication.The cookie is read from a mounted secret on each lookup to support rotation. Visitor credentials are not forwarded, and credentials remain outside frontend configuration.
Deployment requires disclosure approval: arbitrary label queries expose aggregate results over evidence readable by the service identity. Use least-privilege access, ingress restrictions where appropriate, TLS, and rate limiting.
Reliability
502for upstream or malformed-response failures,504for timeouts, and503when busy.Cache-Control: no-store; failures are never rendered as misleading grey badges.Verification
Both badge tests passed using an isolated Node-only Vitest configuration. Coverage includes query translation, pagination, SVG status precedence, credential rotation, validation, upstream failures, concurrency limits, and timeouts.