@andesyte-oss/security-rules 0.1.3 → 0.1.4

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/dist/index.d.ts CHANGED
@@ -4,7 +4,9 @@
4
4
  * no network request to any rule registry.
5
5
  */
6
6
  export declare function rulesDir(): string;
7
- export declare function rulePaths(): string[];
7
+ export declare function rulePaths(options?: {
8
+ reviewSinks?: boolean;
9
+ }): string[];
8
10
  export declare const RULESET_NAME = "andesyte-local";
9
11
  export declare const RULESET_VERSION: string;
10
12
  export interface RulesetDescriptor {
@@ -15,4 +17,6 @@ export interface RulesetDescriptor {
15
17
  languageExtensions: Readonly<Record<string, readonly string[]>>;
16
18
  }
17
19
  /** Complete descriptor consumed by scanner adapters. */
18
- export declare function ruleset(): RulesetDescriptor;
20
+ export declare function ruleset(options?: {
21
+ reviewSinks?: boolean;
22
+ }): RulesetDescriptor;
package/dist/index.js CHANGED
@@ -16,12 +16,15 @@ export function rulesDir() {
16
16
  }
17
17
  throw new Error("packaged rules directory not found");
18
18
  }
19
- export function rulePaths() {
19
+ export function rulePaths(options = {}) {
20
20
  const dir = rulesDir();
21
- return readdirSync(dir)
21
+ const files = readdirSync(dir)
22
22
  .filter((f) => f.endsWith(".yml") || f.endsWith(".yaml"))
23
23
  .sort()
24
24
  .map((f) => join(dir, f));
25
+ if (options.reviewSinks)
26
+ files.push(join(dir, "review", "unsafe-sinks-js.yml"));
27
+ return files;
25
28
  }
26
29
  export const RULESET_NAME = "andesyte-local";
27
30
  function packageVersion() {
@@ -35,11 +38,11 @@ function packageVersion() {
35
38
  }
36
39
  export const RULESET_VERSION = packageVersion();
37
40
  /** Complete descriptor consumed by scanner adapters. */
38
- export function ruleset() {
41
+ export function ruleset(options = {}) {
39
42
  return {
40
43
  name: RULESET_NAME,
41
44
  version: RULESET_VERSION,
42
- rulePaths: rulePaths(),
45
+ rulePaths: rulePaths(options),
43
46
  languageExtensions: {},
44
47
  };
45
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andesyte-oss/security-rules",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Andesyte curated Semgrep security rules, shipped as packaged local files (no registry fetch).",
5
5
  "homepage": "https://andesyte.com",
6
6
  "author": "Andesyte <lewis@andesyte.com>",
@@ -72,6 +72,8 @@ rules:
72
72
  - pattern: $X.choices[0].message.content
73
73
  - pattern: $X.choices[0].delta.content
74
74
  - pattern: $X.content[0].text
75
+ - pattern: $X.response.text()
76
+ - pattern: $X.models.generateContent(...)
75
77
  - pattern: generateText(...)
76
78
  - pattern: streamText(...)
77
79
  pattern-sanitizers:
@@ -201,6 +203,8 @@ rules:
201
203
  - pattern: $X.choices[0].message.content
202
204
  - pattern: $X.choices[0].delta.content
203
205
  - pattern: $X.content[0].text
206
+ - pattern: $X.response.text()
207
+ - pattern: $X.models.generateContent(...)
204
208
  - pattern: generateText(...)
205
209
  - pattern: streamText(...)
206
210
  pattern-sinks:
@@ -219,3 +223,31 @@ rules:
219
223
  - pattern: "$CP.spawnSync($CMD, $ARGS, { ..., shell: true, ... })"
220
224
  - pattern: "spawnSync($CMD, $ARGS, { ..., shell: true, ... })"
221
225
  - focus-metavariable: $CMD
226
+
227
+ - id: ai.insecure-output-handling.eval-llm-response-js
228
+ message: >-
229
+ Model output reaches dynamic JavaScript execution. Treat generated code as
230
+ untrusted and do not execute it with eval or Function.
231
+ severity: ERROR
232
+ languages: [typescript, javascript]
233
+ mode: taint
234
+ metadata:
235
+ cwe: "CWE-94: Improper Control of Generation of Code"
236
+ owasp: "LLM02:2026 Insecure Output Handling"
237
+ impact: HIGH
238
+ pattern-sources:
239
+ - pattern-either:
240
+ - pattern: $X.choices[0].message.content
241
+ - pattern: $X.choices[0].delta.content
242
+ - pattern: $X.content[0].text
243
+ - pattern: $X.response.text()
244
+ - pattern: $X.models.generateContent(...)
245
+ - pattern: generateText(...)
246
+ - pattern: streamText(...)
247
+ pattern-sinks:
248
+ - patterns:
249
+ - pattern-either:
250
+ - pattern: eval($CODE)
251
+ - pattern: Function($CODE)
252
+ - pattern: new Function($CODE)
253
+ - focus-metavariable: $CODE
@@ -0,0 +1,34 @@
1
+ rules:
2
+ - id: ai.sink-review.dynamic-code-js
3
+ message: >-
4
+ REVIEW REQUIRED: non-literal data reaches dynamic JavaScript execution.
5
+ Its origin is unknown to this check.
6
+ severity: WARNING
7
+ languages: [typescript, javascript]
8
+ metadata:
9
+ cwe: "CWE-94: Improper Control of Generation of Code"
10
+ analysis_kind: sink-review
11
+ patterns:
12
+ - pattern-either:
13
+ - pattern: eval($CODE)
14
+ - pattern: Function($CODE)
15
+ - pattern: new Function($CODE)
16
+ - pattern-not: eval("...")
17
+ - pattern-not: Function("...")
18
+ - pattern-not: new Function("...")
19
+ - id: ai.sink-review.raw-html-js
20
+ message: >-
21
+ REVIEW REQUIRED: non-literal data reaches a raw HTML sink. Its origin is
22
+ unknown to this check.
23
+ severity: WARNING
24
+ languages: [typescript, javascript]
25
+ metadata:
26
+ cwe: "CWE-79: Cross-site Scripting"
27
+ analysis_kind: sink-review
28
+ patterns:
29
+ - pattern-either:
30
+ - pattern: $EL.innerHTML = $HTML
31
+ - pattern: $EL.outerHTML = $HTML
32
+ - pattern: $EL.insertAdjacentHTML($POS, $HTML)
33
+ - pattern: |
34
+ <$TAG dangerouslySetInnerHTML={{ __html: $HTML }} />