Skip to content

security(promtail): redact URL-embedded credentials (#194)#511

Merged
mvillmow merged 3 commits into
mainfrom
194-url-embedded-secrets-redaction
May 13, 2026
Merged

security(promtail): redact URL-embedded credentials (#194)#511
mvillmow merged 3 commits into
mainfrom
194-url-embedded-secrets-redaction

Conversation

@mvillmow
Copy link
Copy Markdown
Contributor

Summary

  • Adds two replace stages to every promtail pipeline that already performs credential redaction (currently hermes and nats):
    • URL-embedded credentials: scheme://user:password@host -> scheme://<redacted>@host
    • Query-string secrets: ?api_key=..., &access_token=..., &client_secret=..., &password=..., &token=..., &auth_token=..., &secret=..., &key=... -> <redacted>
  • Adds regression tests in tests/test_configs.py that iterate over every redaction-enabled scrape job and assert both forms are stripped.
  • Out of scope (separate issues): adding redaction to pipelines that don't currently have it (Add syslog pipeline redaction stages for secret patterns #190 syslog, etc).

Closes #194

Test plan

  • pixi run test — 319 passed, coverage 99.40%
  • Verified each new regex against the Go RE2 engine (promtail's runtime) with positive + negative cases (alice:hunter2@, ?api_key=abc, &access_token=..., plus a no-creds URL).
  • Verified YAML still parses (python -c "import yaml; yaml.safe_load(open('configs/promtail.yml'))").

Generated with Claude Code

mvillmow and others added 2 commits May 13, 2026 07:02
Adds two new replace stages to the hermes pipeline:
- scheme://user:password@host -> scheme://<redacted>@host
- ?api_key=... / &access_token=... / &client_secret=... / etc -> <redacted>

Adds regression tests asserting both forms are stripped before logs leave
promtail.

Closes #194

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…194)

The nats scrape job gained credential redaction in #191 (merged after
this branch diverged). Mirror the URL-embedded + query-string secret
stages so the new pipeline has the same coverage as hermes.

Generalise the regression tests to assert that every scrape job which
performs credential redaction also strips URL-embedded credentials and
query-string API keys.

Refs #194

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mvillmow mvillmow force-pushed the 194-url-embedded-secrets-redaction branch from 2d75683 to f18eafe Compare May 13, 2026 14:03
…#194)

The rebased redaction pipelines on top of #190 (syslog secrets) and
#191/#509 (NATS secrets) left the syslog job without URL-embedded
credential and query-string secret redaction, while hermes and nats
both had them. The test_url_embedded_credentials_redacted_in_all_redaction_pipelines
test (which enumerates all jobs already doing replace-based redaction)
demanded URL-cred handling for every such job — so syslog regressed.

Also adds 'yamllint disable-line rule:line-length' to the three
query-string regex lines, which intentionally exceed 120 chars because
splitting an alternation across YAML lines would inject whitespace into
the regex and break matching.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mvillmow mvillmow merged commit 7759e85 into main May 13, 2026
20 checks passed
@mvillmow mvillmow deleted the 194-url-embedded-secrets-redaction branch May 13, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend redaction regex to cover URL-embedded secrets

1 participant