Skip to content

fix(observability): avoid leaking Sentry setup secrets - #5489

Merged
JSONbored merged 2 commits into
mainfrom
codex/fix-sensitive-data-exposure-in-setup-script
Jul 12, 2026
Merged

fix(observability): avoid leaking Sentry setup secrets#5489
JSONbored merged 2 commits into
mainfrom
codex/fix-sensitive-data-exposure-in-setup-script

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Prevent accidental local exposure of high-value credentials (SENTRY_API_TOKEN and GRAFANA_ADMIN_PASSWORD) that were being placed on curl command lines and exported into child environments while preserving the script's idempotent create/update/health-check behavior.

Description

  • Stop auto-exporting .env by removing set -a when sourcing .env so secrets are not put into child process environments.
  • Replace Basic-Auth-in-argv with a temporary, permissioned netrc file and use --netrc-file so Grafana admin credentials are not visible in process argv.
  • Add a grafana_curl() wrapper that calls env -u GRAFANA_ADMIN_PASSWORD -u SENTRY_API_TOKEN curl ... to ensure those env vars are removed from curl's child environment.
  • Pipe the JSON payload to curl with --data-binary @- (stdin) instead of -d "$(payload)" to keep the Sentry API token out of curl process arguments.
  • Add a unit regression assertion in test/unit/selfhost-grafana-sentry-datasource.test.ts that verifies the script no longer contains set -a, -u "$AUTH", or -d "$(payload)" and that the new secure patterns (--netrc-file, --data-binary @-, and env -u ... curl) are present.

Testing

  • Ran bash -n scripts/setup-sentry-datasource.sh and it returned clean syntax (no errors).
  • Ran npx vitest run test/unit/selfhost-grafana-sentry-datasource.test.ts and the test file passed (10 tests total).
  • Confirmed behavior is preserved: idempotent datasource GET/PUT/POST and health-check continue to run while secrets are no longer exposed in argv or inherited child environments.

Codex Task

@JSONbored JSONbored self-assigned this Jul 12, 2026
@JSONbored
JSONbored marked this pull request as draft July 12, 2026 23:08
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 12, 2026
@loopover-orb

loopover-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-12 23:23:04 UTC

2 files · 2 blockers · readiness 89/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.

2. Maintainer requires a linked issue — Link the relevant issue (for example `Closes #123`) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers No AI review summary
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (draft PR; no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 44 registered-repo PR(s), 36 merged, 424 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 44 PR(s), 424 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ⚠️ ℹ️ Insufficient signal risk: clean · value: insufficient-signal — Nothing measurable for the structural-improvement analyzers on this PR (e.g. no code files changed).
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 44 PR(s), 424 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Mark ready when done.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.72%. Comparing base (29c18f2) to head (3dff84b).
⚠️ Report is 17 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5489   +/-   ##
=======================================
  Coverage   94.72%   94.72%           
=======================================
  Files         559      559           
  Lines       44664    44664           
  Branches    14664    14664           
=======================================
  Hits        42308    42308           
  Misses       1621     1621           
  Partials      735      735           
Flag Coverage Δ
shard-1 44.04% <ø> (ø)
shard-2 35.20% <ø> (ø)
shard-3 32.00% <ø> (ø)
shard-4 32.05% <ø> (ø)
shard-5 32.67% <ø> (ø)
shard-6 43.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…atasource.sh

The PR only hardened setup-sentry-datasource.sh, but setup-github-datasource.sh
has the byte-identical vulnerable pattern -- set -a-exported GITHUB_TOKEN/
GRAFANA_ADMIN_PASSWORD, an AUTH="admin:$PASSWORD" curl -u argv, and -d
"$(payload)" embedding the token in argv too -- and both scripts' own header
comments document them as siblings/templates for each other. Applies the
identical hardening: a temp 0600 netrc file, a grafana_curl() wrapper that
also strips both secrets from curl's child env via env -u, and piping the
payload over stdin instead of argv. Verified end-to-end against a real local
HTTP server (create + update + health-check all authenticate correctly via
--netrc-file alone). Also adds this script's first-ever dedicated test file --
it previously had none.
@JSONbored
JSONbored marked this pull request as ready for review July 12, 2026 23:30
@JSONbored
JSONbored merged commit c187f4e into main Jul 12, 2026
18 checks passed
@JSONbored
JSONbored deleted the codex/fix-sensitive-data-exposure-in-setup-script branch July 12, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant