feat(security): config secret redaction — Spring application.{properties,yml} + Shopify {% schema %} (closes #58 phase-2)#136
Merged
Conversation
…ies,yml} + Shopify {% schema %} (closes #58 phase-2)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
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.




Summary
Implements Phase 2 of issue #58 — config secret redaction for Spring
application.properties/application.ymland Shopify Liquid{% schema %}blocks.(Supersedes the closed PR #133 — that PR was based on the Phase 1 branch
feat/issue-58-path-traversal-phase-1, which got deleted when PR #131 was merged. This PR is rebased directly ontomainand contains only the Phase 2 commit.)CodeLens's job is to map code structure — not to be a vault for production secrets. But many config-file formats mix structural metadata (key names) with sensitive values (passwords, API keys, connection strings) in the same file. If an agent-driven extraction layer indexes these files naively, CodeLens becomes a secret sink — the value ends up in the SQLite registry,
outline.json, MCP tool responses, and snapshot exports.This PR provides format-aware redaction that returns a key-only view of these config files. The raw file content stays on disk — an agent that needs the actual value reads the file directly, just like any source file. CodeLens never persists it.
Depends on #131 (Phase 1, MERGED) — Phase 2's
safe_read_file_for_indexingcomposes Phase 1'ssafe_read_file_within_projectwith the new redaction layer.Files
New:
scripts/security/config_secret_redaction.py—redact_application_properties(),redact_application_yml(),redact_shopify_schema(),redact_config_file()(auto-detect),is_config_file(),safe_read_file_for_indexing()(composes Phase 1 path-traversal + Phase 2 redaction)tests/test_config_secret_redaction.py— 63 tests covering all three formats, idempotency, malformed-JSON handling, profile-specific Spring variants, integration with Phase 1 path traversalModified:
scripts/security/__init__.py— re-exports Phase 2 public API alongside Phase 1Key design decisions
server.port,spring.datasource.url,spring.application.name, etc.) is intentionally narrow.application.ymlis a strict subset of YAML where every value is on the same line as its key — the line-by-line approach handles it correctly. A full YAML parser would also happily load anchors, tags, and multi-line strings — each one a redaction-bypass waiting to happen.url:,port:,password:) — not the dotted path. The properties-file allowlist matches dotted paths; the YAML allowlist matches bare keys. Both are conservative.defaultfield whose value is a non-empty string with<redacted>. Number/boolean defaults preserved (they're never secrets). Malformed JSON → block replaced with a{% comment %}schema redacted (malformed JSON){% endcomment %}marker so the agent sees something happened.safe_read_file_for_indexingcomposes Phase 1 + Phase 2. Single safe entry point for any extraction layer that might ingest config files: path-traversal check first (Phase 1), then format-aware redaction (Phase 2), then return.What Phase 2 deliberately does NOT do
secrets_engine.py's job, already shipped).Acceptance criteria
application.propertiesvalues redacted (except structural allowlist)application.ymlscalar values redacted (except allowlist + numbers/booleans){% schema %}stringdefaultfields redactedapplication-prod.properties) detectedsafe_read_file_for_indexingintegrates Phase 1 path-traversal + Phase 2 redactionjson+reonly)(Phases 3–7 of #58 — git safety guard, Secretlint, file system MCP tools, LLM schema validation, PoC generation — are out of scope for this Phase 2 PR.)
Test results
tests/test_config_secret_redaction.py— all passtests/test_path_traversal.py, 41 tests) — still pass (no regression after rebase onto merged main)Closes #58 (phase-2).