@akasecurity/ai-tc-codex 0.9.14 → 0.9.15
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 +4 -4
- package/scripts/apply-suppressions.js +366 -80
- package/scripts/backfill.js +470 -121
- package/scripts/content-retention.js +184 -55
- package/scripts/filescan.js +470 -121
- package/scripts/firstrun.js +256 -81
- package/scripts/history-sync.js +190 -61
- package/scripts/intro.js +59 -10
- package/scripts/onboard.js +164 -43
- package/scripts/post-tool-use.js +514 -124
- package/scripts/pre-tool-use.js +514 -124
- package/scripts/query.js +255 -80
- package/scripts/reconcile.js +451 -111
- package/scripts/remediate.js +471 -122
- package/scripts/scan-worker.js +241 -34
- package/scripts/session-start.js +507 -126
- package/scripts/start-light.js +59 -10
- package/scripts/stop.js +147 -29
- package/scripts/sync.js +473 -124
- package/scripts/user-prompt-submit.js +514 -124
package/scripts/start-light.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.10/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.10/node_modules/ignore/index.js"(exports, module) {
|
|
38
38
|
"use strict";
|
|
39
39
|
function makeArray(subject) {
|
|
40
40
|
return Array.isArray(subject) ? subject : [subject];
|
|
@@ -429,6 +429,13 @@ var require_ignore = __commonJS({
|
|
|
429
429
|
}
|
|
430
430
|
};
|
|
431
431
|
var WILDCARD = "[^\\/]*";
|
|
432
|
+
var separatorAfter = (run, at) => {
|
|
433
|
+
let separator = EMPTY;
|
|
434
|
+
for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
|
|
435
|
+
separator += run[index].single;
|
|
436
|
+
}
|
|
437
|
+
return separator;
|
|
438
|
+
};
|
|
432
439
|
var pinWildcards = (source) => {
|
|
433
440
|
if (source.indexOf(WILDCARD) < 0) {
|
|
434
441
|
return source;
|
|
@@ -498,7 +505,7 @@ var require_ignore = __commonJS({
|
|
|
498
505
|
out += token.single;
|
|
499
506
|
return;
|
|
500
507
|
}
|
|
501
|
-
out += at === lastWildcard ? WILDCARD : `(?:(?!${run
|
|
508
|
+
out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
|
|
502
509
|
});
|
|
503
510
|
run = [];
|
|
504
511
|
};
|
|
@@ -22985,7 +22992,29 @@ var StorePosturePlugin = external_exports.object({
|
|
|
22985
22992
|
*/
|
|
22986
22993
|
policyBundleVersion: external_exports.string().max(200).nullable(),
|
|
22987
22994
|
/** Epoch millis, on the CLIENT clock, of that fetch. */
|
|
22988
|
-
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
|
|
22995
|
+
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
22996
|
+
/**
|
|
22997
|
+
* The newest version the host's own install record holds for this plugin —
|
|
22998
|
+
* what is on disk. After an update it leads `version` (the running copy) by
|
|
22999
|
+
* one launch. Null when no usable version can be read: no install record
|
|
23000
|
+
* (a plugin run from a checkout), no entry with a valid version, or every
|
|
23001
|
+
* such entry names an `installPath` that no longer exists; OPTIONAL, not
|
|
23002
|
+
* required, so a build that predates the member keeps getting its 200.
|
|
23003
|
+
* Bounded like `version`.
|
|
23004
|
+
*/
|
|
23005
|
+
installedVersion: external_exports.string().max(64).nullable().optional(),
|
|
23006
|
+
/**
|
|
23007
|
+
* The local-store schema version this running build migrates a store to:
|
|
23008
|
+
* the number of store migrations it carries, the count it stamps into
|
|
23009
|
+
* `PRAGMA user_version`. A snapshot whose `schemaVersion` is above it
|
|
23010
|
+
* usually describes a store a newer build migrated. It is a hint, not a
|
|
23011
|
+
* verdict: the stamp is write-only, so a store whose count ran past this
|
|
23012
|
+
* build's while this build knows every migration in its ledger reads above
|
|
23013
|
+
* it too, which is why describeStoreSkew decides skew on ledger tags and
|
|
23014
|
+
* never on the count. OPTIONAL for the same reason as `installedVersion`;
|
|
23015
|
+
* bounded like `schemaVersion`.
|
|
23016
|
+
*/
|
|
23017
|
+
buildSchemaVersion: external_exports.number().int().min(0).max(MAX_INT4).optional()
|
|
22989
23018
|
}).meta({ id: "StorePosturePlugin" });
|
|
22990
23019
|
var StorePostureSnapshot = external_exports.object({
|
|
22991
23020
|
deviceId: external_exports.guid(),
|
|
@@ -23969,10 +23998,15 @@ var ParsedPointer = external_exports.object({
|
|
|
23969
23998
|
});
|
|
23970
23999
|
var VaultEntry = external_exports.object({
|
|
23971
24000
|
pointerId: external_exports.string(),
|
|
23972
|
-
// The keyed HMAC of the raw
|
|
23973
|
-
// derived under.
|
|
23974
|
-
// independently of the vault encryption
|
|
24001
|
+
// The keyed HMAC of the EXACT raw bytes under `exception.key`, and the epoch it
|
|
24002
|
+
// was derived under. The vault's own dedupe key: a value and its invisibly
|
|
24003
|
+
// padded twin are two rows. It rotates independently of the vault encryption
|
|
24004
|
+
// key below. Never matched against an exception or grant.
|
|
23975
24005
|
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
24006
|
+
// The same HMAC over the raw with invisible padding removed: the identity a
|
|
24007
|
+
// reveal-to-model grant and every exception match on. Shared by a value and
|
|
24008
|
+
// its padded twin.
|
|
24009
|
+
valueIdentityFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
23976
24010
|
fingerprintKeyVersion: external_exports.number().int().positive(),
|
|
23977
24011
|
// The vault-key epoch this row's ciphertext was sealed under.
|
|
23978
24012
|
keyVersion: external_exports.number().int().positive(),
|
|
@@ -24414,10 +24448,18 @@ var SeveritySummaryItem = external_exports.object({
|
|
|
24414
24448
|
count: external_exports.number().int().nonnegative(),
|
|
24415
24449
|
// Resolution-aware breakdown (optional, additive). Populated once findings
|
|
24416
24450
|
// carry lifecycle state: `caught` = handled in-flight (enforced); `openAtRest`
|
|
24417
|
-
// = still open with no in-flight enforcement (needs remediation)
|
|
24418
|
-
//
|
|
24451
|
+
// = still open with no in-flight enforcement (needs remediation); `dismissed`
|
|
24452
|
+
// = closed by a human judgement rather than a fix — visible, but not counted as
|
|
24453
|
+
// needing remediation. The three are disjoint. Absent on the legacy count-only
|
|
24454
|
+
// response until the resolution feature lands.
|
|
24419
24455
|
caught: external_exports.number().int().nonnegative().optional(),
|
|
24420
|
-
openAtRest: external_exports.number().int().nonnegative().optional()
|
|
24456
|
+
openAtRest: external_exports.number().int().nonnegative().optional(),
|
|
24457
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
24458
|
+
// The two halves of `caught`, for a reader that wants them apart: `handled` =
|
|
24459
|
+
// in-flight findings an enforcement action already contained; `resolved` =
|
|
24460
|
+
// at-rest findings closed out by fixing them. `handled + resolved === caught`.
|
|
24461
|
+
handled: external_exports.number().int().nonnegative().optional(),
|
|
24462
|
+
resolved: external_exports.number().int().nonnegative().optional()
|
|
24421
24463
|
}).meta({ id: "SeveritySummaryItem" });
|
|
24422
24464
|
var SeveritySummaryResponse = external_exports.object({
|
|
24423
24465
|
// Sum of bySeverity[].count.
|
|
@@ -24425,6 +24467,9 @@ var SeveritySummaryResponse = external_exports.object({
|
|
|
24425
24467
|
// Findings still open at rest (sum of bySeverity[].openAtRest). Optional and
|
|
24426
24468
|
// additive — absent on the legacy response until the resolution feature lands.
|
|
24427
24469
|
needsRemediation: external_exports.number().int().nonnegative().optional(),
|
|
24470
|
+
// Findings a user dismissed (sum of bySeverity[].dismissed). Excluded from
|
|
24471
|
+
// needsRemediation, and kept visible here so an accepted risk is not erased.
|
|
24472
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
24428
24473
|
// All four severity levels are always present (count may be 0).
|
|
24429
24474
|
bySeverity: external_exports.array(SeveritySummaryItem)
|
|
24430
24475
|
}).meta({ id: "SeveritySummaryResponse" });
|
|
@@ -25734,6 +25779,10 @@ function escapeRegExp2(value) {
|
|
|
25734
25779
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25735
25780
|
}
|
|
25736
25781
|
|
|
25782
|
+
// ../../packages/detections/src/format-chars.ts
|
|
25783
|
+
var HAS_FORMAT_CHAR = new RegExp("\\p{Cf}", "u");
|
|
25784
|
+
var FORMAT_CHAR_GLOBAL = new RegExp("\\p{Cf}", "gu");
|
|
25785
|
+
|
|
25737
25786
|
// ../../packages/detections/src/regex-cache.ts
|
|
25738
25787
|
var singles = /* @__PURE__ */ new WeakMap();
|
|
25739
25788
|
var keywordLists = /* @__PURE__ */ new WeakMap();
|
package/scripts/stop.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.10/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.10/node_modules/ignore/index.js"(exports, module) {
|
|
38
38
|
"use strict";
|
|
39
39
|
function makeArray(subject) {
|
|
40
40
|
return Array.isArray(subject) ? subject : [subject];
|
|
@@ -429,6 +429,13 @@ var require_ignore = __commonJS({
|
|
|
429
429
|
}
|
|
430
430
|
};
|
|
431
431
|
var WILDCARD = "[^\\/]*";
|
|
432
|
+
var separatorAfter = (run, at) => {
|
|
433
|
+
let separator = EMPTY;
|
|
434
|
+
for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
|
|
435
|
+
separator += run[index].single;
|
|
436
|
+
}
|
|
437
|
+
return separator;
|
|
438
|
+
};
|
|
432
439
|
var pinWildcards = (source) => {
|
|
433
440
|
if (source.indexOf(WILDCARD) < 0) {
|
|
434
441
|
return source;
|
|
@@ -498,7 +505,7 @@ var require_ignore = __commonJS({
|
|
|
498
505
|
out += token.single;
|
|
499
506
|
return;
|
|
500
507
|
}
|
|
501
|
-
out += at === lastWildcard ? WILDCARD : `(?:(?!${run
|
|
508
|
+
out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
|
|
502
509
|
});
|
|
503
510
|
run = [];
|
|
504
511
|
};
|
|
@@ -675,13 +682,13 @@ var require_ignore = __commonJS({
|
|
|
675
682
|
const rules = this._rules;
|
|
676
683
|
const { length } = rules;
|
|
677
684
|
const shortcut = this._basenameCount * 2 >= length;
|
|
678
|
-
const
|
|
685
|
+
const basename7 = shortcut ? basenameOf(path) : path;
|
|
679
686
|
for (let index = 0; index < length; index++) {
|
|
680
687
|
const rule = rules[index];
|
|
681
688
|
const { negative } = rule;
|
|
682
689
|
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
683
690
|
if (!skip && rule[mode].test(
|
|
684
|
-
shortcut && rule._basenameOnly ?
|
|
691
|
+
shortcut && rule._basenameOnly ? basename7 : path
|
|
685
692
|
)) {
|
|
686
693
|
ignored = !negative;
|
|
687
694
|
unignored = negative;
|
|
@@ -5885,7 +5892,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
5885
5892
|
var NONE = 0;
|
|
5886
5893
|
var ASSUMED = 1;
|
|
5887
5894
|
var PROVEN = 2;
|
|
5888
|
-
function isRecursive(inst, stack,
|
|
5895
|
+
function isRecursive(inst, stack, resolve3) {
|
|
5889
5896
|
const cached2 = recursive.get(inst);
|
|
5890
5897
|
if (cached2 !== void 0)
|
|
5891
5898
|
return cached2 ? PROVEN : NONE;
|
|
@@ -5895,7 +5902,7 @@ function isRecursive(inst, stack, resolve2) {
|
|
|
5895
5902
|
let result = NONE;
|
|
5896
5903
|
const check2 = (child) => {
|
|
5897
5904
|
if (result !== PROVEN && child?._zod) {
|
|
5898
|
-
const answer = isRecursive(child, stack,
|
|
5905
|
+
const answer = isRecursive(child, stack, resolve3);
|
|
5899
5906
|
if (answer > result)
|
|
5900
5907
|
result = answer;
|
|
5901
5908
|
}
|
|
@@ -5906,7 +5913,7 @@ function isRecursive(inst, stack, resolve2) {
|
|
|
5906
5913
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
5907
5914
|
if (spread && !desc.enumerable)
|
|
5908
5915
|
continue;
|
|
5909
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
5916
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve3) : NONE;
|
|
5910
5917
|
if (child > answer)
|
|
5911
5918
|
answer = child;
|
|
5912
5919
|
}
|
|
@@ -5970,7 +5977,7 @@ function isRecursive(inst, stack, resolve2) {
|
|
|
5970
5977
|
break;
|
|
5971
5978
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
5972
5979
|
case "lazy": {
|
|
5973
|
-
const inner = def._cachedInner ?? (
|
|
5980
|
+
const inner = def._cachedInner ?? (resolve3 ? inst._zod.innerType : void 0);
|
|
5974
5981
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
5975
5982
|
break;
|
|
5976
5983
|
}
|
|
@@ -22985,7 +22992,29 @@ var StorePosturePlugin = external_exports.object({
|
|
|
22985
22992
|
*/
|
|
22986
22993
|
policyBundleVersion: external_exports.string().max(200).nullable(),
|
|
22987
22994
|
/** Epoch millis, on the CLIENT clock, of that fetch. */
|
|
22988
|
-
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable()
|
|
22995
|
+
policyFetchedAt: external_exports.number().int().min(0).max(MAX_DATE_MS).nullable(),
|
|
22996
|
+
/**
|
|
22997
|
+
* The newest version the host's own install record holds for this plugin —
|
|
22998
|
+
* what is on disk. After an update it leads `version` (the running copy) by
|
|
22999
|
+
* one launch. Null when no usable version can be read: no install record
|
|
23000
|
+
* (a plugin run from a checkout), no entry with a valid version, or every
|
|
23001
|
+
* such entry names an `installPath` that no longer exists; OPTIONAL, not
|
|
23002
|
+
* required, so a build that predates the member keeps getting its 200.
|
|
23003
|
+
* Bounded like `version`.
|
|
23004
|
+
*/
|
|
23005
|
+
installedVersion: external_exports.string().max(64).nullable().optional(),
|
|
23006
|
+
/**
|
|
23007
|
+
* The local-store schema version this running build migrates a store to:
|
|
23008
|
+
* the number of store migrations it carries, the count it stamps into
|
|
23009
|
+
* `PRAGMA user_version`. A snapshot whose `schemaVersion` is above it
|
|
23010
|
+
* usually describes a store a newer build migrated. It is a hint, not a
|
|
23011
|
+
* verdict: the stamp is write-only, so a store whose count ran past this
|
|
23012
|
+
* build's while this build knows every migration in its ledger reads above
|
|
23013
|
+
* it too, which is why describeStoreSkew decides skew on ledger tags and
|
|
23014
|
+
* never on the count. OPTIONAL for the same reason as `installedVersion`;
|
|
23015
|
+
* bounded like `schemaVersion`.
|
|
23016
|
+
*/
|
|
23017
|
+
buildSchemaVersion: external_exports.number().int().min(0).max(MAX_INT4).optional()
|
|
22989
23018
|
}).meta({ id: "StorePosturePlugin" });
|
|
22990
23019
|
var StorePostureSnapshot = external_exports.object({
|
|
22991
23020
|
deviceId: external_exports.guid(),
|
|
@@ -23964,10 +23993,15 @@ var ParsedPointer = external_exports.object({
|
|
|
23964
23993
|
});
|
|
23965
23994
|
var VaultEntry = external_exports.object({
|
|
23966
23995
|
pointerId: external_exports.string(),
|
|
23967
|
-
// The keyed HMAC of the raw
|
|
23968
|
-
// derived under.
|
|
23969
|
-
// independently of the vault encryption
|
|
23996
|
+
// The keyed HMAC of the EXACT raw bytes under `exception.key`, and the epoch it
|
|
23997
|
+
// was derived under. The vault's own dedupe key: a value and its invisibly
|
|
23998
|
+
// padded twin are two rows. It rotates independently of the vault encryption
|
|
23999
|
+
// key below. Never matched against an exception or grant.
|
|
23970
24000
|
valueFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
24001
|
+
// The same HMAC over the raw with invisible padding removed: the identity a
|
|
24002
|
+
// reveal-to-model grant and every exception match on. Shared by a value and
|
|
24003
|
+
// its padded twin.
|
|
24004
|
+
valueIdentityFingerprint: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
23971
24005
|
fingerprintKeyVersion: external_exports.number().int().positive(),
|
|
23972
24006
|
// The vault-key epoch this row's ciphertext was sealed under.
|
|
23973
24007
|
keyVersion: external_exports.number().int().positive(),
|
|
@@ -24415,10 +24449,18 @@ var SeveritySummaryItem = external_exports.object({
|
|
|
24415
24449
|
count: external_exports.number().int().nonnegative(),
|
|
24416
24450
|
// Resolution-aware breakdown (optional, additive). Populated once findings
|
|
24417
24451
|
// carry lifecycle state: `caught` = handled in-flight (enforced); `openAtRest`
|
|
24418
|
-
// = still open with no in-flight enforcement (needs remediation)
|
|
24419
|
-
//
|
|
24452
|
+
// = still open with no in-flight enforcement (needs remediation); `dismissed`
|
|
24453
|
+
// = closed by a human judgement rather than a fix — visible, but not counted as
|
|
24454
|
+
// needing remediation. The three are disjoint. Absent on the legacy count-only
|
|
24455
|
+
// response until the resolution feature lands.
|
|
24420
24456
|
caught: external_exports.number().int().nonnegative().optional(),
|
|
24421
|
-
openAtRest: external_exports.number().int().nonnegative().optional()
|
|
24457
|
+
openAtRest: external_exports.number().int().nonnegative().optional(),
|
|
24458
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
24459
|
+
// The two halves of `caught`, for a reader that wants them apart: `handled` =
|
|
24460
|
+
// in-flight findings an enforcement action already contained; `resolved` =
|
|
24461
|
+
// at-rest findings closed out by fixing them. `handled + resolved === caught`.
|
|
24462
|
+
handled: external_exports.number().int().nonnegative().optional(),
|
|
24463
|
+
resolved: external_exports.number().int().nonnegative().optional()
|
|
24422
24464
|
}).meta({ id: "SeveritySummaryItem" });
|
|
24423
24465
|
var SeveritySummaryResponse = external_exports.object({
|
|
24424
24466
|
// Sum of bySeverity[].count.
|
|
@@ -24426,6 +24468,9 @@ var SeveritySummaryResponse = external_exports.object({
|
|
|
24426
24468
|
// Findings still open at rest (sum of bySeverity[].openAtRest). Optional and
|
|
24427
24469
|
// additive — absent on the legacy response until the resolution feature lands.
|
|
24428
24470
|
needsRemediation: external_exports.number().int().nonnegative().optional(),
|
|
24471
|
+
// Findings a user dismissed (sum of bySeverity[].dismissed). Excluded from
|
|
24472
|
+
// needsRemediation, and kept visible here so an accepted risk is not erased.
|
|
24473
|
+
dismissed: external_exports.number().int().nonnegative().optional(),
|
|
24429
24474
|
// All four severity levels are always present (count may be 0).
|
|
24430
24475
|
bySeverity: external_exports.array(SeveritySummaryItem)
|
|
24431
24476
|
}).meta({ id: "SeveritySummaryResponse" });
|
|
@@ -24877,6 +24922,26 @@ function ensureDataDirSync(dir) {
|
|
|
24877
24922
|
function tightenFile(file2) {
|
|
24878
24923
|
chmodBestEffort(file2, DATA_FILE_MODE);
|
|
24879
24924
|
}
|
|
24925
|
+
function writeExclusiveOwnerOnlySync(file2, data) {
|
|
24926
|
+
writeFileSync(file2, data, { mode: DATA_FILE_MODE, flag: "wx" });
|
|
24927
|
+
}
|
|
24928
|
+
function writeOwnerOnlyFileSync(file2, data) {
|
|
24929
|
+
const tmp = `${file2}.${String(process.pid)}.tmp`;
|
|
24930
|
+
try {
|
|
24931
|
+
rmSync2(tmp, { force: true });
|
|
24932
|
+
} catch {
|
|
24933
|
+
}
|
|
24934
|
+
try {
|
|
24935
|
+
writeExclusiveOwnerOnlySync(tmp, data);
|
|
24936
|
+
renameSync(tmp, file2);
|
|
24937
|
+
} finally {
|
|
24938
|
+
try {
|
|
24939
|
+
rmSync2(tmp, { force: true });
|
|
24940
|
+
} catch {
|
|
24941
|
+
}
|
|
24942
|
+
}
|
|
24943
|
+
tightenFile(file2);
|
|
24944
|
+
}
|
|
24880
24945
|
|
|
24881
24946
|
// ../../packages/persistence/src/database.ts
|
|
24882
24947
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
@@ -26000,6 +26065,10 @@ function escapeRegExp2(value) {
|
|
|
26000
26065
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26001
26066
|
}
|
|
26002
26067
|
|
|
26068
|
+
// ../../packages/detections/src/format-chars.ts
|
|
26069
|
+
var HAS_FORMAT_CHAR = new RegExp("\\p{Cf}", "u");
|
|
26070
|
+
var FORMAT_CHAR_GLOBAL = new RegExp("\\p{Cf}", "gu");
|
|
26071
|
+
|
|
26003
26072
|
// ../../packages/detections/src/regex-cache.ts
|
|
26004
26073
|
var singles = /* @__PURE__ */ new WeakMap();
|
|
26005
26074
|
var keywordLists = /* @__PURE__ */ new WeakMap();
|
|
@@ -26248,6 +26317,40 @@ import { Worker } from "worker_threads";
|
|
|
26248
26317
|
// ../../packages/plugin-sdk/src/hook-fail-opens.ts
|
|
26249
26318
|
import { readFileSync as readFileSync12 } from "fs";
|
|
26250
26319
|
import { join as join19 } from "path";
|
|
26320
|
+
var HOOK_FAIL_OPENS_FILENAME = "hook-fail-opens.json";
|
|
26321
|
+
function hookFailOpensPath(dataDir2) {
|
|
26322
|
+
return join19(dataDir2, HOOK_FAIL_OPENS_FILENAME);
|
|
26323
|
+
}
|
|
26324
|
+
function recordHookFailOpen(dataDir2, nowMs) {
|
|
26325
|
+
try {
|
|
26326
|
+
ensureDataDirSync(dataDir2);
|
|
26327
|
+
const previous = readHookFailOpens(dataDir2);
|
|
26328
|
+
const next = {
|
|
26329
|
+
// Saturates at the largest count the reader accepts: one past it would
|
|
26330
|
+
// read back as nothing recorded and restart the tally from one.
|
|
26331
|
+
failOpens: Math.min((previous?.failOpens ?? 0) + 1, Number.MAX_SAFE_INTEGER),
|
|
26332
|
+
lastAtMs: nowMs
|
|
26333
|
+
};
|
|
26334
|
+
writeOwnerOnlyFileSync(hookFailOpensPath(dataDir2), `${JSON.stringify(next)}
|
|
26335
|
+
`);
|
|
26336
|
+
} catch {
|
|
26337
|
+
}
|
|
26338
|
+
}
|
|
26339
|
+
function readHookFailOpens(dataDir2) {
|
|
26340
|
+
try {
|
|
26341
|
+
const parsed = JSON.parse(readFileSync12(hookFailOpensPath(dataDir2), "utf8"));
|
|
26342
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
26343
|
+
const record2 = parsed;
|
|
26344
|
+
if (!isPositiveSafeInteger(record2.failOpens)) return null;
|
|
26345
|
+
if (!isPositiveSafeInteger(record2.lastAtMs)) return null;
|
|
26346
|
+
return { failOpens: record2.failOpens, lastAtMs: record2.lastAtMs };
|
|
26347
|
+
} catch {
|
|
26348
|
+
return null;
|
|
26349
|
+
}
|
|
26350
|
+
}
|
|
26351
|
+
function isPositiveSafeInteger(value) {
|
|
26352
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
26353
|
+
}
|
|
26251
26354
|
|
|
26252
26355
|
// ../../packages/plugin-sdk/src/host-floor.ts
|
|
26253
26356
|
import { readFileSync as readFileSync14 } from "fs";
|
|
@@ -26468,7 +26571,7 @@ function triggerReconcile(dataDir2, sessionId, transcriptPath) {
|
|
|
26468
26571
|
|
|
26469
26572
|
// src/hooks/shared.ts
|
|
26470
26573
|
async function readStdin() {
|
|
26471
|
-
return new Promise((
|
|
26574
|
+
return new Promise((resolve3) => {
|
|
26472
26575
|
let data = "";
|
|
26473
26576
|
let settled = false;
|
|
26474
26577
|
const finish = () => {
|
|
@@ -26477,7 +26580,7 @@ async function readStdin() {
|
|
|
26477
26580
|
clearTimeout(timer);
|
|
26478
26581
|
process.stdin.removeListener("data", onData);
|
|
26479
26582
|
process.stdin.removeListener("end", finish);
|
|
26480
|
-
|
|
26583
|
+
resolve3(data);
|
|
26481
26584
|
};
|
|
26482
26585
|
const onData = (chunk) => {
|
|
26483
26586
|
data += chunk;
|
|
@@ -26501,6 +26604,12 @@ function getString(record2, key) {
|
|
|
26501
26604
|
const value = record2[key];
|
|
26502
26605
|
return typeof value === "string" ? value : void 0;
|
|
26503
26606
|
}
|
|
26607
|
+
function countFailOpen(base) {
|
|
26608
|
+
try {
|
|
26609
|
+
recordHookFailOpen(dataDir(base), Date.now());
|
|
26610
|
+
} catch {
|
|
26611
|
+
}
|
|
26612
|
+
}
|
|
26504
26613
|
|
|
26505
26614
|
// src/hooks/stop-payload.ts
|
|
26506
26615
|
function parseStopPayload(input2) {
|
|
@@ -26513,7 +26622,7 @@ function parseStopPayload(input2) {
|
|
|
26513
26622
|
|
|
26514
26623
|
// src/hooks/store-health.ts
|
|
26515
26624
|
import { mkdirSync as mkdirSync6, readFileSync as readFileSync22, writeFileSync as writeFileSync9 } from "fs";
|
|
26516
|
-
import { dirname as
|
|
26625
|
+
import { dirname as dirname8, join as join35 } from "path";
|
|
26517
26626
|
|
|
26518
26627
|
// ../../packages/remote/src/http.ts
|
|
26519
26628
|
import { request as httpRequest } from "http";
|
|
@@ -26523,6 +26632,9 @@ var MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
|
|
26523
26632
|
// ../../packages/remote/src/client.ts
|
|
26524
26633
|
var SLASH2 = "/".charCodeAt(0);
|
|
26525
26634
|
|
|
26635
|
+
// ../../packages/plugin-runtime/src/attached/with-timeout.ts
|
|
26636
|
+
var REQUEST_TIMEOUT_MS = 2e3;
|
|
26637
|
+
|
|
26526
26638
|
// ../../packages/plugin-runtime/src/attached/forward-drops.ts
|
|
26527
26639
|
import { readFileSync as readFileSync18 } from "fs";
|
|
26528
26640
|
import { join as join28 } from "path";
|
|
@@ -26550,13 +26662,18 @@ import { spawn as spawn2 } from "child_process";
|
|
|
26550
26662
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
26551
26663
|
var HISTORY_SYNC_THROTTLE_MS = 5 * 60 * 1e3;
|
|
26552
26664
|
|
|
26665
|
+
// ../../packages/plugin-runtime/src/attached/install-record.ts
|
|
26666
|
+
import { readFile as readFile2, stat } from "fs/promises";
|
|
26667
|
+
import { basename as basename6, dirname as dirname7, join as join30, resolve as resolve2 } from "path";
|
|
26668
|
+
|
|
26553
26669
|
// ../../packages/plugin-runtime/src/attached/plugin-block.ts
|
|
26554
26670
|
import { readFileSync as readFileSync19 } from "fs";
|
|
26671
|
+
var INSTALL_RECORD_READ_TIMEOUT_MS = REQUEST_TIMEOUT_MS / 2;
|
|
26555
26672
|
|
|
26556
26673
|
// ../../packages/plugin-runtime/src/attached/policy-store.ts
|
|
26557
26674
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
26558
|
-
import { readFile as
|
|
26559
|
-
import { join as
|
|
26675
|
+
import { readFile as readFile3, rm, writeFile as writeFile2 } from "fs/promises";
|
|
26676
|
+
import { join as join31 } from "path";
|
|
26560
26677
|
|
|
26561
26678
|
// ../../packages/plugin-runtime/src/attached/atomic-publish.ts
|
|
26562
26679
|
import { rename as rename2 } from "fs/promises";
|
|
@@ -26566,7 +26683,7 @@ var ATTEMPTS = 1 + IMMEDIATE_RETRIES + TIMED_RETRIES;
|
|
|
26566
26683
|
|
|
26567
26684
|
// ../../packages/plugin-runtime/src/attached/posture-report-state.ts
|
|
26568
26685
|
import { readFileSync as readFileSync20 } from "fs";
|
|
26569
|
-
import { join as
|
|
26686
|
+
import { join as join32 } from "path";
|
|
26570
26687
|
var OUTCOME_KEYS = {
|
|
26571
26688
|
ok: true,
|
|
26572
26689
|
unauthorized: true,
|
|
@@ -26588,12 +26705,12 @@ import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
|
26588
26705
|
|
|
26589
26706
|
// ../../packages/plugin-runtime/src/attached/posture-store.ts
|
|
26590
26707
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
26591
|
-
import { readFile as
|
|
26592
|
-
import { join as
|
|
26708
|
+
import { readFile as readFile4, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
26709
|
+
import { join as join33 } from "path";
|
|
26593
26710
|
|
|
26594
26711
|
// ../../packages/plugin-runtime/src/attached/sync-state.ts
|
|
26595
26712
|
import { readFileSync as readFileSync21 } from "fs";
|
|
26596
|
-
import { join as
|
|
26713
|
+
import { join as join34 } from "path";
|
|
26597
26714
|
|
|
26598
26715
|
// ../../packages/plugin-runtime/src/attached/status.ts
|
|
26599
26716
|
var REFUSAL_LINES = {
|
|
@@ -26635,12 +26752,12 @@ var EXCEPTION_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
|
26635
26752
|
// src/hooks/store-health.ts
|
|
26636
26753
|
var STORE_REDIRECT_MARKER = "store-redirect-last-session";
|
|
26637
26754
|
function markerDirs(dataDir2) {
|
|
26638
|
-
return [dataDir2,
|
|
26755
|
+
return [dataDir2, dirname8(dataDir2)];
|
|
26639
26756
|
}
|
|
26640
26757
|
function alreadyClaimed(dirs, marker, sessionId) {
|
|
26641
26758
|
return dirs.some((dir) => {
|
|
26642
26759
|
try {
|
|
26643
|
-
return readFileSync22(
|
|
26760
|
+
return readFileSync22(join35(dir, marker), "utf8") === sessionId;
|
|
26644
26761
|
} catch {
|
|
26645
26762
|
return false;
|
|
26646
26763
|
}
|
|
@@ -26650,7 +26767,7 @@ function recordClaim(dirs, marker, sessionId) {
|
|
|
26650
26767
|
for (const dir of dirs) {
|
|
26651
26768
|
try {
|
|
26652
26769
|
mkdirSync6(dir, { recursive: true, mode: DATA_DIR_MODE });
|
|
26653
|
-
writeFileSync9(
|
|
26770
|
+
writeFileSync9(join35(dir, marker), sessionId, { mode: DATA_FILE_MODE });
|
|
26654
26771
|
return;
|
|
26655
26772
|
} catch {
|
|
26656
26773
|
}
|
|
@@ -26675,7 +26792,7 @@ function formatMode(mode) {
|
|
|
26675
26792
|
}
|
|
26676
26793
|
function warnIfStoreRedirected(config2, sessionId, write = (message) => void process.stderr.write(message)) {
|
|
26677
26794
|
try {
|
|
26678
|
-
const paths = symlinkedStorePaths(
|
|
26795
|
+
const paths = symlinkedStorePaths(dirname8(config2.dataDir));
|
|
26679
26796
|
if (paths.length === 0) return;
|
|
26680
26797
|
if (!sessionId) {
|
|
26681
26798
|
write(storeRedirectedMessage(paths));
|
|
@@ -26705,5 +26822,6 @@ async function main() {
|
|
|
26705
26822
|
try {
|
|
26706
26823
|
await main();
|
|
26707
26824
|
} catch {
|
|
26825
|
+
countFailOpen();
|
|
26708
26826
|
}
|
|
26709
26827
|
process.exit(0);
|