@hasna/hooks 0.12.4 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/hooks-mcp.js +2 -2
- package/bin/index.js +3 -3
- package/bin/native-safety-worker.cjs +1 -1
- package/bin/serve.js +2 -2
- package/dist/index.js +3 -3
- package/dist/lib/codex-safety-check.d.ts +1 -1
- package/hooks/hook-signed-link-guard/src/links.ts +61 -6
- package/hooks/hook-signed-link-output/README.md +43 -10
- package/hooks/hook-signed-link-output/src/hook.ts +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -365,7 +365,7 @@ Codex is installed through npm, pass the platform package's native binary rather
|
|
|
365
365
|
than its JavaScript launcher. Executable ownership, permissions, ancestry and
|
|
366
366
|
bytes are checked. Supported protocol versions are 0.153.0, 0.154.0,
|
|
367
367
|
0.154.0-alpha.6.1, 0.155.0, 0.155.1, 0.156.1, 0.157.0, 0.157.1, 0.158.0, 0.159.0, 0.159.2,
|
|
368
|
-
0.159.3 and 0.160.
|
|
368
|
+
0.159.3, 0.160.0 and 0.160.1;
|
|
369
369
|
other versions refuse pending compatibility validation. Updating Codex can
|
|
370
370
|
therefore require a compatible Hooks release before native safety verification
|
|
371
371
|
and trust provisioning succeed. Keep existing hook definitions and trust intact
|
package/bin/hooks-mcp.js
CHANGED
|
@@ -347,8 +347,8 @@ var init_registry = __esm(() => {
|
|
|
347
347
|
{
|
|
348
348
|
name: "signed-link-output",
|
|
349
349
|
displayName: "Signed Link Output",
|
|
350
|
-
description: "Claude PostToolUse backstop: replaces
|
|
351
|
-
version: "0.1.
|
|
350
|
+
description: "Claude PostToolUse backstop: replaces capability links in tool output \u2014 signature-class query or fragment parameters, and anchored path-borne provider classes such as the Stripe Connect onboarding link \u2014 with a redaction marker (updatedToolOutput, where the running Claude Code supports it) and tells the model not to repeat or store the link. Every string is walked, so nested metadata such as a browser result's `_meta.browser_use.url` is covered. It runs after the tool, so it cannot undo display or other persistence",
|
|
351
|
+
version: "0.1.1",
|
|
352
352
|
category: "Security",
|
|
353
353
|
event: "PostToolUse",
|
|
354
354
|
matcher: "^(Bash|WebFetch|mcp__.*)$",
|
package/bin/index.js
CHANGED
|
@@ -378,8 +378,8 @@ var init_registry = __esm(() => {
|
|
|
378
378
|
{
|
|
379
379
|
name: "signed-link-output",
|
|
380
380
|
displayName: "Signed Link Output",
|
|
381
|
-
description: "Claude PostToolUse backstop: replaces
|
|
382
|
-
version: "0.1.
|
|
381
|
+
description: "Claude PostToolUse backstop: replaces capability links in tool output \u2014 signature-class query or fragment parameters, and anchored path-borne provider classes such as the Stripe Connect onboarding link \u2014 with a redaction marker (updatedToolOutput, where the running Claude Code supports it) and tells the model not to repeat or store the link. Every string is walked, so nested metadata such as a browser result's `_meta.browser_use.url` is covered. It runs after the tool, so it cannot undo display or other persistence",
|
|
382
|
+
version: "0.1.1",
|
|
383
383
|
category: "Security",
|
|
384
384
|
event: "PostToolUse",
|
|
385
385
|
matcher: "^(Bash|WebFetch|mcp__.*)$",
|
|
@@ -36598,7 +36598,7 @@ var init_codex_safety_check = __esm(() => {
|
|
|
36598
36598
|
init_native_readiness_command();
|
|
36599
36599
|
init_native_safety2();
|
|
36600
36600
|
init_native_readiness();
|
|
36601
|
-
SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0"];
|
|
36601
|
+
SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1"];
|
|
36602
36602
|
versions = new Set(SUPPORTED_CODEX_SAFETY_VERSIONS);
|
|
36603
36603
|
CodexSafetyError = class CodexSafetyError extends Error {
|
|
36604
36604
|
code;
|
|
@@ -17,4 +17,4 @@ var{defineProperty:fZ,getOwnPropertyNames:t0,getOwnPropertyDescriptor:e0}=Object
|
|
|
17
17
|
`).replace(/%s/g,()=>G[K++]?.value??"")+(K<G.length?" "+G.slice(K).map((H)=>H.value).join(" "):"")}if(z==="cat"){let Y=Z.indexOf("<<");if(Y<0)return null;let G=JZ(Z,Y),K=Z.indexOf(`
|
|
18
18
|
`,Y);if(!G||K<0)return null;let H=LZ(Z,K,[G]);if(H<0)return null;let B=Z.slice(K+1,H);return B.slice(0,B.lastIndexOf(G.delimiter)).replace(/\n$/,"")}return null}function rZ(Z,J,$){for(let X of tZ(Z).bodies){let z=Z0(X);if(z===null)continue;let Q=m(z,J+1,$.debug);if(Q.refused)return Q}return q}function m(Z,J=0,$=!1){if(typeof Z!=="string"||!Z.trim())return q;if(J>r3)return EZ.test(Z)?F("unclassifiable"):q;let{segments:X,trustworthy:z}=K0(Z);if(!z)return EZ.test(Z)?F("unclassifiable"):q;let Q=$,Y=(G)=>m(G,J+1,Q);for(let G of e3(Z)){if(G.runsBody){let K=Y(G.body);if(K.refused)return K}if(!G.quoted){let K=tZ(G.body,"heredoc");if(!K.complete&&EZ.test(G.body))return F("unclassifiable");for(let H of K.bodies){let B=Y(H);if(B.refused)return B}}}for(let G=0;G<X.length;G++){let K=X[G];for(let L of K.words){let v=tZ(L.text);if(!v.complete&&EZ.test(L.text))return F("unclassifiable");for(let k of v.bodies){let w=Y(k);if(w.refused)return w}}let H=l(K),B=K.words.map((L,v)=>({word:XZ(L.text),redirect:K.redirects.has(v)})),U=B.slice(0,H<0?B.length:H).map((L)=>L.word),V=H>=0?o(B[H].word.value):"";if(H<0||["export","declare","typeset","readonly","local"].includes(V)){if(Q=m0([...U,...B.slice(H+1).map((L)=>L.word)],Q),H<0)continue}let C=m0(U,Q),_=B.slice(H+1).filter((L)=>!L.redirect).map((L)=>L.word),O=B.slice(H+1).filter((L)=>L.redirect).map((L)=>L.word),M=B[H].word,j=o(M.value),c={depth:J,appendsArgs:!1,debug:C};if(H>0&&B[H-1].word.value==="function"){let L=_.filter((k)=>!["{","()","(",")"].includes(k.value)),v=$0(L,c);if(v.refused)return v;continue}if(G>0&&d0(K.sepBefore)&&eZ(j,_)){let L=X[G-1],v=o3(Z,L),k=v===null?null:Z0(v);if(k!==null){let w=m(k,J+1,C);if(w.refused)return w}}let p=X[G+1];if(p&&/<\(\s*$/.test(p.sepBefore)&&(yZ.has(j)||j==="source"||j===".")){let L=p.words[0].start-p.sepBefore.length+p.sepBefore.lastIndexOf("("),v=qZ(Z,L),k=v<0?null:Z0(Z.slice(L+1,v-1));if(k!==null){let w=m(k,J+1,C);if(w.refused)return w}}let a=i0(j,M,_,O,K.words.slice(0,H+1),c);if(a.refused)return a}return q}function o3(Z,J){let $=J.words[0],X=J.words[J.words.length-1];return $&&X?Z.slice($.start,X.end):null}function t3(Z){let J=o(Z.value);return/[$`]/.test(J)||J===""?void 0:J}function i0(Z,J,$,X,z,Q){let Y=Q.depth,G=(K)=>m(K,Y+1,Q.debug);if(J.opaque){let K=t3(J);if(K===void 0){let H=$.find((U)=>!U.value.startsWith("-")),B=RZ($,Q);if(!B.refused)return q;return B.rule!=="unclassifiable"||H!==void 0&&!H.opaque&&A3.has(H.value)?B:q}Z=K}if(Z==="gh")return RZ($,Q);if(yZ.has(Z)){let K=Q0($);if(K){let H=G(K.value);if(H.refused||!K.opaque)return H;return rZ(K.raw,Y,Q)}for(let H of X){let B=G(H.value);if(B.refused)return B;if(H.opaque){let U=rZ(H.raw,Y,Q);if(U.refused)return U}}return q}if(p3.has(Z)){let K=$.findIndex((B)=>B.value==="-c"||B.value==="--command"||/^-[A-Za-z]*c$/.test(B.value)),H=K>=0?$[K+1]:void 0;return H?G(H.value):oZ($,Q)}if(Z==="eval"||Z==="watch"){let K=$;if(Z==="watch"){let B=0;while(B<$.length&&$[B].value.startsWith("-")){if($[B].value==="--"){B++;break}if(["-n","--interval","-q","--equexit"].includes($[B].value))B++;B++}K=$.slice(B)}let H=G(K.map((B)=>B.value).join(" "));if(H.refused)return H;for(let B of K){let U=rZ(B.raw,Y,Q);if(U.refused)return U}return q}if(Z==="env")return G(FZ([...z.map((K)=>XZ(K.text).value),...$.map((K)=>K.value)]));if(Z==="ssh"){let K=0;for(;K<$.length;K++){let U=$[K].value;if(!U.startsWith("-"))break;if(a3.has(U))K++}let H=$.slice(K+1);if(H[0]?.value==="--")H.shift();let B=H.map((U)=>U.value).join(" ");return B?G(B):q}if(Z==="xargs"){let K=0,H=!1;for(;K<$.length;K++){let B=$[K].value;if(B==="--"){K++;break}if(!B.startsWith("-"))break;if(/^-I|^-i|^--replace/.test(B))H=!0;if(s3.has(B))K++}return $0($.slice(K),{depth:Y,appendsArgs:!H,debug:Q.debug})}if(Z==="find"){for(let K=0;K<$.length;K++){if(!["-exec","-execdir","-ok","-okdir"].includes($[K].value))continue;let H=K+1;while(H<$.length&&$[H].value!==";"&&$[H].value!=="+")H++;let B=$0($.slice(K+1,H),Q);if(B.refused)return B;K=H}return q}if(d3.has(Z))return oZ($,Q);if(i3.get(Z)?.includes($[0]?.value??""))return oZ($.slice(1),Q);return q}function $0(Z,J){if(Z.length===0)return q;let $=o(Z[0].value);if($==="gh")return RZ(Z.slice(1),J);if(yZ.has($)){let X=Q0(Z.slice(1));return X?m(X.value,J.depth+1,J.debug):q}return i0($,Z[0],Z.slice(1),[],[],J)}function oZ(Z,J){let $=Z.findIndex((X)=>!X.opaque&&o(X.value)==="gh"&&(X.value==="gh"||X.value.includes("/")));return $>=0?RZ(Z.slice($+1),J):q}function Q0(Z){for(let J=0;J<Z.length;J++){let $=Z[J].value;if($==="--")return;if(!$.startsWith("-")&&!$.startsWith("+"))return;if($==="-c"||/^-[A-Za-z]+$/.test($)&&$.includes("c"))return Z.slice(J+1).find((X)=>!X.value.startsWith("-")||X.value==="-");if(/^[-+][A-Za-z]*[oO]$/.test($))J++}return}function e3(Z){let J=[],$=0;for(;;){let X=Z.indexOf("<<",$);if(X<0)break;if($=X+2,Z[X+2]==="<"||X>0&&Z[X-1]==="<"){$=X+3;continue}let z=JZ(Z,X);if(!z)continue;let Q=Z.lastIndexOf(`
|
|
19
19
|
`,X)+1,Y=Z.indexOf(`
|
|
20
|
-
`,X);if(Y<0)continue;let G=LZ(Z,Y,[z]),K=G<0?Z.slice(Y+1):Z.slice(Y+1,G),H=G<0?K:K.slice(0,Math.max(0,K.lastIndexOf(z.delimiter))).replace(/\n$/,""),B=Z.slice(Q,X)+" HEREDOC_OPERATOR "+Z.slice(z.end,Y);J.push({body:H,runsBody:Z4(B),quoted:z.quoted})}return J}function Z4(Z){let{segments:J}=K0(Z),$=J.findIndex((G)=>G.words.some((K)=>K.text==="HEREDOC_OPERATOR"));if($<0)return!1;let X=(G)=>{let K=l(G);if(K<0)return{verb:"",args:[]};let H=G.words.slice(K+1).filter((B)=>B.text!=="HEREDOC_OPERATOR").map((B)=>XZ(B.text));return{verb:o(XZ(G.words[K].text).value),args:H}},{verb:z,args:Q}=X(J[$]);if(z==="ssh"||eZ(z,Q))return!0;if((z==="source"||z===".")&&["/dev/stdin","/dev/fd/0","/proc/self/fd/0"].includes(Q[0]?.value??""))return!0;let Y=J[$+1];if(z==="cat"&&Y&&d0(Y.sepBefore)){let G=X(Y);return G.verb==="ssh"||eZ(G.verb,G.args)}return!1}var $4=/(?:^|[^A-Za-z0-9_.-])gh(?:$|[^A-Za-z0-9_.-])/;function s0(){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:J0}}}var J4=new Set(["Bash","Monitor"]);function a0(Z){if(Z?.hook_event_name!=="PreToolUse"||!J4.has(Z.tool_name??""))return{continue:!0};let J=$Z(Z);if(!J.trim())return{continue:!0};try{return m(J).refused?s0():{continue:!0}}catch{return $4.test(J)?s0():{continue:!0}}}function X4(Z){if(Z!=="trash-guard"&&Z!=="workspace-repos-guard")throw Error("Invalid safety capability")}function n0(Z,J){X4(Z);let $=Z,X=JSON.parse(J);if(!X||Array.isArray(X)||X.hook_event_name!=="PreToolUse"||typeof X.tool_name!=="string"||!X.tool_input||typeof X.tool_input!=="object"||Array.isArray(X.tool_input)||typeof X.cwd!=="string"||!Y0.isAbsolute(X.cwd))throw Error("Invalid safety input");if(X.tool_name==="Bash"&&typeof X.tool_input.command!=="string")throw Error("Invalid shell input");if(X.tool_name==="Monitor"&&X.tool_input.command!==void 0&&typeof X.tool_input.command!=="string")throw Error("Invalid monitor input");let z=X.hasna_execution;if(z!==void 0&&(!z||Object.keys(z).sort().join()!=="agent,schema"||z.schema!=="hasna.hooks.execution.v1"||typeof z.agent!=="string"||!/^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/.test(z.agent)))throw Error("Invalid execution capability");let Q=z===void 0?void 0:{runtime:process.execPath,home:SZ.homedir(),path:process.env.PATH,agent:z.agent};if(Q&&(!Y0.isAbsolute(Q.runtime)||!Q.path))throw Error("Invalid bound execution context");if(["apply_patch","ApplyPatch","functions.apply_patch"].includes(X.tool_name)){if(X.tool_input.command!==void 0&&X.tool_input.patch!==void 0&&X.tool_input.command!==X.tool_input.patch)throw Error("Conflicting patch aliases");let O=X.tool_input.command??X.tool_input.patch;if(typeof O!=="string")throw Error("Invalid patch input");X.tool_input={...X.tool_input,command:O,patch:O}}let Y=X.tool_name==="Monitor",G=X.tool_name==="Bash"||Y&&typeof X.tool_input.command==="string",K=Y&&G?{...X,tool_name:"Bash"}:X,H=(O)=>({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:O}}),B=y0(K).output,U=a0(K),V=G&&NZ(K.tool_input.command,{home:SZ.homedir(),cwd:X.cwd}).handoffHits.length>0,C=$==="trash-guard"&&(!Y||G)?I0(K,{home:SZ.homedir(),cwd:X.cwd,findTrash:DZ,inspectTrash:BZ,execution:Q}):{continue:!0};if(Y&&C.hookSpecificOutput?.permissionDecision==="allow")C=H("[trash-guard] A deletion inside a Monitor command is refused; run it with the Bash tool, where it is redirected into trash.");let _=B.decision==="block"?H(B.reason):U.hookSpecificOutput?U:V?H("[workspace-repos-guard] Deletion under a protected repository checkout is refused."):C;return JSON.stringify({verdict:"continue"in _?null:_})}var z4=2,K4="0.12.
|
|
20
|
+
`,X);if(Y<0)continue;let G=LZ(Z,Y,[z]),K=G<0?Z.slice(Y+1):Z.slice(Y+1,G),H=G<0?K:K.slice(0,Math.max(0,K.lastIndexOf(z.delimiter))).replace(/\n$/,""),B=Z.slice(Q,X)+" HEREDOC_OPERATOR "+Z.slice(z.end,Y);J.push({body:H,runsBody:Z4(B),quoted:z.quoted})}return J}function Z4(Z){let{segments:J}=K0(Z),$=J.findIndex((G)=>G.words.some((K)=>K.text==="HEREDOC_OPERATOR"));if($<0)return!1;let X=(G)=>{let K=l(G);if(K<0)return{verb:"",args:[]};let H=G.words.slice(K+1).filter((B)=>B.text!=="HEREDOC_OPERATOR").map((B)=>XZ(B.text));return{verb:o(XZ(G.words[K].text).value),args:H}},{verb:z,args:Q}=X(J[$]);if(z==="ssh"||eZ(z,Q))return!0;if((z==="source"||z===".")&&["/dev/stdin","/dev/fd/0","/proc/self/fd/0"].includes(Q[0]?.value??""))return!0;let Y=J[$+1];if(z==="cat"&&Y&&d0(Y.sepBefore)){let G=X(Y);return G.verb==="ssh"||eZ(G.verb,G.args)}return!1}var $4=/(?:^|[^A-Za-z0-9_.-])gh(?:$|[^A-Za-z0-9_.-])/;function s0(){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:J0}}}var J4=new Set(["Bash","Monitor"]);function a0(Z){if(Z?.hook_event_name!=="PreToolUse"||!J4.has(Z.tool_name??""))return{continue:!0};let J=$Z(Z);if(!J.trim())return{continue:!0};try{return m(J).refused?s0():{continue:!0}}catch{return $4.test(J)?s0():{continue:!0}}}function X4(Z){if(Z!=="trash-guard"&&Z!=="workspace-repos-guard")throw Error("Invalid safety capability")}function n0(Z,J){X4(Z);let $=Z,X=JSON.parse(J);if(!X||Array.isArray(X)||X.hook_event_name!=="PreToolUse"||typeof X.tool_name!=="string"||!X.tool_input||typeof X.tool_input!=="object"||Array.isArray(X.tool_input)||typeof X.cwd!=="string"||!Y0.isAbsolute(X.cwd))throw Error("Invalid safety input");if(X.tool_name==="Bash"&&typeof X.tool_input.command!=="string")throw Error("Invalid shell input");if(X.tool_name==="Monitor"&&X.tool_input.command!==void 0&&typeof X.tool_input.command!=="string")throw Error("Invalid monitor input");let z=X.hasna_execution;if(z!==void 0&&(!z||Object.keys(z).sort().join()!=="agent,schema"||z.schema!=="hasna.hooks.execution.v1"||typeof z.agent!=="string"||!/^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/.test(z.agent)))throw Error("Invalid execution capability");let Q=z===void 0?void 0:{runtime:process.execPath,home:SZ.homedir(),path:process.env.PATH,agent:z.agent};if(Q&&(!Y0.isAbsolute(Q.runtime)||!Q.path))throw Error("Invalid bound execution context");if(["apply_patch","ApplyPatch","functions.apply_patch"].includes(X.tool_name)){if(X.tool_input.command!==void 0&&X.tool_input.patch!==void 0&&X.tool_input.command!==X.tool_input.patch)throw Error("Conflicting patch aliases");let O=X.tool_input.command??X.tool_input.patch;if(typeof O!=="string")throw Error("Invalid patch input");X.tool_input={...X.tool_input,command:O,patch:O}}let Y=X.tool_name==="Monitor",G=X.tool_name==="Bash"||Y&&typeof X.tool_input.command==="string",K=Y&&G?{...X,tool_name:"Bash"}:X,H=(O)=>({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:O}}),B=y0(K).output,U=a0(K),V=G&&NZ(K.tool_input.command,{home:SZ.homedir(),cwd:X.cwd}).handoffHits.length>0,C=$==="trash-guard"&&(!Y||G)?I0(K,{home:SZ.homedir(),cwd:X.cwd,findTrash:DZ,inspectTrash:BZ,execution:Q}):{continue:!0};if(Y&&C.hookSpecificOutput?.permissionDecision==="allow")C=H("[trash-guard] A deletion inside a Monitor command is refused; run it with the Bash tool, where it is redirected into trash.");let _=B.decision==="block"?H(B.reason):U.hookSpecificOutput?U:V?H("[workspace-repos-guard] Deletion under a protected repository checkout is refused."):C;return JSON.stringify({verdict:"continue"in _?null:_})}var z4=2,K4="0.12.5";function Q4(Z,J){return n0(Z,J)}
|
package/bin/serve.js
CHANGED
|
@@ -314,8 +314,8 @@ var HOOKS = [
|
|
|
314
314
|
{
|
|
315
315
|
name: "signed-link-output",
|
|
316
316
|
displayName: "Signed Link Output",
|
|
317
|
-
description: "Claude PostToolUse backstop: replaces
|
|
318
|
-
version: "0.1.
|
|
317
|
+
description: "Claude PostToolUse backstop: replaces capability links in tool output \u2014 signature-class query or fragment parameters, and anchored path-borne provider classes such as the Stripe Connect onboarding link \u2014 with a redaction marker (updatedToolOutput, where the running Claude Code supports it) and tells the model not to repeat or store the link. Every string is walked, so nested metadata such as a browser result's `_meta.browser_use.url` is covered. It runs after the tool, so it cannot undo display or other persistence",
|
|
318
|
+
version: "0.1.1",
|
|
319
319
|
category: "Security",
|
|
320
320
|
event: "PostToolUse",
|
|
321
321
|
matcher: "^(Bash|WebFetch|mcp__.*)$",
|
package/dist/index.js
CHANGED
|
@@ -7177,8 +7177,8 @@ var HOOKS = [
|
|
|
7177
7177
|
{
|
|
7178
7178
|
name: "signed-link-output",
|
|
7179
7179
|
displayName: "Signed Link Output",
|
|
7180
|
-
description: "Claude PostToolUse backstop: replaces
|
|
7181
|
-
version: "0.1.
|
|
7180
|
+
description: "Claude PostToolUse backstop: replaces capability links in tool output \u2014 signature-class query or fragment parameters, and anchored path-borne provider classes such as the Stripe Connect onboarding link \u2014 with a redaction marker (updatedToolOutput, where the running Claude Code supports it) and tells the model not to repeat or store the link. Every string is walked, so nested metadata such as a browser result's `_meta.browser_use.url` is covered. It runs after the tool, so it cannot undo display or other persistence",
|
|
7181
|
+
version: "0.1.1",
|
|
7182
7182
|
category: "Security",
|
|
7183
7183
|
event: "PostToolUse",
|
|
7184
7184
|
matcher: "^(Bash|WebFetch|mcp__.*)$",
|
|
@@ -42562,7 +42562,7 @@ async function verifyNativeSafetyCommand(command, home = homedir8()) {
|
|
|
42562
42562
|
}
|
|
42563
42563
|
|
|
42564
42564
|
// src/lib/codex-safety-check.ts
|
|
42565
|
-
var SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0"];
|
|
42565
|
+
var SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1"];
|
|
42566
42566
|
var versions = new Set(SUPPORTED_CODEX_SAFETY_VERSIONS);
|
|
42567
42567
|
var matcher = "^(Bash|apply_patch|ApplyPatch|functions\\.apply_patch)$";
|
|
42568
42568
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { verifyNativeSafetyCommand } from "../native-safety.js";
|
|
2
2
|
/** Exact `codex --version` outputs whose app-server protocol was measured
|
|
3
3
|
* against the real native binary. Anything else refuses as native_unsupported. */
|
|
4
|
-
export declare const SUPPORTED_CODEX_SAFETY_VERSIONS: readonly ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0"];
|
|
4
|
+
export declare const SUPPORTED_CODEX_SAFETY_VERSIONS: readonly ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1"];
|
|
5
5
|
export type CodexSafetyCode = "native_unavailable" | "native_unsafe_executable" | "native_executable_required" | "native_unsupported" | "native_failed" | "native_discovery_failed" | "hooks_disabled" | "guard_missing" | "guard_ambiguous" | "guard_definition_invalid" | "guard_disabled" | "guard_untrusted" | "guard_changed" | "guard_failed";
|
|
6
6
|
export declare class CodexSafetyError extends Error {
|
|
7
7
|
readonly code: CodexSafetyCode;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
* Signed-link shapes in text.
|
|
3
3
|
*
|
|
4
4
|
* The same shape the in-process harness redaction uses for this class: an
|
|
5
|
-
* absolute http(s) URL
|
|
6
|
-
* parameter
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* absolute http(s) URL that carries a capability — a capability-class query or
|
|
6
|
+
* fragment parameter, or a capability carried in the path of a measured
|
|
7
|
+
* provider class. The measured signed action links carry `expires`,
|
|
8
|
+
* `pr_number`, `repository`, `return_to` and `signature`; `signature` is the
|
|
9
|
+
* discriminating parameter, and the other capability names below are the same
|
|
10
|
+
* class.
|
|
9
11
|
*
|
|
10
12
|
* A match is replaced by the URL's origin plus `/[redacted signed link]`, so a
|
|
11
13
|
* reader keeps the host for diagnosis and nothing else. The matched text is
|
|
@@ -23,6 +25,31 @@ export const SIGNED_LINK_PARAMS: readonly string[] = [
|
|
|
23
25
|
"token",
|
|
24
26
|
];
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Anchored, provider-scoped path-borne capability classes.
|
|
30
|
+
*
|
|
31
|
+
* Some providers put the whole proof in the URL path, so a parameter scan
|
|
32
|
+
* reports their capability links clean (HP659: a Stripe Connect account
|
|
33
|
+
* onboarding link reached a transcript through browser tool-result metadata).
|
|
34
|
+
* Each entry names one measured provider class: the exact host plus the path
|
|
35
|
+
* shape that carries the token. A generic "long path" heuristic would flag
|
|
36
|
+
* ordinary links, so extend this table only with a class that was measured.
|
|
37
|
+
* Do not fetch a link to test it.
|
|
38
|
+
*
|
|
39
|
+
* This mirrors the scanner's table in @hasna/secrets (`signed-urls.ts`), so a
|
|
40
|
+
* link one Hasna component redacts is a link the other recognizes.
|
|
41
|
+
*/
|
|
42
|
+
export const PATH_CAPABILITY_CLASSES: ReadonlyArray<{ hostname: string; path: RegExp }> = [
|
|
43
|
+
{
|
|
44
|
+
// Stripe Connect account-onboarding links: /setup/<letter>/<token> and the
|
|
45
|
+
// documented /setup/c/acct_<id>/<token> form. The onboarding token is the
|
|
46
|
+
// capability and the link is the account's entry point; nothing in the
|
|
47
|
+
// query marks it.
|
|
48
|
+
hostname: "connect.stripe.com",
|
|
49
|
+
path: /^\/setup\/[a-z]\/(?:acct_[A-Za-z0-9]+\/)?[^/?#]+\/?$/i,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
26
53
|
/** Cheap pre-filter: any absolute URL. (A keyword pre-filter would miss percent- or entity-encoded names.) */
|
|
27
54
|
const HINT = /https?:\/\//i;
|
|
28
55
|
|
|
@@ -75,13 +102,41 @@ export function hasSignatureParameter(url: string): boolean {
|
|
|
75
102
|
return false;
|
|
76
103
|
}
|
|
77
104
|
|
|
105
|
+
/**
|
|
106
|
+
* True when a URL's path carries a capability of an anchored, provider-scoped
|
|
107
|
+
* class (see `PATH_CAPABILITY_CLASSES`). The host and path shape are the whole
|
|
108
|
+
* rule: an ordinary URL, the bare provider origin, a host that merely ends with
|
|
109
|
+
* the provider name, and the same path shape on another host are all untouched.
|
|
110
|
+
* Separators are decoded first, exactly as the parameter check does, so a JSON
|
|
111
|
+
* `\u003f` (`?`) or `\u0026` (`&`) straight after the token cannot push the
|
|
112
|
+
* token out of the matched path segment.
|
|
113
|
+
*/
|
|
114
|
+
export function hasPathBorneCapability(url: string): boolean {
|
|
115
|
+
let parsed: URL;
|
|
116
|
+
try { parsed = new URL(decodeSeparators(url)); } catch { return false; }
|
|
117
|
+
const hostname = parsed.hostname.replace(/\.$/, "").toLowerCase();
|
|
118
|
+
for (const klass of PATH_CAPABILITY_CLASSES) {
|
|
119
|
+
if (hostname === klass.hostname && klass.path.test(parsed.pathname)) return true;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* True when a URL carries a capability: a signature-class query or fragment
|
|
126
|
+
* parameter, or an anchored path-borne class. The count and the redaction share
|
|
127
|
+
* this predicate, so the two cannot disagree.
|
|
128
|
+
*/
|
|
129
|
+
export function carriesCapability(url: string): boolean {
|
|
130
|
+
return hasSignatureParameter(url) || hasPathBorneCapability(url);
|
|
131
|
+
}
|
|
132
|
+
|
|
78
133
|
/** Number of signed-link URLs in `text`. */
|
|
79
134
|
export function countSignedLinks(text: string): number {
|
|
80
135
|
if (typeof text !== "string" || !text || !HINT.test(text)) return 0;
|
|
81
136
|
let count = 0;
|
|
82
137
|
for (const match of text.matchAll(URL_PATTERN)) {
|
|
83
138
|
const url = match[0].replace(TRAILING_PUNCTUATION, "");
|
|
84
|
-
if (
|
|
139
|
+
if (carriesCapability(url)) count++;
|
|
85
140
|
}
|
|
86
141
|
return count;
|
|
87
142
|
}
|
|
@@ -92,7 +147,7 @@ export function redactSignedLinks(text: string): string {
|
|
|
92
147
|
return text.replace(URL_PATTERN, (match) => {
|
|
93
148
|
const trailing = match.match(TRAILING_PUNCTUATION)?.[0] ?? "";
|
|
94
149
|
const url = trailing ? match.slice(0, -trailing.length) : match;
|
|
95
|
-
if (!
|
|
150
|
+
if (!carriesCapability(url)) return match;
|
|
96
151
|
const origin = url.match(/^https?:\/\/[^/?#]+/i)?.[0];
|
|
97
152
|
return origin ? `${origin}/${REDACTION_MARKER}${trailing}` : `${REDACTION_MARKER}${trailing}`;
|
|
98
153
|
});
|
|
@@ -4,13 +4,26 @@ Claude Code PostToolUse hook, installed as `hooks run signed-link-output`
|
|
|
4
4
|
(matcher `Bash`, `WebFetch` and MCP tools). It is the backstop behind the
|
|
5
5
|
`signed-link-guard` PreToolUse guard.
|
|
6
6
|
|
|
7
|
-
When a tool result contains a
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
When a tool result contains a capability link it returns the two fields below.
|
|
8
|
+
Two shapes are recognised:
|
|
9
|
+
|
|
10
|
+
- an absolute `http(s)` URL whose query or fragment carries `signature`, `sig`,
|
|
11
|
+
`x-amz-signature`, `x-goog-signature`, `x-ms-signature`, `hmac` or `token`;
|
|
12
|
+
separators are recognised in their encoded forms too: `&` (also repeated,
|
|
13
|
+
`&amp;`), `&`, `&`, the JSON escape `\u0026` and percent-encoded
|
|
14
|
+
parameter names.
|
|
15
|
+
- an absolute `http(s)` URL of an anchored, provider-scoped path-borne class:
|
|
16
|
+
the exact provider host plus the measured path shape that carries the token.
|
|
17
|
+
The measured class is the Stripe Connect account-onboarding link
|
|
18
|
+
(`connect.stripe.com/setup/<letter>/<token>`, including the documented
|
|
19
|
+
`connect.stripe.com/setup/c/acct_<id>/<token>` form), the shape that reached
|
|
20
|
+
a transcript through browser tool-result metadata in HP659. The table mirrors
|
|
21
|
+
the scanner's in `@hasna/secrets` (`signed-urls.ts`).
|
|
22
|
+
|
|
23
|
+
Every string of the tool result is walked, so a capability in nested metadata —
|
|
24
|
+
for example a browser tool result's `_meta.browser_use.url` — is redacted like
|
|
25
|
+
one in ordinary output text. A result with no such link gets no output at all,
|
|
26
|
+
however large it is.
|
|
14
27
|
|
|
15
28
|
- `hookSpecificOutput.updatedToolOutput`: the same tool result with each such
|
|
16
29
|
URL replaced by `<origin>/[redacted signed link]`. Keys, order and
|
|
@@ -23,10 +36,26 @@ It never blocks, and it never prints, logs or stores a matched URL.
|
|
|
23
36
|
|
|
24
37
|
## What it can and cannot do
|
|
25
38
|
|
|
26
|
-
- Output replacement depends on the running Claude Code
|
|
39
|
+
- Output replacement depends on the running harness. Claude Code's 2.1.285
|
|
27
40
|
build accepts `updatedToolOutput` on PostToolUse for every tool, checks it
|
|
28
41
|
against the tool's output schema, and uses the original output (with a hook
|
|
29
42
|
error) when the check fails. Older builds may ignore or reject the field.
|
|
43
|
+
- Codex has no output rewrite: that is a native capability limit on Codex, not
|
|
44
|
+
a configuration toggle. Stock Codex 0.160.0, stable 0.160.1 and shipped Hoshi
|
|
45
|
+
0.5.2 share the same relevant hook schema, parser, event and core consumers.
|
|
46
|
+
The rewrite field this hook emits, `updatedToolOutput`, is not in Codex's
|
|
47
|
+
PostToolUse output schema, so Codex rejects that response as unknown and the
|
|
48
|
+
hook fails open: the redaction does not apply and the notice sent with it is
|
|
49
|
+
dropped. Codex's own rewrite field, `updatedMCPToolOutput`, is parsed but
|
|
50
|
+
explicitly unsupported (the hook run is marked Failed, `should_block` stays
|
|
51
|
+
false, and `additionalContext` is dropped); an async hook preserves the
|
|
52
|
+
context only. A notice-only response (`additionalContext` without a rewrite
|
|
53
|
+
field, as this hook returns when the copy bound prevents a rewrite) is
|
|
54
|
+
accepted, so the notice can still reach the model on Codex; the link is never
|
|
55
|
+
rewritten there. The controls Codex does support are `decision: block` with a
|
|
56
|
+
non-empty reason, or exit 2 — they reject the model-facing result after
|
|
57
|
+
execution, but they do not rewrite the payload and do not remove prior
|
|
58
|
+
transcript exposure. Codex-side wiring is a harness-owned follow-up.
|
|
30
59
|
- It runs after the tool has run. The command already executed, the terminal
|
|
31
60
|
may already have shown the output, and files the command or the harness
|
|
32
61
|
wrote (including a spill file for large output) keep the link. Whether the
|
|
@@ -34,8 +63,12 @@ It never blocks, and it never prints, logs or stores a matched URL.
|
|
|
34
63
|
- PostToolUse hooks run in parallel on the original output and the last
|
|
35
64
|
rewrite wins, so another rewriting hook can undo this one. This hook returns
|
|
36
65
|
a rewrite only when it changed something.
|
|
37
|
-
- A
|
|
38
|
-
|
|
66
|
+
- A path-borne capability is recognised only for the anchored, measured
|
|
67
|
+
provider classes in `PATH_CAPABILITY_CLASSES` (currently
|
|
68
|
+
`connect.stripe.com` with `^/setup/<letter>/(acct_<id>/)?<token>/?$`). A
|
|
69
|
+
token in the path of an unmeasured provider class is not recognised until
|
|
70
|
+
that class is measured and added; a generic "long path" heuristic would flag
|
|
71
|
+
ordinary links.
|
|
39
72
|
- Output larger than its copy bound (1,000,000 JSON nodes or 2,000 levels
|
|
40
73
|
deep) is still scanned for links; when one is found the notice is added but
|
|
41
74
|
the output is not rewritten, because a partial copy would change the
|
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* PostToolUse hook: signed-link-output (Claude Code)
|
|
5
5
|
*
|
|
6
6
|
* The second layer behind signed-link-guard. When a tool result contains a
|
|
7
|
-
*
|
|
8
|
-
* capability-class parameter such as `signature
|
|
7
|
+
* capability link — an absolute URL whose query or fragment carries a
|
|
8
|
+
* capability-class parameter such as `signature`, or a URL of an anchored,
|
|
9
|
+
* provider-scoped path-borne class such as the Stripe Connect onboarding link
|
|
10
|
+
* (`connect.stripe.com/setup/<letter>/<token>`, including the documented
|
|
11
|
+
* `connect.stripe.com/setup/c/acct_<id>/<token>` form) — this hook:
|
|
9
12
|
*
|
|
10
13
|
* 1. returns `hookSpecificOutput.updatedToolOutput`: the same tool result
|
|
11
14
|
* with each such URL replaced by `<origin>/[redacted signed link]`, and
|
package/package.json
CHANGED