@akasecurity/ai-tc-codex 0.9.22 → 0.9.23
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 +88 -12
- package/scripts/backfill.js +103 -16
- package/scripts/content-retention.js +37 -0
- package/scripts/filescan.js +148 -49
- package/scripts/firstrun.js +100 -15
- package/scripts/history-sync.js +100 -15
- package/scripts/onboard.js +62 -5
- package/scripts/post-tool-use.js +103 -16
- package/scripts/pre-tool-use.js +103 -16
- package/scripts/query.js +100 -15
- package/scripts/reconcile.js +101 -15
- package/scripts/remediate.js +110 -19
- package/scripts/scan-worker.js +42 -8
- package/scripts/session-start.js +146 -48
- package/scripts/stop.js +100 -15
- package/scripts/sync.js +148 -49
- package/scripts/user-prompt-submit.js +103 -16
package/scripts/sync.js
CHANGED
|
@@ -32,9 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
mod
|
|
33
33
|
));
|
|
34
34
|
|
|
35
|
-
// ../../node_modules/.pnpm/ignore@7.0.
|
|
35
|
+
// ../../node_modules/.pnpm/ignore@7.0.14/node_modules/ignore/index.js
|
|
36
36
|
var require_ignore = __commonJS({
|
|
37
|
-
"../../node_modules/.pnpm/ignore@7.0.
|
|
37
|
+
"../../node_modules/.pnpm/ignore@7.0.14/node_modules/ignore/index.js"(exports, module) {
|
|
38
38
|
"use strict";
|
|
39
39
|
function makeArray(subject) {
|
|
40
40
|
return Array.isArray(subject) ? subject : [subject];
|
|
@@ -46,6 +46,7 @@ var require_ignore = __commonJS({
|
|
|
46
46
|
var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
|
|
47
47
|
var BOM = "\uFEFF";
|
|
48
48
|
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
49
|
+
var REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/;
|
|
49
50
|
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
50
51
|
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
51
52
|
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
@@ -227,6 +228,20 @@ var require_ignore = __commonJS({
|
|
|
227
228
|
(_, run, space) => space ? run.slice(0, run.length - run.length % 2) + SPACE2 : run,
|
|
228
229
|
ESCAPE + SPACE2
|
|
229
230
|
],
|
|
231
|
+
// git's wildmatch() reads a run of two or more asterisks as one globstar
|
|
232
|
+
// whenever the run fills a path segment: it starts the pattern or follows
|
|
233
|
+
// a `/`, and it ends the pattern or comes before a `/`. A run of two is
|
|
234
|
+
// already `**`; a longer one is folded into `**` here, so the steps
|
|
235
|
+
// below only ever have to know `**`.
|
|
236
|
+
// `***/foo` -> `**/foo`, `a/***/b` -> `a/**/b`, `a/***` -> `a/**`
|
|
237
|
+
// git also takes a run beside a literal prefix (`a***/b`) or beside an
|
|
238
|
+
// escaped slash (`***\/b`) as a globstar, and this does not; the README
|
|
239
|
+
// lists both, under "A run of asterisks".
|
|
240
|
+
[
|
|
241
|
+
/(^|\/)\*{3,}(?=\/|$)/g,
|
|
242
|
+
(_, start) => `${start}**`,
|
|
243
|
+
"*"
|
|
244
|
+
],
|
|
230
245
|
// Escape metacharacters
|
|
231
246
|
// which is written down by users but means special for regular expressions.
|
|
232
247
|
// > There are 12 characters with special meanings:
|
|
@@ -488,6 +503,9 @@ var require_ignore = __commonJS({
|
|
|
488
503
|
return out;
|
|
489
504
|
};
|
|
490
505
|
var makeRegexPrefix = (pattern) => {
|
|
506
|
+
if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) {
|
|
507
|
+
pattern = "**";
|
|
508
|
+
}
|
|
491
509
|
const { source, sources } = extractBrackets(pattern);
|
|
492
510
|
const replaced = REPLACERS.reduce(
|
|
493
511
|
// A pass whose matcher finds nothing hands back the very string it was
|
|
@@ -703,39 +721,33 @@ var require_ignore = __commonJS({
|
|
|
703
721
|
}
|
|
704
722
|
// Test one single path without recursively checking parent directories
|
|
705
723
|
//
|
|
706
|
-
// -
|
|
707
|
-
//
|
|
708
|
-
|
|
709
|
-
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
710
|
-
// @returns {TestResult} true if a file is ignored
|
|
711
|
-
test(path2, checkUnignored, mode) {
|
|
712
|
-
let ignored = false;
|
|
713
|
-
let unignored = false;
|
|
714
|
-
let matchedRule;
|
|
724
|
+
// - mode `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
725
|
+
// @returns {TestResult}
|
|
726
|
+
test(path2, mode) {
|
|
715
727
|
const rules = this._rules;
|
|
716
728
|
const { length } = rules;
|
|
717
729
|
const shortcut = this._basenameCount * 2 >= length;
|
|
718
730
|
const basename7 = shortcut ? basenameOf(path2) : path2;
|
|
719
|
-
for (let index =
|
|
731
|
+
for (let index = length - 1; index >= 0; index--) {
|
|
720
732
|
const rule = rules[index];
|
|
721
|
-
|
|
722
|
-
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
723
|
-
if (!skip && rule[mode].test(
|
|
733
|
+
if (rule[mode].test(
|
|
724
734
|
shortcut && rule._basenameOnly ? basename7 : path2
|
|
725
735
|
)) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
736
|
+
const { negative } = rule;
|
|
737
|
+
const ret = {
|
|
738
|
+
ignored: !negative,
|
|
739
|
+
unignored: negative
|
|
740
|
+
};
|
|
741
|
+
if (!negative) {
|
|
742
|
+
ret.rule = rule;
|
|
743
|
+
}
|
|
744
|
+
return ret;
|
|
729
745
|
}
|
|
730
746
|
}
|
|
731
|
-
|
|
732
|
-
ignored,
|
|
733
|
-
unignored
|
|
747
|
+
return {
|
|
748
|
+
ignored: false,
|
|
749
|
+
unignored: false
|
|
734
750
|
};
|
|
735
|
-
if (matchedRule) {
|
|
736
|
-
ret.rule = matchedRule;
|
|
737
|
-
}
|
|
738
|
-
return ret;
|
|
739
751
|
}
|
|
740
752
|
};
|
|
741
753
|
var throwError = (message, Ctor) => {
|
|
@@ -808,36 +820,36 @@ var require_ignore = __commonJS({
|
|
|
808
820
|
return this.add(pattern);
|
|
809
821
|
}
|
|
810
822
|
// @returns {TestResult}
|
|
811
|
-
_test(originalPath, cache
|
|
823
|
+
_test(originalPath, cache) {
|
|
812
824
|
const path2 = originalPath && checkPath.convert(originalPath);
|
|
813
825
|
checkPath(
|
|
814
826
|
path2,
|
|
815
827
|
originalPath,
|
|
816
828
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
817
829
|
);
|
|
818
|
-
return this._t(path2, cache
|
|
830
|
+
return this._t(path2, cache);
|
|
819
831
|
}
|
|
820
832
|
checkIgnore(path2) {
|
|
821
833
|
if (path2.charCodeAt(path2.length - 1) !== SLASH_CODE) {
|
|
822
834
|
return this.test(path2);
|
|
823
835
|
}
|
|
824
|
-
const dir = this._t(path2, this._testCache
|
|
836
|
+
const dir = this._t(path2, this._testCache);
|
|
825
837
|
if (dir.ignored) {
|
|
826
838
|
return dir;
|
|
827
839
|
}
|
|
828
840
|
const literal2 = this._rules.testLiteral(path2);
|
|
829
841
|
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
830
842
|
}
|
|
831
|
-
_t(path2, cache
|
|
843
|
+
_t(path2, cache) {
|
|
832
844
|
if (path2 in cache) {
|
|
833
845
|
return cache[path2];
|
|
834
846
|
}
|
|
835
847
|
const parentPath = parentOf(path2);
|
|
836
|
-
const parent = parentPath ? this._t(parentPath, cache
|
|
837
|
-
return cache[path2] = parent && parent.ignored ? parent : this._rules.test(path2,
|
|
848
|
+
const parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
|
|
849
|
+
return cache[path2] = parent && parent.ignored ? parent : this._rules.test(path2, MODE_IGNORE);
|
|
838
850
|
}
|
|
839
851
|
ignores(path2) {
|
|
840
|
-
return this._test(path2, this._ignoreCache
|
|
852
|
+
return this._test(path2, this._ignoreCache).ignored;
|
|
841
853
|
}
|
|
842
854
|
createFilter() {
|
|
843
855
|
return (path2) => !this.ignores(path2);
|
|
@@ -847,7 +859,7 @@ var require_ignore = __commonJS({
|
|
|
847
859
|
}
|
|
848
860
|
// @returns {TestResult}
|
|
849
861
|
test(path2) {
|
|
850
|
-
return this._test(path2, this._testCache
|
|
862
|
+
return this._test(path2, this._testCache);
|
|
851
863
|
}
|
|
852
864
|
};
|
|
853
865
|
var factory = (options) => new Ignore(options);
|
|
@@ -25125,6 +25137,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
25125
25137
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
25126
25138
|
);
|
|
25127
25139
|
}
|
|
25140
|
+
/**
|
|
25141
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
25142
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
25143
|
+
* every row.
|
|
25144
|
+
*
|
|
25145
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
25146
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
25147
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
25148
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
25149
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
25150
|
+
*
|
|
25151
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
25152
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
25153
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
25154
|
+
*
|
|
25155
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
25156
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
25157
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
25158
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
25159
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
25160
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
25161
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
25162
|
+
*/
|
|
25163
|
+
countFingerprintEpochs(currentVersion) {
|
|
25164
|
+
const row = getRow(
|
|
25165
|
+
this.db.prepare(
|
|
25166
|
+
`SELECT COUNT(*) AS total,
|
|
25167
|
+
COALESCE(
|
|
25168
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
25169
|
+
0
|
|
25170
|
+
) AS stale
|
|
25171
|
+
FROM secret_vault`
|
|
25172
|
+
),
|
|
25173
|
+
{ currentVersion }
|
|
25174
|
+
) ?? { stale: 0, total: 0 };
|
|
25175
|
+
return { stale: row.stale, total: row.total };
|
|
25176
|
+
}
|
|
25128
25177
|
};
|
|
25129
25178
|
|
|
25130
25179
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -26972,13 +27021,22 @@ var SecretVault = class {
|
|
|
26972
27021
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
26973
27022
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
26974
27023
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
27024
|
+
*
|
|
27025
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
27026
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
27027
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
27028
|
+
* than a bare success count.
|
|
26975
27029
|
*/
|
|
26976
27030
|
async refreshFingerprints(next) {
|
|
26977
27031
|
let refreshed = 0;
|
|
27032
|
+
let skipped = 0;
|
|
26978
27033
|
for (const row of this.#repo.listAll()) {
|
|
26979
27034
|
try {
|
|
26980
27035
|
const raw = await this.#openRow(row);
|
|
26981
|
-
if (raw === null)
|
|
27036
|
+
if (raw === null) {
|
|
27037
|
+
skipped += 1;
|
|
27038
|
+
continue;
|
|
27039
|
+
}
|
|
26982
27040
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
26983
27041
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
26984
27042
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -26986,10 +27044,10 @@ var SecretVault = class {
|
|
|
26986
27044
|
});
|
|
26987
27045
|
refreshed += 1;
|
|
26988
27046
|
} catch {
|
|
26989
|
-
|
|
27047
|
+
skipped += 1;
|
|
26990
27048
|
}
|
|
26991
27049
|
}
|
|
26992
|
-
return refreshed;
|
|
27050
|
+
return { refreshed, skipped };
|
|
26993
27051
|
}
|
|
26994
27052
|
/**
|
|
26995
27053
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -29538,6 +29596,21 @@ function registerPack(pack) {
|
|
|
29538
29596
|
function getLoadedRules() {
|
|
29539
29597
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
29540
29598
|
}
|
|
29599
|
+
function outsideWrittenRegions(candidates, context) {
|
|
29600
|
+
const regions = context?.writtenRegions;
|
|
29601
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
29602
|
+
return candidates.filter((c) => {
|
|
29603
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
29604
|
+
const { start, end } = c.match.span;
|
|
29605
|
+
return !regions.some(
|
|
29606
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
29607
|
+
c.rule,
|
|
29608
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
29609
|
+
"code_change"
|
|
29610
|
+
)
|
|
29611
|
+
);
|
|
29612
|
+
});
|
|
29613
|
+
}
|
|
29541
29614
|
function spansOverlap(a, b) {
|
|
29542
29615
|
return a.start < b.end && a.end > b.start;
|
|
29543
29616
|
}
|
|
@@ -29725,17 +29798,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
29725
29798
|
function scanText(text, ruleset, context) {
|
|
29726
29799
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
29727
29800
|
const normalization = normalizeFormatChars(text);
|
|
29728
|
-
const originalCandidates =
|
|
29801
|
+
const originalCandidates = outsideWrittenRegions(
|
|
29802
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
29803
|
+
context
|
|
29804
|
+
);
|
|
29729
29805
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
29730
29806
|
const pooledOriginal = originalCandidates.map(
|
|
29731
29807
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
29732
29808
|
);
|
|
29733
|
-
const normalizedCandidates =
|
|
29734
|
-
normalization.normalized,
|
|
29735
|
-
|
|
29736
|
-
|
|
29737
|
-
context
|
|
29738
|
-
)
|
|
29809
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
29810
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
29811
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
29812
|
+
),
|
|
29813
|
+
context
|
|
29814
|
+
);
|
|
29739
29815
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
29740
29816
|
return mergeOverlappingSameRule(findings, text);
|
|
29741
29817
|
}
|
|
@@ -29796,6 +29872,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
29796
29872
|
"code-flaws/sql-inject-concat-dot",
|
|
29797
29873
|
"code-flaws/sql-inject-format",
|
|
29798
29874
|
"code-flaws/sql-inject-interp",
|
|
29875
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
29799
29876
|
"code-flaws/ssrf-user-url",
|
|
29800
29877
|
"code-flaws/xss-dangerously-set",
|
|
29801
29878
|
"code-flaws/xss-inner-html",
|
|
@@ -30934,7 +31011,7 @@ var sql_inject_concat_dot_default = {
|
|
|
30934
31011
|
severity: "high",
|
|
30935
31012
|
matcher: {
|
|
30936
31013
|
type: "regex",
|
|
30937
|
-
pattern:
|
|
31014
|
+
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*\\.",
|
|
30938
31015
|
flags: "gi"
|
|
30939
31016
|
},
|
|
30940
31017
|
appliesTo: {
|
|
@@ -30952,7 +31029,7 @@ var sql_inject_concat_default = {
|
|
|
30952
31029
|
severity: "high",
|
|
30953
31030
|
matcher: {
|
|
30954
31031
|
type: "regex",
|
|
30955
|
-
pattern:
|
|
31032
|
+
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*\\+",
|
|
30956
31033
|
flags: "gi"
|
|
30957
31034
|
},
|
|
30958
31035
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -30967,7 +31044,7 @@ var sql_inject_format_default = {
|
|
|
30967
31044
|
severity: "high",
|
|
30968
31045
|
matcher: {
|
|
30969
31046
|
type: "regex",
|
|
30970
|
-
pattern:
|
|
31047
|
+
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]+\\})",
|
|
30971
31048
|
flags: "gi"
|
|
30972
31049
|
},
|
|
30973
31050
|
examples: [
|
|
@@ -30976,6 +31053,24 @@ var sql_inject_format_default = {
|
|
|
30976
31053
|
]
|
|
30977
31054
|
};
|
|
30978
31055
|
|
|
31056
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
31057
|
+
var sql_inject_interp_multiline_default = {
|
|
31058
|
+
specVersion: 1,
|
|
31059
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
31060
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
31061
|
+
category: "code_flaw",
|
|
31062
|
+
severity: "high",
|
|
31063
|
+
matcher: {
|
|
31064
|
+
type: "regex",
|
|
31065
|
+
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_])',
|
|
31066
|
+
flags: "gi"
|
|
31067
|
+
},
|
|
31068
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
31069
|
+
appliesTo: {
|
|
31070
|
+
extensions: [".rb", ".php"]
|
|
31071
|
+
}
|
|
31072
|
+
};
|
|
31073
|
+
|
|
30979
31074
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
30980
31075
|
var sql_inject_interp_default = {
|
|
30981
31076
|
specVersion: 1,
|
|
@@ -30985,7 +31080,7 @@ var sql_inject_interp_default = {
|
|
|
30985
31080
|
severity: "high",
|
|
30986
31081
|
matcher: {
|
|
30987
31082
|
type: "regex",
|
|
30988
|
-
pattern: "([\
|
|
31083
|
+
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_])',
|
|
30989
31084
|
flags: "gi"
|
|
30990
31085
|
},
|
|
30991
31086
|
examples: [
|
|
@@ -32713,12 +32808,13 @@ var BUNDLED_PACKS = [
|
|
|
32713
32808
|
{
|
|
32714
32809
|
packId: "code-flaws",
|
|
32715
32810
|
name: "Code Security Flaws",
|
|
32716
|
-
version: "0.1.
|
|
32811
|
+
version: "0.1.6",
|
|
32717
32812
|
rawRules: [
|
|
32718
32813
|
sql_inject_concat_default,
|
|
32719
32814
|
sql_inject_concat_dot_default,
|
|
32720
32815
|
sql_inject_format_default,
|
|
32721
32816
|
sql_inject_interp_default,
|
|
32817
|
+
sql_inject_interp_multiline_default,
|
|
32722
32818
|
cmd_inject_shell_default,
|
|
32723
32819
|
cmd_inject_exec_default,
|
|
32724
32820
|
cmd_inject_node_exec_default,
|
|
@@ -32750,6 +32846,7 @@ var BUNDLED_PACKS = [
|
|
|
32750
32846
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
32751
32847
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
32752
32848
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
32849
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
32753
32850
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
32754
32851
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
32755
32852
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -33861,6 +33958,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
33861
33958
|
text,
|
|
33862
33959
|
filePath: context?.filePath,
|
|
33863
33960
|
eventKind: context?.eventKind,
|
|
33961
|
+
writtenRegions: context?.writtenRegions,
|
|
33864
33962
|
attribute: scanOpts?.attribute === true
|
|
33865
33963
|
}),
|
|
33866
33964
|
reply: (message) => {
|
|
@@ -34662,7 +34760,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
34662
34760
|
input.text,
|
|
34663
34761
|
{
|
|
34664
34762
|
filePath: input.metadata?.filePath,
|
|
34665
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
34763
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
34764
|
+
writtenRegions: opts2.writtenRegions
|
|
34666
34765
|
},
|
|
34667
34766
|
{
|
|
34668
34767
|
sourceTool: input.sourceTool,
|