Fix broken main: define Config.public_only, and add a reviewed path to public serving - #1
Merged
Conversation
github.py filters the repo listing on `cfg.public_only`, but the field was
never added to Config, so `collect()` raised AttributeError on every pass:
File "/app/jq_collector/github.py", line 306, in <genexpr>
or (cfg.public_only and ...)
AttributeError: 'Config' object has no attribute 'public_only'
The local refresh loop is unaffected, so the collector keeps serving and the
target stays "up" - it just silently loses every CI, drift, pull-request and
issue series, and the board shows No data for two thirds of its panels.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Filtering private repos out of collection is not sufficient on its own. With anonymous access enabled, a visitor can POST arbitrary PromQL to /api/ds/query and read the raw label index through /api/datasources/proxy - and purged names linger in that index until head compaction, so deleting the data does not remove the names. Measured on this stack: after purging all seven private repos, the index still returned every one of them, and a Prometheus restart did not clear it. So this adds both halves: - docker-compose.public.yml turns anonymous access off and Grafana's public-dashboard feature on. A public link serves only that dashboard's own queries with no datasource behind it; /api/search, /api/ds/query and the proxy all return 401. - scripts/check-public-safe.sh is the preflight. It verifies each exported repo is public *on GitHub* rather than trusting our own label, that anonymous queries and the proxy are refused, that Prometheus and the collector stay loopback-only, and that no public link is live while JQ_PUBLIC_ONLY is off. Non-zero exit if not. - Public dashboards do not resolve template variables, so every panel filtered on $repo renders No data behind a public link. make-public-dashboard.py generates fleet-public.json from fleet.json with the variable and its selectors stripped. - check-dashboard.py now validates every dashboard in the folder, not just fleet.json, so the generated copy cannot drift unnoticed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
mainis currently brokengithub.pyfilters the repo listing oncfg.public_only, but the field was never added toConfig. Every GitHub refresh raises:This fails quietly. The local refresh loop is unaffected, so the collector keeps serving
/metricsand the Prometheus target stays up — it just loses every CI, drift, pull-request and issue series, and the board shows No data on roughly two thirds of its panels. Confirmed by checking outmaininto a temp dir and instantiatingConfig.First commit is the four-line fix, isolated so it can be reviewed or reverted on its own.
Second commit: serving the board world-readable
Restricting collection to public repos is not sufficient on its own, which is the part worth reviewing.
With anonymous access enabled, a visitor can POST arbitrary PromQL to
/api/ds/queryand read the raw label index via/api/datasources/proxy. Purged names linger in that index until head compaction — measured here, after deleting all seven private repos the index still returned every one of their names, and a Prometheus restart did not clear them. Deleting the data does not remove the names.So this adds both halves:
docker-compose.public.yml— anonymous off, Grafana public dashboards on. A public link serves only that dashboard's own queries with no datasource behind it. Verified: public link and its panel queries200;/api/search,/api/ds/queryand the proxy all401.scripts/check-public-safe.sh— the preflight. Verifies each exported repo is public on GitHub rather than trusting our ownvisibilitylabel, that anonymous queries and the proxy are refused, that Prometheus and the collector stay loopback-only, and that no public link is live whileJQ_PUBLIC_ONLYis off. Exits non-zero otherwise.scripts/make-public-dashboard.py— public dashboards don't resolve template variables, so every panel filtered on$reporenders No data behind a public link. This generatesfleet-public.jsonfromfleet.jsonwith the variable and its selectors stripped.check-dashboard.pynow validates every dashboard in the folder, so the generated copy can't drift unnoticed.Verification
No CI exists in this repo, so this was checked by hand from a clean
git archiveof the branch:Config.public_only = Truefleet-public.jsonregenerates from sourceDefault behaviour is unchanged:
JQ_PUBLIC_ONLYdefaults tofalseand the overlay is opt-in.🤖 Generated with Claude Code