xploitscan-shared-rules 1.27.0 → 1.27.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/dist/index.cjs +28 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1803,6 +1803,7 @@ var missingAuthMiddleware = {
|
|
|
1803
1803
|
description: "API routes without authentication checks allow unauthorized access.",
|
|
1804
1804
|
check(content, filePath, project) {
|
|
1805
1805
|
if (!isServerSideFile(filePath, content)) return [];
|
|
1806
|
+
if (PUBLIC_BY_CONVENTION_ROUTE.test(routeSegmentName(filePath))) return [];
|
|
1806
1807
|
const routePatterns = [
|
|
1807
1808
|
// Express/Hono style
|
|
1808
1809
|
/\.(get|post|put|patch|delete)\s*\(\s*["'`][^"'`]+["'`]\s*,\s*(?:async\s+)?\(?(?:req|c|ctx)/gi,
|
|
@@ -1868,7 +1869,22 @@ var missingAuthMiddleware = {
|
|
|
1868
1869
|
/\bjwt\.verify\b/i,
|
|
1869
1870
|
/\bbearer\s/i,
|
|
1870
1871
|
/\b(?:protect|guard)\(/i,
|
|
1871
|
-
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i
|
|
1872
|
+
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i,
|
|
1873
|
+
// A handler that can answer HTTP 401 is, by definition, deciding whether
|
|
1874
|
+
// the caller is allowed in. This catches the whole family of
|
|
1875
|
+
// capability-token flows the named patterns above miss — magic links,
|
|
1876
|
+
// share links, unsubscribe links, invite/claim URLs — where there is no
|
|
1877
|
+
// session and no account, and the unguessable token in the request IS
|
|
1878
|
+
// the credential, checked by a bespoke lookup like
|
|
1879
|
+
// `findShareByToken(slug, token)`.
|
|
1880
|
+
//
|
|
1881
|
+
// 401 only, deliberately not 403. 401 means "I could not authenticate
|
|
1882
|
+
// you"; 403 is routinely returned by things that never identified the
|
|
1883
|
+
// caller at all — an Origin allowlist on an anonymous analytics beacon,
|
|
1884
|
+
// a feature flag, a geo block. Accepting 403 would suppress genuinely
|
|
1885
|
+
// unauthenticated routes.
|
|
1886
|
+
/\bstatus(?:Code)?\s*[:(]\s*401\b/,
|
|
1887
|
+
/\bsendStatus\s*\(\s*401\b/
|
|
1872
1888
|
];
|
|
1873
1889
|
const APP_LEVEL_AUTH = [
|
|
1874
1890
|
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i,
|
|
@@ -1928,6 +1944,15 @@ var missingAuthMiddleware = {
|
|
|
1928
1944
|
return filterSilenced(unauthenticated, content, "VC003");
|
|
1929
1945
|
}
|
|
1930
1946
|
};
|
|
1947
|
+
var PUBLIC_BY_CONVENTION_ROUTE = /^(?:og|opengraph-image|twitter-image|icon|apple-icon|favicon|sitemap|robots|manifest|badge)(?:[.-]\w+)?$/i;
|
|
1948
|
+
function routeSegmentName(filePath) {
|
|
1949
|
+
const segments = filePath.split("/");
|
|
1950
|
+
const base = segments[segments.length - 1] ?? "";
|
|
1951
|
+
if (/^route\.(?:ts|tsx|js|jsx|mjs|cjs)$/i.test(base)) {
|
|
1952
|
+
return segments[segments.length - 2] ?? "";
|
|
1953
|
+
}
|
|
1954
|
+
return base.replace(/\.[^.]+$/, "");
|
|
1955
|
+
}
|
|
1931
1956
|
var supabaseNoRLS = {
|
|
1932
1957
|
id: "VC004",
|
|
1933
1958
|
title: "Supabase Client Without Row Level Security",
|
|
@@ -2461,10 +2486,10 @@ var insecureCookies = {
|
|
|
2461
2486
|
check(content, filePath) {
|
|
2462
2487
|
if (isTestFile(filePath)) return [];
|
|
2463
2488
|
if (!/cookie/i.test(content)) return [];
|
|
2464
|
-
const setCookiePattern = /(?:set-cookie|setCookie
|
|
2489
|
+
const setCookiePattern = /(?:set-cookie|setCookie|\bcookie\s*=|res\.cookie\s*\()/gi;
|
|
2465
2490
|
if (!setCookiePattern.test(content)) return [];
|
|
2466
2491
|
const hasHttpOnly = /httpOnly\s*:\s*true|httponly/i.test(content);
|
|
2467
|
-
const hasSecure = /secure\s*:\s*
|
|
2492
|
+
const hasSecure = /secure\s*:\s*(?!false\b)\S/i.test(content) || /;\s*secure/i.test(content);
|
|
2468
2493
|
const hasSameSite = /sameSite\s*:|samesite/i.test(content);
|
|
2469
2494
|
const matches = [];
|
|
2470
2495
|
if (!hasHttpOnly || !hasSecure || !hasSameSite) {
|