@akasecurity/ai-tc-antigravity 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/package.json +3 -3
- package/plugin.json +1 -1
- package/scripts/apply-suppressions.js +148 -31
- package/scripts/backfill.js +187 -41
- package/scripts/content-retention.js +97 -19
- package/scripts/fail-open-count.js +32 -6
- 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 +32 -6
- package/scripts/pre-invocation.js +258 -98
- package/scripts/pre-tool-use.js +183 -37
- package/scripts/query.js +173 -46
- package/scripts/reconcile.js +188 -43
- package/scripts/remediate.js +191 -41
- package/scripts/scan-worker.js +74 -14
- package/scripts/start-light.js +32 -6
- package/scripts/stop.js +32 -6
- package/scripts/sync.js +244 -87
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akasecurity/ai-tc-antigravity",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.24",
|
|
4
4
|
"description": "AI Traffic Control — inspect and govern AI prompts in Antigravity CLI",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@akasecurity/eslint-config": "0.8.0",
|
|
31
31
|
"@akasecurity/plugin-runtime": "0.8.0",
|
|
32
32
|
"@akasecurity/persistence": "0.8.0",
|
|
33
|
-
"@akasecurity/
|
|
33
|
+
"@akasecurity/plugin-sdk": "0.8.0",
|
|
34
34
|
"@akasecurity/schema": "0.8.0",
|
|
35
35
|
"@akasecurity/setup-wizard": "0.8.0",
|
|
36
|
-
"@akasecurity/
|
|
36
|
+
"@akasecurity/scanner": "0.8.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsup",
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://antigravity.google/schemas/v1/plugin.json",
|
|
3
3
|
"name": "aka-antigravity",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.24",
|
|
5
5
|
"description": "AI Traffic Control — inspect and govern AI prompts in Antigravity. Detection runs locally; events are recorded to a local SQLite store on your machine.",
|
|
6
6
|
"hooks": "./hooks.json",
|
|
7
7
|
"skills": "./skills",
|
|
@@ -8783,7 +8783,11 @@ var ListFindingTypesQuery = object({
|
|
|
8783
8783
|
// and so is not bounded by what any page happens to hold.
|
|
8784
8784
|
includeId: string2().optional(),
|
|
8785
8785
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8786
|
-
cursor: string2().optional()
|
|
8786
|
+
cursor: string2().optional(),
|
|
8787
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8788
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8789
|
+
// from wherever it lands.
|
|
8790
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8787
8791
|
});
|
|
8788
8792
|
var ListFindingTypesResponse = object({
|
|
8789
8793
|
totals: object({
|
|
@@ -8864,7 +8868,11 @@ var ListFindingInstancesQuery = object({
|
|
|
8864
8868
|
sessionId: string2().optional(),
|
|
8865
8869
|
from: iso_exports.datetime().optional(),
|
|
8866
8870
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
8867
|
-
cursor: string2().optional()
|
|
8871
|
+
cursor: string2().optional(),
|
|
8872
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8873
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8874
|
+
// from wherever it lands.
|
|
8875
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8868
8876
|
});
|
|
8869
8877
|
var ListFindingInstancesResponse = object({
|
|
8870
8878
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -8936,7 +8944,11 @@ var ListFindingLocationsQuery = object({
|
|
|
8936
8944
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
8937
8945
|
includeId: string2().optional(),
|
|
8938
8946
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
8939
|
-
cursor: string2().optional()
|
|
8947
|
+
cursor: string2().optional(),
|
|
8948
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8949
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8950
|
+
// from wherever it lands.
|
|
8951
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8940
8952
|
});
|
|
8941
8953
|
var ListFindingLocationsResponse = object({
|
|
8942
8954
|
totals: object({
|
|
@@ -11410,7 +11422,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
11410
11422
|
var ListVaultInventoryQuery = object({
|
|
11411
11423
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11412
11424
|
// Opaque; names the last row of the page just served.
|
|
11413
|
-
cursor: string2().optional()
|
|
11425
|
+
cursor: string2().optional(),
|
|
11426
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11427
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11428
|
+
// from wherever it lands.
|
|
11429
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11414
11430
|
});
|
|
11415
11431
|
var ListVaultInventoryResponse = object({
|
|
11416
11432
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -11422,7 +11438,11 @@ var ListVaultInventoryResponse = object({
|
|
|
11422
11438
|
});
|
|
11423
11439
|
var ListVaultReuseQuery = object({
|
|
11424
11440
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11425
|
-
cursor: string2().optional()
|
|
11441
|
+
cursor: string2().optional(),
|
|
11442
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11443
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11444
|
+
// from wherever it lands.
|
|
11445
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11426
11446
|
});
|
|
11427
11447
|
var ListVaultReuseResponse = object({
|
|
11428
11448
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -11438,9 +11458,15 @@ var ListVaultDerefsQuery = object({
|
|
|
11438
11458
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
11439
11459
|
includeBatched: boolean2().optional(),
|
|
11440
11460
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11441
|
-
cursor: string2().optional()
|
|
11461
|
+
cursor: string2().optional(),
|
|
11462
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11463
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11464
|
+
// from wherever it lands.
|
|
11465
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11442
11466
|
});
|
|
11443
11467
|
var ListVaultDerefsResponse = object({
|
|
11468
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
11469
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
11444
11470
|
items: array(VaultDeref),
|
|
11445
11471
|
nextCursor: string2().nullable(),
|
|
11446
11472
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -18876,7 +18902,7 @@ var SqliteFindingsRepository = class {
|
|
|
18876
18902
|
};
|
|
18877
18903
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
18878
18904
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
18879
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
18905
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
18880
18906
|
const page = sorted.slice(start, start + limit);
|
|
18881
18907
|
const lastOnPage = page.at(-1);
|
|
18882
18908
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -18970,7 +18996,7 @@ var SqliteFindingsRepository = class {
|
|
|
18970
18996
|
accumulator.add(row);
|
|
18971
18997
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
18972
18998
|
total += 1;
|
|
18973
|
-
if (!isPastCursor(row)) continue;
|
|
18999
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
18974
19000
|
if (items.length < limit) {
|
|
18975
19001
|
items.push(toInstanceDetail(row));
|
|
18976
19002
|
last = row;
|
|
@@ -19059,7 +19085,7 @@ var SqliteFindingsRepository = class {
|
|
|
19059
19085
|
}
|
|
19060
19086
|
}
|
|
19061
19087
|
sorted.sort(compareLocationOrder);
|
|
19062
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
19088
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
19063
19089
|
const page = sorted.slice(start, start + limit);
|
|
19064
19090
|
const lastOnPage = page.at(-1);
|
|
19065
19091
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -21687,6 +21713,9 @@ function pageLimit(requested, fallback) {
|
|
|
21687
21713
|
if (requested === void 0) return fallback;
|
|
21688
21714
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
21689
21715
|
}
|
|
21716
|
+
function pageOffset(requested) {
|
|
21717
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
21718
|
+
}
|
|
21690
21719
|
function encodeReuseCursor(payload) {
|
|
21691
21720
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
21692
21721
|
}
|
|
@@ -22034,7 +22063,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
22034
22063
|
*/
|
|
22035
22064
|
listInventory(query = {}, now = Date.now()) {
|
|
22036
22065
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
22037
|
-
const
|
|
22066
|
+
const offset = pageOffset(query.offset);
|
|
22067
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
22038
22068
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
22039
22069
|
const rows = allRows(
|
|
22040
22070
|
this.db.prepare(
|
|
@@ -22048,11 +22078,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
22048
22078
|
FROM secret_vault v
|
|
22049
22079
|
${where}
|
|
22050
22080
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
22051
|
-
LIMIT :limit`
|
|
22081
|
+
LIMIT :limit OFFSET :offset`
|
|
22052
22082
|
),
|
|
22053
22083
|
bindParams({
|
|
22054
22084
|
now,
|
|
22055
22085
|
limit: limit + 1,
|
|
22086
|
+
offset,
|
|
22056
22087
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
22057
22088
|
})
|
|
22058
22089
|
);
|
|
@@ -22076,7 +22107,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
22076
22107
|
*/
|
|
22077
22108
|
listReuse(query = {}, now = Date.now()) {
|
|
22078
22109
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
22079
|
-
const
|
|
22110
|
+
const offset = pageOffset(query.offset);
|
|
22111
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
22080
22112
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
22081
22113
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
22082
22114
|
const rows = allRows(
|
|
@@ -22091,11 +22123,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
22091
22123
|
FROM secret_vault v
|
|
22092
22124
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
22093
22125
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
22094
|
-
LIMIT :limit`
|
|
22126
|
+
LIMIT :limit OFFSET :offset`
|
|
22095
22127
|
),
|
|
22096
22128
|
bindParams({
|
|
22097
22129
|
now,
|
|
22098
22130
|
limit: limit + 1,
|
|
22131
|
+
offset,
|
|
22099
22132
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
22100
22133
|
})
|
|
22101
22134
|
);
|
|
@@ -22120,7 +22153,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
22120
22153
|
*/
|
|
22121
22154
|
listDerefs(query = {}) {
|
|
22122
22155
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
22123
|
-
const
|
|
22156
|
+
const offset = pageOffset(query.offset);
|
|
22157
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
22124
22158
|
const conditions = [];
|
|
22125
22159
|
if (query.includeBatched !== true) {
|
|
22126
22160
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -22133,21 +22167,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
22133
22167
|
this.db.prepare(
|
|
22134
22168
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
22135
22169
|
FROM secret_vault_deref ${where}
|
|
22136
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
22170
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
22137
22171
|
),
|
|
22138
22172
|
bindParams({
|
|
22139
22173
|
limit: limit + 1,
|
|
22174
|
+
offset,
|
|
22140
22175
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
22141
22176
|
})
|
|
22142
22177
|
);
|
|
22143
22178
|
const hasMore = rows.length > limit;
|
|
22144
22179
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
22145
22180
|
const last = page[page.length - 1];
|
|
22146
|
-
const
|
|
22147
|
-
this.db
|
|
22148
|
-
|
|
22149
|
-
|
|
22181
|
+
const counts = getRow(
|
|
22182
|
+
this.db.prepare(
|
|
22183
|
+
`SELECT count(*) AS total,
|
|
22184
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
22185
|
+
FROM secret_vault_deref`
|
|
22186
|
+
)
|
|
22187
|
+
) ?? { total: 0, hidden: 0 };
|
|
22188
|
+
const includeBatched = query.includeBatched === true;
|
|
22189
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
22150
22190
|
return {
|
|
22191
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
22151
22192
|
items: page.map((r) => ({
|
|
22152
22193
|
id: r.id,
|
|
22153
22194
|
pointerId: r.pointer_id,
|
|
@@ -22172,6 +22213,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
22172
22213
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
22173
22214
|
);
|
|
22174
22215
|
}
|
|
22216
|
+
/**
|
|
22217
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
22218
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
22219
|
+
* every row.
|
|
22220
|
+
*
|
|
22221
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
22222
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
22223
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
22224
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
22225
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
22226
|
+
*
|
|
22227
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
22228
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
22229
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
22230
|
+
*
|
|
22231
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
22232
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
22233
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
22234
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
22235
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
22236
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
22237
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
22238
|
+
*/
|
|
22239
|
+
countFingerprintEpochs(currentVersion) {
|
|
22240
|
+
const row = getRow(
|
|
22241
|
+
this.db.prepare(
|
|
22242
|
+
`SELECT COUNT(*) AS total,
|
|
22243
|
+
COALESCE(
|
|
22244
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
22245
|
+
0
|
|
22246
|
+
) AS stale
|
|
22247
|
+
FROM secret_vault`
|
|
22248
|
+
),
|
|
22249
|
+
{ currentVersion }
|
|
22250
|
+
) ?? { stale: 0, total: 0 };
|
|
22251
|
+
return { stale: row.stale, total: row.total };
|
|
22252
|
+
}
|
|
22175
22253
|
};
|
|
22176
22254
|
|
|
22177
22255
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -24610,6 +24688,21 @@ function registerPack(pack) {
|
|
|
24610
24688
|
function getLoadedRules() {
|
|
24611
24689
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
24612
24690
|
}
|
|
24691
|
+
function outsideWrittenRegions(candidates, context) {
|
|
24692
|
+
const regions = context?.writtenRegions;
|
|
24693
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
24694
|
+
return candidates.filter((c) => {
|
|
24695
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
24696
|
+
const { start, end } = c.match.span;
|
|
24697
|
+
return !regions.some(
|
|
24698
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
24699
|
+
c.rule,
|
|
24700
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
24701
|
+
"code_change"
|
|
24702
|
+
)
|
|
24703
|
+
);
|
|
24704
|
+
});
|
|
24705
|
+
}
|
|
24613
24706
|
function spansOverlap(a, b) {
|
|
24614
24707
|
return a.start < b.end && a.end > b.start;
|
|
24615
24708
|
}
|
|
@@ -24797,17 +24890,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
24797
24890
|
function scanText(text, ruleset, context) {
|
|
24798
24891
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
24799
24892
|
const normalization = normalizeFormatChars(text);
|
|
24800
|
-
const originalCandidates =
|
|
24893
|
+
const originalCandidates = outsideWrittenRegions(
|
|
24894
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
24895
|
+
context
|
|
24896
|
+
);
|
|
24801
24897
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
24802
24898
|
const pooledOriginal = originalCandidates.map(
|
|
24803
24899
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
24804
24900
|
);
|
|
24805
|
-
const normalizedCandidates =
|
|
24806
|
-
normalization.normalized,
|
|
24807
|
-
|
|
24808
|
-
|
|
24809
|
-
context
|
|
24810
|
-
)
|
|
24901
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
24902
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
24903
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
24904
|
+
),
|
|
24905
|
+
context
|
|
24906
|
+
);
|
|
24811
24907
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
24812
24908
|
return mergeOverlappingSameRule(findings, text);
|
|
24813
24909
|
}
|
|
@@ -24868,6 +24964,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
24868
24964
|
"code-flaws/sql-inject-concat-dot",
|
|
24869
24965
|
"code-flaws/sql-inject-format",
|
|
24870
24966
|
"code-flaws/sql-inject-interp",
|
|
24967
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
24871
24968
|
"code-flaws/ssrf-user-url",
|
|
24872
24969
|
"code-flaws/xss-dangerously-set",
|
|
24873
24970
|
"code-flaws/xss-inner-html",
|
|
@@ -25957,7 +26054,7 @@ var sql_inject_concat_dot_default = {
|
|
|
25957
26054
|
severity: "high",
|
|
25958
26055
|
matcher: {
|
|
25959
26056
|
type: "regex",
|
|
25960
|
-
pattern:
|
|
26057
|
+
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*\\.",
|
|
25961
26058
|
flags: "gi"
|
|
25962
26059
|
},
|
|
25963
26060
|
appliesTo: {
|
|
@@ -25975,7 +26072,7 @@ var sql_inject_concat_default = {
|
|
|
25975
26072
|
severity: "high",
|
|
25976
26073
|
matcher: {
|
|
25977
26074
|
type: "regex",
|
|
25978
|
-
pattern:
|
|
26075
|
+
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*\\+",
|
|
25979
26076
|
flags: "gi"
|
|
25980
26077
|
},
|
|
25981
26078
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -25990,7 +26087,7 @@ var sql_inject_format_default = {
|
|
|
25990
26087
|
severity: "high",
|
|
25991
26088
|
matcher: {
|
|
25992
26089
|
type: "regex",
|
|
25993
|
-
pattern:
|
|
26090
|
+
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]+\\})",
|
|
25994
26091
|
flags: "gi"
|
|
25995
26092
|
},
|
|
25996
26093
|
examples: [
|
|
@@ -25999,6 +26096,24 @@ var sql_inject_format_default = {
|
|
|
25999
26096
|
]
|
|
26000
26097
|
};
|
|
26001
26098
|
|
|
26099
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
26100
|
+
var sql_inject_interp_multiline_default = {
|
|
26101
|
+
specVersion: 1,
|
|
26102
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
26103
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
26104
|
+
category: "code_flaw",
|
|
26105
|
+
severity: "high",
|
|
26106
|
+
matcher: {
|
|
26107
|
+
type: "regex",
|
|
26108
|
+
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_])',
|
|
26109
|
+
flags: "gi"
|
|
26110
|
+
},
|
|
26111
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
26112
|
+
appliesTo: {
|
|
26113
|
+
extensions: [".rb", ".php"]
|
|
26114
|
+
}
|
|
26115
|
+
};
|
|
26116
|
+
|
|
26002
26117
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
26003
26118
|
var sql_inject_interp_default = {
|
|
26004
26119
|
specVersion: 1,
|
|
@@ -26008,7 +26123,7 @@ var sql_inject_interp_default = {
|
|
|
26008
26123
|
severity: "high",
|
|
26009
26124
|
matcher: {
|
|
26010
26125
|
type: "regex",
|
|
26011
|
-
pattern: "([\
|
|
26126
|
+
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_])',
|
|
26012
26127
|
flags: "gi"
|
|
26013
26128
|
},
|
|
26014
26129
|
examples: [
|
|
@@ -27736,12 +27851,13 @@ var BUNDLED_PACKS = [
|
|
|
27736
27851
|
{
|
|
27737
27852
|
packId: "code-flaws",
|
|
27738
27853
|
name: "Code Security Flaws",
|
|
27739
|
-
version: "0.1.
|
|
27854
|
+
version: "0.1.6",
|
|
27740
27855
|
rawRules: [
|
|
27741
27856
|
sql_inject_concat_default,
|
|
27742
27857
|
sql_inject_concat_dot_default,
|
|
27743
27858
|
sql_inject_format_default,
|
|
27744
27859
|
sql_inject_interp_default,
|
|
27860
|
+
sql_inject_interp_multiline_default,
|
|
27745
27861
|
cmd_inject_shell_default,
|
|
27746
27862
|
cmd_inject_exec_default,
|
|
27747
27863
|
cmd_inject_node_exec_default,
|
|
@@ -27773,6 +27889,7 @@ var BUNDLED_PACKS = [
|
|
|
27773
27889
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
27774
27890
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
27775
27891
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
27892
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
27776
27893
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
27777
27894
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
27778
27895
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|