vigilsutra 0.4.2 → 0.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.
@@ -4,6 +4,8 @@ export const isCode = (f) => CODE_EXT.has(f.ext);
4
4
  export const isJs = (f) => JS_EXT.has(f.ext);
5
5
  export const isPy = (f) => f.ext === ".py";
6
6
  export const isWorkflow = (f) => /^\.github\/workflows\/[^/]+\.ya?ml$/.test(f.path);
7
+ /** A composite action: its steps use `uses:` and `run:` like a workflow job. */
8
+ export const isCompositeAction = (f) => /^action\.ya?ml$/.test(f.name) && /^\s*using:\s*["']?composite\b/m.test(f.text);
7
9
  export const isDockerfile = (f) => /^dockerfile(\..+)?$/.test(f.name) || f.name.endsWith(".dockerfile");
8
10
  export const isYaml = (f) => f.ext === ".yaml" || f.ext === ".yml";
9
11
  export const isTerraform = (f) => f.ext === ".tf";
@@ -12,12 +14,15 @@ export const isK8s = (f) => isYaml(f) && /^[ \t]*apiVersion:/m.test(f.text) && /
12
14
  export function isCommentLine(line) {
13
15
  return /^\s*(\/\/|#|\*|\/\*|<!--)/.test(line);
14
16
  }
17
+ const FILLER = new Set("your my example change me changeme placeholder dummy sample test todo password secret none null undefined key token api here value xxx".split(" "));
15
18
  /** Values that are clearly placeholders, examples or templating. */
16
19
  export function isPlaceholder(value) {
17
20
  const v = value.trim();
18
21
  return (v.length < 8 ||
19
22
  /^\[?redacted\]?$/i.test(v) ||
20
- /^(x+|\*+|\.+|<.*>|\$\{.*\}|\{\{.*\}\}|%.*%|your[-_ ]|example|changeme|change[-_]me|placeholder|dummy|sample|test|todo|password|secret|none|null|undefined|process\.env|os\.environ|env\()/i.test(v) ||
23
+ /^(x+|\*+|\.+|<.*>|\$\{.*\}|\{\{.*\}\}|%.*%)$|^(your[-_ ]|process\.env|os\.environ|env\()/i.test(v) ||
24
+ // Only a value made entirely of filler words is a placeholder: "test-password-123" is, "password-Xk9fQ2" is not.
25
+ v.toLowerCase().split(/[-_ .!]+|\d+/).every((w) => !w || FILLER.has(w)) ||
21
26
  /(^|[^a-z])(example|placeholder|dummy|changeme|xxxx)/i.test(v));
22
27
  }
23
28
  export function lineRule(file, re, opts = {}) {
@@ -27,24 +32,30 @@ export function lineRule(file, re, opts = {}) {
27
32
  // Long lines are scanned in overlapping windows so a token past 2,000 characters is still seen.
28
33
  // The excerpt is the window, not the whole line.
29
34
  const parts = line.length > 2000 ? windows(line, 2000, 1900) : [{ text: line }];
30
- for (const part of parts) {
35
+ let hit;
36
+ const secrets = [];
37
+ const matched = new Set(); // line offsets; windows overlap
38
+ for (const [p, part] of parts.entries()) {
31
39
  if (opts.skipComments && isCommentLine(part.text))
32
40
  continue;
33
41
  g.lastIndex = 0;
34
- const m = g.exec(part.text);
35
- if (!m)
36
- continue;
37
- if (opts.filter && !opts.filter(m, part.text, i + 1))
38
- continue;
39
- const hit = { line: i + 1, excerpt: part.text };
40
- if (opts.secretGroup !== undefined) {
41
- const val = m[opts.secretGroup];
42
- const start = part.text.indexOf(val, m.index);
43
- hit.secretSpan = [start, start + val.length];
42
+ // Every match is read: to count them, and so that no second secret on the line survives in an excerpt.
43
+ for (let m = g.exec(part.text); m; m = g.exec(part.text)) {
44
+ if (opts.secretGroup !== undefined)
45
+ secrets.push(m[opts.secretGroup] ?? m[0]);
46
+ if (!opts.filter || opts.filter(m, part.text, i + 1)) {
47
+ hit ??= { line: i + 1, excerpt: part.text, at: m.index };
48
+ matched.add(p * 1900 + m.index);
49
+ }
50
+ if (!m[0])
51
+ g.lastIndex++;
44
52
  }
45
- hits.push(hit);
46
- break;
47
53
  }
54
+ if (!hit)
55
+ return;
56
+ if (matched.size > 1)
57
+ hit.note = `${matched.size - 1} more match(es) on this line.`;
58
+ hits.push(secrets.length ? { ...hit, secrets } : hit);
48
59
  });
49
60
  return hits;
50
61
  }
@@ -77,6 +88,37 @@ export function insideString(line, idx) {
77
88
  export function stripStrings(line) {
78
89
  return line.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/g, '""');
79
90
  }
91
+ const blockCache = new WeakMap();
92
+ /**
93
+ * The `{}` blocks around a line: the opener lines, outermost first, and the text of the innermost block.
94
+ * Braces are counted per line; comment lines are ignored.
95
+ */
96
+ export function enclosingBlock(f, line) {
97
+ let b = blockCache.get(f);
98
+ if (!b) {
99
+ const open = [];
100
+ const end = new Map();
101
+ const stack = [];
102
+ f.lines.forEach((text, i) => {
103
+ open.push(stack.slice(-8));
104
+ if (isCommentLine(text))
105
+ return;
106
+ for (const c of text) {
107
+ if (c === "{")
108
+ stack.push(i);
109
+ else if (c === "}" && stack.length)
110
+ end.set(stack.pop(), i);
111
+ }
112
+ });
113
+ blockCache.set(f, (b = { open, end }));
114
+ }
115
+ const chain = b.open[line - 1] ?? [];
116
+ const inner = chain[chain.length - 1];
117
+ return {
118
+ openers: chain.map((i) => f.lines[i]),
119
+ body: inner === undefined ? "" : f.lines.slice(inner, (b.end.get(inner) ?? f.lines.length - 1) + 1).join("\n")
120
+ };
121
+ }
80
122
  /** Looks back up to `n` lines (inclusive of the hit line) for a pattern. */
81
123
  export function lookBack(f, line, n, re) {
82
124
  for (let i = Math.max(0, line - 1 - n); i <= line - 1; i++)
package/dist/scope.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { lstatSync, readdirSync, realpathSync, openSync, readSync, closeSync, fstatSync } from "node:fs";
2
2
  import { join, basename, extname, relative, isAbsolute } from "node:path";
3
3
  import { makeIgnoreMatcher } from "./policy.js";
4
+ import { decodeText } from "./decode.js";
4
5
  import { createGitCache, sameIdentity, shouldSkipUntrackedDotenv } from "./git-index.js";
5
6
  /** True when `p` is `root` or lies beneath it (case-insensitive on Windows). */
6
7
  export function isInside(root, p) {
@@ -27,11 +28,7 @@ function readChecked(abs, expected) {
27
28
  break;
28
29
  off += n;
29
30
  }
30
- const head = Math.min(off, 8192);
31
- for (let i = 0; i < head; i++)
32
- if (buf[i] === 0)
33
- return "binary";
34
- return buf.toString("utf8", 0, off);
31
+ return decodeText(buf.subarray(0, off)) ?? "binary";
35
32
  }
36
33
  finally {
37
34
  closeSync(fd);
@@ -0,0 +1,18 @@
1
+ /** The candidate within two edits of `input`, if there is one. */
2
+ export function closest(input, candidates) {
3
+ const distance = (a, b) => {
4
+ let row = Array.from({ length: b.length + 1 }, (_v, i) => i);
5
+ for (let i = 1; i <= a.length; i++) {
6
+ const next = [i];
7
+ for (let j = 1; j <= b.length; j++)
8
+ next[j] = Math.min(next[j - 1] + 1, row[j] + 1, row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
9
+ row = next;
10
+ }
11
+ return row[b.length];
12
+ };
13
+ // Long input cannot be a typo of a short word, and skipping it bounds the work.
14
+ if (input.length > 40)
15
+ return undefined;
16
+ const [best] = candidates.map((c) => [distance(input, c), c]).sort((a, b) => a[0] - b[0]);
17
+ return best && best[0] <= 2 ? best[1] : undefined;
18
+ }
package/docs/rules.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rules (version 1.2.0)
1
+ # Rules (version 1.9.0)
2
2
 
3
3
  Generated from the rule definitions by `node docs/gen-rules.mjs > docs/rules.md`. CWE ids are orientation only; no standards control mapping is asserted (mapping unverified).
4
4
 
@@ -16,10 +16,20 @@ Generated from the rule definitions by `node docs/gen-rules.mjs > docs/rules.md`
16
16
  | VS-SECRET-010 | Google API key in source | high | medium | potential | SecretWatch | CWE-798 |
17
17
  | VS-SECRET-011 | Azure storage account key in source | high | high | confirmed | SecretWatch | CWE-798 |
18
18
  | VS-SECRET-012 | GitLab personal access token in source | high | high | confirmed | SecretWatch | CWE-798 |
19
+ | VS-CICD-005 | Workflow does not limit token permissions | low | high | potential | PipelineGuard | CWE-250 |
20
+ | VS-K8S-007 | Workload sets no resource limits | low | medium | potential | ContainerGuard | CWE-770 |
21
+ | VS-DB-001 | Database accepts connections without a password | high | high | potential | InfraGuard | CWE-306 |
22
+ | VS-DB-002 | Database or search engine security switched off | high | medium | potential | InfraGuard | CWE-306 |
23
+ | VS-IAC-004 | Database or storage exposed publicly | high | high | potential | InfraGuard | CWE-284 |
24
+ | VS-IAC-005 | Access granted to everyone | high | medium | potential | InfraGuard | CWE-732 |
25
+ | VS-K8S-004 | Pod mounts a host path | medium | high | potential | ContainerGuard | CWE-668 |
26
+ | VS-K8S-005 | Container adds a dangerous Linux capability | high | medium | potential | ContainerGuard | CWE-250 |
27
+ | VS-K8S-006 | RBAC role grants a wildcard | high | high | potential | ContainerGuard | CWE-269 |
28
+ | VS-COMPOSE-001 | Compose service has host-level access | high | high | confirmed | ContainerGuard | CWE-250 |
19
29
  | VS-CICD-001 | GitHub Action not pinned to a commit SHA | low | high | potential | PipelineGuard | CWE-829 |
20
- | VS-CICD-002 | pull_request_target workflow checks out pull-request code | high | medium | potential | PipelineGuard | CWE-829, CWE-94 |
30
+ | VS-CICD-002 | Privileged workflow checks out pull-request code | high | medium | potential | PipelineGuard | CWE-829, CWE-94 |
21
31
  | VS-CICD-003 | Workflow grants write-all permissions | medium | high | confirmed | PipelineGuard | CWE-250, CWE-732 |
22
- | VS-CICD-004 | Untrusted GitHub context interpolated into a shell step | high | medium | potential | PipelineGuard | CWE-78, CWE-77 |
32
+ | VS-CICD-004 | Untrusted GitHub context interpolated into a script step | high | medium | potential | PipelineGuard | CWE-78, CWE-77 |
23
33
  | VS-DOCKER-001 | Container runs as root (no USER instruction) | medium | high | confirmed | ContainerGuard | CWE-250 |
24
34
  | VS-DOCKER-002 | Base image uses :latest or no tag | low | high | confirmed | ContainerGuard | CWE-829 |
25
35
  | VS-DOCKER-003 | Remote script piped into a shell during build | medium | medium | potential | ContainerGuard | CWE-494 |
@@ -29,6 +39,7 @@ Generated from the rule definitions by `node docs/gen-rules.mjs > docs/rules.md`
29
39
  | VS-IAC-001 | Security group or firewall open to the whole internet | medium | medium | potential | InfraGuard | CWE-284 |
30
40
  | VS-IAC-002 | Public-read or public-write storage ACL | high | high | confirmed | InfraGuard | CWE-732 |
31
41
  | VS-IAC-003 | IAM policy with wildcard action | high | medium | potential | InfraGuard | CWE-269, CWE-732 |
42
+ | VS-CODE-013 | Request data reaches a shell or SQL call (Go, Java, Kotlin, PHP, Ruby, C#) | high | medium | potential | CodeGuard | CWE-78, CWE-89 |
32
43
  | VS-CODE-001 | Dynamic code execution (eval / new Function / exec) | high | medium | potential | CodeGuard | CWE-95 |
33
44
  | VS-CODE-002 | Shell command built from a dynamic string | high | medium | potential | CodeGuard | CWE-78 |
34
45
  | VS-CODE-003 | Insecure deserialization (pickle / unsafe YAML) | high | medium | potential | CodeGuard | CWE-502 |
@@ -36,6 +47,12 @@ Generated from the rule definitions by `node docs/gen-rules.mjs > docs/rules.md`
36
47
  | VS-CODE-005 | TLS certificate verification disabled | high | high | confirmed | CodeGuard | CWE-295 |
37
48
  | VS-CODE-006 | Weak hash algorithm (MD5 / SHA-1) | low | low | potential | CodeGuard | CWE-327 |
38
49
  | VS-CODE-007 | Raw HTML sink (innerHTML / dangerouslySetInnerHTML) | medium | low | potential | CodeGuard | CWE-79 |
50
+ | VS-CODE-008 | Request data used as a database query (NoSQL injection) | high | medium | potential | CodeGuard | CWE-943 |
51
+ | VS-CODE-009 | Request data used as a file path (path traversal) | high | medium | potential | CodeGuard | CWE-22 |
52
+ | VS-CODE-010 | Request data used as an outbound URL (SSRF) | high | medium | potential | CodeGuard | CWE-918 |
53
+ | VS-CODE-011 | Redirect target taken from the request (open redirect) | medium | medium | potential | CodeGuard | CWE-601 |
54
+ | VS-CODE-012 | Session cookie protection switched off | medium | medium | potential | CodeGuard | CWE-1004, CWE-614 |
55
+ | VS-AGENT-004 | Hidden Unicode characters in code or agent instructions | medium | high | potential | AgentShield | CWE-1007 |
39
56
  | VS-AGENT-001 | Instruction file tries to override agent safety or scope | medium | low | potential | AgentShield | CWE-1427 |
40
57
  | VS-AGENT-002 | Agent configuration disables permission prompts | high | medium | potential | AgentShield | CWE-250 |
41
58
  | VS-AGENT-003 | MCP server launched via unpinned remote package | low | medium | potential | AgentShield | CWE-829 |
@@ -95,7 +112,7 @@ A `.env` file (not an example, sample, or template) contains a secret-named vari
95
112
 
96
113
  - **Fix:** Treat the credential as compromised: revoke or rotate it at the issuer first, then remove it from the repository and load it from an environment variable or secret manager. Deleting it from the latest commit does not remove it from git history.
97
114
  - **Verify:** Re-run `vigilsutra audit` after removing the value; then confirm the credential was rotated at the issuer and review git history for earlier exposure.
98
- - **False positives:** Placeholder values and non-secret settings. `.env.example`, `.env.sample`, and `.env.template` are not reported. A local `.env` that git does not track is not a finding.
115
+ - **False positives:** Placeholder values and non-secret settings. `.env.example`, `.env.sample`, and `.env.template` are left to VS-SECRET-004, which reports values that look real. A local `.env` that git does not track is not a finding.
99
116
 
100
117
  ### VS-SECRET-007: JSON Web Token in source
101
118
 
@@ -145,6 +162,86 @@ A string matching a GitLab personal access token (glpat-) is committed.
145
162
  - **Verify:** Re-run `vigilsutra audit` after removing the value; then confirm the credential was rotated at the issuer and review git history for earlier exposure.
146
163
  - **False positives:** Revoked tokens.
147
164
 
165
+ ### VS-CICD-005: Workflow does not limit token permissions
166
+
167
+ The workflow declares no `permissions`, so its token gets the repository default, which may include write access.
168
+
169
+ - **Fix:** Add `permissions: contents: read` at the top level and grant more to single jobs only where needed.
170
+ - **Verify:** The workflow declares `permissions` and still passes.
171
+ - **False positives:** Repositories whose default token permission is already read-only.
172
+
173
+ ### VS-K8S-007: Workload sets no resource limits
174
+
175
+ No `limits` appear in the manifest, so one container can use all the CPU or memory of a node.
176
+
177
+ - **Fix:** Set memory and CPU requests and limits for each container.
178
+ - **Verify:** `kubectl describe pod` shows limits.
179
+ - **False positives:** Clusters that apply defaults with a LimitRange. The check looks at the whole file, not each container.
180
+
181
+ ### VS-DB-001: Database accepts connections without a password
182
+
183
+ A setting lets a database accept logins with no password (PostgreSQL `trust`, or an allowed empty MySQL or MariaDB password).
184
+
185
+ - **Fix:** Require a password from a secret store and use `scram-sha-256` for PostgreSQL.
186
+ - **Verify:** A connection without a password is refused.
187
+ - **False positives:** Throw-away databases in local development or CI that no other host can reach.
188
+
189
+ ### VS-DB-002: Database or search engine security switched off
190
+
191
+ Redis protected mode, Elasticsearch or OpenSearch security, or MongoDB authorization is disabled.
192
+
193
+ - **Fix:** Enable authentication and bind the service to a private network.
194
+ - **Verify:** An unauthenticated request is refused.
195
+ - **False positives:** Local development setups that no other host can reach.
196
+
197
+ ### VS-IAC-004: Database or storage exposed publicly
198
+
199
+ A Terraform setting makes a database publicly accessible, or turns off a block on public storage access.
200
+
201
+ - **Fix:** Keep databases in private networks and leave public access blocks enabled.
202
+ - **Verify:** The plan shows public access disabled.
203
+ - **False positives:** Buckets or databases that are public by documented design.
204
+
205
+ ### VS-IAC-005: Access granted to everyone
206
+
207
+ A policy grants access to `*`, `allUsers` or `allAuthenticatedUsers`.
208
+
209
+ - **Fix:** Name the accounts, roles or service principals that need access, or add a restricting condition.
210
+ - **Verify:** The grant names specific principals.
211
+ - **False positives:** Public website objects, and statements narrowed by a condition. Check the condition.
212
+
213
+ ### VS-K8S-004: Pod mounts a host path
214
+
215
+ A `hostPath` volume exposes files of the node to the pod. A writable or sensitive path lets a compromised container take over the node.
216
+
217
+ - **Fix:** Use a persistent volume, ConfigMap or emptyDir. If a node agent needs the path, mount it read-only and as narrowly as possible.
218
+ - **Verify:** No `hostPath` volume remains, or the exception is documented and read-only.
219
+ - **False positives:** Node agents such as log collectors that must read one specific path.
220
+
221
+ ### VS-K8S-005: Container adds a dangerous Linux capability
222
+
223
+ Adding `ALL`, `SYS_ADMIN`, `SYS_MODULE`, `SYS_PTRACE` or `NET_ADMIN` gives the container powers close to root on the host.
224
+
225
+ - **Fix:** Drop all capabilities and add only a narrow one the workload is shown to need.
226
+ - **Verify:** The capability is gone from `add` or `cap_add` and the workload still runs.
227
+ - **False positives:** Network and storage agents that need the capability.
228
+
229
+ ### VS-K8S-006: RBAC role grants a wildcard
230
+
231
+ A Role or ClusterRole lists `*` as a verb or resource, which grants far more than a workload needs.
232
+
233
+ - **Fix:** List the exact verbs and resources, and prefer a namespaced Role.
234
+ - **Verify:** No `*` remains in `verbs` or `resources`.
235
+ - **False positives:** Cluster administration roles that are bound only to operators.
236
+
237
+ ### VS-COMPOSE-001: Compose service has host-level access
238
+
239
+ `privileged: true`, host network or PID mode, or a mounted Docker socket lets the service control the host.
240
+
241
+ - **Fix:** Remove the setting. If a tool needs the Docker API, put a filtering proxy in front of the socket.
242
+ - **Verify:** The setting is gone and the service still starts.
243
+ - **False positives:** Local development tools that manage containers by design.
244
+
148
245
  ### VS-CICD-001: GitHub Action not pinned to a commit SHA
149
246
 
150
247
  A third-party action is referenced by a mutable tag or branch. If the tag is moved or the publisher is compromised, the workflow runs attacker-controlled code.
@@ -153,9 +250,9 @@ A third-party action is referenced by a mutable tag or branch. If the tag is mov
153
250
  - **Verify:** Every `uses:` line for a non-local action ends in @<40 hex>.
154
251
  - **False positives:** First-party `actions/*` references are lower risk; local `./` actions and Docker digests are skipped.
155
252
 
156
- ### VS-CICD-002: pull_request_target workflow checks out pull-request code
253
+ ### VS-CICD-002: Privileged workflow checks out pull-request code
157
254
 
158
- A workflow triggered by `pull_request_target` runs with repository secrets and a write token. Checking out the PR head and then running its code lets an outside contributor execute code with those privileges.
255
+ A workflow triggered by `pull_request_target` or `workflow_run` runs with repository secrets and a write token. Checking out the PR head and then running its code lets an outside contributor execute code with those privileges.
159
256
 
160
257
  - **Fix:** Use `pull_request` for untrusted code. If `pull_request_target` is required, do not check out or execute PR-controlled content, and keep permissions minimal.
161
258
  - **Verify:** Confirm no step after the checkout executes files from the PR head, or remove the head checkout.
@@ -169,9 +266,9 @@ A workflow triggered by `pull_request_target` runs with repository secrets and a
169
266
  - **Verify:** No `write-all` remains and the workflow still passes.
170
267
  - **False positives:** None expected; the setting is explicit.
171
268
 
172
- ### VS-CICD-004: Untrusted GitHub context interpolated into a shell step
269
+ ### VS-CICD-004: Untrusted GitHub context interpolated into a script step
173
270
 
174
- Attacker-controlled fields (PR title/body, branch name, issue or comment text) are expanded directly inside a `run:` script. A crafted value can inject shell commands.
271
+ Attacker-controlled fields (PR title/body, branch name, issue or comment text) are expanded directly inside a `run:` or `actions/github-script` script. A crafted value can inject commands.
175
272
 
176
273
  - **Fix:** Pass the value through an environment variable (`env: TITLE: ${{ github.event.pull_request.title }}`) and reference it as `"$TITLE"` in the script.
177
274
  - **Verify:** The expression no longer appears inside a `run:` body.
@@ -227,7 +324,7 @@ hostNetwork, hostPID or hostIPC removes namespace isolation between the pod and
227
324
 
228
325
  ### VS-IAC-001: Security group or firewall open to the whole internet
229
326
 
230
- A Terraform rule allows 0.0.0.0/0 (or ::/0). Open ingress to administrative or database ports exposes them to internet scanning and attack.
327
+ A Terraform rule allows 0.0.0.0/0, ::/0 or an Azure `*`/`Internet` source. Open ingress to administrative or database ports exposes them to internet scanning and attack.
231
328
 
232
329
  - **Fix:** Restrict CIDR ranges to known addresses or place the service behind a load balancer, VPN or bastion.
233
330
  - **Verify:** Ingress CIDRs are restricted or documented as intentionally public.
@@ -249,6 +346,14 @@ An IAM statement allows `*` actions, which grants administrator-level power to w
249
346
  - **Verify:** Wildcard replaced with an explicit action list.
250
347
  - **False positives:** Deny statements and break-glass roles that are tightly controlled. Check Effect.
251
348
 
349
+ ### VS-CODE-013: Request data reaches a shell or SQL call (Go, Java, Kotlin, PHP, Ruby, C#)
350
+
351
+ A request value is placed into a command, evaluated code or SQL text on the same line, which allows command or SQL injection.
352
+
353
+ - **Fix:** Pass arguments as a list and use parameterised queries. Never build commands or SQL from request text.
354
+ - **Verify:** Send shell and quote characters and confirm they have no effect.
355
+ - **False positives:** Values validated or escaped before this line.
356
+
252
357
  ### VS-CODE-001: Dynamic code execution (eval / new Function / exec)
253
358
 
254
359
  Strings are compiled and executed as code. If any part is attacker-influenced this is remote code execution. Confidence is raised when the argument name traces to a request-like assignment in this project, including through a relative import. Object fields, dynamic imports, and function calls are not tracked.
@@ -305,6 +410,54 @@ Assigning strings to HTML sinks can cause cross-site scripting if the content in
305
410
  - **Verify:** Sink removed or input proven sanitised; test with a `<script>` payload.
306
411
  - **False positives:** Constant markup or content already sanitised.
307
412
 
413
+ ### VS-CODE-008: Request data used as a database query (NoSQL injection)
414
+
415
+ A request object is passed straight into a query, or text is built into a `$where` clause. An attacker can send operators such as `$ne` or script and change what the query matches.
416
+
417
+ - **Fix:** Pick the expected fields, check their type, and avoid `$where`.
418
+ - **Verify:** Send an object where a string is expected and confirm it is rejected.
419
+ - **False positives:** Input already validated against a schema before this line.
420
+
421
+ ### VS-CODE-009: Request data used as a file path (path traversal)
422
+
423
+ A file is opened, sent or deleted using a request value, so `../` sequences can reach files outside the intended folder.
424
+
425
+ - **Fix:** Resolve the path and require it to stay inside an allowed folder, or map an id to a known file name.
426
+ - **Verify:** Request `../` and an absolute path and confirm both are refused.
427
+ - **False positives:** Values already reduced to a base name or checked against an allow list.
428
+
429
+ ### VS-CODE-010: Request data used as an outbound URL (SSRF)
430
+
431
+ The server fetches a URL taken from the request, which can reach internal services and cloud metadata endpoints.
432
+
433
+ - **Fix:** Allow only known hosts, resolve and block private address ranges, and do not follow redirects to them.
434
+ - **Verify:** Request a loopback or link-local address and confirm it is refused.
435
+ - **False positives:** A value checked against an allow list before this line.
436
+
437
+ ### VS-CODE-011: Redirect target taken from the request (open redirect)
438
+
439
+ The redirect destination comes from the request, so a link to this site can send people to an attacker's site.
440
+
441
+ - **Fix:** Redirect to relative paths or to an allow list of destinations.
442
+ - **Verify:** Request an external destination and confirm it is refused.
443
+ - **False positives:** A value validated as a local path before this line.
444
+
445
+ ### VS-CODE-012: Session cookie protection switched off
446
+
447
+ `httpOnly` or `secure` is disabled for a cookie, which exposes it to scripts or to unencrypted connections.
448
+
449
+ - **Fix:** Set `httpOnly` and `secure` to true and choose a `sameSite` value.
450
+ - **Verify:** The Set-Cookie response header carries HttpOnly and Secure.
451
+ - **False positives:** Cookies that scripts must read, or settings used only for local development.
452
+
453
+ ### VS-AGENT-004: Hidden Unicode characters in code or agent instructions
454
+
455
+ Invisible or direction-changing characters make a file read differently to a person than to a compiler or AI assistant (Trojan Source, rules-file backdoor).
456
+
457
+ - **Fix:** Delete the characters, then read the line again. Treat hidden text in an instruction file as hostile until its author explains it.
458
+ - **Verify:** Re-run `vigilsutra audit`; an editor that shows invisible characters displays none on the line.
459
+ - **False positives:** Right-to-left text that needs direction controls in a string, and test data about Unicode.
460
+
308
461
  ### VS-AGENT-001: Instruction file tries to override agent safety or scope
309
462
 
310
463
  An agent instruction file contains phrases typical of prompt injection (ignore previous instructions, disable safety, exfiltrate). Repositories are untrusted input to any AI agent that reads them.
package/llms.txt CHANGED
@@ -1,11 +1,11 @@
1
1
  # VigilSutra AI
2
2
 
3
- > VigilSutra AI (CLI: `vigilsutra`, v0.4.0) is an open-source, offline-first security and privacy auditor for codebases, created by [Vatsal Shah](https://shahvatsal.com). It scans for hardcoded secrets (including git history for SHA-1 and SHA-256 repos), GitHub Actions risks, Docker, Kubernetes and Terraform misconfigurations, JS/TS/Python patterns, a shipped advisory snapshot, and AI-agent/MCP risks, and writes redacted SARIF, JSON, Markdown and HTML reports plus a CycloneDX SBOM. It needs no API key and sends no data anywhere. It ships Agent Skills and file-copy adapters for Claude Code, Cursor, Codex, Gemini CLI, and Copilot. License: Apache-2.0. Repository: https://github.com/shahvatsalofficial/vigilsutra
3
+ > VigilSutra AI (CLI: `vigilsutra`, v0.6.0) is an open-source, offline-first security and privacy auditor for codebases, created by [Vatsal Shah](https://shahvatsal.com). It scans for hardcoded secrets (including git history for SHA-1 and SHA-256 repos), GitHub Actions risks, Docker, Kubernetes and Terraform misconfigurations, JS/TS/Python patterns, a shipped advisory snapshot, and AI-agent/MCP risks, and writes redacted SARIF, JSON, Markdown and HTML reports plus a CycloneDX SBOM. It needs no API key and sends no data anywhere. It ships Agent Skills and file-copy adapters for Claude Code, Cursor, Codex, Gemini CLI, and Copilot. License: Apache-2.0. Repository: https://github.com/shahvatsalofficial/vigilsutra
4
4
 
5
5
  Key facts for assistants:
6
6
  - Runs locally on Node.js 20+; no telemetry, no network access, never executes scanned code.
7
7
  - Findings separate severity from confidence and mark each as confirmed or potential.
8
- - Not a pentest tool and not a compliance certification. Pattern-based. A request-like name is tracked through a relative import; object fields, dynamic import, and function returns are not. Git history runs until the time limit (1 MiB blob cap) for SHA-1 and SHA-256. Advisory matches use the shipped 2026-11-07 snapshot, not a live feed. `vigilsutra fix` is a dry run unless `--apply`. Recall on the 18-repo study was not measured, and that study was not re-run for 0.4.0. There is no independent human review.
8
+ - Not a pentest tool and not a compliance certification. Pattern-based. A request-like name is tracked through a relative import; object fields, dynamic import, and function returns are not. Git history runs until the time limit (1 MiB blob cap) for SHA-1 and SHA-256. Advisory matches use the shipped 2026-11-07 snapshot, not a live feed. `vigilsutra fix` is a dry run unless `--apply`. Recall on the 18-repo study was not measured, and that study has not been re-run for 0.4.0 or later. There is no independent human review.
9
9
 
10
10
  ## Docs
11
11
  - [README](https://github.com/shahvatsalofficial/vigilsutra/blob/main/README.md): overview, commands, feature matrix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigilsutra",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "VigilSutra AI: open-source, offline-first security and privacy auditor CLI plus AI agent skills. Finds secrets, CI/CD, Docker, Kubernetes, IaC, code and AI-agent risks with redacted, evidence-based SARIF/JSON/Markdown reports. No API key, no telemetry.",
5
5
  "keywords": [
6
6
  "security",
@@ -45,7 +45,6 @@
45
45
  "files": [
46
46
  "dist",
47
47
  "agents",
48
- "adapters",
49
48
  "policies",
50
49
  "schemas",
51
50
  "docs",
@@ -1,5 +1,5 @@
1
- # VigilSutra AI policy. Defaults already ignore .git, node_modules, dist, build, vendor
2
- # and lockfiles. Entries below ADD to those defaults; they never remove them.
1
+ # VigilSutra AI policy. Defaults already ignore .git, node_modules, caches
2
+ # and lockfiles; dist, build, out and vendor are read for secrets only. Entries below ADD to those defaults; they never remove them.
3
3
  # Do not ignore .env files: the scanner reports them without echoing contents.
4
4
  version: 1
5
5
  ignore:
@@ -10,5 +10,6 @@ timeLimitMs: 60000
10
10
  # failOn: high
11
11
  disableRules: []
12
12
  # A waiver hides one rule on one path until the UTC date (inclusive). Expired waivers do not hide findings.
13
+ # A waiver is ruleId|path[:line]|owner|YYYY-MM-DD[|reason]. The path may contain * or **.
13
14
  # waivers:
14
15
  # - VS-CODE-001|src/legacy.js|your-name|2026-12-31
@@ -7,7 +7,7 @@
7
7
  "properties": {
8
8
  "id": { "type": "string" },
9
9
  "fingerprint": { "type": "string", "pattern": "^[0-9a-f]{32}$" },
10
- "ruleId": { "type": "string", "pattern": "^VS-[A-Z]+-[0-9]{3}$" },
10
+ "ruleId": { "type": "string", "pattern": "^VS-[A-Z0-9]+-[0-9]{3}$" },
11
11
  "ruleVersion": { "type": "string" },
12
12
  "title": { "type": "string" },
13
13
  "category": { "type": "string" },