fix: reject non-https URLs in data/metrics.json (scripts/validate-metrics.mjs) - #304
Open
kubestellar-hive[bot] wants to merge 1 commit into
Open
kubestellar-hive[bot] wants to merge 1 commit into
kubestellar-hive[bot] wants to merge 1 commit into
Conversation
validate-metrics.mjs checked every URL field in data/metrics.json for presence but never for scheme, while every one of those values is rendered directly into an <a href> by MetricsDashboard and by the SyncStatus block in ReferenceArchitectures. A javascript: value in metrics[].sourceUrl, series.*.sourceUrl, breakdowns.*.sourceUrl, referenceArchitectureLifecycle.sourceUrl or sources.*.repository passed npm run validate:metrics and was emitted verbatim into the built HTML. sources.*.repository is also string-concatenated into a commit URL, so a javascript: value there survives the concatenation as a javascript: URL. Adds a checkUrl() helper that parses with new URL and requires the https scheme, wired into all six sinks. Absent values are skipped so the existing presence checks remain the single source of 'missing', and every pre-existing error message and path is unchanged. Closes #303 Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
Contributor
Author
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "sec-check" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
This was referenced Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security Fix
scripts/validate-metrics.mjsis the only gate ondata/metrics.json, and it checked every URL field for presence but never for scheme. Every one of those values is rendered directly into an<a href>on the published site, so ajavascript:value passednpm run validate:metricsand was emitted verbatim into the built HTML.Six sinks were unguarded:
metrics[].sourceUrlsrc/components/MetricsDashboard/index.js:33series.*.sourceUrlsrc/components/MetricsDashboard/index.js:39breakdowns.*.sourceUrlsrc/components/MetricsDashboard/index.js:50referenceArchitectureLifecycle.sourceUrlsrc/components/MetricsDashboard/index.js:19sources.architectures.repositorysrc/components/ReferenceArchitectures/index.js:26and, concatenated intocommitUrl,:30sources.*.sourceUrlsources.*.repositoryis string-concatenated (`${repository}/commit/${revision}`), so ajavascript:value survives the concatenation as ajavascript:URL.scripts/validate-awards.mjsalready performs the equivalent check for the sibling filedata/awards.json; this bringsvalidate-metrics.mjsin line.What changed
scripts/validate-metrics.mjsgains acheckUrl()helper that parses withnew URL(so relative and unparseable values are rejected too) and requires thehttps:scheme, wired into all six sinks.pathare byte-identical. The twoObject.valuesloops becameObject.entriesonly so the new error can name the offending key.data/metrics.jsonpasses unchanged — all six live values are alreadyhttps://.Verification
Files and coordination
This PR claims exactly two files:
scripts/validate-metrics.mjs— the fixtests/validate-metrics-urls.test.mjs— new file, 9 testsNo other open PR touches
scripts/validate-metrics.mjs. The new tests deliberately live in a new file rather than intests/validate-metrics.test.mjs, which open PR #263 is editing, so the two do not conflict. #287 (tests/metrics-data.test.mjs) and #239 (tests/projects-born-data.test.mjs) are likewise test-only and in different files.Closes #303
Filed by sec-check agent (ACMM L4/L5 — hold-gated mode). Hold-gated: human review required.
— hive: agent=sec-check backend=copilot model=claude-opus-5