cc-safety-net 2.5.1 → 2.6.0

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.
@@ -2,7 +2,7 @@
2
2
  "id": "cc-safety-net",
3
3
  "name": "CC Safety Net",
4
4
  "description": "Block destructive commands and secret-file access before OpenClaw runs a tool.",
5
- "version": "2.5.1",
5
+ "version": "2.6.0",
6
6
  "activation": {
7
7
  "onStartup": true
8
8
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-safety-net",
3
- "version": "2.5.1",
3
+ "version": "2.6.0",
4
4
  "description": "Block destructive commands and secret-file access before OpenClaw runs a tool.",
5
5
  "type": "module",
6
6
  "openclaw": {
package/dist/pi/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import{J,_,ot,l}from"../chunks/index-8cqwk53d.js";import{ne}from"../chunks/index-1sddy8kp.js";import{L,ue,xe}from"../chunks/index-w2aadm3e.js";import"../chunks/index-3rm5n91g.js";var C="cc-safety-net",u="Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",p="Help me with CC Safety Net.";function d(o){o.registerCommand(C,{description:u,handler:async(n,t)=>{o.sendUserMessage(c(n),t.isIdle()?void 0:{deliverAs:"followUp"})}})}function c(o){return`${ne.slice(ne.indexOf("# CC Safety Net")).trimEnd()}
1
+ import{Y,P,it,u}from"../chunks/index-wwg1vy7s.js";import{re}from"../chunks/index-5ht7pdm3.js";import{j,de,Se}from"../chunks/index-6r8xp8d7.js";import"../chunks/index-a00fdxyv.js";var m="cc-safety-net",C="Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",p="Help me with CC Safety Net.";function s(o){o.registerCommand(m,{description:C,handler:async(n,t)=>{o.sendUserMessage(c(n),t.isIdle()?void 0:{deliverAs:"followUp"})}})}function c(o){return`${re.slice(re.indexOf("# CC Safety Net")).trimEnd()}
2
2
 
3
3
  ## User request
4
4
 
5
- ${o.trim()||p}`}var f=new Map([["bash","posix"],["powershell","powershell"]]),g={agent:"pi",debugLabel:"pi tool_call",extract:(o,n,t)=>y(o,n,t),getSessionId:(o,n)=>n.sessionManager.getSessionId(),allow:void 0,block:(o)=>w(o),includeEvidenceOnError:(o)=>o.route.kind==="command"};function m(o){o.on("tool_call",T)}var T=P();function P(o={}){return xe(g,o)}function y(o,n,t){if(!o||typeof o!=="object")return;let e=o;if(e.type!==void 0&&e.type!=="tool_call")return;if(typeof e.toolName!=="string"||e.toolName.trim()==="")return r(n);if(typeof n.cwd!=="string"||n.cwd.trim()==="")return r(n,e.toolName);let i=ot(".",[n.cwd],t);if(!i)return ue({directory:"session",problem:"unusable",cwd:n.cwd},{toolName:e.toolName});let a=f.get(e.toolName);if(!e.input||typeof e.input!=="object")return a?r(n,e.toolName):void 0;if(!a)return l(e.toolName,e.input,{kind:_(e.toolName)},{configCwd:i,executionCwd:i},null);let s=e.input.command;if(typeof s!=="string"||s.trim()==="")return r(n,e.toolName);return l(e.toolName,e.input,{kind:"command",shell:a},{configCwd:i,executionCwd:i},s)}function r(o,n){return L(typeof o.cwd==="string"&&o.cwd.trim()?o.cwd:null,{toolName:n})}function w(o){return{block:!0,reason:J(o)}}function v(o){m(o),d(o)}export{v as default};
5
+ ${o.trim()||p}`}var f=new Map([["bash","posix"],["powershell","powershell"]]),g={agent:"pi",debugLabel:"pi tool_call",extract:(o,n,t)=>w(o,n,t),getSessionId:(o,n)=>n.sessionManager.getSessionId(),allow:void 0,block:(o)=>v(o),includeEvidenceOnError:(o)=>o.route.kind==="command"};function d(o){o.on("tool_call",T)}var T=y();function y(o={}){return Se(g,o)}function w(o,n,t){if(!o||typeof o!=="object")return;let e=o;if(e.type!==void 0&&e.type!=="tool_call")return;if(typeof e.toolName!=="string"||e.toolName.trim()==="")return i(n);if(typeof n.cwd!=="string"||n.cwd.trim()==="")return i(n,e.toolName);let l=it(".",[n.cwd],t);if(!l)return de({directory:"session",problem:"unusable",cwd:n.cwd},{toolName:e.toolName});let r=f.get(e.toolName);if(!e.input||typeof e.input!=="object")return r?i(n,e.toolName):void 0;if(!r)return u(e.toolName,e.input,{kind:P(e.toolName)},{configCwd:l,executionCwd:l},null);let a=e.input.command;if(typeof a!=="string"||a.trim()==="")return i(n,e.toolName);return u(e.toolName,e.input,{kind:"command",shell:r},{configCwd:l,executionCwd:l},a)}function i(o,n){return j(typeof o.cwd==="string"&&o.cwd.trim()?o.cwd:null,{toolName:n})}function v(o){return{block:!0,reason:Y(o)}}function N(o){d(o),s(o)}export{N as default};
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "cc-safety-net",
3
- "version": "2.5.1",
3
+ "version": "2.6.0",
4
4
  "description": "A coding agent CLI hook - block destructive commands and secret file access",
5
5
  "keywords": [
6
6
  "amp",
7
7
  "claude-code",
8
8
  "cursor",
9
9
  "deepseek-harness",
10
+ "devin",
11
+ "devin-cli",
12
+ "droid",
13
+ "factory-droid",
10
14
  "grok",
11
15
  "grok-build",
12
16
  "opencode",
@@ -54,7 +58,7 @@
54
58
  "./package.json": "./package.json"
55
59
  },
56
60
  "scripts": {
57
- "audit:dependencies": "bun audit",
61
+ "audit:dependencies": "bun audit --ignore=GHSA-ch52-4w7c-c8xp",
58
62
  "build": "bun run clean && bun scripts/project-bun.ts scripts/build.ts",
59
63
  "build:types": "tsc --project tsconfig.build.json --emitDeclarationOnly --declaration",
60
64
  "verify:package": "bun run scripts/verify-package.ts",
@@ -129,5 +133,5 @@
129
133
  "./dist/pi/index.js"
130
134
  ]
131
135
  },
132
- "gitHead": "5b9a1ab73610c0b977f1b9eadadbdc42cf511113"
136
+ "gitHead": "3793a43e9b1cab3458622c95175103bcf48ef1c6"
133
137
  }
@@ -1,4 +0,0 @@
1
- import{a,s,K,f,Pe,d,Le,y,p,V}from"./index-8cqwk53d.js";import{appendFileSync as ne,mkdirSync as oe}from"node:fs";import{isAbsolute as ie,join as I}from"node:path";import{lstatSync as C,readdirSync as j,readFileSync as U,rmdirSync as B,statSync as L,unlinkSync as X,utimesSync as z,writeFileSync as Y}from"node:fs";import{join as m}from"node:path";function re(t,e={}){return Le(d(t,e),t.home).policy.audit.retention_days}var S=86400000,Z=".last-prune",J=/^\d{4}-\d{2}$/,Q=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,O=(t)=>Math.floor(t/S);function q(t,e,r=()=>new Date){try{let n=r().getTime();if(!L(e,{throwIfNoEntry:!1})?.isDirectory())return;let o=m(e,Z),c=L(o,{throwIfNoEntry:!1})?.mtimeMs;if(c!==void 0&&O(c)===O(n))return;let i=n-re(t)*S,u=new Date(n).toISOString().slice(0,7);for(let l of A(e)){if(l.isDirectory()){W(m(e,l.name),i,u);continue}if(l.isFile()&&l.name.endsWith(".jsonl"))ee(m(e,l.name),i)}Y(o,"",{mode:384}),z(o,n/1000,n/1000)}catch{}}function W(t,e,r){for(let n of A(t)){if(!n.isDirectory()||!J.test(n.name))continue;let o=m(t,n.name);for(let c of A(o)){if(!c.isFile())continue;let i=Q.exec(c.name);if(!i||i[2]!==n.name)continue;let u=Date.parse(`${i[1]}T00:00:00.000Z`)+S;if(!Number.isFinite(u)||u>=e)continue;T(m(o,c.name))}if(n.name!==r)G(o)}G(t)}function ee(t,e){try{let r=C(t);if(r.mtimeMs>=e)return;let n=U(t,"utf-8").split(`
2
- `).filter((o)=>o.trim()).map(te);if(n.length===0)return;if(n.some((o)=>o===void 0||o>=e))return;if(C(t).mtimeMs!==r.mtimeMs)return;T(t)}catch{}}function te(t){try{let e=JSON.parse(t).ts,r=typeof e==="string"?Date.parse(e):Number.NaN;return Number.isFinite(r)?r:void 0}catch{return}}function A(t){try{return j(t,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function T(t){try{X(t)}catch{}}function G(t){try{B(t)}catch{}}var ae="2.5.1",ce=1e4,de=2000,ue=256,se=32768;function le(t){let e=t.trim();if(!e)return null;let r=e.replace(/[^A-Za-z0-9_.-]+/g,"_");if(r=r.replace(/^[._-]+|[._-]+$/g,"").slice(0,128),!r||r==="."||r==="..")return null;return r}function me(t){return(t??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function _(t,e,r,n,o,c,i={}){let u=le(e);if(!u)return;let l=F(t);if(!l)return;try{let E=(i.now??(()=>new Date))().toISOString(),N=g(K(r),i.failureStage?Number.POSITIVE_INFINITY:ce),h=g(K(n),de),w=i.toolName?g(K(i.toolName),ue):void 0,v=c===null?void 0:g(K(c),se),D=I(l,me(v?.value??null),E.slice(0,7));oe(D,{recursive:!0,mode:448});let H=I(D,`${E.slice(0,10)}-${u}.jsonl`),P={ts:E,id:(i.createId??Pe)(),v:ae,sessionId:u,decision:i.decision??"deny",agent:i.agent,shape:i.shape,level:i.level,configFallback:i.configFallback,toolName:w?.value,command:N.value,segment:h.value,...N.truncated||h.truncated||w?.truncated||v?.truncated?{truncated:!0}:{},reason:o,ruleId:i.ruleId,intent:i.intent,failureStage:i.failureStage,errorCode:i.errorCode,cwd:v?.value??null};ne(H,`${JSON.stringify(P)}
3
- `,{encoding:"utf-8",mode:384}),q(t,l,i.now)}catch{}}function g(t,e){return{value:t.slice(0,e),truncated:t.length>e}}function He(t){let e=t.env.get("CC_SAFETY_NET_AUDIT_HOME");if(t.env.get("NODE_ENV")==="test"&&!e)return null;let r=e||t.home;return r&&ie(r)?r:null}function F(t){let e=He(t);return e?I(e,".cc-safety-net","logs"):null}function k(t,e,r,n=!0,o){if(e.decision.kind==="allow"){if(!r||t.route.kind!=="command")return;let u=b(t);return{decision:"allow",command:u,segment:u,reason:"allowed",cwd:t.context.executionCwd,toolName:t.toolName,level:e.level,...e.configFallback?{configFallback:!0}:{}}}let c=e.decision.evidence,i=c?.command??(n?b(t):"");return{decision:"deny",command:i,segment:c?.segment??i,reason:e.decision.reason,cwd:t.context.executionCwd,toolName:t.toolName,level:e.level,...e.configFallback?{configFallback:!0}:{},ruleId:e.decision.ruleId,intent:e.decision.intent,failureStage:o?.stage,errorCode:o?.errorCode}}function b(t){return"command"in t?t.command??"":""}function x(t,e,r,n){if(!e)return;let o;try{o=r()}catch{return}if(typeof o!=="string"||!o.trim())return;_(t,o,e.command,e.segment,e.reason,e.cwd,{decision:e.decision,agent:n.agent,shape:n.shape,level:e.level,configFallback:e.configFallback,toolName:e.toolName,ruleId:e.ruleId,intent:e.intent,failureStage:e.failureStage,errorCode:e.errorCode})}function ve(t,e,r,n){let o;try{o=r()}catch{return}if(typeof o!=="string"||!o.trim())return;_(t,o,e.command??"",e.segment??e.command??"",e.reason,n.cwd??null,{decision:"deny",agent:n.agent,shape:n.shape,toolName:n.toolName??e.toolName,ruleId:e.ruleId,intent:e.intent})}function M(t,e,r){try{let n=V(e,{environment:t,...r.guard});return R(t,e,n,r),n}catch(n){if(!(n instanceof p))throw n;throw R(t,e,n.evaluation,r,!(n.cause instanceof f),{stage:n.stage,errorCode:fe(n.cause)}),n}}function R(t,e,r,n,o=!0,c){x(t,k(e,r,n.guard?.auditAllowed??!1,o,c),n.audit.getSessionId,{agent:n.audit.agent,shape:n.audit.shape})}function fe(t){if(t instanceof s)return a[t.kind].errorCode;if(t instanceof f)return"tool-input-limit";if(t instanceof y)return"structural-shell-syntax-limit";return"unexpected-error"}
4
- export{re,q,He,F,ve,M};