xploitscan-shared-rules 1.27.0 → 1.27.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/dist/index.cjs CHANGED
@@ -644,11 +644,17 @@ var NON_APP_PATH_PATTERNS = [
644
644
  // which makes even a repo-root `.claude/` a nested segment.
645
645
  ".claude/**",
646
646
  ".agent/**",
647
+ // Plural too. `.agent/**` alone let `.agents/skills/**` through as app code,
648
+ // and agent scaffolds ship .tsx templates — so every rule fired on somebody
649
+ // else's boilerplate. Found 2026-09-15 while specifying the unwired-control
650
+ // check, which produced 4 accusations against one such template.
651
+ ".agents/**",
647
652
  ".cursor/**",
648
653
  ".superpowers/**",
649
654
  ".windsurf/**",
650
655
  "**/.claude/**",
651
656
  "**/.agent/**",
657
+ "**/.agents/**",
652
658
  "**/.cursor/**",
653
659
  "**/.superpowers/**",
654
660
  "**/.windsurf/**",
@@ -2104,6 +2110,7 @@ var missingAuthMiddleware = {
2104
2110
  description: "API routes without authentication checks allow unauthorized access.",
2105
2111
  check(content, filePath, project) {
2106
2112
  if (!isServerSideFile(filePath, content)) return [];
2113
+ if (PUBLIC_BY_CONVENTION_ROUTE.test(routeSegmentName(filePath))) return [];
2107
2114
  const routePatterns = [
2108
2115
  // Express/Hono style
2109
2116
  /\.(get|post|put|patch|delete)\s*\(\s*["'`][^"'`]+["'`]\s*,\s*(?:async\s+)?\(?(?:req|c|ctx)/gi,
@@ -2169,7 +2176,22 @@ var missingAuthMiddleware = {
2169
2176
  /\bjwt\.verify\b/i,
2170
2177
  /\bbearer\s/i,
2171
2178
  /\b(?:protect|guard)\(/i,
2172
- /\.use\([^)]*(?:auth|session|protect|requireAuth)/i
2179
+ /\.use\([^)]*(?:auth|session|protect|requireAuth)/i,
2180
+ // A handler that can answer HTTP 401 is, by definition, deciding whether
2181
+ // the caller is allowed in. This catches the whole family of
2182
+ // capability-token flows the named patterns above miss — magic links,
2183
+ // share links, unsubscribe links, invite/claim URLs — where there is no
2184
+ // session and no account, and the unguessable token in the request IS
2185
+ // the credential, checked by a bespoke lookup like
2186
+ // `findShareByToken(slug, token)`.
2187
+ //
2188
+ // 401 only, deliberately not 403. 401 means "I could not authenticate
2189
+ // you"; 403 is routinely returned by things that never identified the
2190
+ // caller at all — an Origin allowlist on an anonymous analytics beacon,
2191
+ // a feature flag, a geo block. Accepting 403 would suppress genuinely
2192
+ // unauthenticated routes.
2193
+ /\bstatus(?:Code)?\s*[:(]\s*401\b/,
2194
+ /\bsendStatus\s*\(\s*401\b/
2173
2195
  ];
2174
2196
  const APP_LEVEL_AUTH = [
2175
2197
  /\.use\([^)]*(?:auth|session|protect|requireAuth)/i,
@@ -2229,6 +2251,15 @@ var missingAuthMiddleware = {
2229
2251
  return filterSilenced(unauthenticated, content, "VC003");
2230
2252
  }
2231
2253
  };
2254
+ var PUBLIC_BY_CONVENTION_ROUTE = /^(?:og|opengraph-image|twitter-image|icon|apple-icon|favicon|sitemap|robots|manifest|badge)(?:[.-]\w+)?$/i;
2255
+ function routeSegmentName(filePath) {
2256
+ const segments = filePath.split("/");
2257
+ const base = segments[segments.length - 1] ?? "";
2258
+ if (/^route\.(?:ts|tsx|js|jsx|mjs|cjs)$/i.test(base)) {
2259
+ return segments[segments.length - 2] ?? "";
2260
+ }
2261
+ return base.replace(/\.[^.]+$/, "");
2262
+ }
2232
2263
  var supabaseNoRLS = {
2233
2264
  id: "VC004",
2234
2265
  title: "Supabase Client Without Row Level Security",
@@ -2762,10 +2793,10 @@ var insecureCookies = {
2762
2793
  check(content, filePath) {
2763
2794
  if (isTestFile(filePath)) return [];
2764
2795
  if (!/cookie/i.test(content)) return [];
2765
- const setCookiePattern = /(?:set-cookie|setCookie|cookie\s*=|res\.cookie\s*\()/gi;
2796
+ const setCookiePattern = /(?:set-cookie|setCookie|\bcookie\s*=|res\.cookie\s*\()/gi;
2766
2797
  if (!setCookiePattern.test(content)) return [];
2767
2798
  const hasHttpOnly = /httpOnly\s*:\s*true|httponly/i.test(content);
2768
- const hasSecure = /secure\s*:\s*true|;\s*secure/i.test(content);
2799
+ const hasSecure = /secure\s*:\s*(?!false\b)\S/i.test(content) || /;\s*secure/i.test(content);
2769
2800
  const hasSameSite = /sameSite\s*:|samesite/i.test(content);
2770
2801
  const matches = [];
2771
2802
  if (!hasHttpOnly || !hasSecure || !hasSameSite) {