diff --git a/manifests/context-packs/skill-triggers@1.json b/manifests/context-packs/skill-triggers@1.json index 2754f65e9..39101dfb0 100644 --- a/manifests/context-packs/skill-triggers@1.json +++ b/manifests/context-packs/skill-triggers@1.json @@ -10,7 +10,7 @@ "id": "hand-seeded", "source": "manual-curation-pending-regeneration" }, - "registryDigest": "23d2319fbb6e5a75b914fd49baab8f8c1f7aab94513911918f3e71a6f96d0d92", + "registryDigest": "e97d914bd5d871e528da92d905fd768be77b89220a108817f59bac2cbc2f0969", "schemaVersion": 1, "triggers": { "skill:agent-runtime-gateway-smoke-test": [ diff --git a/skills/continuous-learning-v2/hooks/observe.sh b/skills/continuous-learning-v2/hooks/observe.sh index c4cdfff2f..93a115620 100755 --- a/skills/continuous-learning-v2/hooks/observe.sh +++ b/skills/continuous-learning-v2/hooks/observe.sh @@ -290,9 +290,11 @@ _SECRET_RE = re.compile( # before scrubbing; a DSN cut by truncation before its "@" ends at \Z, # except a bare trailing host:port after http(s):// such as http://localhost:3000; # any other scheme (postgres://app:1234) is redacted even when the password is numeric (#3568). +# PEM blocks run first: a label such as secret= in front of the BEGIN marker +# would otherwise let _SECRET_RE eat "-----BEGIN" and hide the block from this match. +_PEM_RE = re.compile(r"-----BEGIN[A-Z ]{0,40}PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]{0,40}PRIVATE KEY-----|\Z)") _SECRET_VALUE_RE = re.compile( - r"-----BEGIN[A-Z ]{0,40}PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]{0,40}PRIVATE KEY-----|\Z)" - r"|(?:(? 2000: @@ -390,9 +393,11 @@ _SECRET_RE = re.compile( # before scrubbing; a DSN cut by truncation before its "@" ends at \Z, # except a bare trailing host:port after http(s):// such as http://localhost:3000; # any other scheme (postgres://app:1234) is redacted even when the password is numeric (#3568). +# PEM blocks run first: a label such as secret= in front of the BEGIN marker +# would otherwise let _SECRET_RE eat "-----BEGIN" and hide the block from this match. +_PEM_RE = re.compile(r"-----BEGIN[A-Z ]{0,40}PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]{0,40}PRIVATE KEY-----|\Z)") _SECRET_VALUE_RE = re.compile( - r"-----BEGIN[A-Z ]{0,40}PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]{0,40}PRIVATE KEY-----|\Z)" - r"|(?:(?= 5000 + val = _PEM_RE.sub("[REDACTED]", val) val = _SECRET_RE.sub(lambda m: m.group(1) + m.group(2) + (m.group(3) or "") + "[REDACTED]", val) val = _SECRET_VALUE_RE.sub(lambda m: (m.group(2) or "") + "[REDACTED]", val) return _CUT_TAIL_RE.sub("[REDACTED]", val) if cut else val diff --git a/tests/hooks/observe-secret-redaction.test.js b/tests/hooks/observe-secret-redaction.test.js index 3fef5e30c..51109e1fe 100644 --- a/tests/hooks/observe-secret-redaction.test.js +++ b/tests/hooks/observe-secret-redaction.test.js @@ -195,7 +195,9 @@ if (process.platform === 'win32') { for (const [label, text, expected] of [ ['long sk-proj key', `OPENAI_API_KEY=${openaiProjectKey}${'B'.repeat(300)}${longTail}`, 'OPENAI_API_KEY=[REDACTED]'], ['sk- password with a suffix', `password=${'sk-'}${'A'.repeat(30)}.${longTail}`, 'password=[REDACTED]'], - ['GitHub token with a suffix', `token=${'ghp_'}${'0'.repeat(30)}/${longTail}`, 'token=[REDACTED]'] + ['GitHub token with a suffix', `token=${'ghp_'}${'0'.repeat(30)}/${longTail}`, 'token=[REDACTED]'], + ['PEM private key block', + `secret=-----BEGIN RSA ${'PRIVATE'} KEY-----\n${longTail}\n-----END RSA PRIVATE KEY-----`, 'secret=[REDACTED]'] ]) { for (const [phase, input, expectedEvent] of [ ['post', { tool_name: 'Read', tool_input: { file_path: '/tmp/x' }, tool_response: { content: text } }],