@misconfig/cli 1.0.0 → 1.0.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 +3 -3
- package/engine/catalog.js +3 -3
- package/engine/index.js +18 -12
- package/engine/mask.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Finds every file that controls your AI coding agents, on your computer and in your project, and checks them for risky settings.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
npx @misconfig/cli@1.0.
|
|
6
|
+
npx @misconfig/cli@1.0.1
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
Run it in a project folder. It works on macOS, Windows and Linux with Node.js 18 or later, and needs no install or account.
|
|
10
10
|
|
|
11
|
-
On Windows, if PowerShell says running scripts is disabled, run `npx.cmd @misconfig/cli@1.0.
|
|
11
|
+
On Windows, if PowerShell says running scripts is disabled, run `npx.cmd @misconfig/cli@1.0.1` instead. There's no need to change your execution policy.
|
|
12
12
|
|
|
13
13
|
## What it checks
|
|
14
14
|
|
|
@@ -54,7 +54,7 @@ Exit codes: `0` when the check ran (and nothing reached `--fail-on`), `1` when `
|
|
|
54
54
|
Check the repository's agent files on every pull request:
|
|
55
55
|
|
|
56
56
|
```yaml
|
|
57
|
-
- run: npx @misconfig/cli@1.0.
|
|
57
|
+
- run: npx @misconfig/cli@1.0.1 --project-only --fail-on high
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
## Share links and badges
|
package/engine/catalog.js
CHANGED
|
@@ -357,9 +357,9 @@ export const RULES = {
|
|
|
357
357
|
},
|
|
358
358
|
"WS-POISON-RISK": {
|
|
359
359
|
severity: "critical", category: "workspace",
|
|
360
|
-
title: "
|
|
361
|
-
why: "{files} in {
|
|
362
|
-
fix: "
|
|
360
|
+
title: "Files in {place} can give orders to agents started there",
|
|
361
|
+
why: "{files} read like instructions to an agent, and an agent started in {place} treats the files there as context. Anything saved there later can add more.",
|
|
362
|
+
fix: "Start agents in project folders only, and delete instruction files you didn't write.",
|
|
363
363
|
},
|
|
364
364
|
"WS-OPENED-IN": {
|
|
365
365
|
severity: "high", category: "workspace",
|
package/engine/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// misconfig.ai rule engine. Runs only in the Worker, never in the browser.
|
|
2
2
|
|
|
3
|
-
import { maskSecrets, looksLikeSecret, looksLikeToken, isMasked, describeMasks } from "./mask.js";
|
|
3
|
+
import { maskSecrets, looksLikeSecret, looksLikeToken, isMasked, isPathLike, describeMasks } from "./mask.js";
|
|
4
4
|
import { parseJSONC, parseTOML } from "./parse.js";
|
|
5
5
|
import { RULES, CATEGORIES } from "./catalog.js";
|
|
6
6
|
|
|
7
|
-
export const RULESET_VERSION = "2026.11.
|
|
7
|
+
export const RULESET_VERSION = "2026.11.2";
|
|
8
8
|
|
|
9
9
|
const WEIGHT = { critical: 30, high: 15, medium: 6, low: 2, info: 0 };
|
|
10
10
|
const SEVERITIES = ["critical", "high", "medium", "low", "info"];
|
|
@@ -13,6 +13,8 @@ const MAX_FILE_CHARS = 450_000;
|
|
|
13
13
|
// Which agents read which files. Used for the control map and attribution.
|
|
14
14
|
const CONTROL = [
|
|
15
15
|
[/(^|\/)claude(\.local)?\.md$/i, ["Claude Code"], "Instructions"],
|
|
16
|
+
[/(^|\/)\.codex\/agents(\.override)?\.md$/i, ["Codex"], "Instructions"],
|
|
17
|
+
[/(^|\/)\.config\/opencode\/agents\.md$/i, ["OpenCode"], "Instructions"],
|
|
16
18
|
[/(^|\/)agents(\.override)?\.md$/i, ["Codex", "OpenCode", "Cursor", "GitHub Copilot", "Zed"], "Instructions"],
|
|
17
19
|
[/(^|\/)gemini\.md$/i, ["Gemini CLI"], "Instructions"],
|
|
18
20
|
[/(^|\/)\.claude\/settings(\.local)?\.json$/i, ["Claude Code"], "Permissions & hooks"],
|
|
@@ -603,7 +605,7 @@ function checkInstructionText(ctx, f) {
|
|
|
603
605
|
textRule("TXT-IMPORT-OUTSIDE", RX_IMPORT_OUTSIDE, (m) => ({ ref: "@" + clip(m[1], 80) }));
|
|
604
606
|
textRule("FLAG-DOCS", RX_DANGER_FLAGS, (m) => ({ flag: m[0].trim() }), { affirmative: true });
|
|
605
607
|
|
|
606
|
-
if (text.length > 60_000) add(ctx, "TXT-HUGE", { file: f, vars: { size: `${Math.round(text.length / 1024)} KB` } });
|
|
608
|
+
if (text.length > 60_000 && !f.loose) add(ctx, "TXT-HUGE", { file: f, vars: { size: `${Math.round(text.length / 1024)} KB` } });
|
|
607
609
|
}
|
|
608
610
|
|
|
609
611
|
// --- MCP servers -------------------------------------------------------------------
|
|
@@ -663,7 +665,7 @@ function normalizeServer(name, def, file) {
|
|
|
663
665
|
const REFERENCE = /^\$\{[^}]+\}$|^\$[A-Za-z_][A-Za-z0-9_]*$|^\{env:[^}]+\}$|^%[A-Za-z_][A-Za-z0-9_]*%$|\$\{(?:env|input):/i;
|
|
664
666
|
|
|
665
667
|
function isSecretValue(key, value) {
|
|
666
|
-
if (typeof value !== "string" || REFERENCE.test(value.trim())) return false;
|
|
668
|
+
if (typeof value !== "string" || REFERENCE.test(value.trim()) || isPathLike(value)) return false;
|
|
667
669
|
if (isMasked(value)) return true;
|
|
668
670
|
if (/^(true|false|\d+|https?:\/\/[^@]*)$/i.test(value)) return false;
|
|
669
671
|
return /(token|secret|key|password|passwd|auth|credential|bearer|cookie|session)/i.test(key) ? looksLikeSecret(value) || value.length >= 20 : looksLikeToken(value) && value.length >= 24;
|
|
@@ -818,8 +820,8 @@ function checkWorkspace(ctx) {
|
|
|
818
820
|
if (downloadsLike) add(ctx, "WS-DOWNLOADS", { vars: { root } });
|
|
819
821
|
|
|
820
822
|
if (downloadsLike) {
|
|
821
|
-
const steering = ctx.files.filter((f) => f.content && (f.kind || f.loose) && isInstructionFile(f) && (!f.loose ||
|
|
822
|
-
if (steering.length) add(ctx, "WS-POISON-RISK", { vars: { files: listNames(steering.map((f) => f.path), 3), root } });
|
|
823
|
+
const steering = ctx.files.filter((f) => f.content && (f.kind || f.loose) && isInstructionFile(f) && (!f.loose || steers(ctx, f)));
|
|
824
|
+
if (steering.length) add(ctx, "WS-POISON-RISK", { vars: { files: listNames(steering.map((f) => f.path), 3), place: `your ${root} folder` } });
|
|
823
825
|
}
|
|
824
826
|
|
|
825
827
|
const looseByDir = new Map();
|
|
@@ -831,8 +833,8 @@ function checkWorkspace(ctx) {
|
|
|
831
833
|
}
|
|
832
834
|
for (const [dir, list] of looseByDir) {
|
|
833
835
|
if (!riskyPlace(dir)) continue;
|
|
834
|
-
const steering = list.filter((f) =>
|
|
835
|
-
if (steering.length) add(ctx, "WS-POISON-RISK", { vars: { files: listNames(steering.map((f) => f.path.split("/").pop()), 3),
|
|
836
|
+
const steering = list.filter((f) => steers(ctx, f));
|
|
837
|
+
if (steering.length) add(ctx, "WS-POISON-RISK", { vars: { files: listNames(steering.map((f) => f.path.split("/").pop()), 3), place: riskyPlace(dir).name } });
|
|
836
838
|
}
|
|
837
839
|
|
|
838
840
|
if (ctx.shape.gitRepos >= 3) add(ctx, "WS-MULTI-REPO", { vars: { count: ctx.shape.gitRepos } });
|
|
@@ -881,8 +883,12 @@ function denyCovers(rule, path) {
|
|
|
881
883
|
}
|
|
882
884
|
}
|
|
883
885
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
+
// A loose file counts as steering an agent only when it reads like orders to
|
|
887
|
+
// one, or carries an injection pattern. Size and encoded blobs don't count:
|
|
888
|
+
// page dumps and logs are full of both.
|
|
889
|
+
const STEERING_RULES = new Set(["TXT-TAGS", "TXT-BIDI", "TXT-ZERO-WIDTH", "TXT-HIDDEN-COMMENT", "TXT-REMOTE-EXEC", "TXT-EXFIL", "TXT-OVERRIDE", "TXT-SECRET-ACCESS", "FLAG-DOCS"]);
|
|
890
|
+
function steers(ctx, f) {
|
|
891
|
+
return Boolean(f.content) && (RX_DIRECTIVE.test(f.content) || ctx.findings.some((x) => x.file === f.path && STEERING_RULES.has(x.id)));
|
|
886
892
|
}
|
|
887
893
|
|
|
888
894
|
function listNames(names, max = 4) {
|
|
@@ -905,7 +911,7 @@ function walk(obj, visit, depth = 0) {
|
|
|
905
911
|
// --- Sprawl ------------------------------------------------------------------------
|
|
906
912
|
|
|
907
913
|
function checkSprawl(ctx) {
|
|
908
|
-
const steering = ctx.files.filter((f) => f.content && f.kind && isInstructionFile(f) && !/(^|\/)\.(claude|github|codex|opencode)\/(commands|prompts|agents|chatmodes|skills|output-styles)\//i.test(f.path));
|
|
914
|
+
const steering = ctx.files.filter((f) => f.content && f.kind && !f.loose && isInstructionFile(f) && !/(^|\/)\.(claude|github|codex|opencode)\/(commands|prompts|agents|chatmodes|skills|output-styles)\//i.test(f.path));
|
|
909
915
|
const tools = new Set(steering.flatMap((f) => f.tools));
|
|
910
916
|
if (steering.length >= 4 && tools.size >= 3) {
|
|
911
917
|
add(ctx, "SPRAWL", { vars: { count: steering.length, list: listNames(steering.map((f) => f.path), 4) } });
|
|
@@ -941,7 +947,7 @@ function agentsIn(controlMap) {
|
|
|
941
947
|
|
|
942
948
|
function summarize(ctx) {
|
|
943
949
|
const findings = ctx.findings.sort(bySeverity);
|
|
944
|
-
const controlFiles = ctx.files.filter((f) => f.kind);
|
|
950
|
+
const controlFiles = ctx.files.filter((f) => f.kind && (!f.loose || steers(ctx, f)));
|
|
945
951
|
const { counts, score, grade } = scoreFindings(findings, controlFiles.length > 0);
|
|
946
952
|
const toolNames = agentsIn(controlFiles);
|
|
947
953
|
const headline = headlineFor(counts, findings[0], controlFiles.length > 0);
|
package/engine/mask.js
CHANGED
|
@@ -66,6 +66,13 @@ export function looksLikeSecret(value) {
|
|
|
66
66
|
return v.length >= 16 && classes >= 2 && entropy(v) >= 3.3 && !/\s/.test(v);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// File paths and path lists, such as C:\Users\sam\AppData\..., /usr/lib/node,
|
|
70
|
+
// ~/.config/app or %APPDATA%\app. A path can point at a secret, but it isn't one.
|
|
71
|
+
export function isPathLike(value) {
|
|
72
|
+
const first = String(value).trim().split(";")[0];
|
|
73
|
+
return /^(?:[A-Za-z]:[\\/]|\\\\|\/(?!\/)[^/\s]*\/|~[\\/]|\.{1,2}[\\/]|%[A-Za-z_][A-Za-z0-9_]*%[\\/]?|\$(?:HOME|\{HOME\})[\\/])/.test(first);
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
// Stricter, for strings with no key name to go on, such as command arguments.
|
|
70
77
|
// Random tokens mix letters and digits; names like GITHUB_TOKEN, flags like
|
|
71
78
|
// --dangerously-skip-permissions and package names are made of words and
|
|
@@ -79,7 +86,7 @@ export function looksLikeToken(value) {
|
|
|
79
86
|
re.lastIndex = 0;
|
|
80
87
|
if (re.test(v)) return true;
|
|
81
88
|
}
|
|
82
|
-
if (!/[0-9]/.test(v) || !/[A-Za-z]/.test(v)) return false;
|
|
89
|
+
if (!/[0-9]/.test(v) || !/[A-Za-z]/.test(v) || isPathLike(v)) return false;
|
|
83
90
|
if (v.split(/[-_.:@+]/).every((part) => !part || WORDY.test(part))) return false;
|
|
84
91
|
return looksLikeSecret(v);
|
|
85
92
|
}
|
|
@@ -102,7 +109,7 @@ export function maskSecrets(text) {
|
|
|
102
109
|
}
|
|
103
110
|
const keepPrefix = (kind) => (match, prefix, value) => {
|
|
104
111
|
if (isMasked(value) || PLACEHOLDER.test(value)) return match;
|
|
105
|
-
if (kind === "assigned-secret" && !looksLikeSecret(value)) return match;
|
|
112
|
+
if (kind === "assigned-secret" && (!looksLikeSecret(value) || isPathLike(value))) return match;
|
|
106
113
|
note(kind);
|
|
107
114
|
return prefix + marker(kind, value.length);
|
|
108
115
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@misconfig/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Finds every file that controls your AI coding agents and checks it for risky settings. Runs on your computer; nothing is uploaded unless you add --share.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|