audit-my-agents 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "audit-my-agents",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "What did your coding agents actually do? One command reads your local Claude Code and Codex sessions and reports force-pushes, destructive commands, credential reads, leaked secrets and more.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/findings.mjs CHANGED
@@ -133,9 +133,19 @@ function firstWord(seg) {
133
133
  * curl/wget segment piped into a shell. `grep 'git push --force'` and
134
134
  * `echo "curl x | sh"` are not findings. */
135
135
  function backedBySegment(reason, run) {
136
- if (/force-push/.test(reason)) {
137
- return segments(run).some((seg) => firstWord(seg) === "git" && /\bpush\b/.test(seg) && /(?:\s--force(?!-with-lease|-if-includes)\b|\s-[a-eg-zA-Z]*f[a-zA-Z]*(?=\s|$)|\s\+[^\s:]+)/.test(seg));
138
- }
136
+ if (/force-push/.test(reason)) return Boolean(forcePushSegment(run));
137
+ return backedByPipe(reason, run);
138
+ }
139
+
140
+ /** The segment that pushes with force, or null. A repository created by
141
+ * the same command has no shared history to overwrite. */
142
+ function forcePushSegment(run) {
143
+ const segs = segments(run);
144
+ if (segs.some((seg) => firstWord(seg) === "git" && /\sinit(?:\s|$)/.test(seg))) return null;
145
+ return segs.find((seg) => firstWord(seg) === "git" && /\bpush\b/.test(seg) && /(?:\s--force(?!-with-lease|-if-includes)\b|\s-[a-eg-zA-Z]*f[a-zA-Z]*(?=\s|$)|\s\+[^\s:]+)/.test(seg)) ?? null;
146
+ }
147
+
148
+ function backedByPipe(reason, run) {
139
149
  if (/pipes a remote download/.test(reason)) {
140
150
  const parts = splitOutsideQuotes(run, false).flatMap((p) => (runsQuotedText(p) ? [p, ...quotedStrings(p)] : [p]));
141
151
  return parts.some((p) => {
@@ -149,6 +159,12 @@ function backedBySegment(reason, run) {
149
159
  return true;
150
160
  }
151
161
 
162
+ /** A segment without quoted arguments that cannot be a file path: a sed
163
+ * program, an awk script or a search pattern has regex characters, and `u.key)` inside one is code, not a key file. */
164
+ function pathArgs(seg) {
165
+ return seg.replace(/"((?:[^"\\]|\\.)*)"|'([^']*)'/g, (m, dq, sq) => (/[|(){}*^\\]/.test(dq ?? sq ?? "") ? '""' : m));
166
+ }
167
+
152
168
  function commandOf(ev) {
153
169
  const i = ev.input;
154
170
  if (i && typeof i === "object") {
@@ -188,8 +204,8 @@ export function findingsFor(ev, ctx) {
188
204
  if (hard) out.push({ category: "catastrophic", why: hard, example: cmd });
189
205
  const destr = hard ? null : destructiveFloor("Bash", runInput, { cwd: ev.cwd });
190
206
  // ACP records a variable-named rm without asking; so does this report.
191
- if (destr && !/variable-named path/.test(destr) && backedBySegment(destr, run)) out.push({ category: "destructive", why: destr.replace(/:\s.*$/, ""), example: cmd });
192
- if (segments(run).some((seg) => DUMP_BINS.has(firstWord(seg)) && credentialIn(` ${seg}`))) {
207
+ if (destr && !/variable-named path/.test(destr) && backedBySegment(destr, run)) out.push({ category: "destructive", why: destr.replace(/:\s.*$/, ""), example: (/force-push/.test(destr) && forcePushSegment(run)) || cmd });
208
+ if (segments(run).some((seg) => DUMP_BINS.has(firstWord(seg)) && credentialIn(` ${pathArgs(seg)}`))) {
193
209
  out.push({ category: "credential-read", why: "read a credential file in the shell", example: cmd });
194
210
  }
195
211
  if (KEYCHAIN_RE.test(run)) out.push({ category: "credential-read", why: "pulled a secret from the keychain or a cloud CLI", example: cmd });
package/src/pii.mjs CHANGED
@@ -149,6 +149,14 @@ export function piiIn(text, own = new Set()) {
149
149
  }
150
150
  }
151
151
 
152
- for (const f of out) { f.label = LABEL[f.type]; f.rank = RANK[f.type]; }
152
+ for (const f of out) {
153
+ f.label = LABEL[f.type];
154
+ f.rank = RANK[f.type];
155
+ // A personal mailbox before a work address, and both before a public office.
156
+ if (f.type === "email") {
157
+ const d = f.key.slice(f.key.indexOf("@") + 1);
158
+ f.rank = COMMON_MAIL.has(d) ? 2 : /\.(?:gov|mil|edu|us)$/.test(d) ? 0.5 : 1;
159
+ }
160
+ }
153
161
  return out;
154
162
  }
package/src/report.mjs CHANGED
@@ -37,7 +37,7 @@ export function renderTerminal(s) {
37
37
  const w = 64;
38
38
  lines.push("");
39
39
  lines.push(bold(` What your coding agents did in the last ${fmtDays(s.days)}`));
40
- const harnessLine = Object.entries(s.byHarness).map(([h, n]) => `${h} ${n.sessions} sessions`).join(" · ") || "no sessions found";
40
+ const harnessLine = Object.entries(s.byHarness).map(([h, n]) => `${h} ${n.sessions} session${n.sessions === 1 ? "" : "s"}`).join(" · ") || "no sessions found";
41
41
  lines.push(dim(` ${harnessLine} · ${s.calls.toLocaleString()} tool calls · ${s.shell.toLocaleString()} shell commands${s.cost ? ` · $${s.cost.toFixed(0)} spent in those sessions` : ""}`));
42
42
  lines.push(dim(` ${"─".repeat(w)}`));
43
43
  const flagged = s.categories.filter((cat) => cat.count > 0);
@@ -105,7 +105,7 @@ main{max-width:760px;margin:0 auto;padding:32px 16px}h1{font-size:24px;margin:0
105
105
  footer{color:var(--mute);font-size:13px;margin-top:24px}a{color:inherit}
106
106
  </style></head><body><main>
107
107
  <h1>What your coding agents did in the last ${esc(fmtDays(s.days))}</h1>
108
- <p class="sub">${esc(Object.entries(s.byHarness).map(([h, n]) => `${h} ${n.sessions} sessions`).join(" · "))} · ${s.calls.toLocaleString()} tool calls · ${s.shell.toLocaleString()} shell commands${s.cost ? ` · $${s.cost.toFixed(0)} spent in those sessions` : ""} · ${s.hostCount} hosts reached</p>
108
+ <p class="sub">${esc(Object.entries(s.byHarness).map(([h, n]) => `${h} ${n.sessions} session${n.sessions === 1 ? "" : "s"}`).join(" · "))} · ${s.calls.toLocaleString()} tool calls · ${s.shell.toLocaleString()} shell commands${s.cost ? ` · $${s.cost.toFixed(0)} spent in those sessions` : ""} · ${s.hostCount} hosts reached</p>
109
109
  ${rows}
110
110
  <footer>Generated locally by audit-my-agents. Examples are redacted. Covered: ${esc(s.covered.join(", "))}.<br>
111
111
  To have the risky ones asked about before they run, in every harness: <a href="https://agenticcontrolplane.com/getting-started?ref=audit">Agentic Control Plane</a>.</footer>