@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/pre-tool-use.js
CHANGED
|
@@ -8777,7 +8777,11 @@ var ListFindingTypesQuery = object({
|
|
|
8777
8777
|
// and so is not bounded by what any page happens to hold.
|
|
8778
8778
|
includeId: string2().optional(),
|
|
8779
8779
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8780
|
-
cursor: string2().optional()
|
|
8780
|
+
cursor: string2().optional(),
|
|
8781
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8782
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8783
|
+
// from wherever it lands.
|
|
8784
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8781
8785
|
});
|
|
8782
8786
|
var ListFindingTypesResponse = object({
|
|
8783
8787
|
totals: object({
|
|
@@ -8858,7 +8862,11 @@ var ListFindingInstancesQuery = object({
|
|
|
8858
8862
|
sessionId: string2().optional(),
|
|
8859
8863
|
from: iso_exports.datetime().optional(),
|
|
8860
8864
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
8861
|
-
cursor: string2().optional()
|
|
8865
|
+
cursor: string2().optional(),
|
|
8866
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8867
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8868
|
+
// from wherever it lands.
|
|
8869
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8862
8870
|
});
|
|
8863
8871
|
var ListFindingInstancesResponse = object({
|
|
8864
8872
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -8930,7 +8938,11 @@ var ListFindingLocationsQuery = object({
|
|
|
8930
8938
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
8931
8939
|
includeId: string2().optional(),
|
|
8932
8940
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
8933
|
-
cursor: string2().optional()
|
|
8941
|
+
cursor: string2().optional(),
|
|
8942
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8943
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8944
|
+
// from wherever it lands.
|
|
8945
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8934
8946
|
});
|
|
8935
8947
|
var ListFindingLocationsResponse = object({
|
|
8936
8948
|
totals: object({
|
|
@@ -11567,7 +11579,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
11567
11579
|
var ListVaultInventoryQuery = object({
|
|
11568
11580
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11569
11581
|
// Opaque; names the last row of the page just served.
|
|
11570
|
-
cursor: string2().optional()
|
|
11582
|
+
cursor: string2().optional(),
|
|
11583
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11584
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11585
|
+
// from wherever it lands.
|
|
11586
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11571
11587
|
});
|
|
11572
11588
|
var ListVaultInventoryResponse = object({
|
|
11573
11589
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -11579,7 +11595,11 @@ var ListVaultInventoryResponse = object({
|
|
|
11579
11595
|
});
|
|
11580
11596
|
var ListVaultReuseQuery = object({
|
|
11581
11597
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11582
|
-
cursor: string2().optional()
|
|
11598
|
+
cursor: string2().optional(),
|
|
11599
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11600
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11601
|
+
// from wherever it lands.
|
|
11602
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11583
11603
|
});
|
|
11584
11604
|
var ListVaultReuseResponse = object({
|
|
11585
11605
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -11595,9 +11615,15 @@ var ListVaultDerefsQuery = object({
|
|
|
11595
11615
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
11596
11616
|
includeBatched: boolean2().optional(),
|
|
11597
11617
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11598
|
-
cursor: string2().optional()
|
|
11618
|
+
cursor: string2().optional(),
|
|
11619
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11620
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11621
|
+
// from wherever it lands.
|
|
11622
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11599
11623
|
});
|
|
11600
11624
|
var ListVaultDerefsResponse = object({
|
|
11625
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
11626
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
11601
11627
|
items: array(VaultDeref),
|
|
11602
11628
|
nextCursor: string2().nullable(),
|
|
11603
11629
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -15129,6 +15155,21 @@ function registerPack(pack) {
|
|
|
15129
15155
|
function getLoadedRules() {
|
|
15130
15156
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
15131
15157
|
}
|
|
15158
|
+
function outsideWrittenRegions(candidates, context) {
|
|
15159
|
+
const regions = context?.writtenRegions;
|
|
15160
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
15161
|
+
return candidates.filter((c) => {
|
|
15162
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
15163
|
+
const { start, end } = c.match.span;
|
|
15164
|
+
return !regions.some(
|
|
15165
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
15166
|
+
c.rule,
|
|
15167
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
15168
|
+
"code_change"
|
|
15169
|
+
)
|
|
15170
|
+
);
|
|
15171
|
+
});
|
|
15172
|
+
}
|
|
15132
15173
|
function spansOverlap(a, b) {
|
|
15133
15174
|
return a.start < b.end && a.end > b.start;
|
|
15134
15175
|
}
|
|
@@ -15316,17 +15357,20 @@ function scanEncoded(text2, ruleset, context) {
|
|
|
15316
15357
|
function scanText(text2, ruleset, context) {
|
|
15317
15358
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
15318
15359
|
const normalization = normalizeFormatChars(text2);
|
|
15319
|
-
const originalCandidates =
|
|
15360
|
+
const originalCandidates = outsideWrittenRegions(
|
|
15361
|
+
buildCandidates(text2, ruleset, extension, context?.eventKind),
|
|
15362
|
+
context
|
|
15363
|
+
);
|
|
15320
15364
|
if (!normalization) return gate(originalCandidates, text2, void 0);
|
|
15321
15365
|
const pooledOriginal = originalCandidates.map(
|
|
15322
15366
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
15323
15367
|
);
|
|
15324
|
-
const normalizedCandidates =
|
|
15325
|
-
normalization.normalized,
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
context
|
|
15329
|
-
)
|
|
15368
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
15369
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
15370
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text2)
|
|
15371
|
+
),
|
|
15372
|
+
context
|
|
15373
|
+
);
|
|
15330
15374
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text2, normalization);
|
|
15331
15375
|
return mergeOverlappingSameRule(findings, text2);
|
|
15332
15376
|
}
|
|
@@ -15387,6 +15431,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
15387
15431
|
"code-flaws/sql-inject-concat-dot",
|
|
15388
15432
|
"code-flaws/sql-inject-format",
|
|
15389
15433
|
"code-flaws/sql-inject-interp",
|
|
15434
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
15390
15435
|
"code-flaws/ssrf-user-url",
|
|
15391
15436
|
"code-flaws/xss-dangerously-set",
|
|
15392
15437
|
"code-flaws/xss-inner-html",
|
|
@@ -16525,7 +16570,7 @@ var sql_inject_concat_dot_default = {
|
|
|
16525
16570
|
severity: "high",
|
|
16526
16571
|
matcher: {
|
|
16527
16572
|
type: "regex",
|
|
16528
|
-
pattern:
|
|
16573
|
+
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*\\.",
|
|
16529
16574
|
flags: "gi"
|
|
16530
16575
|
},
|
|
16531
16576
|
appliesTo: {
|
|
@@ -16543,7 +16588,7 @@ var sql_inject_concat_default = {
|
|
|
16543
16588
|
severity: "high",
|
|
16544
16589
|
matcher: {
|
|
16545
16590
|
type: "regex",
|
|
16546
|
-
pattern:
|
|
16591
|
+
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*\\+",
|
|
16547
16592
|
flags: "gi"
|
|
16548
16593
|
},
|
|
16549
16594
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -16558,7 +16603,7 @@ var sql_inject_format_default = {
|
|
|
16558
16603
|
severity: "high",
|
|
16559
16604
|
matcher: {
|
|
16560
16605
|
type: "regex",
|
|
16561
|
-
pattern:
|
|
16606
|
+
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]+\\})",
|
|
16562
16607
|
flags: "gi"
|
|
16563
16608
|
},
|
|
16564
16609
|
examples: [
|
|
@@ -16567,6 +16612,24 @@ var sql_inject_format_default = {
|
|
|
16567
16612
|
]
|
|
16568
16613
|
};
|
|
16569
16614
|
|
|
16615
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
16616
|
+
var sql_inject_interp_multiline_default = {
|
|
16617
|
+
specVersion: 1,
|
|
16618
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
16619
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
16620
|
+
category: "code_flaw",
|
|
16621
|
+
severity: "high",
|
|
16622
|
+
matcher: {
|
|
16623
|
+
type: "regex",
|
|
16624
|
+
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_])',
|
|
16625
|
+
flags: "gi"
|
|
16626
|
+
},
|
|
16627
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
16628
|
+
appliesTo: {
|
|
16629
|
+
extensions: [".rb", ".php"]
|
|
16630
|
+
}
|
|
16631
|
+
};
|
|
16632
|
+
|
|
16570
16633
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
16571
16634
|
var sql_inject_interp_default = {
|
|
16572
16635
|
specVersion: 1,
|
|
@@ -16576,7 +16639,7 @@ var sql_inject_interp_default = {
|
|
|
16576
16639
|
severity: "high",
|
|
16577
16640
|
matcher: {
|
|
16578
16641
|
type: "regex",
|
|
16579
|
-
pattern: "([\
|
|
16642
|
+
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_])',
|
|
16580
16643
|
flags: "gi"
|
|
16581
16644
|
},
|
|
16582
16645
|
examples: [
|
|
@@ -18304,12 +18367,13 @@ var BUNDLED_PACKS = [
|
|
|
18304
18367
|
{
|
|
18305
18368
|
packId: "code-flaws",
|
|
18306
18369
|
name: "Code Security Flaws",
|
|
18307
|
-
version: "0.1.
|
|
18370
|
+
version: "0.1.6",
|
|
18308
18371
|
rawRules: [
|
|
18309
18372
|
sql_inject_concat_default,
|
|
18310
18373
|
sql_inject_concat_dot_default,
|
|
18311
18374
|
sql_inject_format_default,
|
|
18312
18375
|
sql_inject_interp_default,
|
|
18376
|
+
sql_inject_interp_multiline_default,
|
|
18313
18377
|
cmd_inject_shell_default,
|
|
18314
18378
|
cmd_inject_exec_default,
|
|
18315
18379
|
cmd_inject_node_exec_default,
|
|
@@ -18341,6 +18405,7 @@ var BUNDLED_PACKS = [
|
|
|
18341
18405
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
18342
18406
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
18343
18407
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
18408
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
18344
18409
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
18345
18410
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
18346
18411
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -25146,7 +25211,7 @@ var SqliteFindingsRepository = class {
|
|
|
25146
25211
|
};
|
|
25147
25212
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
25148
25213
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
25149
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
25214
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
25150
25215
|
const page = sorted.slice(start, start + limit);
|
|
25151
25216
|
const lastOnPage = page.at(-1);
|
|
25152
25217
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -25240,7 +25305,7 @@ var SqliteFindingsRepository = class {
|
|
|
25240
25305
|
accumulator.add(row);
|
|
25241
25306
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
25242
25307
|
total += 1;
|
|
25243
|
-
if (!isPastCursor(row)) continue;
|
|
25308
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
25244
25309
|
if (items.length < limit) {
|
|
25245
25310
|
items.push(toInstanceDetail(row));
|
|
25246
25311
|
last = row;
|
|
@@ -25329,7 +25394,7 @@ var SqliteFindingsRepository = class {
|
|
|
25329
25394
|
}
|
|
25330
25395
|
}
|
|
25331
25396
|
sorted.sort(compareLocationOrder);
|
|
25332
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
25397
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
25333
25398
|
const page = sorted.slice(start, start + limit);
|
|
25334
25399
|
const lastOnPage = page.at(-1);
|
|
25335
25400
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -27957,6 +28022,9 @@ function pageLimit(requested, fallback) {
|
|
|
27957
28022
|
if (requested === void 0) return fallback;
|
|
27958
28023
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
27959
28024
|
}
|
|
28025
|
+
function pageOffset(requested) {
|
|
28026
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
28027
|
+
}
|
|
27960
28028
|
function encodeReuseCursor(payload) {
|
|
27961
28029
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
27962
28030
|
}
|
|
@@ -28304,7 +28372,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28304
28372
|
*/
|
|
28305
28373
|
listInventory(query = {}, now = Date.now()) {
|
|
28306
28374
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
28307
|
-
const
|
|
28375
|
+
const offset = pageOffset(query.offset);
|
|
28376
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
28308
28377
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
28309
28378
|
const rows = allRows(
|
|
28310
28379
|
this.db.prepare(
|
|
@@ -28318,11 +28387,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
28318
28387
|
FROM secret_vault v
|
|
28319
28388
|
${where}
|
|
28320
28389
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
28321
|
-
LIMIT :limit`
|
|
28390
|
+
LIMIT :limit OFFSET :offset`
|
|
28322
28391
|
),
|
|
28323
28392
|
bindParams({
|
|
28324
28393
|
now,
|
|
28325
28394
|
limit: limit + 1,
|
|
28395
|
+
offset,
|
|
28326
28396
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
28327
28397
|
})
|
|
28328
28398
|
);
|
|
@@ -28346,7 +28416,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28346
28416
|
*/
|
|
28347
28417
|
listReuse(query = {}, now = Date.now()) {
|
|
28348
28418
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
28349
|
-
const
|
|
28419
|
+
const offset = pageOffset(query.offset);
|
|
28420
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
28350
28421
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
28351
28422
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
28352
28423
|
const rows = allRows(
|
|
@@ -28361,11 +28432,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
28361
28432
|
FROM secret_vault v
|
|
28362
28433
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
28363
28434
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
28364
|
-
LIMIT :limit`
|
|
28435
|
+
LIMIT :limit OFFSET :offset`
|
|
28365
28436
|
),
|
|
28366
28437
|
bindParams({
|
|
28367
28438
|
now,
|
|
28368
28439
|
limit: limit + 1,
|
|
28440
|
+
offset,
|
|
28369
28441
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
28370
28442
|
})
|
|
28371
28443
|
);
|
|
@@ -28390,7 +28462,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
28390
28462
|
*/
|
|
28391
28463
|
listDerefs(query = {}) {
|
|
28392
28464
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
28393
|
-
const
|
|
28465
|
+
const offset = pageOffset(query.offset);
|
|
28466
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
28394
28467
|
const conditions = [];
|
|
28395
28468
|
if (query.includeBatched !== true) {
|
|
28396
28469
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -28403,21 +28476,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
28403
28476
|
this.db.prepare(
|
|
28404
28477
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
28405
28478
|
FROM secret_vault_deref ${where}
|
|
28406
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
28479
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
28407
28480
|
),
|
|
28408
28481
|
bindParams({
|
|
28409
28482
|
limit: limit + 1,
|
|
28483
|
+
offset,
|
|
28410
28484
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
28411
28485
|
})
|
|
28412
28486
|
);
|
|
28413
28487
|
const hasMore = rows.length > limit;
|
|
28414
28488
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
28415
28489
|
const last = page[page.length - 1];
|
|
28416
|
-
const
|
|
28417
|
-
this.db
|
|
28418
|
-
|
|
28419
|
-
|
|
28490
|
+
const counts = getRow(
|
|
28491
|
+
this.db.prepare(
|
|
28492
|
+
`SELECT count(*) AS total,
|
|
28493
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
28494
|
+
FROM secret_vault_deref`
|
|
28495
|
+
)
|
|
28496
|
+
) ?? { total: 0, hidden: 0 };
|
|
28497
|
+
const includeBatched = query.includeBatched === true;
|
|
28498
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
28420
28499
|
return {
|
|
28500
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
28421
28501
|
items: page.map((r) => ({
|
|
28422
28502
|
id: r.id,
|
|
28423
28503
|
pointerId: r.pointer_id,
|
|
@@ -28442,6 +28522,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
28442
28522
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
28443
28523
|
);
|
|
28444
28524
|
}
|
|
28525
|
+
/**
|
|
28526
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
28527
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
28528
|
+
* every row.
|
|
28529
|
+
*
|
|
28530
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
28531
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
28532
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
28533
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
28534
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
28535
|
+
*
|
|
28536
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
28537
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
28538
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
28539
|
+
*
|
|
28540
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
28541
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
28542
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
28543
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
28544
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
28545
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
28546
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
28547
|
+
*/
|
|
28548
|
+
countFingerprintEpochs(currentVersion) {
|
|
28549
|
+
const row = getRow(
|
|
28550
|
+
this.db.prepare(
|
|
28551
|
+
`SELECT COUNT(*) AS total,
|
|
28552
|
+
COALESCE(
|
|
28553
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
28554
|
+
0
|
|
28555
|
+
) AS stale
|
|
28556
|
+
FROM secret_vault`
|
|
28557
|
+
),
|
|
28558
|
+
{ currentVersion }
|
|
28559
|
+
) ?? { stale: 0, total: 0 };
|
|
28560
|
+
return { stale: row.stale, total: row.total };
|
|
28561
|
+
}
|
|
28445
28562
|
};
|
|
28446
28563
|
|
|
28447
28564
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -30308,13 +30425,22 @@ var SecretVault = class {
|
|
|
30308
30425
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
30309
30426
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
30310
30427
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
30428
|
+
*
|
|
30429
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
30430
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
30431
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
30432
|
+
* than a bare success count.
|
|
30311
30433
|
*/
|
|
30312
30434
|
async refreshFingerprints(next) {
|
|
30313
30435
|
let refreshed = 0;
|
|
30436
|
+
let skipped = 0;
|
|
30314
30437
|
for (const row of this.#repo.listAll()) {
|
|
30315
30438
|
try {
|
|
30316
30439
|
const raw = await this.#openRow(row);
|
|
30317
|
-
if (raw === null)
|
|
30440
|
+
if (raw === null) {
|
|
30441
|
+
skipped += 1;
|
|
30442
|
+
continue;
|
|
30443
|
+
}
|
|
30318
30444
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
30319
30445
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
30320
30446
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -30322,10 +30448,10 @@ var SecretVault = class {
|
|
|
30322
30448
|
});
|
|
30323
30449
|
refreshed += 1;
|
|
30324
30450
|
} catch {
|
|
30325
|
-
|
|
30451
|
+
skipped += 1;
|
|
30326
30452
|
}
|
|
30327
30453
|
}
|
|
30328
|
-
return refreshed;
|
|
30454
|
+
return { refreshed, skipped };
|
|
30329
30455
|
}
|
|
30330
30456
|
/**
|
|
30331
30457
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -30839,8 +30965,25 @@ function bundledMaskingRules() {
|
|
|
30839
30965
|
return ensureBundledPacks() ? getLoadedRules() : null;
|
|
30840
30966
|
}
|
|
30841
30967
|
|
|
30968
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
30969
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
30970
|
+
function notRegularFile(path) {
|
|
30971
|
+
return `not a regular file: ${path}`;
|
|
30972
|
+
}
|
|
30973
|
+
function readRegularFile(path, maxBytes) {
|
|
30974
|
+
const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
30975
|
+
try {
|
|
30976
|
+
const stat2 = fstatSync(fd);
|
|
30977
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path));
|
|
30978
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
|
|
30979
|
+
return readFileSync16(fd, "utf8");
|
|
30980
|
+
} finally {
|
|
30981
|
+
closeSync2(fd);
|
|
30982
|
+
}
|
|
30983
|
+
}
|
|
30984
|
+
|
|
30842
30985
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
30843
|
-
import { existsSync as existsSync9,
|
|
30986
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
30844
30987
|
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
30845
30988
|
function remoteWithoutCredentials(remote) {
|
|
30846
30989
|
const withoutInfo = withoutUserinfo(remote);
|
|
@@ -30929,9 +31072,10 @@ function resolveGitContext(root) {
|
|
|
30929
31072
|
const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
30930
31073
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
30931
31074
|
}
|
|
31075
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
30932
31076
|
function safeRead(path) {
|
|
30933
31077
|
try {
|
|
30934
|
-
return
|
|
31078
|
+
return readRegularFile(path, MAX_GIT_METADATA_BYTES);
|
|
30935
31079
|
} catch {
|
|
30936
31080
|
return void 0;
|
|
30937
31081
|
}
|
|
@@ -31252,6 +31396,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
31252
31396
|
text: text2,
|
|
31253
31397
|
filePath: context?.filePath,
|
|
31254
31398
|
eventKind: context?.eventKind,
|
|
31399
|
+
writtenRegions: context?.writtenRegions,
|
|
31255
31400
|
attribute: scanOpts?.attribute === true
|
|
31256
31401
|
}),
|
|
31257
31402
|
reply: (message) => {
|
|
@@ -32065,7 +32210,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
32065
32210
|
input.text,
|
|
32066
32211
|
{
|
|
32067
32212
|
filePath: input.metadata?.filePath,
|
|
32068
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
32213
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
32214
|
+
writtenRegions: opts2.writtenRegions
|
|
32069
32215
|
},
|
|
32070
32216
|
{
|
|
32071
32217
|
sourceTool: input.sourceTool,
|
|
@@ -35564,21 +35710,21 @@ function resolveCodexHome(env, home = homedir3()) {
|
|
|
35564
35710
|
|
|
35565
35711
|
// ../../packages/plugin-sdk/src/account/observation-log.ts
|
|
35566
35712
|
import { createHash as createHash13 } from "crypto";
|
|
35567
|
-
import { closeSync as
|
|
35713
|
+
import { closeSync as closeSync3, constants as constants2, fstatSync as fstatSync2, mkdirSync as mkdirSync2, openSync as openSync3, readSync, writeSync } from "fs";
|
|
35568
35714
|
import { join as join35 } from "path";
|
|
35569
35715
|
var SESSION_LOG_CAP_BYTES = 16 * 1024 * 1024;
|
|
35570
35716
|
var SESSION_LOG_TAIL_BYTES = 64 * 1024;
|
|
35571
35717
|
var NEWLINE = 10;
|
|
35572
35718
|
var SAFE_SESSION_ID = /^[A-Za-z0-9._-]+$/;
|
|
35573
35719
|
function sessionLogOpenFlags(noFollow) {
|
|
35574
|
-
return
|
|
35720
|
+
return constants2.O_WRONLY | constants2.O_APPEND | constants2.O_CREAT | (noFollow ?? 0);
|
|
35575
35721
|
}
|
|
35576
35722
|
var SESSION_LOG_OPEN_FLAGS = sessionLogOpenFlags(
|
|
35577
|
-
|
|
35723
|
+
constants2.O_NOFOLLOW
|
|
35578
35724
|
);
|
|
35579
35725
|
function closeQuietly2(fd) {
|
|
35580
35726
|
try {
|
|
35581
|
-
|
|
35727
|
+
closeSync3(fd);
|
|
35582
35728
|
} catch {
|
|
35583
35729
|
}
|
|
35584
35730
|
}
|
|
@@ -35601,8 +35747,8 @@ function appendObservation(stateDir, sessionId, observation, capBytes = SESSION_
|
|
|
35601
35747
|
let fd;
|
|
35602
35748
|
try {
|
|
35603
35749
|
mkdirSync2(stateDir, { recursive: true, mode: DATA_DIR_MODE });
|
|
35604
|
-
fd =
|
|
35605
|
-
if (
|
|
35750
|
+
fd = openSync3(sessionLogPath(stateDir, sessionId), openFlags, DATA_FILE_MODE);
|
|
35751
|
+
if (fstatSync2(fd).size + Buffer.byteLength(line) > capBytes) return false;
|
|
35606
35752
|
writeSync(fd, line);
|
|
35607
35753
|
return true;
|
|
35608
35754
|
} catch {
|
|
@@ -35632,12 +35778,12 @@ function parseLines(buffer, base) {
|
|
|
35632
35778
|
function readRange(path, from, capBytes) {
|
|
35633
35779
|
let fd;
|
|
35634
35780
|
try {
|
|
35635
|
-
fd =
|
|
35781
|
+
fd = openSync3(path, "r");
|
|
35636
35782
|
} catch {
|
|
35637
35783
|
return void 0;
|
|
35638
35784
|
}
|
|
35639
35785
|
try {
|
|
35640
|
-
const size =
|
|
35786
|
+
const size = fstatSync2(fd).size;
|
|
35641
35787
|
const length = Math.max(0, Math.min(size, capBytes) - from);
|
|
35642
35788
|
const buffer = Buffer.alloc(length);
|
|
35643
35789
|
let filled = 0;
|
|
@@ -35684,7 +35830,7 @@ function classifyObservation(observation) {
|
|
|
35684
35830
|
}
|
|
35685
35831
|
|
|
35686
35832
|
// ../../packages/plugin-sdk/src/account/codex-head.ts
|
|
35687
|
-
import { closeSync as
|
|
35833
|
+
import { closeSync as closeSync4, openSync as openSync4, readSync as readSync2 } from "fs";
|
|
35688
35834
|
var CODEX_HEAD_READ_BYTES = 64 * 1024;
|
|
35689
35835
|
var CODEX_HEAD_MAX_BYTES = 1024 * 1024;
|
|
35690
35836
|
var NEWLINE2 = 10;
|
|
@@ -35717,7 +35863,7 @@ function parseHead(line) {
|
|
|
35717
35863
|
function readCodexHead(rolloutPath) {
|
|
35718
35864
|
let fd;
|
|
35719
35865
|
try {
|
|
35720
|
-
fd =
|
|
35866
|
+
fd = openSync4(rolloutPath, "r");
|
|
35721
35867
|
} catch (error2) {
|
|
35722
35868
|
return isNotFound(error2) ? "pending" : void 0;
|
|
35723
35869
|
}
|
|
@@ -35742,14 +35888,14 @@ function readCodexHead(rolloutPath) {
|
|
|
35742
35888
|
return void 0;
|
|
35743
35889
|
} finally {
|
|
35744
35890
|
try {
|
|
35745
|
-
|
|
35891
|
+
closeSync4(fd);
|
|
35746
35892
|
} catch {
|
|
35747
35893
|
}
|
|
35748
35894
|
}
|
|
35749
35895
|
}
|
|
35750
35896
|
|
|
35751
35897
|
// ../../packages/plugin-sdk/src/account/codex-login.ts
|
|
35752
|
-
import { closeSync as
|
|
35898
|
+
import { closeSync as closeSync5, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync6, openSync as openSync5, readSync as readSync3 } from "fs";
|
|
35753
35899
|
import { join as join36 } from "path";
|
|
35754
35900
|
var CODEX_AUTH_MAX_BYTES = 64 * 1024;
|
|
35755
35901
|
var CODEX_ID_TOKEN_MAX_CHARS = 16 * 1024;
|
|
@@ -35782,8 +35928,8 @@ var DROPPED = new Set(CODEX_DROPPED_FIELDS);
|
|
|
35782
35928
|
var PRESENCE = new Set(CODEX_PRESENCE_FIELDS);
|
|
35783
35929
|
var BASE64URL = /^[A-Za-z0-9_-]+$/;
|
|
35784
35930
|
var UUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
35785
|
-
var NOFOLLOW =
|
|
35786
|
-
var READ_FLAGS =
|
|
35931
|
+
var NOFOLLOW = constants3.O_NOFOLLOW ?? 0;
|
|
35932
|
+
var READ_FLAGS = constants3.O_RDONLY | NOFOLLOW;
|
|
35787
35933
|
var ABSENT = { status: "absent" };
|
|
35788
35934
|
var MODE = { status: "mode" };
|
|
35789
35935
|
var MALFORMED = { status: "malformed" };
|
|
@@ -35905,12 +36051,12 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform = process.pla
|
|
|
35905
36051
|
let fd;
|
|
35906
36052
|
try {
|
|
35907
36053
|
if (platform === "win32" && lstatSync6(path).isSymbolicLink()) return MALFORMED;
|
|
35908
|
-
fd =
|
|
36054
|
+
fd = openSync5(path, openFlags);
|
|
35909
36055
|
} catch (error2) {
|
|
35910
36056
|
return isNotFound2(error2) ? ABSENT : MALFORMED;
|
|
35911
36057
|
}
|
|
35912
36058
|
try {
|
|
35913
|
-
const stat2 =
|
|
36059
|
+
const stat2 = fstatSync3(fd);
|
|
35914
36060
|
if (!stat2.isFile() || stat2.size > CODEX_AUTH_MAX_BYTES) return MALFORMED;
|
|
35915
36061
|
if (platform !== "win32" && (stat2.uid !== process.getuid?.() || (stat2.mode & 18) !== 0)) {
|
|
35916
36062
|
return MALFORMED;
|
|
@@ -35922,7 +36068,7 @@ function inspectCodexLogin(codexHome, attachedUserDigest, platform = process.pla
|
|
|
35922
36068
|
return MALFORMED;
|
|
35923
36069
|
} finally {
|
|
35924
36070
|
try {
|
|
35925
|
-
|
|
36071
|
+
closeSync5(fd);
|
|
35926
36072
|
} catch {
|
|
35927
36073
|
}
|
|
35928
36074
|
}
|