Repository navigation
feat(insights): redact secrets in digests and saved reports - #1339
Merged
Merged
Conversation
Session content reaching the analysis model and the report under ~/.infer/insights/ now passes a local redactor first: PEM private-key blocks, GitHub token shapes (ghp_, gho_, ghu_, ghs_, ghr_, github_pat_), and the values of provider-secret env vars set in the environment, plain and JSON-escaped. Patterns mirror infer-action's src/redact.ts.
3 tasks
inference-gateway-maintainer
Bot
marked this pull request as ready for review
September 26, 2026 16:08
inference-gateway-maintainer
Bot
requested a review
from a team
as a code owner
September 26, 2026 16:08
5 tasks
Contributor
|
@infer Can you review this? are we making sure the LLM never sees leaked secrets in the flow? |
Contributor
Author
|
Model: Todos
Pull Request✅ Infer Result: SuccessReview: are we making sure the LLM never sees leaked secrets in the flow?Short answer: yes for the mainline flow - and I verified it end to end - but three residual holes keep it short of "never". Two are one-line fixes. What I verified as covered
Findings
Minor notes (no action required)
Model: Tokens: 352,631 in · 21,715 out · 374,346 total (8 requests) Tool calls: 14 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
Contributor
|
🎉 This PR is included in version 0.210.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Resolves #1338
Summary
infer insightssent verbatim session content to the analysis model and saved it into the report under~/.infer/insights/- a failed tool call whose error echoes a credential, or a log line printing one, ended up in the provider request and the saved markdown. The digest and the report now pass through a local redactor before either leaves the process, reusing the patterns infer-action already ships insrc/redact.ts.Changes
internal/insights/redact.go:redact()masks credential shapes and secret env values locally, before any network call. Patterns kept in step with infer-action'sredact.ts:-----BEGIN [A-Z ]*PRIVATE KEY( BLOCK)?-----...), covering RSA, DSA, EC, OpenSSH, PKCS#8 and PGP keys.ghp_,gho_,ghu_,ghs_,ghr_(36+ chars) andgithub_pat_(82+ chars).SECRET_ENV_NAMES: GITHUB_TOKEN, the generated provider API-key list, OTEL_EXPORTER_OTLP_HEADERS, MEMORY_TOKEN, MEMORY_DEPLOY_KEY) are redacted when set in the environment, both plain and JSON-escaped (values shorter than 8 chars are skipped, matching infer-action's default).buildDigestwraps its return inredact(...)- one choke point covering the session intents, the memory index, and the verbatim failure and log samples beforeanalyzemakes the model call. Counts and normalized error keys (which are never rendered) are unaffected.renderReportwraps its return inredact(...)- the saved report under~/.infer/insights/is redacted the same way, including failure and log samples.[redacted](markdown-safe; matches the browser tool's existing redaction convention).internal/insights/redact_test.go: the requiredbuildDigesttest drives the full collect path with a GitHub token echoed in a tool error sample and asserts it is masked (and counts unchanged); a report-rendering test pins failure/log samples; table-driven tests cover the credential shapes and env-value redaction (plain, JSON-escaped, short-value skip).Docs follow-up: inference-gateway/docs#830 (insights redaction is user-facing; the affected pages are listed there).
Downstream impact: none beyond docs - no schema, config, or env-var changes; only the docs repo needs a follow-up (inference-gateway/docs#830).
Verification
go test ./internal/insights/and fulltask testpass.task precommit:runpasses (mod:tidy, mocks, fmt, golangci-lint 0 issues, markdownlint).