molecule-core/workspace-template
Molecule AI Backend Engineer c1b4dca5b7 fix(security): redact secrets from commit_memory payloads (#834)
Add _redact_secrets() in builtin_tools/security.py and apply it at every
commit_memory call site before content reaches the memories table.

Patterns scrubbed (replaced with [REDACTED]):
- sk-[A-Za-z0-9_-]{20,}          OpenAI/Anthropic keys (sk-, sk-ant-, sk-proj-)
- ghp_[A-Za-z0-9]{36}            GitHub classic PAT
- ghs_[A-Za-z0-9]{36}            GitHub server-to-server token
- github_pat_[A-Za-z0-9_]{82}    GitHub fine-grained PAT
- AKIA[0-9A-Z]{16}               AWS access key ID
- key/token/secret/password/api_key=<40+ chars>  Generic contextual (value replaced,
  keyword preserved: "api_key=[REDACTED]" not "[REDACTED]")

Call sites wired:
- builtin_tools/memory.py::commit_memory()     — LangChain tool (LangGraph path)
- a2a_tools.py::tool_commit_memory()           — MCP server path
- executor_helpers.py::commit_memory()         — CLI/SDK executor path

Implementation guarantees:
- Pure function (no side effects, no I/O)
- Idempotent: [REDACTED] does not match any pattern
- No false positives on normal prose (all patterns require ≥20-char prefix
  or ≥40-char value after known keyword)

Tests (36 passing):
- Per-pattern unit tests for all 6 secret types
- Idempotency tests
- Normal prose non-regression tests
- Integration: a2a_tools.tool_commit_memory scrubs ghp_ tokens before HTTP POST
- Integration: executor_helpers.commit_memory scrubs AWS keys and OpenAI keys
- Source inspection: memory.py imports and applies _redact_secrets before
  build_awareness_client() (i.e. before any storage operation)

conftest.py updated to load the real builtin_tools/security.py so that
executor_helpers and a2a_tools can import _redact_secrets during test collection.

Closes #834
Sub-issue of #725

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 22:43:50 +00:00
..
adapters feat(adapters): add Google ADK runtime adapter (#542) 2026-04-17 00:08:17 +00:00
builtin_tools fix(security): redact secrets from commit_memory payloads (#834) 2026-04-17 22:43:50 +00:00
molecule_audit fix(security): address Security Auditor findings on audit-ledger (#651) 2026-04-17 07:30:10 +00:00
plugins_registry fix(plugins_registry): deduplicate handlers in _deep_merge_hooks() 2026-04-17 05:22:00 +00:00
policies initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
scripts fix(github): refresh installation token when TTL < 10 min (#547) (#567) 2026-04-17 00:47:03 +00:00
skill_loader fix(security): hitl task-id ownership + wire fail_open_if_no_scanner in loader (closes #265, #268) 2026-04-15 21:18:52 -07:00
tests fix(security): redact secrets from commit_memory payloads (#834) 2026-04-17 22:43:50 +00:00
a2a_cli.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
a2a_client.py fix(a2a): add missing Authorization header to delegation and message calls (#401) 2026-04-16 00:53:18 -07:00
a2a_executor.py fix: properly remove adapter subdirectories + move shared code to root 2026-04-16 04:59:13 -07:00
a2a_mcp_server.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
a2a_tools.py fix(security): redact secrets from commit_memory payloads (#834) 2026-04-17 22:43:50 +00:00
adapter_base.py fix: properly remove adapter subdirectories + move shared code to root 2026-04-16 04:59:13 -07:00
agent.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
agents_md.py feat(#733): implement AGENTS.md auto-generation 2026-04-17 16:20:39 +00:00
build-all.sh chore: extract workspace runtime to PyPI + move adapter Dockerfiles to template repos 2026-04-16 04:33:10 -07:00
claude_sdk_executor.py feat(issue-652): wire effort and task_budget to claude sdk output_config 2026-04-17 07:33:07 +00:00
cli_executor.py feat(adapters): add gemini-cli runtime adapter (closes #332) (#379) 2026-04-15 23:30:00 -07:00
config.py fix(gate-6): restore claude-opus-4-7 default — reverted by pre-#743 branch 2026-04-17 16:21:04 +00:00
consolidation.py fix(security): N1 — add auth headers to all platform calls in Python callers 2026-04-14 08:37:50 +00:00
coordinator.py fix: properly remove adapter subdirectories + move shared code to root 2026-04-16 04:59:13 -07:00
Dockerfile fix(template): copy molecule-git-token-helper.sh into image and fix path 2026-04-17 06:27:08 +00:00
entrypoint.sh fix(template): copy molecule-git-token-helper.sh into image and fix path 2026-04-17 06:27:08 +00:00
events.py fix(security): Cycle 5 — auth middleware, injection hardening, skill sandbox 2026-04-14 04:44:42 +00:00
executor_helpers.py fix(security): redact secrets from commit_memory payloads (#834) 2026-04-17 22:43:50 +00:00
heartbeat.py fix(security): N1 — add auth headers to all platform calls in Python callers 2026-04-14 08:37:50 +00:00
hermes_executor.py fix(merge): combine response_format (#498) and tools (#497) in hermes_executor 2026-04-17 07:03:22 +00:00
initial_prompt.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
main.py feat(#733): implement AGENTS.md auto-generation 2026-04-17 16:20:39 +00:00
molecule_ai_status.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
platform_auth.py fix(security): H3 github_pat_ redaction + M4 atomic token write (audit cycle 10) 2026-04-14 09:34:27 +00:00
plugins.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
preflight.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
prompt.py fix: properly remove adapter subdirectories + move shared code to root 2026-04-16 04:59:13 -07:00
pytest.ini initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
rebuild-runtime-images.sh fix(security): allowlist-validate runtime arg in rebuild-runtime-images.sh 2026-04-17 10:27:11 +00:00
requirements.txt feat: molecule-audit-ledger — HMAC-SHA256 immutable agent event log (#594) 2026-04-17 06:55:36 +00:00
shared_runtime.py fix: properly remove adapter subdirectories + move shared code to root 2026-04-16 04:59:13 -07:00
transcript_auth.py fix(security): /transcript endpoint fails closed when auth token missing (#328) 2026-04-15 21:17:37 -07:00
watcher.py fix(security): H1 — replace MD5 with SHA-256 in config/skill watchers 2026-04-14 07:52:07 +00:00