@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/remediate.js
CHANGED
|
@@ -8781,7 +8781,11 @@ var ListFindingTypesQuery = object({
|
|
|
8781
8781
|
// and so is not bounded by what any page happens to hold.
|
|
8782
8782
|
includeId: string2().optional(),
|
|
8783
8783
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_TYPES_LIMIT).optional(),
|
|
8784
|
-
cursor: string2().optional()
|
|
8784
|
+
cursor: string2().optional(),
|
|
8785
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8786
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8787
|
+
// from wherever it lands.
|
|
8788
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8785
8789
|
});
|
|
8786
8790
|
var ListFindingTypesResponse = object({
|
|
8787
8791
|
totals: object({
|
|
@@ -8862,7 +8866,11 @@ var ListFindingInstancesQuery = object({
|
|
|
8862
8866
|
sessionId: string2().optional(),
|
|
8863
8867
|
from: iso_exports.datetime().optional(),
|
|
8864
8868
|
limit: coerce_exports.number().int().min(1).max(MAX_FLAT_FINDINGS_LIMIT).optional(),
|
|
8865
|
-
cursor: string2().optional()
|
|
8869
|
+
cursor: string2().optional(),
|
|
8870
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8871
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8872
|
+
// from wherever it lands.
|
|
8873
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8866
8874
|
});
|
|
8867
8875
|
var ListFindingInstancesResponse = object({
|
|
8868
8876
|
// Instances matching the filters across the whole scope, not just this
|
|
@@ -8934,7 +8942,11 @@ var ListFindingLocationsQuery = object({
|
|
|
8934
8942
|
// rather than a deep-link corner. Never affects totals, facets or the cursor.
|
|
8935
8943
|
includeId: string2().optional(),
|
|
8936
8944
|
limit: coerce_exports.number().int().min(1).max(MAX_FINDING_LOCATIONS_LIMIT).optional(),
|
|
8937
|
-
cursor: string2().optional()
|
|
8945
|
+
cursor: string2().optional(),
|
|
8946
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
8947
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
8948
|
+
// from wherever it lands.
|
|
8949
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
8938
8950
|
});
|
|
8939
8951
|
var ListFindingLocationsResponse = object({
|
|
8940
8952
|
totals: object({
|
|
@@ -11571,7 +11583,11 @@ var MAX_VAULT_PAGE_LIMIT = 200;
|
|
|
11571
11583
|
var ListVaultInventoryQuery = object({
|
|
11572
11584
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11573
11585
|
// Opaque; names the last row of the page just served.
|
|
11574
|
-
cursor: string2().optional()
|
|
11586
|
+
cursor: string2().optional(),
|
|
11587
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11588
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11589
|
+
// from wherever it lands.
|
|
11590
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11575
11591
|
});
|
|
11576
11592
|
var ListVaultInventoryResponse = object({
|
|
11577
11593
|
// Vaulted values across the whole store, not just this page — cursor-
|
|
@@ -11583,7 +11599,11 @@ var ListVaultInventoryResponse = object({
|
|
|
11583
11599
|
});
|
|
11584
11600
|
var ListVaultReuseQuery = object({
|
|
11585
11601
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11586
|
-
cursor: string2().optional()
|
|
11602
|
+
cursor: string2().optional(),
|
|
11603
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11604
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11605
|
+
// from wherever it lands.
|
|
11606
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11587
11607
|
});
|
|
11588
11608
|
var ListVaultReuseResponse = object({
|
|
11589
11609
|
// Reused values across the whole store — the number the section's claim
|
|
@@ -11599,9 +11619,15 @@ var ListVaultDerefsQuery = object({
|
|
|
11599
11619
|
// over a Server Action, which preserves the type, never as a URL param.
|
|
11600
11620
|
includeBatched: boolean2().optional(),
|
|
11601
11621
|
limit: coerce_exports.number().int().min(1).max(MAX_VAULT_PAGE_LIMIT).optional(),
|
|
11602
|
-
cursor: string2().optional()
|
|
11622
|
+
cursor: string2().optional(),
|
|
11623
|
+
// A row position to read from, for jumping to a page instead of stepping to
|
|
11624
|
+
// it. Takes precedence over `cursor`, and the page's `nextCursor` carries on
|
|
11625
|
+
// from wherever it lands.
|
|
11626
|
+
offset: coerce_exports.number().int().min(0).optional()
|
|
11603
11627
|
});
|
|
11604
11628
|
var ListVaultDerefsResponse = object({
|
|
11629
|
+
// Rows this filter selects across the whole trail, not just this page.
|
|
11630
|
+
totals: object({ derefs: number2().int().nonnegative() }),
|
|
11605
11631
|
items: array(VaultDeref),
|
|
11606
11632
|
nextCursor: string2().nullable(),
|
|
11607
11633
|
// Display/view-render rows the query hid, over the WHOLE trail rather than
|
|
@@ -20413,7 +20439,7 @@ var SqliteFindingsRepository = class {
|
|
|
20413
20439
|
};
|
|
20414
20440
|
const limit = query.limit ?? DEFAULT_FINDING_TYPES_LIMIT;
|
|
20415
20441
|
const cursor = query.cursor === void 0 ? null : decodeGroupCursor(query.cursor);
|
|
20416
|
-
const start = cursor === null ? 0 : firstAfter(sorted, cursor);
|
|
20442
|
+
const start = query.offset ?? (cursor === null ? 0 : firstAfter(sorted, cursor));
|
|
20417
20443
|
const page = sorted.slice(start, start + limit);
|
|
20418
20444
|
const lastOnPage = page.at(-1);
|
|
20419
20445
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeGroupCursor(lastOnPage) : null;
|
|
@@ -20507,7 +20533,7 @@ var SqliteFindingsRepository = class {
|
|
|
20507
20533
|
accumulator.add(row);
|
|
20508
20534
|
if (!matchesInstanceFilters(row, opts)) continue;
|
|
20509
20535
|
total += 1;
|
|
20510
|
-
if (!isPastCursor(row)) continue;
|
|
20536
|
+
if (query.offset === void 0 ? !isPastCursor(row) : total <= query.offset) continue;
|
|
20511
20537
|
if (items.length < limit) {
|
|
20512
20538
|
items.push(toInstanceDetail(row));
|
|
20513
20539
|
last = row;
|
|
@@ -20596,7 +20622,7 @@ var SqliteFindingsRepository = class {
|
|
|
20596
20622
|
}
|
|
20597
20623
|
}
|
|
20598
20624
|
sorted.sort(compareLocationOrder);
|
|
20599
|
-
const start = cursor === null ? 0 : firstLocationAfter(sorted, cursor);
|
|
20625
|
+
const start = query.offset ?? (cursor === null ? 0 : firstLocationAfter(sorted, cursor));
|
|
20600
20626
|
const page = sorted.slice(start, start + limit);
|
|
20601
20627
|
const lastOnPage = page.at(-1);
|
|
20602
20628
|
const nextCursor = start + limit < sorted.length && lastOnPage ? encodeLocationCursor(lastOnPage) : null;
|
|
@@ -23224,6 +23250,9 @@ function pageLimit(requested, fallback) {
|
|
|
23224
23250
|
if (requested === void 0) return fallback;
|
|
23225
23251
|
return Math.min(Math.max(1, Math.trunc(requested)), MAX_VAULT_PAGE_LIMIT);
|
|
23226
23252
|
}
|
|
23253
|
+
function pageOffset(requested) {
|
|
23254
|
+
return requested === void 0 ? 0 : Math.max(0, Math.trunc(requested));
|
|
23255
|
+
}
|
|
23227
23256
|
function encodeReuseCursor(payload) {
|
|
23228
23257
|
return Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
23229
23258
|
}
|
|
@@ -23571,7 +23600,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
23571
23600
|
*/
|
|
23572
23601
|
listInventory(query = {}, now = Date.now()) {
|
|
23573
23602
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
23574
|
-
const
|
|
23603
|
+
const offset = pageOffset(query.offset);
|
|
23604
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
23575
23605
|
const where = cursor === null ? "" : "WHERE (v.last_seen < :cursorLastSeen OR (v.last_seen = :cursorLastSeen AND v.pointer_id < :cursorPointerId))";
|
|
23576
23606
|
const rows = allRows(
|
|
23577
23607
|
this.db.prepare(
|
|
@@ -23585,11 +23615,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
23585
23615
|
FROM secret_vault v
|
|
23586
23616
|
${where}
|
|
23587
23617
|
ORDER BY v.last_seen DESC, v.pointer_id DESC
|
|
23588
|
-
LIMIT :limit`
|
|
23618
|
+
LIMIT :limit OFFSET :offset`
|
|
23589
23619
|
),
|
|
23590
23620
|
bindParams({
|
|
23591
23621
|
now,
|
|
23592
23622
|
limit: limit + 1,
|
|
23623
|
+
offset,
|
|
23593
23624
|
...cursor === null ? {} : { cursorLastSeen: cursor.startedAtMs, cursorPointerId: cursor.id }
|
|
23594
23625
|
})
|
|
23595
23626
|
);
|
|
@@ -23613,7 +23644,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
23613
23644
|
*/
|
|
23614
23645
|
listReuse(query = {}, now = Date.now()) {
|
|
23615
23646
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_INVENTORY_LIMIT);
|
|
23616
|
-
const
|
|
23647
|
+
const offset = pageOffset(query.offset);
|
|
23648
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeReuseCursor(query.cursor);
|
|
23617
23649
|
const after = cursor === null ? "" : `AND (v.occurrence_count < :cursorOccurrences
|
|
23618
23650
|
OR (v.occurrence_count = :cursorOccurrences AND v.pointer_id < :cursorPointerId))`;
|
|
23619
23651
|
const rows = allRows(
|
|
@@ -23628,11 +23660,12 @@ var SqliteSecretVaultRepository = class {
|
|
|
23628
23660
|
FROM secret_vault v
|
|
23629
23661
|
WHERE ${REUSED_PREDICATE} ${after}
|
|
23630
23662
|
ORDER BY v.occurrence_count DESC, v.pointer_id DESC
|
|
23631
|
-
LIMIT :limit`
|
|
23663
|
+
LIMIT :limit OFFSET :offset`
|
|
23632
23664
|
),
|
|
23633
23665
|
bindParams({
|
|
23634
23666
|
now,
|
|
23635
23667
|
limit: limit + 1,
|
|
23668
|
+
offset,
|
|
23636
23669
|
...cursor === null ? {} : { cursorOccurrences: cursor.occurrences, cursorPointerId: cursor.pointerId }
|
|
23637
23670
|
})
|
|
23638
23671
|
);
|
|
@@ -23657,7 +23690,8 @@ var SqliteSecretVaultRepository = class {
|
|
|
23657
23690
|
*/
|
|
23658
23691
|
listDerefs(query = {}) {
|
|
23659
23692
|
const limit = pageLimit(query.limit, DEFAULT_VAULT_DEREFS_LIMIT);
|
|
23660
|
-
const
|
|
23693
|
+
const offset = pageOffset(query.offset);
|
|
23694
|
+
const cursor = query.cursor === void 0 || query.offset !== void 0 ? null : decodeKeysetCursor(query.cursor);
|
|
23661
23695
|
const conditions = [];
|
|
23662
23696
|
if (query.includeBatched !== true) {
|
|
23663
23697
|
conditions.push(`reason NOT IN ('display', 'view-render')`);
|
|
@@ -23670,21 +23704,28 @@ var SqliteSecretVaultRepository = class {
|
|
|
23670
23704
|
this.db.prepare(
|
|
23671
23705
|
`SELECT id, pointer_id, at, target, reason, outcome, grant_id, pointer_count
|
|
23672
23706
|
FROM secret_vault_deref ${where}
|
|
23673
|
-
ORDER BY at DESC, id DESC LIMIT :limit`
|
|
23707
|
+
ORDER BY at DESC, id DESC LIMIT :limit OFFSET :offset`
|
|
23674
23708
|
),
|
|
23675
23709
|
bindParams({
|
|
23676
23710
|
limit: limit + 1,
|
|
23711
|
+
offset,
|
|
23677
23712
|
...cursor === null ? {} : { cursorAt: cursor.startedAtMs, cursorId: cursor.id }
|
|
23678
23713
|
})
|
|
23679
23714
|
);
|
|
23680
23715
|
const hasMore = rows.length > limit;
|
|
23681
23716
|
const page = hasMore ? rows.slice(0, limit) : rows;
|
|
23682
23717
|
const last = page[page.length - 1];
|
|
23683
|
-
const
|
|
23684
|
-
this.db
|
|
23685
|
-
|
|
23686
|
-
|
|
23718
|
+
const counts = getRow(
|
|
23719
|
+
this.db.prepare(
|
|
23720
|
+
`SELECT count(*) AS total,
|
|
23721
|
+
count(*) FILTER (WHERE reason IN ('display', 'view-render')) AS hidden
|
|
23722
|
+
FROM secret_vault_deref`
|
|
23723
|
+
)
|
|
23724
|
+
) ?? { total: 0, hidden: 0 };
|
|
23725
|
+
const includeBatched = query.includeBatched === true;
|
|
23726
|
+
const hiddenBatched = includeBatched ? 0 : counts.hidden;
|
|
23687
23727
|
return {
|
|
23728
|
+
totals: { derefs: includeBatched ? counts.total : counts.total - counts.hidden },
|
|
23688
23729
|
items: page.map((r) => ({
|
|
23689
23730
|
id: r.id,
|
|
23690
23731
|
pointerId: r.pointer_id,
|
|
@@ -23709,6 +23750,43 @@ var SqliteSecretVaultRepository = class {
|
|
|
23709
23750
|
`SELECT COUNT(*) AS n FROM secret_vault v WHERE ${REUSED_PREDICATE}`
|
|
23710
23751
|
);
|
|
23711
23752
|
}
|
|
23753
|
+
/**
|
|
23754
|
+
* Every entry held, and how many of them are NOT under `currentVersion` — the
|
|
23755
|
+
* standing record of a fingerprint-key rotation whose re-key did not reach
|
|
23756
|
+
* every row.
|
|
23757
|
+
*
|
|
23758
|
+
* This is the durable form of what `SecretVault.refreshFingerprints` reports
|
|
23759
|
+
* once. That count is an event, gone the moment it is printed; this is the
|
|
23760
|
+
* condition, and it stays true until some later rotation re-keys the rows. It
|
|
23761
|
+
* is therefore the one that can answer "is a shortfall still outstanding?" —
|
|
23762
|
+
* including for a rotation run from the CLI, which no dashboard render saw.
|
|
23763
|
+
*
|
|
23764
|
+
* `<>` rather than `<`: a row ahead of the current version is equally
|
|
23765
|
+
* unmatchable, and that is reachable — a key file restored from a backup, or
|
|
23766
|
+
* replaced after being lost, leaves rows stamped higher than the key is.
|
|
23767
|
+
*
|
|
23768
|
+
* Both numbers come from ONE statement, which is why this returns a pair
|
|
23769
|
+
* instead of offering two counts to call. Read separately, a purge landing
|
|
23770
|
+
* between them hands back a `stale` counted over rows the later `total` no
|
|
23771
|
+
* longer includes, and a disclosure built from that pair states a fraction
|
|
23772
|
+
* true of no state of the table — "1 of 0 stored values", or a negative
|
|
23773
|
+
* remainder. Same reasoning as `purgeVault`'s count, which comes from the
|
|
23774
|
+
* delete rather than from a `countEntries` standing beside it.
|
|
23775
|
+
*/
|
|
23776
|
+
countFingerprintEpochs(currentVersion) {
|
|
23777
|
+
const row = getRow(
|
|
23778
|
+
this.db.prepare(
|
|
23779
|
+
`SELECT COUNT(*) AS total,
|
|
23780
|
+
COALESCE(
|
|
23781
|
+
SUM(CASE WHEN fingerprint_key_version <> :currentVersion THEN 1 ELSE 0 END),
|
|
23782
|
+
0
|
|
23783
|
+
) AS stale
|
|
23784
|
+
FROM secret_vault`
|
|
23785
|
+
),
|
|
23786
|
+
{ currentVersion }
|
|
23787
|
+
) ?? { stale: 0, total: 0 };
|
|
23788
|
+
return { stale: row.stale, total: row.total };
|
|
23789
|
+
}
|
|
23712
23790
|
};
|
|
23713
23791
|
|
|
23714
23792
|
// ../../packages/persistence/src/repositories/security.ts
|
|
@@ -25518,13 +25596,22 @@ var SecretVault = class {
|
|
|
25518
25596
|
* fingerprint collides with a row already refreshed, is skipped rather than
|
|
25519
25597
|
* aborting the pass — one damaged entry must not strand the re-key of every
|
|
25520
25598
|
* other. A skipped row keeps resolving under its old fingerprint epoch.
|
|
25599
|
+
*
|
|
25600
|
+
* Every skip is COUNTED, because best-effort and silent are different things:
|
|
25601
|
+
* the loss above is invisible at the moment it happens and only shows up later
|
|
25602
|
+
* as a duplicate pointer, so the pass owes its caller a denominator rather
|
|
25603
|
+
* than a bare success count.
|
|
25521
25604
|
*/
|
|
25522
25605
|
async refreshFingerprints(next) {
|
|
25523
25606
|
let refreshed = 0;
|
|
25607
|
+
let skipped = 0;
|
|
25524
25608
|
for (const row of this.#repo.listAll()) {
|
|
25525
25609
|
try {
|
|
25526
25610
|
const raw = await this.#openRow(row);
|
|
25527
|
-
if (raw === null)
|
|
25611
|
+
if (raw === null) {
|
|
25612
|
+
skipped += 1;
|
|
25613
|
+
continue;
|
|
25614
|
+
}
|
|
25528
25615
|
this.#repo.refreshFingerprint(row.pointerId, {
|
|
25529
25616
|
valueFingerprint: exactFingerprintValue(next, raw),
|
|
25530
25617
|
valueIdentityFingerprint: fingerprintValue(next, raw),
|
|
@@ -25532,10 +25619,10 @@ var SecretVault = class {
|
|
|
25532
25619
|
});
|
|
25533
25620
|
refreshed += 1;
|
|
25534
25621
|
} catch {
|
|
25535
|
-
|
|
25622
|
+
skipped += 1;
|
|
25536
25623
|
}
|
|
25537
25624
|
}
|
|
25538
|
-
return refreshed;
|
|
25625
|
+
return { refreshed, skipped };
|
|
25539
25626
|
}
|
|
25540
25627
|
/**
|
|
25541
25628
|
* Destroy every entry, making all outstanding pointers permanently
|
|
@@ -26874,6 +26961,21 @@ function registerPack(pack) {
|
|
|
26874
26961
|
function getLoadedRules() {
|
|
26875
26962
|
return [...packs.values()].flatMap((p) => p.rules);
|
|
26876
26963
|
}
|
|
26964
|
+
function outsideWrittenRegions(candidates, context) {
|
|
26965
|
+
const regions = context?.writtenRegions;
|
|
26966
|
+
if (!regions || regions.length === 0 || context.eventKind !== "tool_use") return candidates;
|
|
26967
|
+
return candidates.filter((c) => {
|
|
26968
|
+
if (c.rule.category !== "code_flaw") return true;
|
|
26969
|
+
const { start, end } = c.match.span;
|
|
26970
|
+
return !regions.some(
|
|
26971
|
+
(r) => r.start <= start && end <= r.end && ruleApplies(
|
|
26972
|
+
c.rule,
|
|
26973
|
+
r.filePath === void 0 ? void 0 : extensionOf(r.filePath),
|
|
26974
|
+
"code_change"
|
|
26975
|
+
)
|
|
26976
|
+
);
|
|
26977
|
+
});
|
|
26978
|
+
}
|
|
26877
26979
|
function spansOverlap(a, b) {
|
|
26878
26980
|
return a.start < b.end && a.end > b.start;
|
|
26879
26981
|
}
|
|
@@ -27061,17 +27163,20 @@ function scanEncoded(text, ruleset, context) {
|
|
|
27061
27163
|
function scanText(text, ruleset, context) {
|
|
27062
27164
|
const extension = context?.filePath ? extensionOf(context.filePath) : void 0;
|
|
27063
27165
|
const normalization = normalizeFormatChars(text);
|
|
27064
|
-
const originalCandidates =
|
|
27166
|
+
const originalCandidates = outsideWrittenRegions(
|
|
27167
|
+
buildCandidates(text, ruleset, extension, context?.eventKind),
|
|
27168
|
+
context
|
|
27169
|
+
);
|
|
27065
27170
|
if (!normalization) return gate(originalCandidates, text, void 0);
|
|
27066
27171
|
const pooledOriginal = originalCandidates.map(
|
|
27067
27172
|
(candidate) => withNormalizedSpan(candidate, normalization)
|
|
27068
27173
|
);
|
|
27069
|
-
const normalizedCandidates =
|
|
27070
|
-
normalization.normalized,
|
|
27071
|
-
|
|
27072
|
-
|
|
27073
|
-
context
|
|
27074
|
-
)
|
|
27174
|
+
const normalizedCandidates = outsideWrittenRegions(
|
|
27175
|
+
buildCandidates(normalization.normalized, ruleset, extension, context?.eventKind).map(
|
|
27176
|
+
(candidate) => mapCandidateToOriginal(candidate, normalization, text)
|
|
27177
|
+
),
|
|
27178
|
+
context
|
|
27179
|
+
);
|
|
27075
27180
|
const findings = gate([...pooledOriginal, ...normalizedCandidates], text, normalization);
|
|
27076
27181
|
return mergeOverlappingSameRule(findings, text);
|
|
27077
27182
|
}
|
|
@@ -27132,6 +27237,7 @@ var BUNDLED_CODE_EVIDENCE = /* @__PURE__ */ new Set([
|
|
|
27132
27237
|
"code-flaws/sql-inject-concat-dot",
|
|
27133
27238
|
"code-flaws/sql-inject-format",
|
|
27134
27239
|
"code-flaws/sql-inject-interp",
|
|
27240
|
+
"code-flaws/sql-inject-interp-multiline",
|
|
27135
27241
|
"code-flaws/ssrf-user-url",
|
|
27136
27242
|
"code-flaws/xss-dangerously-set",
|
|
27137
27243
|
"code-flaws/xss-inner-html",
|
|
@@ -28270,7 +28376,7 @@ var sql_inject_concat_dot_default = {
|
|
|
28270
28376
|
severity: "high",
|
|
28271
28377
|
matcher: {
|
|
28272
28378
|
type: "regex",
|
|
28273
|
-
pattern:
|
|
28379
|
+
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*\\.",
|
|
28274
28380
|
flags: "gi"
|
|
28275
28381
|
},
|
|
28276
28382
|
appliesTo: {
|
|
@@ -28288,7 +28394,7 @@ var sql_inject_concat_default = {
|
|
|
28288
28394
|
severity: "high",
|
|
28289
28395
|
matcher: {
|
|
28290
28396
|
type: "regex",
|
|
28291
|
-
pattern:
|
|
28397
|
+
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*\\+",
|
|
28292
28398
|
flags: "gi"
|
|
28293
28399
|
},
|
|
28294
28400
|
examples: ['"SELECT * FROM users WHERE id = " + userId']
|
|
@@ -28303,7 +28409,7 @@ var sql_inject_format_default = {
|
|
|
28303
28409
|
severity: "high",
|
|
28304
28410
|
matcher: {
|
|
28305
28411
|
type: "regex",
|
|
28306
|
-
pattern:
|
|
28412
|
+
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]+\\})",
|
|
28307
28413
|
flags: "gi"
|
|
28308
28414
|
},
|
|
28309
28415
|
examples: [
|
|
@@ -28312,6 +28418,24 @@ var sql_inject_format_default = {
|
|
|
28312
28418
|
]
|
|
28313
28419
|
};
|
|
28314
28420
|
|
|
28421
|
+
// ../../rules/code-flaws/sql-inject-interp-multiline.json
|
|
28422
|
+
var sql_inject_interp_multiline_default = {
|
|
28423
|
+
specVersion: 1,
|
|
28424
|
+
id: "code-flaws/sql-inject-interp-multiline",
|
|
28425
|
+
name: "SQL injection via Ruby string interpolation or PHP variable (statement on its own line, e.g. a heredoc)",
|
|
28426
|
+
category: "code_flaw",
|
|
28427
|
+
severity: "high",
|
|
28428
|
+
matcher: {
|
|
28429
|
+
type: "regex",
|
|
28430
|
+
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_])',
|
|
28431
|
+
flags: "gi"
|
|
28432
|
+
},
|
|
28433
|
+
examples: ["sql = <<~SQL\n SELECT * FROM users WHERE id = #{params[:id]}\nSQL"],
|
|
28434
|
+
appliesTo: {
|
|
28435
|
+
extensions: [".rb", ".php"]
|
|
28436
|
+
}
|
|
28437
|
+
};
|
|
28438
|
+
|
|
28315
28439
|
// ../../rules/code-flaws/sql-inject-interp.json
|
|
28316
28440
|
var sql_inject_interp_default = {
|
|
28317
28441
|
specVersion: 1,
|
|
@@ -28321,7 +28445,7 @@ var sql_inject_interp_default = {
|
|
|
28321
28445
|
severity: "high",
|
|
28322
28446
|
matcher: {
|
|
28323
28447
|
type: "regex",
|
|
28324
|
-
pattern: "([\
|
|
28448
|
+
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_])',
|
|
28325
28449
|
flags: "gi"
|
|
28326
28450
|
},
|
|
28327
28451
|
examples: [
|
|
@@ -30049,12 +30173,13 @@ var BUNDLED_PACKS = [
|
|
|
30049
30173
|
{
|
|
30050
30174
|
packId: "code-flaws",
|
|
30051
30175
|
name: "Code Security Flaws",
|
|
30052
|
-
version: "0.1.
|
|
30176
|
+
version: "0.1.6",
|
|
30053
30177
|
rawRules: [
|
|
30054
30178
|
sql_inject_concat_default,
|
|
30055
30179
|
sql_inject_concat_dot_default,
|
|
30056
30180
|
sql_inject_format_default,
|
|
30057
30181
|
sql_inject_interp_default,
|
|
30182
|
+
sql_inject_interp_multiline_default,
|
|
30058
30183
|
cmd_inject_shell_default,
|
|
30059
30184
|
cmd_inject_exec_default,
|
|
30060
30185
|
cmd_inject_node_exec_default,
|
|
@@ -30086,6 +30211,7 @@ var BUNDLED_PACKS = [
|
|
|
30086
30211
|
"code-flaws/sql-inject-concat-dot": "SQL injection (PHP)",
|
|
30087
30212
|
"code-flaws/sql-inject-format": "SQL injection (format string)",
|
|
30088
30213
|
"code-flaws/sql-inject-interp": "SQL injection (interpolation)",
|
|
30214
|
+
"code-flaws/sql-inject-interp-multiline": "SQL injection (interpolation)",
|
|
30089
30215
|
"code-flaws/cmd-inject-shell": "Command injection (shell)",
|
|
30090
30216
|
"code-flaws/cmd-inject-exec": "Command injection (Java exec)",
|
|
30091
30217
|
"code-flaws/cmd-inject-node-exec": "Command injection (Node exec)",
|
|
@@ -30762,8 +30888,25 @@ function bundledMaskingRules() {
|
|
|
30762
30888
|
return ensureBundledPacks() ? getLoadedRules() : null;
|
|
30763
30889
|
}
|
|
30764
30890
|
|
|
30891
|
+
// ../../packages/plugin-sdk/src/regular-file.ts
|
|
30892
|
+
import { closeSync as closeSync2, constants, fstatSync, openSync as openSync2, readFileSync as readFileSync16 } from "fs";
|
|
30893
|
+
function notRegularFile(path) {
|
|
30894
|
+
return `not a regular file: ${path}`;
|
|
30895
|
+
}
|
|
30896
|
+
function readRegularFile(path, maxBytes) {
|
|
30897
|
+
const fd = openSync2(path, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
30898
|
+
try {
|
|
30899
|
+
const stat2 = fstatSync(fd);
|
|
30900
|
+
if (!stat2.isFile()) throw new Error(notRegularFile(path));
|
|
30901
|
+
if (maxBytes !== void 0 && stat2.size > maxBytes) throw new Error(`file too large: ${path}`);
|
|
30902
|
+
return readFileSync16(fd, "utf8");
|
|
30903
|
+
} finally {
|
|
30904
|
+
closeSync2(fd);
|
|
30905
|
+
}
|
|
30906
|
+
}
|
|
30907
|
+
|
|
30765
30908
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
30766
|
-
import { existsSync as existsSync9,
|
|
30909
|
+
import { existsSync as existsSync9, statSync as statSync7 } from "fs";
|
|
30767
30910
|
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute3, join as join24, sep as sep4 } from "path";
|
|
30768
30911
|
function resolveRepo(cwd) {
|
|
30769
30912
|
try {
|
|
@@ -30842,9 +30985,10 @@ function resolveGitContext(root) {
|
|
|
30842
30985
|
const headRoot = basename2(commonGitDir) === ".git" ? dirname5(commonGitDir) : root;
|
|
30843
30986
|
return { configPath: join24(commonGitDir, "config"), headRoot };
|
|
30844
30987
|
}
|
|
30988
|
+
var MAX_GIT_METADATA_BYTES = 1024 * 1024;
|
|
30845
30989
|
function safeRead(path) {
|
|
30846
30990
|
try {
|
|
30847
|
-
return
|
|
30991
|
+
return readRegularFile(path, MAX_GIT_METADATA_BYTES);
|
|
30848
30992
|
} catch {
|
|
30849
30993
|
return void 0;
|
|
30850
30994
|
}
|
|
@@ -31165,6 +31309,7 @@ function createIsolatedScanner(data, opts = {}) {
|
|
|
31165
31309
|
text,
|
|
31166
31310
|
filePath: context?.filePath,
|
|
31167
31311
|
eventKind: context?.eventKind,
|
|
31312
|
+
writtenRegions: context?.writtenRegions,
|
|
31168
31313
|
attribute: scanOpts?.attribute === true
|
|
31169
31314
|
}),
|
|
31170
31315
|
reply: (message) => {
|
|
@@ -31912,7 +32057,8 @@ function createPluginRuntime(gateway, settings, opts) {
|
|
|
31912
32057
|
input.text,
|
|
31913
32058
|
{
|
|
31914
32059
|
filePath: input.metadata?.filePath,
|
|
31915
|
-
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind
|
|
32060
|
+
eventKind: opts2.kindScopedRules === false ? void 0 : input.kind,
|
|
32061
|
+
writtenRegions: opts2.writtenRegions
|
|
31916
32062
|
},
|
|
31917
32063
|
{
|
|
31918
32064
|
sourceTool: input.sourceTool,
|
|
@@ -35944,6 +36090,7 @@ var DAY_MS5 = 24 * 60 * 60 * 1e3;
|
|
|
35944
36090
|
|
|
35945
36091
|
// src/remediation/redact.ts
|
|
35946
36092
|
import {
|
|
36093
|
+
chmodSync as chmodSync4,
|
|
35947
36094
|
lstatSync as lstatSync6,
|
|
35948
36095
|
readdirSync as readdirSync5,
|
|
35949
36096
|
readFileSync as readFileSync27,
|
|
@@ -36000,9 +36147,11 @@ function sweepStrandedTemps(realPath) {
|
|
|
36000
36147
|
for (const name of names) {
|
|
36001
36148
|
if (!name.startsWith(prefix) || !name.endsWith(TMP_SUFFIX)) continue;
|
|
36002
36149
|
const pidPart = name.slice(prefix.length, name.length - TMP_SUFFIX.length);
|
|
36003
|
-
if (
|
|
36004
|
-
|
|
36005
|
-
|
|
36150
|
+
if (pidPart !== "") {
|
|
36151
|
+
if (!/^\d+$/.test(pidPart)) continue;
|
|
36152
|
+
const pid = Number(pidPart);
|
|
36153
|
+
if (pid !== process.pid && isProcessAlive(pid)) continue;
|
|
36154
|
+
}
|
|
36006
36155
|
try {
|
|
36007
36156
|
const stranded = join40(dir, name);
|
|
36008
36157
|
if (!lstatSync6(stranded).isFile()) continue;
|
|
@@ -36049,6 +36198,7 @@ function redactLeakedKeysDetailed(targets, scope = platformRedactionScope()) {
|
|
|
36049
36198
|
const tmpPath = tempPathFor(filePath);
|
|
36050
36199
|
try {
|
|
36051
36200
|
writeFileSync7(tmpPath, content, { mode, flag: "wx" });
|
|
36201
|
+
chmodSync4(tmpPath, mode);
|
|
36052
36202
|
renameSync5(tmpPath, filePath);
|
|
36053
36203
|
} catch {
|
|
36054
36204
|
try {
|