xploitscan-shared-rules 1.28.0 → 1.29.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.
- package/dist/index.cjs +225 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +224 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
MODEL_TRIAGE: () => MODEL_TRIAGE,
|
|
41
41
|
NON_APP_PATH_PATTERNS: () => NON_APP_PATH_PATTERNS,
|
|
42
42
|
PRO_RULE_COUNT: () => PRO_RULE_COUNT,
|
|
43
|
+
QUALITY_EXAMPLES: () => QUALITY_EXAMPLES,
|
|
43
44
|
RULE_IMPACTS: () => RULE_IMPACTS,
|
|
44
45
|
TEST_FILE_PATTERN: () => TEST_FILE_PATTERN,
|
|
45
46
|
TOTAL_RULE_COUNT: () => TOTAL_RULE_COUNT,
|
|
@@ -11319,7 +11320,7 @@ function collectWrites(src) {
|
|
|
11319
11320
|
}
|
|
11320
11321
|
var ENQUEUES = /\b(?:queue\s*\.\s*add|inngest\s*\.\s*send|qstash|boss\s*\.\s*send|after\s*\(|waitUntil\s*\(|\.\s*enqueue\s*\(|\.\s*publish\s*\(|\.\s*sendMessage\s*\(|outbox|dead[_-]?letter|deadLetter|retryQueue|scheduleRetry|schedule\s*\()/i;
|
|
11321
11322
|
var NON_2XX = /\bstatus\s*:\s*[45]\d\d|\.\s*status\s*\(\s*[45]\d\d|\bsendStatus\s*\(\s*[45]\d\d|\bHTTPException\s*\(\s*[45]\d\d|new\s+Response\s*\([^)]{0,200}?\b[45]\d\d/;
|
|
11322
|
-
var STALENESS = /\b(?:lt|lte|gt|gte|older|stale|timeout|timedout|retry|retries|attempt|attempts|updated_?at|created_?at|processed_?at|last_?\w+|since|interval|
|
|
11323
|
+
var STALENESS = /\b(?:lt|lte|gt|gte|older|stale|timeout|timedout|retry|retries|attempt|attempts|updated_?at|created_?at|processed_?at|last_?\w+|since|interval|current_?timestamp)\b|\bDate\.now\b|\bnow\s*\(|\bdate(?:time)?\s*\(|\bdate_?sub\s*\(|['"`]\s*now\s*['"`]/i;
|
|
11323
11324
|
var READ_VERB = /\b(?:select|from|find\w*|query|scan|rows|fetchAll|getAll|list)\b/i;
|
|
11324
11325
|
function repoReselects(files, originPath, originIndex, table, value) {
|
|
11325
11326
|
const tableToken = table.replace(/["'`]/g, "");
|
|
@@ -12601,6 +12602,228 @@ var unassociatedLabel = {
|
|
|
12601
12602
|
}
|
|
12602
12603
|
};
|
|
12603
12604
|
|
|
12605
|
+
// src/quality/examples.ts
|
|
12606
|
+
var QUALITY_EXAMPLES = {
|
|
12607
|
+
QA001: {
|
|
12608
|
+
path: "supabase/functions/list-items/index.ts",
|
|
12609
|
+
language: "typescript",
|
|
12610
|
+
difference: "The catch answers with 500 and an error instead of 200 and an empty list, so the caller can tell a broken query from an account with no items.",
|
|
12611
|
+
vulnerable: `Deno.serve(async (req) => {
|
|
12612
|
+
try {
|
|
12613
|
+
const { data } = await supabase.from("items").select("*");
|
|
12614
|
+
return new Response(JSON.stringify({ items: data }), { status: 200 });
|
|
12615
|
+
} catch (err) {
|
|
12616
|
+
console.error(err);
|
|
12617
|
+
return new Response(JSON.stringify({ items: [] }), { status: 200 });
|
|
12618
|
+
}
|
|
12619
|
+
});`,
|
|
12620
|
+
safe: `Deno.serve(async (req) => {
|
|
12621
|
+
try {
|
|
12622
|
+
const { data } = await supabase.from("items").select("*");
|
|
12623
|
+
return new Response(JSON.stringify({ items: data }), { status: 200 });
|
|
12624
|
+
} catch (err) {
|
|
12625
|
+
console.error(err);
|
|
12626
|
+
return new Response(JSON.stringify({ error: "Could not load items" }), { status: 500 });
|
|
12627
|
+
}
|
|
12628
|
+
});`
|
|
12629
|
+
},
|
|
12630
|
+
QA002: {
|
|
12631
|
+
path: "app/settings/ApiKeyRow.tsx",
|
|
12632
|
+
language: "tsx",
|
|
12633
|
+
difference: "The failure branch tells the user instead of returning silently, so a revoke that did not happen cannot show as one that did.",
|
|
12634
|
+
vulnerable: `"use client";
|
|
12635
|
+
import { toast } from "sonner";
|
|
12636
|
+
|
|
12637
|
+
export function ApiKeyRow({ keyId }) {
|
|
12638
|
+
async function handleRevoke() {
|
|
12639
|
+
const res = await fetch(\`/api/keys/\${keyId}/revoke\`, { method: "POST" });
|
|
12640
|
+
if (!res.ok) return;
|
|
12641
|
+
toast.success("API key revoked");
|
|
12642
|
+
}
|
|
12643
|
+
|
|
12644
|
+
return <button onClick={handleRevoke}>Revoke</button>;
|
|
12645
|
+
}`,
|
|
12646
|
+
safe: `"use client";
|
|
12647
|
+
import { toast } from "sonner";
|
|
12648
|
+
|
|
12649
|
+
export function ApiKeyRow({ keyId }) {
|
|
12650
|
+
async function handleRevoke() {
|
|
12651
|
+
const res = await fetch(\`/api/keys/\${keyId}/revoke\`, { method: "POST" });
|
|
12652
|
+
if (!res.ok) {
|
|
12653
|
+
toast.error("Could not revoke the key. Try again.");
|
|
12654
|
+
return;
|
|
12655
|
+
}
|
|
12656
|
+
toast.success("API key revoked");
|
|
12657
|
+
}
|
|
12658
|
+
|
|
12659
|
+
return <button onClick={handleRevoke}>Revoke</button>;
|
|
12660
|
+
}`
|
|
12661
|
+
},
|
|
12662
|
+
QA003: {
|
|
12663
|
+
path: "app/api/billing/webhook/route.ts",
|
|
12664
|
+
language: "typescript",
|
|
12665
|
+
difference: "The catch rethrows, so the row is not left saying a credit was issued that never left Stripe \u2014 and the webhook is redelivered.",
|
|
12666
|
+
vulnerable: `export async function POST(req) {
|
|
12667
|
+
const referral = await db.get("SELECT id FROM referrals WHERE status = 'pending' LIMIT 1");
|
|
12668
|
+
await db.run("UPDATE referrals SET status = 'rewarded' WHERE id = ?", referral.id);
|
|
12669
|
+
try {
|
|
12670
|
+
await stripe.customers.createBalanceTransaction(customerId, { amount: -1000, currency: "usd" });
|
|
12671
|
+
} catch (err) {
|
|
12672
|
+
logError("credit failed", err);
|
|
12673
|
+
}
|
|
12674
|
+
return new Response(JSON.stringify({ ok: true }), { status: 200 });
|
|
12675
|
+
}`,
|
|
12676
|
+
safe: `export async function POST(req) {
|
|
12677
|
+
const referral = await db.get("SELECT id FROM referrals WHERE status = 'pending' LIMIT 1");
|
|
12678
|
+
await db.run("UPDATE referrals SET status = 'rewarded' WHERE id = ?", referral.id);
|
|
12679
|
+
try {
|
|
12680
|
+
await stripe.customers.createBalanceTransaction(customerId, { amount: -1000, currency: "usd" });
|
|
12681
|
+
} catch (err) {
|
|
12682
|
+
logError("credit failed", err);
|
|
12683
|
+
throw err;
|
|
12684
|
+
}
|
|
12685
|
+
return new Response(JSON.stringify({ ok: true }), { status: 200 });
|
|
12686
|
+
}`
|
|
12687
|
+
},
|
|
12688
|
+
QA004: {
|
|
12689
|
+
path: "app/api/cron/cleanup/route.ts",
|
|
12690
|
+
language: "typescript",
|
|
12691
|
+
difference: 'The secret is read once and the handler refuses to run without it, so an unset variable can no longer make the comparison succeed against "Bearer undefined".',
|
|
12692
|
+
vulnerable: `export async function GET(req) {
|
|
12693
|
+
const auth = req.headers.get("authorization");
|
|
12694
|
+
if (auth !== \`Bearer \${process.env.CRON_SECRET}\`) {
|
|
12695
|
+
return new Response("Unauthorized", { status: 401 });
|
|
12696
|
+
}
|
|
12697
|
+
await purgeExpiredRows();
|
|
12698
|
+
return new Response("ok");
|
|
12699
|
+
}`,
|
|
12700
|
+
safe: `export async function GET(req) {
|
|
12701
|
+
const secret = process.env.CRON_SECRET;
|
|
12702
|
+
if (!secret) throw new Error("CRON_SECRET is not set");
|
|
12703
|
+
const auth = req.headers.get("authorization");
|
|
12704
|
+
if (auth !== \`Bearer \${secret}\`) {
|
|
12705
|
+
return new Response("Unauthorized", { status: 401 });
|
|
12706
|
+
}
|
|
12707
|
+
await purgeExpiredRows();
|
|
12708
|
+
return new Response("ok");
|
|
12709
|
+
}`
|
|
12710
|
+
},
|
|
12711
|
+
QA005: {
|
|
12712
|
+
path: "app/components/SortableTable.tsx",
|
|
12713
|
+
language: "tsx",
|
|
12714
|
+
difference: "The handler moves onto a real button, which the browser makes focusable, Enter- and Space-activatable, and announces as a control.",
|
|
12715
|
+
vulnerable: `export function SortableTable({ rows, onSort }) {
|
|
12716
|
+
return (
|
|
12717
|
+
<table>
|
|
12718
|
+
<thead>
|
|
12719
|
+
<tr>
|
|
12720
|
+
<th className="cursor-pointer select-none" onClick={() => onSort("name")}>
|
|
12721
|
+
Name
|
|
12722
|
+
</th>
|
|
12723
|
+
</tr>
|
|
12724
|
+
</thead>
|
|
12725
|
+
</table>
|
|
12726
|
+
);
|
|
12727
|
+
}`,
|
|
12728
|
+
safe: `export function SortableTable({ rows, onSort }) {
|
|
12729
|
+
return (
|
|
12730
|
+
<table>
|
|
12731
|
+
<thead>
|
|
12732
|
+
<tr>
|
|
12733
|
+
<th>
|
|
12734
|
+
<button type="button" className="cursor-pointer select-none" onClick={() => onSort("name")}>
|
|
12735
|
+
Name
|
|
12736
|
+
</button>
|
|
12737
|
+
</th>
|
|
12738
|
+
</tr>
|
|
12739
|
+
</thead>
|
|
12740
|
+
</table>
|
|
12741
|
+
);
|
|
12742
|
+
}`
|
|
12743
|
+
},
|
|
12744
|
+
QA006: {
|
|
12745
|
+
path: "app/components/ConfirmDialog.tsx",
|
|
12746
|
+
language: "tsx",
|
|
12747
|
+
difference: "The panel declares itself a modal dialog, takes focus when it opens and closes on Escape, so a screen reader announces it and a keyboard can reach and leave it.",
|
|
12748
|
+
vulnerable: `export function ConfirmDialog({ open, onClose, onConfirm }) {
|
|
12749
|
+
if (!open) return null;
|
|
12750
|
+
return (
|
|
12751
|
+
<div className="fixed inset-0 bg-black/50 flex items-center justify-center">
|
|
12752
|
+
<div className="bg-white rounded-xl p-6">
|
|
12753
|
+
<h2>Delete this project?</h2>
|
|
12754
|
+
<button onClick={onClose}>Cancel</button>
|
|
12755
|
+
<button onClick={onConfirm}>Delete</button>
|
|
12756
|
+
</div>
|
|
12757
|
+
</div>
|
|
12758
|
+
);
|
|
12759
|
+
}`,
|
|
12760
|
+
safe: `export function ConfirmDialog({ open, onClose, onConfirm }) {
|
|
12761
|
+
const ref = useRef(null);
|
|
12762
|
+
useEffect(() => {
|
|
12763
|
+
if (!open) return;
|
|
12764
|
+
ref.current?.focus();
|
|
12765
|
+
const onKey = (e) => { if (e.key === "Escape") onClose(); };
|
|
12766
|
+
document.addEventListener("keydown", onKey);
|
|
12767
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
12768
|
+
}, [open, onClose]);
|
|
12769
|
+
|
|
12770
|
+
if (!open) return null;
|
|
12771
|
+
return (
|
|
12772
|
+
<div className="fixed inset-0 bg-black/50 flex items-center justify-center">
|
|
12773
|
+
<div
|
|
12774
|
+
role="dialog"
|
|
12775
|
+
aria-modal="true"
|
|
12776
|
+
aria-labelledby="confirm-title"
|
|
12777
|
+
ref={ref}
|
|
12778
|
+
tabIndex={-1}
|
|
12779
|
+
className="bg-white rounded-xl p-6"
|
|
12780
|
+
>
|
|
12781
|
+
<h2 id="confirm-title">Delete this project?</h2>
|
|
12782
|
+
<button onClick={onClose}>Cancel</button>
|
|
12783
|
+
<button onClick={onConfirm}>Delete</button>
|
|
12784
|
+
</div>
|
|
12785
|
+
</div>
|
|
12786
|
+
);
|
|
12787
|
+
}`
|
|
12788
|
+
},
|
|
12789
|
+
QA007: {
|
|
12790
|
+
path: "app/api/orders/route.ts",
|
|
12791
|
+
language: "typescript",
|
|
12792
|
+
difference: "The query takes a bounded page, so one account with years of history cannot decide how much memory the request uses.",
|
|
12793
|
+
vulnerable: `export async function GET(req) {
|
|
12794
|
+
const userId = await requireUser(req);
|
|
12795
|
+
const orders = await prisma.order.findMany({ where: { userId } });
|
|
12796
|
+
return Response.json({ orders });
|
|
12797
|
+
}`,
|
|
12798
|
+
safe: `export async function GET(req) {
|
|
12799
|
+
const userId = await requireUser(req);
|
|
12800
|
+
const orders = await prisma.order.findMany({ where: { userId }, take: 50 });
|
|
12801
|
+
return Response.json({ orders });
|
|
12802
|
+
}`
|
|
12803
|
+
},
|
|
12804
|
+
QA008: {
|
|
12805
|
+
path: "app/components/SignupForm.tsx",
|
|
12806
|
+
language: "tsx",
|
|
12807
|
+
difference: "The label points at the input, so a screen reader reads the field's name and clicking the text focuses the field.",
|
|
12808
|
+
vulnerable: `export function SignupForm() {
|
|
12809
|
+
return (
|
|
12810
|
+
<form>
|
|
12811
|
+
<label>Email address</label>
|
|
12812
|
+
<input type="email" name="email" />
|
|
12813
|
+
</form>
|
|
12814
|
+
);
|
|
12815
|
+
}`,
|
|
12816
|
+
safe: `export function SignupForm() {
|
|
12817
|
+
return (
|
|
12818
|
+
<form>
|
|
12819
|
+
<label htmlFor="email">Email address</label>
|
|
12820
|
+
<input id="email" type="email" name="email" />
|
|
12821
|
+
</form>
|
|
12822
|
+
);
|
|
12823
|
+
}`
|
|
12824
|
+
}
|
|
12825
|
+
};
|
|
12826
|
+
|
|
12604
12827
|
// src/quality/index.ts
|
|
12605
12828
|
var qualityRules = [
|
|
12606
12829
|
silentFailedRead,
|
|
@@ -12657,6 +12880,7 @@ function scanQuality(files, rules = qualityRules) {
|
|
|
12657
12880
|
MODEL_TRIAGE,
|
|
12658
12881
|
NON_APP_PATH_PATTERNS,
|
|
12659
12882
|
PRO_RULE_COUNT,
|
|
12883
|
+
QUALITY_EXAMPLES,
|
|
12660
12884
|
RULE_IMPACTS,
|
|
12661
12885
|
TEST_FILE_PATTERN,
|
|
12662
12886
|
TOTAL_RULE_COUNT,
|