@hasna/hooks 0.11.7 → 0.12.1
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 +129 -4
- package/bin/hooks-mcp.js +39 -7
- package/bin/index.js +739 -129
- package/bin/native-safety-entry.js +15 -1718
- package/bin/serve.js +36 -9
- package/dist/index.js +51 -17
- package/dist/lib/codex-safety-check.d.ts +3 -0
- package/dist/lib/native-safety-registration.d.ts +49 -6
- package/dist/lib/registry.d.ts +15 -0
- package/dist/native-safety.d.ts +4 -0
- package/dist/native-safety.js +8 -4
- package/dist/sdk/index.js +1 -1
- package/hooks/hook-signed-link-guard/README.md +228 -0
- package/hooks/hook-signed-link-guard/package.json +12 -0
- package/hooks/hook-signed-link-guard/src/classify.ts +1280 -0
- package/hooks/hook-signed-link-guard/src/hook.ts +72 -0
- package/hooks/hook-signed-link-guard/src/jq.ts +545 -0
- package/hooks/hook-signed-link-guard/src/links.ts +136 -0
- package/hooks/hook-signed-link-output/README.md +47 -0
- package/hooks/hook-signed-link-output/package.json +12 -0
- package/hooks/hook-signed-link-output/src/hook.ts +111 -0
- package/hooks/hook-trash-guard/src/hook.ts +204 -80
- package/hooks/native-safety-entry.ts +28 -7
- package/package.json +2 -2
- package/scripts/validate-package.ts +12 -2
|
@@ -224,6 +224,12 @@ console.log("packed credential-file reference, rotation and terminal failure pas
|
|
|
224
224
|
* a runtime SDK import, and one bundled-hook run with an isolated data dir.
|
|
225
225
|
*/
|
|
226
226
|
async function validatePackedNativeSafety(packageDir: string, smokeDir: string): Promise<void> {
|
|
227
|
+
const worker = join(packageDir, "bin/native-safety-entry.js");
|
|
228
|
+
const bytes = await readFile(worker);
|
|
229
|
+
// The supervisor passes the worker as one `--eval` argument; Linux refuses a
|
|
230
|
+
// single argument over 32 pages (131,072 bytes with 4 KiB pages), and every
|
|
231
|
+
// command would then fail to launch. Check it before the launch smoke tests.
|
|
232
|
+
if (bytes.length >= 131_072) throw new Error(`Packed native worker is ${bytes.length} bytes; one exec argument holds at most 131072`);
|
|
227
233
|
const home = join(smokeDir, "native-safety-home");
|
|
228
234
|
await mkdir(home, { mode: 0o700 });
|
|
229
235
|
const settings = join(home, ".codex", "hooks.json");
|
|
@@ -250,12 +256,16 @@ async function validatePackedNativeSafety(packageDir: string, smokeDir: string):
|
|
|
250
256
|
if (benign.status !== 0 || benign.stdout !== "" || benign.stderr !== "") throw new Error("Packed native benign verdict failed");
|
|
251
257
|
const refused = invoke(`rm -- ${join(home, "owned-fixture")}`);
|
|
252
258
|
if (refused.status !== 0 || JSON.parse(refused.stdout).hookSpecificOutput.permissionDecision !== "deny") throw new Error("Packed native missing-Trash refusal failed");
|
|
259
|
+
// The packed worker carries the signed-link guard for every Bash command.
|
|
260
|
+
const composite = invoke("gh pr view 1175 --json body");
|
|
261
|
+
if (composite.status !== 0 || JSON.parse(composite.stdout).hookSpecificOutput.permissionDecisionReason
|
|
262
|
+
!== "composite output withheld: signed-link shape; use bounded scalar projections per class disposition 799310") throw new Error("Packed native signed-link refusal failed");
|
|
263
|
+
const scalar = invoke("gh pr view 1175 --json headRefOid,headRefName");
|
|
264
|
+
if (scalar.status !== 0 || scalar.stdout !== "" || scalar.stderr !== "") throw new Error("Packed native scalar gh read was not allowed");
|
|
253
265
|
const probe = join(smokeDir, "native-registration.ts");
|
|
254
266
|
await writeFile(probe, `import { getRegisteredHooksForTarget } from "@hasna/hooks"; console.log(JSON.stringify(getRegisteredHooksForTarget("global", "codex")));`);
|
|
255
267
|
const listed = spawnSync(runtime, [probe], { cwd: smokeDir, env, encoding: "utf8", timeout: 15_000 });
|
|
256
268
|
if (listed.status !== 0 || JSON.stringify(JSON.parse(listed.stdout)) !== '["trash-guard"]') throw new Error("Packed SDK cannot recognize the compiled CLI safety registration");
|
|
257
|
-
const worker = join(packageDir, "bin/native-safety-entry.js");
|
|
258
|
-
const bytes = await readFile(worker);
|
|
259
269
|
try {
|
|
260
270
|
await writeFile(worker, Buffer.concat([bytes, Buffer.from("\n// changed fixture\n")]));
|
|
261
271
|
const changed = invoke("rm -- owned-fixture");
|