@akasecurity/ai-tc-codex 0.9.22 → 0.9.24
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/.codex-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/apply-suppressions.js +148 -31
- package/scripts/backfill.js +186 -40
- package/scripts/content-retention.js +97 -19
- package/scripts/filescan.js +242 -85
- package/scripts/firstrun.js +174 -47
- package/scripts/history-sync.js +160 -34
- package/scripts/intro.js +32 -6
- package/scripts/onboard.js +122 -24
- package/scripts/post-tool-use.js +200 -54
- package/scripts/pre-tool-use.js +200 -54
- package/scripts/query.js +173 -46
- package/scripts/reconcile.js +196 -51
- package/scripts/remediate.js +190 -40
- package/scripts/scan-worker.js +74 -14
- package/scripts/session-start.js +280 -120
- package/scripts/start-light.js +32 -6
- package/scripts/stop.js +178 -51
- package/scripts/sync.js +244 -87
- package/scripts/user-prompt-submit.js +206 -60
package/scripts/onboard.js
CHANGED
|
@@ -8771,7 +8771,11 @@ var ListFindingTypesQuery = object({
|
|
|
8771
8771
|
// and so is not bounded by what any page happens to hold.
|
|
8772
8772
|
includeId: string2().optional(),
|
|
8773
8773
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8774
|
-
cursor: string2().optional()
|
|
8774
|
+
cursor: string2().optional(),
|
|
8775
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8776
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8777
|
+
// from wherever it lands.
|
|
8778
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8775
8779
|
});
|
|
8776
8780
|
var ListFindingTypesResponse = object({
|
|
8777
8781
|
totals: object({
|
|
@@ -8852,7 +8856,11 @@ var ListFindingInstancesQuery = object({
|
|
|
8852
8856
|
sessionId: string2().optional(),
|
|
8853
8857
|
from: iso_exports.datetime().optional(),
|
|
8854
8858
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
8855
|
-
cursor: string2().optional()
|
|
8859
|
+
cursor: string2().optional(),
|
|
8860
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8861
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8862
|
+
// from wherever it lands.
|
|
8863
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8856
8864
|
});
|
|
8857
8865
|
var ListFindingInstancesResponse = object({
|
|
8858
8866
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -8924,7 +8932,11 @@ var ListFindingLocationsQuery = object({
|
|
|
8924
8932
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
8925
8933
|
includeId: string2().optional(),
|
|
8926
8934
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
8927
|
-
cursor: string2().optional()
|
|
8935
|
+
cursor: string2().optional(),
|
|
8936
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8937
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8938
|
+
// from wherever it lands.
|
|
8939
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8928
8940
|
});
|
|
8929
8941
|
var ListFindingLocationsResponse = object({
|
|
8930
8942
|
totals: object({
|
|
@@ -11499,7 +11511,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
11499
11511
|
var ListVaultInventoryQuery = object({
|
|
11500
11512
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11501
11513
|
// Opaque; names the last row of the page just served.
|
|
11502
|
-
cursor: string2().optional()
|
|
11514
|
+
cursor: string2().optional(),
|
|
11515
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11516
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11517
|
+
// from wherever it lands.
|
|
11518
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11503
11519
|
});
|
|
11504
11520
|
var ListVaultInventoryResponse = object({
|
|
11505
11521
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -11511,7 +11527,11 @@ var ListVaultInventoryResponse = object({
|
|
|
11511
11527
|
});
|
|
11512
11528
|
var ListVaultReuseQuery = object({
|
|
11513
11529
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11514
|
-
cursor: string2().optional()
|
|
11530
|
+
cursor: string2().optional(),
|
|
11531
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11532
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11533
|
+
// from wherever it lands.
|
|
11534
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11515
11535
|
});
|
|
11516
11536
|
var ListVaultReuseResponse = object({
|
|
11517
11537
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -11527,9 +11547,15 @@ var ListVaultDerefsQuery = object({
|
|
|
11527
11547
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
11528
11548
|
includeBatched: boolean2().optional(),
|
|
11529
11549
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11530
|
-
cursor: string2().optional()
|
|
11550
|
+
cursor: string2().optional(),
|
|
11551
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11552
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11553
|
+
// from wherever it lands.
|
|
11554
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11531
11555
|
});
|
|
11532
11556
|
var ListVaultDerefsResponse = object({
|
|
11557
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
11558
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
11533
11559
|
items: array(VaultDeref),
|
|
11534
11560
|
nextCursor: string2().nullable(),
|
|
11535
11561
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -19399,7 +19425,7 @@ var SqliteFindingsRepository = class {
|
|
|
19399
19425
|
};
|
|
19400
19426
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
19401
19427
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
19402
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
19428
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
19403
19429
|
const page = sorted.slice(start, start + limit);
|
|
19404
19430
|
const lastOnPage = page.at(-1);
|
|
19405
19431
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -19493,7 +19519,7 @@ var SqliteFindingsRepository = class {
|
|
|
19493
19519
|
accumulator.add(row);
|
|
19494
19520
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
19495
19521
|
total += 1;
|
|
19496
|
-
if (!isPastCursor(row)) continue;
|
|
19522
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
19497
19523
|
if (items.length < limit) {
|
|
19498
19524
|
items.push(toInstanceDetail(row));
|
|
19499
19525
|
last = row;
|
|
@@ -19582,7 +19608,7 @@ var SqliteFindingsRepository = class {
|
|
|
19582
19608
|
}
|
|
19583
19609
|
}
|
|
19584
19610
|
sorted.sort(compareLocationOrder);
|
|
19585
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
19611
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
19586
19612
|
const page = sorted.slice(start, start + limit);
|
|
19587
19613
|
const lastOnPage = page.at(-1);
|
|
19588
19614
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -22210,6 +22236,9 @@ function pageLimit(requested, fallback) {
|
|
|
22210
22236
|
if (requested === void 0) return fallback;
|
|
22211
22237
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
22212
22238
|
}
|
|
22239
|
+
function pageOffset(requested) {
|
|
22240
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
22241
|
+
}
|
|
22213
22242
|
function encodeReuseCursor(payload) {
|
|
22214
22243
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
22215
22244
|
}
|
|
@@ -22557,7 +22586,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
22557
22586
|
*/
|
|
22558
22587
|
listInventory(query = {}, now = Date.now()) {
|
|
22559
22588
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
22560
|
-
const
|
|
22589
|
+
const offset = pageOffset(query.offset);
|
|
22590
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
22561
22591
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
22562
22592
|
const rows = allRows(
|
|
22563
22593
|
this.db.prepare(
|
|
@@ -22571,11 +22601,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
22571
22601
|
FROM secret_vault v
|
|
22572
22602
|
${where}
|
|
22573
22603
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
22574
|
-
LIMIT :limit`
|
|
22604
|
+
LIMIT :limit OFFSET :offset`
|
|
22575
22605
|
),
|
|
22576
22606
|
bindParams({
|
|
22577
22607
|
now,
|
|
22578
22608
|
limit: limit + 1,
|
|
22609
|
+
offset,
|
|
22579
22610
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
22580
22611
|
})
|
|
22581
22612
|
);
|
|
@@ -22599,7 +22630,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
22599
22630
|
*/
|
|
22600
22631
|
listReuse(query = {}, now = Date.now()) {
|
|
22601
22632
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
22602
|
-
const
|
|
22633
|
+
const offset = pageOffset(query.offset);
|
|
22634
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
22603
22635
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
22604
22636
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
22605
22637
|
const rows = allRows(
|
|
@@ -22614,11 +22646,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
22614
22646
|
FROM secret_vault v
|
|
22615
22647
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
22616
22648
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
22617
|
-
LIMIT :limit`
|
|
22649
|
+
LIMIT :limit OFFSET :offset`
|
|
22618
22650
|
),
|
|
22619
22651
|
bindParams({
|
|
22620
22652
|
now,
|
|
22621
22653
|
limit: limit + 1,
|
|
22654
|
+
offset,
|
|
22622
22655
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
22623
22656
|
})
|
|
22624
22657
|
);
|
|
@@ -22643,7 +22676,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
22643
22676
|
*/
|
|
22644
22677
|
listDerefs(query = {}) {
|
|
22645
22678
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
22646
|
-
const
|
|
22679
|
+
const offset = pageOffset(query.offset);
|
|
22680
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
22647
22681
|
const conditions = [];
|
|
22648
22682
|
if (query.includeBatched !== true) {
|
|
22649
22683
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -22656,21 +22690,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
22656
22690
|
this.db.prepare(
|
|
22657
22691
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
22658
22692
|
FROM secret_vault_deref ${where}
|
|
22659
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
22693
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
22660
22694
|
),
|
|
22661
22695
|
bindParams({
|
|
22662
22696
|
limit: limit + 1,
|
|
22697
|
+
offset,
|
|
22663
22698
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
22664
22699
|
})
|
|
22665
22700
|
);
|
|
22666
22701
|
const hasMore = rows.length > limit;
|
|
22667
22702
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
22668
22703
|
const last = page[page.length - 1];
|
|
22669
|
-
const
|
|
22670
|
-
this.db
|
|
22671
|
-
|
|
22672
|
-
|
|
22704
|
+
const counts = getRow(
|
|
22705
|
+
this.db.prepare(
|
|
22706
|
+
`SELECT count(*) AS total,
|
|
22707
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
22708
|
+
FROM secret_vault_deref`
|
|
22709
|
+
)
|
|
22710
|
+
) ?? { total: 0, hidden: 0 };
|
|
22711
|
+
const includeBatched = query.includeBatched === true;
|
|
22712
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
22673
22713
|
return {
|
|
22714
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
22674
22715
|
items: page.map((r) => ({
|
|
22675
22716
|
id: r.id,
|
|
22676
22717
|
pointerId: r.pointer_id,
|
|
@@ -22695,6 +22736,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
22695
22736
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
22696
22737
|
);
|
|
22697
22738
|
}
|
|
22739
|
+
/**
|
|
22740
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
22741
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
22742
|
+
* every row.
|
|
22743
|
+
*
|
|
22744
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
22745
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
22746
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
22747
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
22748
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
22749
|
+
*
|
|
22750
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
22751
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
22752
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
22753
|
+
*
|
|
22754
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
22755
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
22756
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
22757
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
22758
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
22759
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
22760
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
22761
|
+
*/
|
|
22762
|
+
countFingerprintEpochs(currentVersion) {
|
|
22763
|
+
const row = getRow(
|
|
22764
|
+
this.db.prepare(
|
|
22765
|
+
`SELECT COUNT(*) AS total,
|
|
22766
|
+
COALESCE(
|
|
22767
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
22768
|
+
0
|
|
22769
|
+
) AS stale
|
|
22770
|
+
FROM secret_vault`
|
|
22771
|
+
),
|
|
22772
|
+
{ currentVersion }
|
|
22773
|
+
) ?? { stale: 0, total: 0 };
|
|
22774
|
+
return { stale: row.stale, total: row.total };
|
|
22775
|
+
}
|
|
22698
22776
|
};
|
|
22699
22777
|
|
|
22700
22778
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -25514,7 +25592,7 @@ var sql_inject_concat_dot_default = {
|
|
|
25514
25592
|
severity: "high",
|
|
25515
25593
|
matcher: {
|
|
25516
25594
|
type: "regex",
|
|
25517
|
-
pattern:
|
|
25595
|
+
pattern: "([\"'])(?=((?:(?!\\1)[^\\n])*?\\b(?:select\\b(?:(?!\\1|\\bselect\\b)[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?!\\1)['\"%]|between\\b)))))\\2(?:(?!\\1(?:(?!\\1)[^\\n])*?\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?[\"']\\s*\\.",
|
|
25518
25596
|
flags: "gi"
|
|
25519
25597
|
},
|
|
25520
25598
|
appliesTo: {
|
|
@@ -25532,7 +25610,7 @@ var sql_inject_concat_default = {
|
|
|
25532
25610
|
severity: "high",
|
|
25533
25611
|
matcher: {
|
|
25534
25612
|
type: "regex",
|
|
25535
|
-
pattern:
|
|
25613
|
+
pattern: "([\"'])\\s*(?=(select\\b(?:(?!\\1\\s*(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?!\\1)['\"%]|between\\b))))\\2(?:(?!\\1\\s*(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+(?:only\\s+)?\\S+(?:(?:\\s+as\\s+[\\w`\\[\\]]+)?\\s+set\\b|(?:\\s*,\\s*[\\w.`\\[\\]$]+)+\\s+set\\s+[\\w.`\\[\\]$]+\\s*=)|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b|where\\b))[^\\n])*?[\"']\\s*\\+",
|
|
25536
25614
|
flags: "gi"
|
|
25537
25615
|
},
|
|
25538
25616
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -25547,7 +25625,7 @@ var sql_inject_format_default = {
|
|
|
25547
25625
|
severity: "high",
|
|
25548
25626
|
matcher: {
|
|
25549
25627
|
type: "regex",
|
|
25550
|
-
pattern:
|
|
25628
|
+
pattern: "([\"'`])\\s*(?=((?:select\\b(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b)|\\1)[^\\n])*?\\bfrom\\b)|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))\\2(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b)|\\1)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|([\"'`])\\s*(?=((?:(?!\\3)[^\\n])*?\\bwhere\\s+[\\w.`\\[\\]${}]+(?:\\s*(?:!=|[=<>])|\\s+(?:in\\s*\\(|like\\s*(?=(?!\\3)['\"%])|between\\b))))\\4(?:(?!\\bwhere\\b|\\3)[^\\n])*?(?:[%][sd]|\\{[^{}\\n]+\\})|(?<=^|\\n)[ \\t]*(?=(select\\b(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))[^\\n])*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))\\5(?:(?!\\b(?:select\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+(?:replace|ignore|rollback|abort|fail))\\s+){0,2}into\\b|update\\s+\\S+\\s+set\\b|delete\\s+from\\b|drop\\s+(?:table|database|index|view)\\b))[^\\n])*?(?:=\\s*['\"]?\\s*(?:%[sd]|\\{[^{}\\n]+\\})|[#$]\\{[^{}\\n]+\\})",
|
|
25551
25629
|
flags: "gi"
|
|
25552
25630
|
},
|
|
25553
25631
|
examples: [
|
|
@@ -25556,6 +25634,24 @@ var sql_inject_format_default = {
|
|
|
25556
25634
|
]
|
|
25557
25635
|
};
|
|
25558
25636
|
|
|
25637
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
25638
|
+
var sql_inject_interp_multiline_default = {
|
|
25639
|
+
specVersion: 1,
|
|
25640
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
25641
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
25642
|
+
category: "code_flaw",
|
|
25643
|
+
severity: "high",
|
|
25644
|
+
matcher: {
|
|
25645
|
+
type: "regex",
|
|
25646
|
+
pattern: '(?<=^|\\n)[ \\t]*(?=(?:select\\b(?:[^\\n]*\\n){0,3}?[^\\n]*?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+\\w+)\\s+){0,2}into\\b|update\\s+(?:(?:low_priority|ignore|or\\s+\\w+)\\s+){0,2}(?:only\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?(?:\\s*,\\s*(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?){0,7}\\s+set(?:\\s+|(?=`))(?:(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+\\s*=|#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;),]|\\n|$|(?:where|order|limit)\\b)))|delete\\s+(?:(?:low_priority|quick|ignore)\\s+){0,3}(?:from\\b|[\\w.`]+(?:\\s*,\\s*[\\w.`]+)*\\s+from\\s+[\\w.`]+(?:\\s+(?:as\\s+)?\\w+)?\\s+(?:(?:inner|cross|(?:left|right)(?:\\s+outer)?)\\s+)?(?:join|using|where)\\b)|where\\s+(?:(?:not\\s+)?(?:\\(\\s*)*(?:#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;)]|\\n|$|(?:and|or|order|group|limit)\\b)))|(?:not\\s+)?exists\\s*\\(|(?:not\\s+)?(?:\\(\\s*)*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?(?:\\s*,\\s*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?){0,4}\\s*(?:\\)\\s*)?(?:[=<>!~@|&:%^*/+-]+|\\b(?:is|in|not|i?like|regexp|rlike|similar\\s+to|glob|between|against|match|exists|and|or)\\b))))(?:select|insert|update|delete|where)\\s[^\\n]*?(?:#\\{|\\$[a-z_])',
|
|
25647
|
+
flags: "gi"
|
|
25648
|
+
},
|
|
25649
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
25650
|
+
appliesTo: {
|
|
25651
|
+
extensions: [".rb", ".php"]
|
|
25652
|
+
}
|
|
25653
|
+
};
|
|
25654
|
+
|
|
25559
25655
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
25560
25656
|
var sql_inject_interp_default = {
|
|
25561
25657
|
specVersion: 1,
|
|
@@ -25565,7 +25661,7 @@ var sql_inject_interp_default = {
|
|
|
25565
25661
|
severity: "high",
|
|
25566
25662
|
matcher: {
|
|
25567
25663
|
type: "regex",
|
|
25568
|
-
pattern: "([\
|
|
25664
|
+
pattern: '(?<![\\w\'"`})\\]])(["\'`])[ \\t]*(?=(?:select\\b(?:#\\{(?:[^{}\\n]|\\{(?:[^{}\\n]|\\{[^{}\\n]{0,100}\\}){0,100}\\}){0,200}\\}|\\{\\$[^}\\n]{0,200}\\}|\\\\(?!\\1[ \\t]*(?:select|insert|update|delete|where)\\b).|(?!\\1)(?!#\\{|\\{\\$|\\\\)[\\s\\S]){0,1000}?\\bfrom\\b|insert\\s+(?:(?:ignore|low_priority|delayed|high_priority|or\\s+\\w+)\\s+){0,2}(?:into\\b|[\\w.`]+\\s*\\()|update\\s+(?:(?:low_priority|ignore|or\\s+\\w+)\\s+){0,2}(?:only\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?(?:\\s*,\\s*(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+(?:\\s+(?:as\\s+)?(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+)?){0,7}(?:(?:\\s+\\w+){0,2}\\s+join\\b(?:(?!\\bset\\b)(?!\\1)[^\\n]){1,300})?\\s+set(?:\\s+|(?=`))(?:(?:[\\w.`\\"$]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\$\\{[^}\\n]{1,200}\\}|->|\\[[^\\]\\n]{1,200}\\])+\\s*=|#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;),]|\\n|$|(?:where|order|limit)\\b)))|delete\\s+(?:(?:low_priority|quick|ignore)\\s+){0,3}(?:from\\b|[\\w.`]+(?:\\s*,\\s*[\\w.`]+)*\\s+from\\s+[\\w.`]+(?:\\s+(?:as\\s+)?\\w+)?\\s+(?:(?:inner|cross|(?:left|right)(?:\\s+outer)?)\\s+)?(?:join|using|where)\\b)|where\\s+(?:(?:not\\s+)?(?:\\(\\s*)*(?:#\\{|\\{\\$|\\$[a-z_]\\w*(?:\\[[^\\]\\n]{1,200}\\])*(?=\\s*(?:["\'`;)]|\\n|$|(?:and|or|order|group|limit)\\b)))|(?:not\\s+)?exists\\s*\\(|(?:not\\s+)?(?:\\(\\s*)*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?(?:\\s*,\\s*(?:[\\w.`$"]|#\\{[^}\\n]{1,200}\\}|\\{\\$[^}\\n]{1,200}\\}|\\[[^\\]\\n]{1,200}\\]|\'[^\'\\n]{0,200}\')+(?:\\s*\\((?:[^()\\n]|\\((?:[^()\\n]|\\([^()\\n]{0,200}\\))*\\))*\\))?){0,4}\\s*(?:\\)\\s*)?(?:[=<>!~@|&:%^*/+-]+|\\b(?:is|in|not|i?like|regexp|rlike|similar\\s+to|glob|between|against|match|exists|and|or)\\b))))\\b(?:select|insert|update|delete|where)\\b(?:(?!\\1)[^\\n])*?(?:#\\{|\\$[a-z_])',
|
|
25569
25665
|
flags: "gi"
|
|
25570
25666
|
},
|
|
25571
25667
|
examples: [
|
|
@@ -27293,12 +27389,13 @@ var BUNDLED_PACKS = [
|
|
|
27293
27389
|
{
|
|
27294
27390
|
packId: "code-flaws",
|
|
27295
27391
|
name: "Code Security Flaws",
|
|
27296
|
-
version: "0.1.
|
|
27392
|
+
version: "0.1.6",
|
|
27297
27393
|
rawRules: [
|
|
27298
27394
|
sql_inject_concat_default,
|
|
27299
27395
|
sql_inject_concat_dot_default,
|
|
27300
27396
|
sql_inject_format_default,
|
|
27301
27397
|
sql_inject_interp_default,
|
|
27398
|
+
sql_inject_interp_multiline_default,
|
|
27302
27399
|
cmd_inject_shell_default,
|
|
27303
27400
|
cmd_inject_exec_default,
|
|
27304
27401
|
cmd_inject_node_exec_default,
|
|
@@ -27330,6 +27427,7 @@ var BUNDLED_PACKS = [
|
|
|
27330
27427
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
27331
27428
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
27332
27429
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
27430
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
27333
27431
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
27334
27432
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
27335
27433
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|