@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/session-start.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) + SPACE : run,
|
|
228
229
|
ESCAPE + SPACE
|
|
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(path, 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(path, mode) {
|
|
715
727
|
const rules = this._rules;
|
|
716
728
|
const { length } = rules;
|
|
717
729
|
const shortcut = this._basenameCount * 2 >= length;
|
|
718
730
|
const basename8 = shortcut ? basenameOf(path) : path;
|
|
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 ? basename8 : path
|
|
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 = (message2, 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 path = originalPath && checkPath.convert(originalPath);
|
|
813
825
|
checkPath(
|
|
814
826
|
path,
|
|
815
827
|
originalPath,
|
|
816
828
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
817
829
|
);
|
|
818
|
-
return this._t(path, cache
|
|
830
|
+
return this._t(path, cache);
|
|
819
831
|
}
|
|
820
832
|
checkIgnore(path) {
|
|
821
833
|
if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
|
|
822
834
|
return this.test(path);
|
|
823
835
|
}
|
|
824
|
-
const dir = this._t(path, this._testCache
|
|
836
|
+
const dir = this._t(path, this._testCache);
|
|
825
837
|
if (dir.ignored) {
|
|
826
838
|
return dir;
|
|
827
839
|
}
|
|
828
840
|
const literal2 = this._rules.testLiteral(path);
|
|
829
841
|
return literal2.ignored || literal2.unignored ? literal2 : dir;
|
|
830
842
|
}
|
|
831
|
-
_t(path, cache
|
|
843
|
+
_t(path, cache) {
|
|
832
844
|
if (path in cache) {
|
|
833
845
|
return cache[path];
|
|
834
846
|
}
|
|
835
847
|
const parentPath = parentOf(path);
|
|
836
|
-
const parent = parentPath ? this._t(parentPath, cache
|
|
837
|
-
return cache[path] = parent && parent.ignored ? parent : this._rules.test(path,
|
|
848
|
+
const parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
|
|
849
|
+
return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, MODE_IGNORE);
|
|
838
850
|
}
|
|
839
851
|
ignores(path) {
|
|
840
|
-
return this._test(path, this._ignoreCache
|
|
852
|
+
return this._test(path, this._ignoreCache).ignored;
|
|
841
853
|
}
|
|
842
854
|
createFilter() {
|
|
843
855
|
return (path) => !this.ignores(path);
|
|
@@ -847,7 +859,7 @@ var require_ignore = __commonJS({
|
|
|
847
859
|
}
|
|
848
860
|
// @returns {TestResult}
|
|
849
861
|
test(path) {
|
|
850
|
-
return this._test(path, this._testCache
|
|
862
|
+
return this._test(path, this._testCache);
|
|
851
863
|
}
|
|
852
864
|
};
|
|
853
865
|
var factory = (options) => new Ignore(options);
|
|
@@ -872,7 +884,7 @@ var require_ignore = __commonJS({
|
|
|
872
884
|
});
|
|
873
885
|
|
|
874
886
|
// src/hooks/session-start.ts
|
|
875
|
-
import { readFileSync as
|
|
887
|
+
import { readFileSync as readFileSync30 } from "fs";
|
|
876
888
|
|
|
877
889
|
// ../../packages/schema/src/drizzle/deferred-migrations.ts
|
|
878
890
|
var DEFERRED_MIGRATION_TAGS = [
|
|
@@ -9650,7 +9662,11 @@ var ListFindingTypesQuery = object({
|
|
|
9650
9662
|
// and so is not bounded by what any page happens to hold.
|
|
9651
9663
|
includeId: string2().optional(),
|
|
9652
9664
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
9653
|
-
cursor: string2().optional()
|
|
9665
|
+
cursor: string2().optional(),
|
|
9666
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9667
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9668
|
+
// from wherever it lands.
|
|
9669
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9654
9670
|
});
|
|
9655
9671
|
var ListFindingTypesResponse = object({
|
|
9656
9672
|
totals: object({
|
|
@@ -9731,7 +9747,11 @@ var ListFindingInstancesQuery = object({
|
|
|
9731
9747
|
sessionId: string2().optional(),
|
|
9732
9748
|
from: iso_exports.datetime().optional(),
|
|
9733
9749
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
9734
|
-
cursor: string2().optional()
|
|
9750
|
+
cursor: string2().optional(),
|
|
9751
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9752
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9753
|
+
// from wherever it lands.
|
|
9754
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9735
9755
|
});
|
|
9736
9756
|
var ListFindingInstancesResponse = object({
|
|
9737
9757
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -9803,7 +9823,11 @@ var ListFindingLocationsQuery = object({
|
|
|
9803
9823
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
9804
9824
|
includeId: string2().optional(),
|
|
9805
9825
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
9806
|
-
cursor: string2().optional()
|
|
9826
|
+
cursor: string2().optional(),
|
|
9827
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
9828
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
9829
|
+
// from wherever it lands.
|
|
9830
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
9807
9831
|
});
|
|
9808
9832
|
var ListFindingLocationsResponse = object({
|
|
9809
9833
|
totals: object({
|
|
@@ -12435,7 +12459,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
12435
12459
|
var ListVaultInventoryQuery = object({
|
|
12436
12460
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12437
12461
|
// Opaque; names the last row of the page just served.
|
|
12438
|
-
cursor: string2().optional()
|
|
12462
|
+
cursor: string2().optional(),
|
|
12463
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12464
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12465
|
+
// from wherever it lands.
|
|
12466
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12439
12467
|
});
|
|
12440
12468
|
var ListVaultInventoryResponse = object({
|
|
12441
12469
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -12447,7 +12475,11 @@ var ListVaultInventoryResponse = object({
|
|
|
12447
12475
|
});
|
|
12448
12476
|
var ListVaultReuseQuery = object({
|
|
12449
12477
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12450
|
-
cursor: string2().optional()
|
|
12478
|
+
cursor: string2().optional(),
|
|
12479
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12480
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12481
|
+
// from wherever it lands.
|
|
12482
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12451
12483
|
});
|
|
12452
12484
|
var ListVaultReuseResponse = object({
|
|
12453
12485
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -12463,9 +12495,15 @@ var ListVaultDerefsQuery = object({
|
|
|
12463
12495
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
12464
12496
|
includeBatched: boolean2().optional(),
|
|
12465
12497
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
12466
|
-
cursor: string2().optional()
|
|
12498
|
+
cursor: string2().optional(),
|
|
12499
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
12500
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
12501
|
+
// from wherever it lands.
|
|
12502
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
12467
12503
|
});
|
|
12468
12504
|
var ListVaultDerefsResponse = object({
|
|
12505
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
12506
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
12469
12507
|
items: array(VaultDeref),
|
|
12470
12508
|
nextCursor: string2().nullable(),
|
|
12471
12509
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -21531,7 +21569,7 @@ var SqliteFindingsRepository = class {
|
|
|
21531
21569
|
};
|
|
21532
21570
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
21533
21571
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
21534
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
21572
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
21535
21573
|
const page = sorted.slice(start, start + limit);
|
|
21536
21574
|
const lastOnPage = page.at(-1);
|
|
21537
21575
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -21625,7 +21663,7 @@ var SqliteFindingsRepository = class {
|
|
|
21625
21663
|
accumulator.add(row);
|
|
21626
21664
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
21627
21665
|
total += 1;
|
|
21628
|
-
if (!isPastCursor(row)) continue;
|
|
21666
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
21629
21667
|
if (items.length < limit) {
|
|
21630
21668
|
items.push(toInstanceDetail(row));
|
|
21631
21669
|
last = row;
|
|
@@ -21714,7 +21752,7 @@ var SqliteFindingsRepository = class {
|
|
|
21714
21752
|
}
|
|
21715
21753
|
}
|
|
21716
21754
|
sorted.sort(compareLocationOrder);
|
|
21717
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
21755
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
21718
21756
|
const page = sorted.slice(start, start + limit);
|
|
21719
21757
|
const lastOnPage = page.at(-1);
|
|
21720
21758
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -24342,6 +24380,9 @@ function pageLimit(requested, fallback) {
|
|
|
24342
24380
|
if (requested === void 0) return fallback;
|
|
24343
24381
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
24344
24382
|
}
|
|
24383
|
+
function pageOffset(requested) {
|
|
24384
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
24385
|
+
}
|
|
24345
24386
|
function encodeReuseCursor(payload) {
|
|
24346
24387
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
24347
24388
|
}
|
|
@@ -24689,7 +24730,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24689
24730
|
*/
|
|
24690
24731
|
listInventory(query = {}, now = Date.now()) {
|
|
24691
24732
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
24692
|
-
const
|
|
24733
|
+
const offset = pageOffset(query.offset);
|
|
24734
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
24693
24735
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
24694
24736
|
const rows = allRows(
|
|
24695
24737
|
this.db.prepare(
|
|
@@ -24703,11 +24745,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
24703
24745
|
FROM secret_vault v
|
|
24704
24746
|
${where}
|
|
24705
24747
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
24706
|
-
LIMIT :limit`
|
|
24748
|
+
LIMIT :limit OFFSET :offset`
|
|
24707
24749
|
),
|
|
24708
24750
|
bindParams({
|
|
24709
24751
|
now,
|
|
24710
24752
|
limit: limit + 1,
|
|
24753
|
+
offset,
|
|
24711
24754
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
24712
24755
|
})
|
|
24713
24756
|
);
|
|
@@ -24731,7 +24774,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24731
24774
|
*/
|
|
24732
24775
|
listReuse(query = {}, now = Date.now()) {
|
|
24733
24776
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
24734
|
-
const
|
|
24777
|
+
const offset = pageOffset(query.offset);
|
|
24778
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
24735
24779
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
24736
24780
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
24737
24781
|
const rows = allRows(
|
|
@@ -24746,11 +24790,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
24746
24790
|
FROM secret_vault v
|
|
24747
24791
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
24748
24792
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
24749
|
-
LIMIT :limit`
|
|
24793
|
+
LIMIT :limit OFFSET :offset`
|
|
24750
24794
|
),
|
|
24751
24795
|
bindParams({
|
|
24752
24796
|
now,
|
|
24753
24797
|
limit: limit + 1,
|
|
24798
|
+
offset,
|
|
24754
24799
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
24755
24800
|
})
|
|
24756
24801
|
);
|
|
@@ -24775,7 +24820,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
24775
24820
|
*/
|
|
24776
24821
|
listDerefs(query = {}) {
|
|
24777
24822
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
24778
|
-
const
|
|
24823
|
+
const offset = pageOffset(query.offset);
|
|
24824
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
24779
24825
|
const conditions = [];
|
|
24780
24826
|
if (query.includeBatched !== true) {
|
|
24781
24827
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -24788,21 +24834,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
24788
24834
|
this.db.prepare(
|
|
24789
24835
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
24790
24836
|
FROM secret_vault_deref ${where}
|
|
24791
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
24837
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
24792
24838
|
),
|
|
24793
24839
|
bindParams({
|
|
24794
24840
|
limit: limit + 1,
|
|
24841
|
+
offset,
|
|
24795
24842
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
24796
24843
|
})
|
|
24797
24844
|
);
|
|
24798
24845
|
const hasMore = rows.length > limit;
|
|
24799
24846
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
24800
24847
|
const last = page[page.length - 1];
|
|
24801
|
-
const
|
|
24802
|
-
this.db
|
|
24803
|
-
|
|
24804
|
-
|
|
24848
|
+
const counts = getRow(
|
|
24849
|
+
this.db.prepare(
|
|
24850
|
+
`SELECT count(*) AS total,
|
|
24851
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
24852
|
+
FROM secret_vault_deref`
|
|
24853
|
+
)
|
|
24854
|
+
) ?? { total: 0, hidden: 0 };
|
|
24855
|
+
const includeBatched = query.includeBatched === true;
|
|
24856
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
24805
24857
|
return {
|
|
24858
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
24806
24859
|
items: page.map((r) => ({
|
|
24807
24860
|
id: r.id,
|
|
24808
24861
|
pointerId: r.pointer_id,
|
|
@@ -24827,6 +24880,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
24827
24880
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
24828
24881
|
);
|
|
24829
24882
|
}
|
|
24883
|
+
/**
|
|
24884
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
24885
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
24886
|
+
* every row.
|
|
24887
|
+
*
|
|
24888
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
24889
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
24890
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
24891
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
24892
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
24893
|
+
*
|
|
24894
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
24895
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
24896
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
24897
|
+
*
|
|
24898
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
24899
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
24900
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
24901
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
24902
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
24903
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
24904
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
24905
|
+
*/
|
|
24906
|
+
countFingerprintEpochs(currentVersion) {
|
|
24907
|
+
const row = getRow(
|
|
24908
|
+
this.db.prepare(
|
|
24909
|
+
`SELECT COUNT(*) AS total,
|
|
24910
|
+
COALESCE(
|
|
24911
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
24912
|
+
0
|
|
24913
|
+
) AS stale
|
|
24914
|
+
FROM secret_vault`
|
|
24915
|
+
),
|
|
24916
|
+
{ currentVersion }
|
|
24917
|
+
) ?? { stale: 0, total: 0 };
|
|
24918
|
+
return { stale: row.stale, total: row.total };
|
|
24919
|
+
}
|
|
24830
24920
|
};
|
|
24831
24921
|
|
|
24832
24922
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -26625,13 +26715,22 @@ var SecretVault = class {
|
|
|
26625
26715
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
26626
26716
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
26627
26717
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
26718
|
+
*
|
|
26719
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
26720
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
26721
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
26722
|
+
* than a bare success count.
|
|
26628
26723
|
*/
|
|
26629
26724
|
async refreshFingerprints(next) {
|
|
26630
26725
|
let refreshed = 0;
|
|
26726
|
+
let skipped = 0;
|
|
26631
26727
|
for (const row of this.#repo.listAll()) {
|
|
26632
26728
|
try {
|
|
26633
26729
|
const raw = await this.#openRow(row);
|
|
26634
|
-
if (raw === null)
|
|
26730
|
+
if (raw === null) {
|
|
26731
|
+
skipped += 1;
|
|
26732
|
+
continue;
|
|
26733
|
+
}
|
|
26635
26734
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
26636
26735
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
26637
26736
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -26639,10 +26738,10 @@ var SecretVault = class {
|
|
|
26639
26738
|
});
|
|
26640
26739
|
refreshed += 1;
|
|
26641
26740
|
} catch {
|
|
26642
|
-
|
|
26741
|
+
skipped += 1;
|
|
26643
26742
|
}
|
|
26644
26743
|
}
|
|
26645
|
-
return refreshed;
|
|
26744
|
+
return { refreshed, skipped };
|
|
26646
26745
|
}
|
|
26647
26746
|
/**
|
|
26648
26747
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -27981,6 +28080,21 @@ function registerPack(pack) {
|
|
|
27981
28080
|
function getLoadedRules() {
|
|
27982
28081
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
27983
28082
|
}
|
|
28083
|
+
function outsideWrittenRegions(candidates, context) {
|
|
28084
|
+
const regions = context?.writtenRegions;
|
|
28085
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
28086
|
+
return candidates.filter((c) => {
|
|
28087
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
28088
|
+
const { start, end } = c.match.span;
|
|
28089
|
+
return !regions.some(
|
|
28090
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
28091
|
+
c.rule,
|
|
28092
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
28093
|
+
"code_change"
|
|
28094
|
+
)
|
|
28095
|
+
);
|
|
28096
|
+
});
|
|
28097
|
+
}
|
|
27984
28098
|
function spansOverlap(a, b) {
|
|
27985
28099
|
return a.start < b.end && a.end > b.start;
|
|
27986
28100
|
}
|
|
@@ -28168,17 +28282,20 @@ function scanEncoded(text2, ruleset, context) {
|
|
|
28168
28282
|
function scanText(text2, ruleset, context) {
|
|
28169
28283
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
28170
28284
|
const normalization = normalizeFormatChars(text2);
|
|
28171
|
-
const originalCandidates =
|
|
28285
|
+
const originalCandidates = outsideWrittenRegions(
|
|
28286
|
+
buildCandidates(text2, ruleset, extension, context?.eventKind),
|
|
28287
|
+
context
|
|
28288
|
+
);
|
|
28172
28289
|
if (!normalization) return gate(originalCandidates, text2, void 0);
|
|
28173
28290
|
const pooledOriginal = originalCandidates.map(
|
|
28174
28291
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
28175
28292
|
);
|
|
28176
|
-
const normalizedCandidates =
|
|
28177
|
-
normalization.normalized,
|
|
28178
|
-
|
|
28179
|
-
|
|
28180
|
-
context
|
|
28181
|
-
)
|
|
28293
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
28294
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
28295
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text2)
|
|
28296
|
+
),
|
|
28297
|
+
context
|
|
28298
|
+
);
|
|
28182
28299
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text2, normalization);
|
|
28183
28300
|
return mergeOverlappingSameRule(findings, text2);
|
|
28184
28301
|
}
|
|
@@ -28239,6 +28356,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
28239
28356
|
"code-flaws/sql-inject-concat-dot",
|
|
28240
28357
|
"code-flaws/sql-inject-format",
|
|
28241
28358
|
"code-flaws/sql-inject-interp",
|
|
28359
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
28242
28360
|
"code-flaws/ssrf-user-url",
|
|
28243
28361
|
"code-flaws/xss-dangerously-set",
|
|
28244
28362
|
"code-flaws/xss-inner-html",
|
|
@@ -29531,7 +29649,7 @@ var sql_inject_concat_dot_default = {
|
|
|
29531
29649
|
severity: "high",
|
|
29532
29650
|
matcher: {
|
|
29533
29651
|
type: "regex",
|
|
29534
|
-
pattern:
|
|
29652
|
+
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*\\.",
|
|
29535
29653
|
flags: "gi"
|
|
29536
29654
|
},
|
|
29537
29655
|
appliesTo: {
|
|
@@ -29549,7 +29667,7 @@ var sql_inject_concat_default = {
|
|
|
29549
29667
|
severity: "high",
|
|
29550
29668
|
matcher: {
|
|
29551
29669
|
type: "regex",
|
|
29552
|
-
pattern:
|
|
29670
|
+
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*\\+",
|
|
29553
29671
|
flags: "gi"
|
|
29554
29672
|
},
|
|
29555
29673
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -29564,7 +29682,7 @@ var sql_inject_format_default = {
|
|
|
29564
29682
|
severity: "high",
|
|
29565
29683
|
matcher: {
|
|
29566
29684
|
type: "regex",
|
|
29567
|
-
pattern:
|
|
29685
|
+
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]+\\})",
|
|
29568
29686
|
flags: "gi"
|
|
29569
29687
|
},
|
|
29570
29688
|
examples: [
|
|
@@ -29573,6 +29691,24 @@ var sql_inject_format_default = {
|
|
|
29573
29691
|
]
|
|
29574
29692
|
};
|
|
29575
29693
|
|
|
29694
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
29695
|
+
var sql_inject_interp_multiline_default = {
|
|
29696
|
+
specVersion: 1,
|
|
29697
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
29698
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
29699
|
+
category: "code_flaw",
|
|
29700
|
+
severity: "high",
|
|
29701
|
+
matcher: {
|
|
29702
|
+
type: "regex",
|
|
29703
|
+
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_])',
|
|
29704
|
+
flags: "gi"
|
|
29705
|
+
},
|
|
29706
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
29707
|
+
appliesTo: {
|
|
29708
|
+
extensions: [".rb", ".php"]
|
|
29709
|
+
}
|
|
29710
|
+
};
|
|
29711
|
+
|
|
29576
29712
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
29577
29713
|
var sql_inject_interp_default = {
|
|
29578
29714
|
specVersion: 1,
|
|
@@ -29582,7 +29718,7 @@ var sql_inject_interp_default = {
|
|
|
29582
29718
|
severity: "high",
|
|
29583
29719
|
matcher: {
|
|
29584
29720
|
type: "regex",
|
|
29585
|
-
pattern: "([\
|
|
29721
|
+
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_])',
|
|
29586
29722
|
flags: "gi"
|
|
29587
29723
|
},
|
|
29588
29724
|
examples: [
|
|
@@ -31310,12 +31446,13 @@ var BUNDLED_PACKS = [
|
|
|
31310
31446
|
{
|
|
31311
31447
|
packId: "code-flaws",
|
|
31312
31448
|
name: "Code Security Flaws",
|
|
31313
|
-
version: "0.1.
|
|
31449
|
+
version: "0.1.6",
|
|
31314
31450
|
rawRules: [
|
|
31315
31451
|
sql_inject_concat_default,
|
|
31316
31452
|
sql_inject_concat_dot_default,
|
|
31317
31453
|
sql_inject_format_default,
|
|
31318
31454
|
sql_inject_interp_default,
|
|
31455
|
+
sql_inject_interp_multiline_default,
|
|
31319
31456
|
cmd_inject_shell_default,
|
|
31320
31457
|
cmd_inject_exec_default,
|
|
31321
31458
|
cmd_inject_node_exec_default,
|
|
@@ -31347,6 +31484,7 @@ var BUNDLED_PACKS = [
|
|
|
31347
31484
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
31348
31485
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
31349
31486
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
31487
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
31350
31488
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
31351
31489
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
31352
31490
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -31697,7 +31835,7 @@ function resolveProviderSafe(resolveProviderFn) {
|
|
|
31697
31835
|
}
|
|
31698
31836
|
|
|
31699
31837
|
// ../../packages/plugin-sdk/src/config-inventory.ts
|
|
31700
|
-
import { readdirSync as readdirSync3,
|
|
31838
|
+
import { readdirSync as readdirSync3, realpathSync as realpathSync2, statSync as statSync8 } from "fs";
|
|
31701
31839
|
import { homedir as homedir3 } from "os";
|
|
31702
31840
|
import { basename as basename4, join as join25, resolve as resolve3 } from "path";
|
|
31703
31841
|
|
|
@@ -32070,8 +32208,25 @@ function maskText(text2) {
|
|
|
32070
32208
|
return scanText2(text2).masked;
|
|
32071
32209
|
}
|
|
32072
32210
|
|
|
32211
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
32212
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
32213
|
+
function notRegularFile(path) {
|
|
32214
|
+
return `not a regular file: ${path}`;
|
|
32215
|
+
}
|
|
32216
|
+
function readRegularFile(path, maxBytes) {
|
|
32217
|
+
const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
32218
|
+
try {
|
|
32219
|
+
const stat2 = fstatSync(fd);
|
|
32220
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path));
|
|
32221
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
|
|
32222
|
+
return readFileSync16(fd, "utf8");
|
|
32223
|
+
} finally {
|
|
32224
|
+
closeSync2(fd);
|
|
32225
|
+
}
|
|
32226
|
+
}
|
|
32227
|
+
|
|
32073
32228
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
32074
|
-
import { existsSync as existsSync9,
|
|
32229
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
32075
32230
|
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
32076
32231
|
function remoteWithoutCredentials(remote) {
|
|
32077
32232
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -32242,9 +32397,10 @@ function resolveGitContext(root) {
|
|
|
32242
32397
|
const headRoot = basename3(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
32243
32398
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
32244
32399
|
}
|
|
32400
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
32245
32401
|
function safeRead(path) {
|
|
32246
32402
|
try {
|
|
32247
|
-
return
|
|
32403
|
+
return readRegularFile(path, MAX_GIT_METADATA_BYTES);
|
|
32248
32404
|
} catch {
|
|
32249
32405
|
return void 0;
|
|
32250
32406
|
}
|
|
@@ -32535,9 +32691,13 @@ function collectConfigFiles(scan2, claudeDir, cwd) {
|
|
|
32535
32691
|
dirConfigFile(scan2, join25(cwd, ".claude", "commands"), "Slash commands", "command");
|
|
32536
32692
|
dirConfigFile(scan2, join25(cwd, ".claude", "agents"), "Subagents", "subagent");
|
|
32537
32693
|
}
|
|
32538
|
-
function configFileEntry(scan2, path, scope, kind) {
|
|
32694
|
+
function configFileEntry(scan2, path, scope, kind, nonFile) {
|
|
32539
32695
|
try {
|
|
32540
32696
|
const stat2 = statSync8(path);
|
|
32697
|
+
if (nonFile !== "keep" && !stat2.isFile()) {
|
|
32698
|
+
if (nonFile === "report") scan2.errors.push({ source: path, reason: notRegularFile(path) });
|
|
32699
|
+
return void 0;
|
|
32700
|
+
}
|
|
32541
32701
|
return { name: basename4(path), path, scope, kind, updatedAt: stat2.mtime.toISOString() };
|
|
32542
32702
|
} catch (err) {
|
|
32543
32703
|
if (!isAbsent(err)) scan2.errors.push({ source: path, reason: message(err) });
|
|
@@ -32545,7 +32705,7 @@ function configFileEntry(scan2, path, scope, kind) {
|
|
|
32545
32705
|
}
|
|
32546
32706
|
}
|
|
32547
32707
|
function settingsConfigFile(scan2, path, scope, kind) {
|
|
32548
|
-
const entry = configFileEntry(scan2, path, scope, kind);
|
|
32708
|
+
const entry = configFileEntry(scan2, path, scope, kind, "skip");
|
|
32549
32709
|
if (!entry) return;
|
|
32550
32710
|
const raw = readOptional(scan2, path, false);
|
|
32551
32711
|
if (raw !== void 0) {
|
|
@@ -32563,7 +32723,7 @@ function settingsConfigFile(scan2, path, scope, kind) {
|
|
|
32563
32723
|
scan2.configFiles.push(entry);
|
|
32564
32724
|
}
|
|
32565
32725
|
function memoryConfigFile(scan2, path, scope, kind) {
|
|
32566
|
-
const entry = configFileEntry(scan2, path, scope, kind);
|
|
32726
|
+
const entry = configFileEntry(scan2, path, scope, kind, "report");
|
|
32567
32727
|
if (!entry) return;
|
|
32568
32728
|
const raw = readOptional(scan2, path);
|
|
32569
32729
|
if (raw !== void 0) {
|
|
@@ -32574,7 +32734,7 @@ function memoryConfigFile(scan2, path, scope, kind) {
|
|
|
32574
32734
|
scan2.configFiles.push(entry);
|
|
32575
32735
|
}
|
|
32576
32736
|
function mcpJsonConfigFile(scan2, path) {
|
|
32577
|
-
const entry = configFileEntry(scan2, path, "project", "MCP servers");
|
|
32737
|
+
const entry = configFileEntry(scan2, path, "project", "MCP servers", "skip");
|
|
32578
32738
|
if (!entry) return;
|
|
32579
32739
|
const raw = readOptional(scan2, path, false);
|
|
32580
32740
|
if (raw !== void 0) {
|
|
@@ -32594,7 +32754,7 @@ function mcpJsonConfigFile(scan2, path) {
|
|
|
32594
32754
|
scan2.configFiles.push(entry);
|
|
32595
32755
|
}
|
|
32596
32756
|
function dirConfigFile(scan2, path, kind, noun) {
|
|
32597
|
-
const entry = configFileEntry(scan2, path, "project", kind);
|
|
32757
|
+
const entry = configFileEntry(scan2, path, "project", kind, "keep");
|
|
32598
32758
|
if (!entry) return;
|
|
32599
32759
|
try {
|
|
32600
32760
|
const count = countMarkdownFiles(path, 0);
|
|
@@ -32790,7 +32950,7 @@ function dedupeMcpServers(servers) {
|
|
|
32790
32950
|
}
|
|
32791
32951
|
function readOptional(scan2, path, record2 = true) {
|
|
32792
32952
|
try {
|
|
32793
|
-
return
|
|
32953
|
+
return readRegularFile(path);
|
|
32794
32954
|
} catch (err) {
|
|
32795
32955
|
if (record2 && !isAbsent(err)) scan2.errors.push({ source: path, reason: message(err) });
|
|
32796
32956
|
return void 0;
|
|
@@ -33070,6 +33230,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
33070
33230
|
text: text2,
|
|
33071
33231
|
filePath: context?.filePath,
|
|
33072
33232
|
eventKind: context?.eventKind,
|
|
33233
|
+
writtenRegions: context?.writtenRegions,
|
|
33073
33234
|
attribute: scanOpts?.attribute === true
|
|
33074
33235
|
}),
|
|
33075
33236
|
reply: (message2) => {
|
|
@@ -33368,7 +33529,7 @@ function createGuardedScanner(partition, gateway, opts) {
|
|
|
33368
33529
|
}
|
|
33369
33530
|
|
|
33370
33531
|
// ../../packages/plugin-sdk/src/hook-fail-opens.ts
|
|
33371
|
-
import { readFileSync as
|
|
33532
|
+
import { readFileSync as readFileSync17 } from "fs";
|
|
33372
33533
|
import { join as join26 } from "path";
|
|
33373
33534
|
var HOOK_FAIL_OPENS_FILENAME = "hook-fail-opens.json";
|
|
33374
33535
|
function hookFailOpensPath(dataDir2) {
|
|
@@ -33391,7 +33552,7 @@ function recordHookFailOpen(dataDir2, nowMs) {
|
|
|
33391
33552
|
}
|
|
33392
33553
|
function readHookFailOpens(dataDir2) {
|
|
33393
33554
|
try {
|
|
33394
|
-
const parsed2 = JSON.parse(
|
|
33555
|
+
const parsed2 = JSON.parse(readFileSync17(hookFailOpensPath(dataDir2), "utf8"));
|
|
33395
33556
|
if (typeof parsed2 !== "object" || parsed2 === null) return null;
|
|
33396
33557
|
const record2 = parsed2;
|
|
33397
33558
|
if (!isPositiveSafeInteger(record2.failOpens)) return null;
|
|
@@ -33407,11 +33568,10 @@ function isPositiveSafeInteger(value) {
|
|
|
33407
33568
|
|
|
33408
33569
|
// ../../packages/plugin-sdk/src/ignore-layers.ts
|
|
33409
33570
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
33410
|
-
import { readFileSync as readFileSync19 } from "fs";
|
|
33411
33571
|
import { join as join27 } from "path";
|
|
33412
33572
|
function readIgnoreLayer(dir, filename, anchorLen) {
|
|
33413
33573
|
try {
|
|
33414
|
-
return { matcher: (0, import_ignore.default)().add(
|
|
33574
|
+
return { matcher: (0, import_ignore.default)().add(readRegularFile(join27(dir, filename))), anchorLen };
|
|
33415
33575
|
} catch {
|
|
33416
33576
|
return void 0;
|
|
33417
33577
|
}
|
|
@@ -33468,7 +33628,7 @@ function resolveInventoryContext(input) {
|
|
|
33468
33628
|
}
|
|
33469
33629
|
|
|
33470
33630
|
// ../../packages/plugin-sdk/src/nudge.ts
|
|
33471
|
-
import { mkdirSync as mkdirSync2, readFileSync as
|
|
33631
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync18, writeFileSync as writeFileSync5 } from "fs";
|
|
33472
33632
|
import { join as join28 } from "path";
|
|
33473
33633
|
var SESSION_START_MARKER = "session-start-last";
|
|
33474
33634
|
function claimSessionStart(dataDir2, sessionId) {
|
|
@@ -33480,7 +33640,7 @@ function claimOncePerSession(dataDir2, marker, sessionId) {
|
|
|
33480
33640
|
const path = join28(dataDir2, marker);
|
|
33481
33641
|
let recent = [];
|
|
33482
33642
|
try {
|
|
33483
|
-
recent =
|
|
33643
|
+
recent = readFileSync18(path, "utf8").split("\n").filter(Boolean);
|
|
33484
33644
|
if (recent.includes(sessionId)) return false;
|
|
33485
33645
|
} catch {
|
|
33486
33646
|
}
|
|
@@ -34884,7 +35044,7 @@ function sessionToolIsKeyed(tool) {
|
|
|
34884
35044
|
|
|
34885
35045
|
// ../../packages/plugin-runtime/src/attached/config-inventory-sync.ts
|
|
34886
35046
|
import { createHash as createHash11 } from "crypto";
|
|
34887
|
-
import { readFileSync as
|
|
35047
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
34888
35048
|
import { join as join35 } from "path";
|
|
34889
35049
|
|
|
34890
35050
|
// ../../packages/plugin-runtime/src/attached/config-inventory-wire.ts
|
|
@@ -34984,7 +35144,7 @@ async function publishByRename(tmp, file, move = rename2) {
|
|
|
34984
35144
|
|
|
34985
35145
|
// ../../packages/plugin-runtime/src/attached/capture-settings.ts
|
|
34986
35146
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
34987
|
-
import { readFileSync as
|
|
35147
|
+
import { readFileSync as readFileSync19 } from "fs";
|
|
34988
35148
|
import { rm, writeFile as writeFile2 } from "fs/promises";
|
|
34989
35149
|
import { join as join33 } from "path";
|
|
34990
35150
|
var HookCaptureSettingsSchema = CaptureSettings.pick({
|
|
@@ -35372,7 +35532,7 @@ function reportKey(request) {
|
|
|
35372
35532
|
function readStagedEntries(dataDir2) {
|
|
35373
35533
|
let parsed2;
|
|
35374
35534
|
try {
|
|
35375
|
-
parsed2 = JSON.parse(
|
|
35535
|
+
parsed2 = JSON.parse(readFileSync20(stagedConfigInventoryPath(dataDir2), "utf8"));
|
|
35376
35536
|
} catch {
|
|
35377
35537
|
return [];
|
|
35378
35538
|
}
|
|
@@ -35396,7 +35556,7 @@ function isTimestamp(value) {
|
|
|
35396
35556
|
}
|
|
35397
35557
|
|
|
35398
35558
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
35399
|
-
import { readFileSync as
|
|
35559
|
+
import { readFileSync as readFileSync21 } from "fs";
|
|
35400
35560
|
import { join as join36 } from "path";
|
|
35401
35561
|
var FORWARD_DROPS_FILENAME = ATTACHED_FORWARD_DROPS_FILENAME;
|
|
35402
35562
|
function forwardDropsPath(dataDir2) {
|
|
@@ -35418,7 +35578,7 @@ function recordForwardDrops(dataDir2, count, nowMs) {
|
|
|
35418
35578
|
}
|
|
35419
35579
|
function readForwardDrops(dataDir2) {
|
|
35420
35580
|
try {
|
|
35421
|
-
const parsed2 = JSON.parse(
|
|
35581
|
+
const parsed2 = JSON.parse(readFileSync21(forwardDropsPath(dataDir2), "utf8"));
|
|
35422
35582
|
if (typeof parsed2 !== "object" || parsed2 === null) return null;
|
|
35423
35583
|
const record2 = parsed2;
|
|
35424
35584
|
if (typeof record2.droppedForwards !== "number" || !Number.isFinite(record2.droppedForwards)) {
|
|
@@ -36522,7 +36682,7 @@ function toWireInspection(insp, nameKey) {
|
|
|
36522
36682
|
}
|
|
36523
36683
|
|
|
36524
36684
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
36525
|
-
import { readFileSync as
|
|
36685
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
36526
36686
|
|
|
36527
36687
|
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
36528
36688
|
import { readFile as readFile3, stat } from "fs/promises";
|
|
@@ -36575,7 +36735,7 @@ function readManifestBuild(manifestUrl, packageName) {
|
|
|
36575
36735
|
if (!manifestBuildCache.has(key)) {
|
|
36576
36736
|
let build;
|
|
36577
36737
|
try {
|
|
36578
|
-
const manifest = JSON.parse(
|
|
36738
|
+
const manifest = JSON.parse(readFileSync22(manifestUrl, "utf8"));
|
|
36579
36739
|
build = typeof manifest.version === "string" && manifest.version.length > 0 ? { package: packageName, version: manifest.version } : void 0;
|
|
36580
36740
|
} catch {
|
|
36581
36741
|
build = void 0;
|
|
@@ -36610,7 +36770,7 @@ async function readInstalledVersionBounded(installRoot) {
|
|
|
36610
36770
|
}
|
|
36611
36771
|
|
|
36612
36772
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
36613
|
-
import { readFileSync as
|
|
36773
|
+
import { readFileSync as readFileSync23 } from "fs";
|
|
36614
36774
|
import { join as join38 } from "path";
|
|
36615
36775
|
var POSTURE_REPORT_STATE_FILENAME = ATTACHED_POSTURE_REPORT_FILENAME;
|
|
36616
36776
|
var OUTCOME_KEYS = {
|
|
@@ -37006,21 +37166,21 @@ function codexHomeDir(home) {
|
|
|
37006
37166
|
|
|
37007
37167
|
// ../../packages/plugin-sdk/src/account/observation-log.ts
|
|
37008
37168
|
import { createHash as createHash12 } from "crypto";
|
|
37009
|
-
import { closeSync as
|
|
37169
|
+
import { closeSync as closeSync3, constants as constants2, fstatSync as fstatSync2, mkdirSync as mkdirSync4, openSync as openSync3, readSync, writeSync } from "fs";
|
|
37010
37170
|
import { join as join41 } from "path";
|
|
37011
37171
|
var SESSION_LOG_CAP_BYTES = 16 * 1024 * 1024;
|
|
37012
37172
|
var SESSION_LOG_TAIL_BYTES = 64 * 1024;
|
|
37013
37173
|
var NEWLINE = 10;
|
|
37014
37174
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
37015
37175
|
function sessionLogOpenFlags(noFollow) {
|
|
37016
|
-
return
|
|
37176
|
+
return constants2.O_WRONLY | constants2.O_APPEND | constants2.O_CREAT | (noFollow ?? 0);
|
|
37017
37177
|
}
|
|
37018
37178
|
var SESSION_LOG_OPEN_FLAGS = sessionLogOpenFlags(
|
|
37019
|
-
|
|
37179
|
+
constants2.O_NOFOLLOW
|
|
37020
37180
|
);
|
|
37021
37181
|
function closeQuietly2(fd) {
|
|
37022
37182
|
try {
|
|
37023
|
-
|
|
37183
|
+
closeSync3(fd);
|
|
37024
37184
|
} catch {
|
|
37025
37185
|
}
|
|
37026
37186
|
}
|
|
@@ -37043,8 +37203,8 @@ function appendObservation(stateDir, sessionId, observation, capBytes = SESSION_
|
|
|
37043
37203
|
let fd;
|
|
37044
37204
|
try {
|
|
37045
37205
|
mkdirSync4(stateDir, { recursive: true, mode: DATA_DIR_MODE });
|
|
37046
|
-
fd =
|
|
37047
|
-
if (
|
|
37206
|
+
fd = openSync3(sessionLogPath(stateDir, sessionId), openFlags, DATA_FILE_MODE);
|
|
37207
|
+
if (fstatSync2(fd).size + Buffer.byteLength(line) > capBytes) return false;
|
|
37048
37208
|
writeSync(fd, line);
|
|
37049
37209
|
return true;
|
|
37050
37210
|
} catch {
|
|
@@ -37074,12 +37234,12 @@ function parseLines(buffer, base) {
|
|
|
37074
37234
|
function readRange(path, from, capBytes) {
|
|
37075
37235
|
let fd;
|
|
37076
37236
|
try {
|
|
37077
|
-
fd =
|
|
37237
|
+
fd = openSync3(path, "r");
|
|
37078
37238
|
} catch {
|
|
37079
37239
|
return void 0;
|
|
37080
37240
|
}
|
|
37081
37241
|
try {
|
|
37082
|
-
const size =
|
|
37242
|
+
const size = fstatSync2(fd).size;
|
|
37083
37243
|
const length = Math.max(0, Math.min(size, capBytes) - from);
|
|
37084
37244
|
const buffer = Buffer.alloc(length);
|
|
37085
37245
|
let filled = 0;
|
|
@@ -37126,7 +37286,7 @@ function classifyObservation(observation) {
|
|
|
37126
37286
|
}
|
|
37127
37287
|
|
|
37128
37288
|
// ../../packages/plugin-sdk/src/account/codex-head.ts
|
|
37129
|
-
import { closeSync as
|
|
37289
|
+
import { closeSync as closeSync4, openSync as openSync4, readSync as readSync2 } from "fs";
|
|
37130
37290
|
var CODEX_HEAD_READ_BYTES = 64 * 1024;
|
|
37131
37291
|
var CODEX_HEAD_MAX_BYTES = 1024 * 1024;
|
|
37132
37292
|
var NEWLINE2 = 10;
|
|
@@ -37159,7 +37319,7 @@ function parseHead(line) {
|
|
|
37159
37319
|
function readCodexHead(rolloutPath) {
|
|
37160
37320
|
let fd;
|
|
37161
37321
|
try {
|
|
37162
|
-
fd =
|
|
37322
|
+
fd = openSync4(rolloutPath, "r");
|
|
37163
37323
|
} catch (error2) {
|
|
37164
37324
|
return isNotFound(error2) ? "pending" : void 0;
|
|
37165
37325
|
}
|
|
@@ -37184,14 +37344,14 @@ function readCodexHead(rolloutPath) {
|
|
|
37184
37344
|
return void 0;
|
|
37185
37345
|
} finally {
|
|
37186
37346
|
try {
|
|
37187
|
-
|
|
37347
|
+
closeSync4(fd);
|
|
37188
37348
|
} catch {
|
|
37189
37349
|
}
|
|
37190
37350
|
}
|
|
37191
37351
|
}
|
|
37192
37352
|
|
|
37193
37353
|
// ../../packages/plugin-sdk/src/account/codex-login.ts
|
|
37194
|
-
import { closeSync as
|
|
37354
|
+
import { closeSync as closeSync5, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync6, openSync as openSync5, readSync as readSync3 } from "fs";
|
|
37195
37355
|
import { join as join42 } from "path";
|
|
37196
37356
|
var CODEX_AUTH_MAX_BYTES = 64 * 1024;
|
|
37197
37357
|
var CODEX_ID_TOKEN_MAX_CHARS = 16 * 1024;
|
|
@@ -37224,8 +37384,8 @@ var DROPPED = new Set(CODEX_DROPPED_FIELDS);
|
|
|
37224
37384
|
var PRESENCE = new Set(CODEX_PRESENCE_FIELDS);
|
|
37225
37385
|
var BASE64URL = /^[A-Za-z0-9_-]+$/;
|
|
37226
37386
|
var UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
37227
|
-
var NOFOLLOW =
|
|
37228
|
-
var READ_FLAGS =
|
|
37387
|
+
var NOFOLLOW = constants3.O_NOFOLLOW ?? 0;
|
|
37388
|
+
var READ_FLAGS = constants3.O_RDONLY | NOFOLLOW;
|
|
37229
37389
|
var ABSENT = { status: "absent" };
|
|
37230
37390
|
var MODE = { status: "mode" };
|
|
37231
37391
|
var MALFORMED = { status: "malformed" };
|
|
@@ -37347,12 +37507,12 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform2 = process.pl
|
|
|
37347
37507
|
let fd;
|
|
37348
37508
|
try {
|
|
37349
37509
|
if (platform2 === "win32" && lstatSync6(path).isSymbolicLink()) return MALFORMED;
|
|
37350
|
-
fd =
|
|
37510
|
+
fd = openSync5(path, openFlags);
|
|
37351
37511
|
} catch (error2) {
|
|
37352
37512
|
return isNotFound2(error2) ? ABSENT : MALFORMED;
|
|
37353
37513
|
}
|
|
37354
37514
|
try {
|
|
37355
|
-
const stat2 =
|
|
37515
|
+
const stat2 = fstatSync3(fd);
|
|
37356
37516
|
if (!stat2.isFile() || stat2.size > CODEX_AUTH_MAX_BYTES) return MALFORMED;
|
|
37357
37517
|
if (platform2 !== "win32" && (stat2.uid !== process.getuid?.() || (stat2.mode & 18) !== 0)) {
|
|
37358
37518
|
return MALFORMED;
|
|
@@ -37364,7 +37524,7 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform2 = process.pl
|
|
|
37364
37524
|
return MALFORMED;
|
|
37365
37525
|
} finally {
|
|
37366
37526
|
try {
|
|
37367
|
-
|
|
37527
|
+
closeSync5(fd);
|
|
37368
37528
|
} catch {
|
|
37369
37529
|
}
|
|
37370
37530
|
}
|
|
@@ -37561,11 +37721,11 @@ function codexHookAccount(input) {
|
|
|
37561
37721
|
}
|
|
37562
37722
|
|
|
37563
37723
|
// ../../packages/plugin-runtime/src/attached/label-drops.ts
|
|
37564
|
-
import { readFileSync as
|
|
37724
|
+
import { readFileSync as readFileSync24 } from "fs";
|
|
37565
37725
|
import { join as join43 } from "path";
|
|
37566
37726
|
|
|
37567
37727
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
37568
|
-
import { readFileSync as
|
|
37728
|
+
import { readFileSync as readFileSync25 } from "fs";
|
|
37569
37729
|
import { join as join44 } from "path";
|
|
37570
37730
|
|
|
37571
37731
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
@@ -38236,11 +38396,11 @@ import { fileURLToPath as fileURLToPath5 } from "url";
|
|
|
38236
38396
|
// src/history/tail.ts
|
|
38237
38397
|
import { createHash as createHash13 } from "crypto";
|
|
38238
38398
|
import {
|
|
38239
|
-
closeSync as
|
|
38240
|
-
fstatSync as
|
|
38399
|
+
closeSync as closeSync6,
|
|
38400
|
+
fstatSync as fstatSync4,
|
|
38241
38401
|
mkdirSync as mkdirSync5,
|
|
38242
|
-
openSync as
|
|
38243
|
-
readFileSync as
|
|
38402
|
+
openSync as openSync6,
|
|
38403
|
+
readFileSync as readFileSync26,
|
|
38244
38404
|
readSync as readSync4,
|
|
38245
38405
|
writeFileSync as writeFileSync7
|
|
38246
38406
|
} from "fs";
|
|
@@ -38276,7 +38436,7 @@ function spawnWorker(args) {
|
|
|
38276
38436
|
}
|
|
38277
38437
|
|
|
38278
38438
|
// src/history/transcripts.ts
|
|
38279
|
-
import { readdirSync as readdirSync6, readFileSync as
|
|
38439
|
+
import { readdirSync as readdirSync6, readFileSync as readFileSync27, statSync as statSync13 } from "fs";
|
|
38280
38440
|
import { homedir as homedir5 } from "os";
|
|
38281
38441
|
import { join as join48 } from "path";
|
|
38282
38442
|
function peekSessionOriginator(transcriptPath) {
|
|
@@ -38287,7 +38447,7 @@ var DAY_MS5 = 24 * 60 * 60 * 1e3;
|
|
|
38287
38447
|
|
|
38288
38448
|
// src/protocol/marker.ts
|
|
38289
38449
|
import { randomBytes as randomBytes6 } from "crypto";
|
|
38290
|
-
import { mkdirSync as mkdirSync6, readFileSync as
|
|
38450
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync28, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "fs";
|
|
38291
38451
|
import { join as join49 } from "path";
|
|
38292
38452
|
var MARKER_FILE = "protocol-marker";
|
|
38293
38453
|
function mintMarker() {
|
|
@@ -38297,7 +38457,7 @@ function sessionProtocolMarker(dataDir2, sessionId) {
|
|
|
38297
38457
|
if (!sessionId) return mintMarker();
|
|
38298
38458
|
const path = join49(dataDir2, MARKER_FILE);
|
|
38299
38459
|
try {
|
|
38300
|
-
const stored = JSON.parse(
|
|
38460
|
+
const stored = JSON.parse(readFileSync28(path, "utf8"));
|
|
38301
38461
|
if (stored.sessionId === sessionId && typeof stored.marker === "string" && /^[0-9a-f]{16}$/.test(stored.marker)) {
|
|
38302
38462
|
return stored.marker;
|
|
38303
38463
|
}
|
|
@@ -38471,7 +38631,7 @@ async function codexSessionStartAccount(config2, input) {
|
|
|
38471
38631
|
}
|
|
38472
38632
|
|
|
38473
38633
|
// src/hooks/store-health.ts
|
|
38474
|
-
import { mkdirSync as mkdirSync7, readFileSync as
|
|
38634
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync29, writeFileSync as writeFileSync9 } from "fs";
|
|
38475
38635
|
import { dirname as dirname12, join as join50 } from "path";
|
|
38476
38636
|
var STORE_REDIRECT_MARKER = "store-redirect-last-session";
|
|
38477
38637
|
var RECENT_SESSIONS2 = 32;
|
|
@@ -38491,7 +38651,7 @@ function alreadyClaimed(dirs, marker, sessionId) {
|
|
|
38491
38651
|
}
|
|
38492
38652
|
function readRecent(dir, marker) {
|
|
38493
38653
|
try {
|
|
38494
|
-
return
|
|
38654
|
+
return readFileSync29(join50(dir, marker), "utf8").split("\n").filter(Boolean);
|
|
38495
38655
|
} catch {
|
|
38496
38656
|
return [];
|
|
38497
38657
|
}
|
|
@@ -38546,7 +38706,7 @@ function harnessVersion() {
|
|
|
38546
38706
|
const manifestPath = process.argv[2];
|
|
38547
38707
|
if (!manifestPath) return void 0;
|
|
38548
38708
|
try {
|
|
38549
|
-
const manifest = JSON.parse(
|
|
38709
|
+
const manifest = JSON.parse(readFileSync30(manifestPath, "utf8"));
|
|
38550
38710
|
return typeof manifest.version === "string" ? manifest.version : void 0;
|
|
38551
38711
|
} catch {
|
|
38552
38712
|
return void 0;
|