xploitscan-shared-rules 1.36.0 → 1.36.2

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 CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Shared XploitScan rule definitions, helpers, compliance mappings, the AI false-positive filter, and the entropy-based secret scanner.
4
4
 
5
- This package is the source of truth for XploitScan's detection logic. It's consumed by the [XploitScan CLI](https://www.npmjs.com/package/xploitscan), the [XploitScan MCP server](https://www.npmjs.com/package/xploitscan-mcp), the [VS Code extension](https://marketplace.visualstudio.com/items?itemName=XploitScan.xploitscan-vscode), the web scan API at [xploitscan.com](https://xploitscan.com), and the [XploitScan GitHub Action](https://github.com/marketplace/actions/xploitscan-security-scanner) — so detection behavior can't drift between surfaces.
5
+ This package is the source of truth for XploitScan's detection logic. It's consumed by the [XploitScan CLI](https://www.npmjs.com/package/xploitscan), the [XploitScan MCP server](https://www.npmjs.com/package/xploitscan-mcp), the [VS Code extension](https://marketplace.visualstudio.com/items?itemName=XploitScan.xploitscan-vscode), the web scan API at [xploitscan.com](https://xploitscan.com), and the [XploitScan GitHub Action](https://github.com/marketplace/actions/xploitscan-security-scanner) — one source of detection logic behind every surface.
6
6
 
7
7
  ## What's in here
8
8
 
9
- - **210+ security rules** — pattern + AST-based detection for hardcoded secrets, SQL injection, XSS, SSRF, prototype pollution, crypto misuse, deserialization, JWT alg confusion, and more.
10
- - **Compliance mappings** — each rule tagged with the SOC2, ISO 27001, and OWASP Top 10 controls it covers.
9
+ - **214 rules** — pattern + AST-based detection for hardcoded secrets, SQL injection, XSS, SSRF, prototype pollution, crypto misuse, deserialization, JWT alg confusion, and more.
10
+ - **Compliance mappings** — each rule tagged with its OWASP Top 10 (2021) category and CWE ID.
11
11
  - **AI false-positive filter** — optional Claude Haiku integration that re-evaluates findings to suppress benign matches before reporting.
12
12
  - **Entropy-based secret scanner** — detects high-entropy strings that look like credentials but don't match a known service-key pattern.
13
13
 
@@ -22,11 +22,11 @@ pnpm add xploitscan-shared-rules
22
22
  ## Usage
23
23
 
24
24
  ```ts
25
- import { getAllRules, scanContent, calculateGrade } from "xploitscan-shared-rules";
25
+ import { runCustomRules, proOnlyRules, calculateGrade } from "xploitscan-shared-rules";
26
26
 
27
- const rules = getAllRules();
28
- const findings = scanContent(sourceCode, filePath, rules);
29
- const { grade, score } = calculateGrade(findings);
27
+ // "pro" + proOnlyRules runs every rule (free + Pro)
28
+ const findings = runCustomRules(sourceCode, filePath, [], "pro", proOnlyRules);
29
+ const { grade, score } = calculateGrade(findings, 1);
30
30
  ```
31
31
 
32
32
  For the full API surface, see the TypeScript definitions in `dist/index.d.ts` (shipped with the package).
package/dist/index.cjs CHANGED
@@ -2735,7 +2735,7 @@ var evalUsage = {
2735
2735
  title: "Use of eval() or Function Constructor",
2736
2736
  severity: "high",
2737
2737
  category: "Injection",
2738
- description: "eval() and new Function() execute arbitrary code, creating severe injection risks. Common in AI-generated code.",
2738
+ description: "eval() and new Function() execute arbitrary code, creating severe injection risks.",
2739
2739
  check(content, filePath) {
2740
2740
  if (filePath.includes("node_modules") || filePath.includes(".min.")) return [];
2741
2741
  if (filePath.match(/(?:webpack|rollup|vite|jest|babel|tsup|esbuild)\.config/i)) return [];
@@ -3399,7 +3399,7 @@ var missingHTTPS = {
3399
3399
  title: "Missing HTTPS Enforcement",
3400
3400
  severity: "high",
3401
3401
  category: "Configuration",
3402
- description: "HTTP URLs in production code, missing HSTS headers, or insecure redirect configurations expose data to man-in-the-middle attacks.",
3402
+ description: "Hardcoded http:// URLs (other than localhost and private-network addresses) send data unencrypted, exposing it to man-in-the-middle attacks.",
3403
3403
  check(content, filePath) {
3404
3404
  if (filePath.endsWith(".example") || filePath.includes("test") || filePath.includes("README")) return [];
3405
3405
  if (filePath.match(/\.(md|txt)$/)) return [];
@@ -3984,7 +3984,7 @@ var weakPasswordRequirements = {
3984
3984
  p,
3985
3985
  weakPasswordRequirements,
3986
3986
  filePath,
3987
- () => "Minimum password length is too low. Require at least 8 characters with complexity (upper+lower+digit+symbol) or 12+ characters without complexity. OWASP ASVS L1 requires 8+; NIST 800-63B recommends 12+."
3987
+ () => "Minimum password length is too low. Require at least 8 characters, and at least 15 when the password is the only authentication factor (NIST SP 800-63B)."
3988
3988
  ));
3989
3989
  }
3990
3990
  if (matches.length > 0) return matches;
@@ -4933,7 +4933,7 @@ var corsServerless = {
4933
4933
  title: "CORS Wildcard in Serverless Config",
4934
4934
  severity: "high",
4935
4935
  category: "Configuration",
4936
- description: "Setting Access-Control-Allow-Origin: * in serverless.yml, vercel.json, or similar configs allows any website to make authenticated requests to your API.",
4936
+ description: "Setting Access-Control-Allow-Origin: * in serverless.yml, vercel.json, or similar configs lets any website read your API's responses.",
4937
4937
  check(content, filePath) {
4938
4938
  if (!filePath.match(/serverless\.(yml|yaml)|vercel\.json|netlify\.toml|amplify\.yml/i)) return [];
4939
4939
  const matches = [];
@@ -5723,7 +5723,7 @@ var complianceMap = {
5723
5723
  VC022: { owasp: "A03:2021", cwe: "CWE-79" },
5724
5724
  VC023: { owasp: "A08:2021", cwe: "CWE-1321" },
5725
5725
  VC024: { owasp: "A04:2021", cwe: "CWE-770" },
5726
- VC025: { owasp: "A03:2021", cwe: "CWE-22" },
5726
+ VC025: { owasp: "A01:2021", cwe: "CWE-22" },
5727
5727
  VC026: { owasp: "A05:2021", cwe: "CWE-693" },
5728
5728
  VC027: { owasp: "A05:2021", cwe: "CWE-693" },
5729
5729
  VC028: { owasp: "A07:2021", cwe: "CWE-20" },
@@ -5751,7 +5751,7 @@ var complianceMap = {
5751
5751
  VC050: { owasp: "A02:2021", cwe: "CWE-319" },
5752
5752
  VC051: { owasp: "A05:2021", cwe: "CWE-200" },
5753
5753
  VC052: { owasp: "A04:2021", cwe: "CWE-770" },
5754
- VC053: { owasp: "A05:2021", cwe: "CWE-798" },
5754
+ VC053: { owasp: "A05:2021", cwe: "CWE-547" },
5755
5755
  VC054: { owasp: "A07:2021", cwe: "CWE-922" },
5756
5756
  VC055: { owasp: "A05:2021", cwe: "CWE-540" },
5757
5757
  VC056: { owasp: "A05:2021", cwe: "CWE-1021" },
@@ -5809,13 +5809,13 @@ var complianceMap = {
5809
5809
  VC108: { owasp: "A01:2021", cwe: "CWE-284" },
5810
5810
  VC109: { owasp: "A01:2021", cwe: "CWE-284" },
5811
5811
  VC110: { owasp: "A09:2021", cwe: "CWE-778" },
5812
- VC111: { owasp: "A05:2021", cwe: "CWE-16" },
5812
+ VC111: { owasp: "A05:2021", cwe: "CWE-653" },
5813
5813
  VC112: { owasp: "A06:2021", cwe: "CWE-1104" },
5814
5814
  VC113: { owasp: "A05:2021", cwe: "CWE-200" },
5815
- VC114: { owasp: "A05:2021", cwe: "CWE-16" },
5815
+ VC114: { owasp: "A05:2021", cwe: "CWE-668" },
5816
5816
  VC115: { owasp: "A02:2021", cwe: "CWE-311" },
5817
5817
  VC116: { owasp: "A05:2021", cwe: "CWE-770" },
5818
- VC117: { owasp: "A03:2021", cwe: "CWE-22" },
5818
+ VC117: { owasp: "A01:2021", cwe: "CWE-22" },
5819
5819
  VC118: { owasp: "A09:2021", cwe: "CWE-532" },
5820
5820
  VC119: { owasp: "A07:2021", cwe: "CWE-798" },
5821
5821
  VC120: { owasp: "A07:2021", cwe: "CWE-352" },
@@ -5858,7 +5858,7 @@ var complianceMap = {
5858
5858
  VC154: { owasp: "A03:2021", cwe: "CWE-20" },
5859
5859
  VC155: { owasp: "A04:2021", cwe: "CWE-770" },
5860
5860
  VC156: { owasp: "A04:2021", cwe: "CWE-770" },
5861
- VC157: { owasp: "A05:2021", cwe: "CWE-16" },
5861
+ VC157: { owasp: "A05:2021", cwe: "CWE-1327" },
5862
5862
  VC158: { owasp: "A01:2021", cwe: "CWE-639" },
5863
5863
  // VC159–VC183: Additional service-specific API key detection.
5864
5864
  // All map to A07:2021 (Identification & Auth Failures) / CWE-798 (Hardcoded
@@ -6537,7 +6537,7 @@ var piiInLogs = {
6537
6537
  title: "Personally Identifiable Information in Logs",
6538
6538
  severity: "high",
6539
6539
  category: "Information Leakage",
6540
- description: "Logging statements that include email addresses, passwords, SSNs, credit card numbers, or other PII can leak sensitive data to log aggregation systems.",
6540
+ description: "Logging statements that include passwords, secrets, tokens, authorization headers, SSNs, credit card numbers or CVVs can leak sensitive data to log aggregation systems.",
6541
6541
  check(content, filePath) {
6542
6542
  if (isTestFile(filePath)) return [];
6543
6543
  if (!filePath.match(/\.(js|ts|jsx|tsx|py|rb|go|java|php)$/)) return [];
@@ -6980,7 +6980,7 @@ var vulnerableDependencies = {
6980
6980
  title: "Potentially Vulnerable Dependency",
6981
6981
  severity: "high",
6982
6982
  category: "Supply Chain",
6983
- description: "Dependencies with known security issues that are commonly found in AI-generated codebases.",
6983
+ description: "Dependency versions with known security issues.",
6984
6984
  check(content, filePath) {
6985
6985
  if (!filePath.endsWith("package.json")) return [];
6986
6986
  if (/node_modules|\.next|dist|build/.test(filePath)) return [];
@@ -6989,7 +6989,7 @@ var vulnerableDependencies = {
6989
6989
  [/"jsonwebtoken"\s*:\s*"[\^~]?[0-7]\./g, "jsonwebtoken < 8.x has signature bypass vulnerabilities"],
6990
6990
  [/"lodash"\s*:\s*"[\^~]?[0-3]\./g, "lodash < 4.x has prototype pollution vulnerabilities"],
6991
6991
  [/"minimist"\s*:\s*"[\^~]?[01]\.[01]\./g, "minimist < 1.2.6 has prototype pollution"],
6992
- [/"node-fetch"\s*:\s*"[\^~]?[12]\./g, "node-fetch < 3.x has data exposure issues"],
6992
+ [/"node-fetch"\s*:\s*"[\^~]?[12]\./g, "node-fetch before 2.6.7 (and 3.x before 3.1.1) forwards cookie and authorization headers on cross-origin redirects (CVE-2022-0235); check that this 1.x/2.x range resolves to 2.6.7 or later"],
6993
6993
  [/"express"\s*:\s*"[\^~]?[0-3]\./g, "express < 4.x has multiple known vulnerabilities"],
6994
6994
  [/"axios"\s*:\s*"[\^~]?0\.[0-9]\./g, "axios < 0.21 has SSRF vulnerabilities"],
6995
6995
  [/"tar"\s*:\s*"[\^~]?[0-5]\./g, "tar < 6.x has path traversal vulnerabilities"],
@@ -7926,7 +7926,7 @@ var ghaThirdPartyActionWithSecrets = {
7926
7926
  title: "GitHub Actions: secrets passed to third-party action",
7927
7927
  severity: "medium",
7928
7928
  category: "Supply Chain",
7929
- description: "Passing repository secrets (`${{ secrets.* }}`) via the `with:` block to a third-party action means the action's source code \u2014 and any transitive dependencies it pulls \u2014 has access to those secrets. The 2025 tj-actions/changed-files supply-chain attack stole secrets exactly this way. Common when intentional (AWS, Cloudflare, GCP credential actions) but worth flagging for review.",
7929
+ description: "Passing repository secrets (`${{ secrets.* }}`) via the `with:` block to a third-party action means the action's source code \u2014 and any transitive dependencies it pulls \u2014 has access to those secrets. A compromised action can read every secret its job has access to: in the March 2025 tj-actions/changed-files compromise, the hijacked action dumped secrets from runner memory into build logs. Common when intentional (AWS, Cloudflare, GCP credential actions) but worth flagging for review.",
7930
7930
  check(content, filePath) {
7931
7931
  if (!GHA_WORKFLOW_RE.test(filePath)) return [];
7932
7932
  const findings = [];
@@ -8988,7 +8988,7 @@ var secretInURLParam = {
8988
8988
  title: "Secret Passed in URL Query Parameter",
8989
8989
  severity: "critical",
8990
8990
  category: "Secrets",
8991
- description: "API keys or tokens in URL query parameters are logged in server access logs, browser history, referrer headers, and proxy logs. Secrets in URLs are one of the most common causes of credential exposure.",
8991
+ description: "API keys or tokens in URL query parameters are logged in server access logs, browser history, referrer headers, and proxy logs.",
8992
8992
  check(content, filePath) {
8993
8993
  if (isTestFile(filePath)) return [];
8994
8994
  if (!filePath.match(/\.(js|ts|jsx|tsx|py|rb|go|java|php)$/)) return [];
@@ -10341,7 +10341,7 @@ function assessHeaders(headers) {
10341
10341
  out.push({
10342
10342
  header: "Strict-Transport-Security",
10343
10343
  severity: "medium",
10344
- message: "No HSTS. A first visit over http can be intercepted before the redirect to https."
10344
+ message: "No HSTS. Any visit that starts over http can be intercepted before the redirect to https."
10345
10345
  });
10346
10346
  }
10347
10347
  if (!h["x-content-type-options"]) {
@@ -10355,7 +10355,7 @@ function assessHeaders(headers) {
10355
10355
  out.push({
10356
10356
  header: "Referrer-Policy",
10357
10357
  severity: "low",
10358
- message: "No referrer policy. Full URLs \u2014 including any ids in the path \u2014 leak to third parties."
10358
+ message: "No referrer policy, so the browser default applies. Current browsers send only your origin to other sites, but older ones send full URLs \u2014 including any ids in the path."
10359
10359
  });
10360
10360
  }
10361
10361
  return out;