@akasecurity/ai-tc-claude-code 0.9.2 → 0.9.3
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/.claude-plugin/plugin.json +1 -1
- package/package.json +3 -3
- package/scripts/apply-suppressions.js +94 -45
- package/scripts/backfill.js +139 -47
- package/scripts/filescan.js +141 -49
- package/scripts/firstrun.js +93 -44
- package/scripts/intro.js +6 -5
- package/scripts/onboard.js +93 -44
- package/scripts/post-tool-use.js +139 -47
- package/scripts/pre-tool-use.js +139 -47
- package/scripts/query.js +93 -44
- package/scripts/reconcile.js +95 -46
- package/scripts/remediate.js +139 -47
- package/scripts/session-start.js +96 -47
- package/scripts/start-light.js +6 -5
- package/scripts/statusline.js +93 -44
- package/scripts/stop.js +7 -6
- package/scripts/user-prompt-submit.js +139 -47
package/scripts/onboard.js
CHANGED
|
@@ -23380,11 +23380,22 @@ function purgeSampleData(db) {
|
|
|
23380
23380
|
function linkHost(input, hostId) {
|
|
23381
23381
|
return hostId ? { ...input, hostId } : input;
|
|
23382
23382
|
}
|
|
23383
|
+
function closeQuietly(db) {
|
|
23384
|
+
try {
|
|
23385
|
+
db.close();
|
|
23386
|
+
} catch {
|
|
23387
|
+
}
|
|
23388
|
+
}
|
|
23383
23389
|
function openWithPragmas(file2) {
|
|
23384
23390
|
const db = new DatabaseSync(file2);
|
|
23385
|
-
|
|
23386
|
-
|
|
23387
|
-
|
|
23391
|
+
try {
|
|
23392
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
23393
|
+
db.exec("PRAGMA busy_timeout = 2000");
|
|
23394
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
23395
|
+
} catch (err) {
|
|
23396
|
+
closeQuietly(db);
|
|
23397
|
+
throw err;
|
|
23398
|
+
}
|
|
23388
23399
|
return db;
|
|
23389
23400
|
}
|
|
23390
23401
|
function backupLegacyStore(file2) {
|
|
@@ -23396,43 +23407,80 @@ function backupLegacyStore(file2) {
|
|
|
23396
23407
|
}
|
|
23397
23408
|
return backup;
|
|
23398
23409
|
}
|
|
23410
|
+
function openAndInitialize(file2) {
|
|
23411
|
+
let db = openWithPragmas(file2);
|
|
23412
|
+
try {
|
|
23413
|
+
if (isForeignSqliteLineage(db)) {
|
|
23414
|
+
db.close();
|
|
23415
|
+
const backup = backupLegacyStore(file2);
|
|
23416
|
+
db = openWithPragmas(file2);
|
|
23417
|
+
akaWarn(
|
|
23418
|
+
`Detected an older, incompatible (tenant-bearing) ${DB_FILENAME}; backed it up to ${backup} and created a fresh store.`
|
|
23419
|
+
);
|
|
23420
|
+
}
|
|
23421
|
+
applyMigrations(db, file2);
|
|
23422
|
+
tightenPerms(file2);
|
|
23423
|
+
const policies = new SqlitePoliciesRepository(db);
|
|
23424
|
+
const installedPacks = new SqliteInstalledPacksRepository(db);
|
|
23425
|
+
const repositories = {
|
|
23426
|
+
events: new SqliteEventsRepository(db),
|
|
23427
|
+
findings: new SqliteFindingsRepository(db),
|
|
23428
|
+
policies,
|
|
23429
|
+
installedPacks,
|
|
23430
|
+
scanLedger: new SqliteScanLedgerRepository(db),
|
|
23431
|
+
exceptions: new SqliteExceptionsRepository(db),
|
|
23432
|
+
resolutions: new SqliteResolutionsRepository(db),
|
|
23433
|
+
ruleProbeCache: new SqliteRuleProbeCacheRepository(db),
|
|
23434
|
+
security: new SqliteSecurityRepository(db),
|
|
23435
|
+
detections: new SqliteDetectionsRepository(db),
|
|
23436
|
+
shares: new SqliteSharesRepository(db),
|
|
23437
|
+
policyCatalog: new SqlitePolicyCatalogRepository(installedPacks),
|
|
23438
|
+
inventory: new SqliteInventoryRepository(db),
|
|
23439
|
+
inventoryAssets: new SqliteInventoryAssetsRepository(db),
|
|
23440
|
+
projectFiles: new SqliteProjectFilesRepository(db),
|
|
23441
|
+
activity: new SqliteActivityRepository(db),
|
|
23442
|
+
sourceProject: new SqliteSourceProjectRepository(db),
|
|
23443
|
+
auditEvents: new SqliteAuditEventsRepository(db),
|
|
23444
|
+
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
23445
|
+
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
23446
|
+
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
23447
|
+
configInventory: new SqliteConfigInventoryRepository(db)
|
|
23448
|
+
};
|
|
23449
|
+
policies.seedDefaults();
|
|
23450
|
+
return { db, ...repositories };
|
|
23451
|
+
} catch (err) {
|
|
23452
|
+
closeQuietly(db);
|
|
23453
|
+
throw err;
|
|
23454
|
+
}
|
|
23455
|
+
}
|
|
23399
23456
|
function openLocalDatabase(dir) {
|
|
23400
23457
|
ensureDataDirSync(dir);
|
|
23401
23458
|
const file2 = join(dir, DB_FILENAME);
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
|
|
23409
|
-
|
|
23410
|
-
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
|
|
23424
|
-
|
|
23425
|
-
|
|
23426
|
-
|
|
23427
|
-
const projectFiles = new SqliteProjectFilesRepository(db);
|
|
23428
|
-
const activity = new SqliteActivityRepository(db);
|
|
23429
|
-
const sourceProject = new SqliteSourceProjectRepository(db);
|
|
23430
|
-
const auditEvents = new SqliteAuditEventsRepository(db);
|
|
23431
|
-
const classifiedData = new SqliteClassifiedDataRepository(db);
|
|
23432
|
-
const inspectionDefinitions = new SqliteInspectionDefinitionsRepository(db);
|
|
23433
|
-
const inspectionFindings = new SqliteInspectionFindingsRepository(db);
|
|
23434
|
-
const configInventory = new SqliteConfigInventoryRepository(db);
|
|
23435
|
-
policies.seedDefaults();
|
|
23459
|
+
const {
|
|
23460
|
+
db,
|
|
23461
|
+
events,
|
|
23462
|
+
findings,
|
|
23463
|
+
policies,
|
|
23464
|
+
installedPacks,
|
|
23465
|
+
scanLedger,
|
|
23466
|
+
exceptions,
|
|
23467
|
+
resolutions,
|
|
23468
|
+
ruleProbeCache,
|
|
23469
|
+
security,
|
|
23470
|
+
detections,
|
|
23471
|
+
shares,
|
|
23472
|
+
policyCatalog,
|
|
23473
|
+
inventory,
|
|
23474
|
+
inventoryAssets,
|
|
23475
|
+
projectFiles,
|
|
23476
|
+
activity,
|
|
23477
|
+
sourceProject,
|
|
23478
|
+
auditEvents,
|
|
23479
|
+
classifiedData,
|
|
23480
|
+
inspectionDefinitions,
|
|
23481
|
+
inspectionFindings,
|
|
23482
|
+
configInventory
|
|
23483
|
+
} = openAndInitialize(file2);
|
|
23436
23484
|
function recordCapture(event, detected) {
|
|
23437
23485
|
failOpenTransaction(db, () => {
|
|
23438
23486
|
const sessionId = event.metadata?.sessionId;
|
|
@@ -23637,8 +23685,9 @@ import { createHash as createHash3 } from "crypto";
|
|
|
23637
23685
|
|
|
23638
23686
|
// ../../packages/persistence/src/fingerprint.ts
|
|
23639
23687
|
import { createHmac, randomBytes } from "crypto";
|
|
23640
|
-
import { readFileSync } from "fs";
|
|
23688
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
23641
23689
|
import { join as join2 } from "path";
|
|
23690
|
+
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
23642
23691
|
|
|
23643
23692
|
// ../../packages/persistence/src/local-layout.ts
|
|
23644
23693
|
import { renameSync as renameSync3 } from "fs";
|
|
@@ -23714,13 +23763,13 @@ function readJson(file2) {
|
|
|
23714
23763
|
}
|
|
23715
23764
|
|
|
23716
23765
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
23717
|
-
import { existsSync as
|
|
23766
|
+
import { existsSync as existsSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
23718
23767
|
import { join as join5 } from "path";
|
|
23719
23768
|
var MARKER = "warn-era-capped";
|
|
23720
23769
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
23721
23770
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
23722
23771
|
const marker = join5(dataDir2, MARKER);
|
|
23723
|
-
if (
|
|
23772
|
+
if (existsSync3(marker)) return { capped: 0, skipped: "already-run" };
|
|
23724
23773
|
const capped = db.policies.capCategoryActions();
|
|
23725
23774
|
writeFileSync2(marker, `${new Date(Date.now()).toISOString()}
|
|
23726
23775
|
`, { mode: DATA_FILE_MODE });
|
|
@@ -23728,7 +23777,7 @@ function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
|
23728
23777
|
}
|
|
23729
23778
|
|
|
23730
23779
|
// ../../packages/plugin-sdk/src/config.ts
|
|
23731
|
-
import { existsSync as
|
|
23780
|
+
import { existsSync as existsSync4 } from "fs";
|
|
23732
23781
|
import { join as join6 } from "path";
|
|
23733
23782
|
|
|
23734
23783
|
// ../../packages/plugin-sdk/src/provider-env.ts
|
|
@@ -23784,7 +23833,7 @@ function loadConfig(base = defaultDataDir()) {
|
|
|
23784
23833
|
try {
|
|
23785
23834
|
ensureLayoutDirSync(base);
|
|
23786
23835
|
const settingsFile = join6(settingsDir(base), "settings.json");
|
|
23787
|
-
if (
|
|
23836
|
+
if (existsSync4(settingsFile)) tightenFile(settingsFile);
|
|
23788
23837
|
} catch {
|
|
23789
23838
|
}
|
|
23790
23839
|
migrateLegacyLayout(base);
|
|
@@ -24520,7 +24569,7 @@ var POLYNOMIAL_PROBES = ["abc-", "a.", "a ", "a=", "x", "0", "a@", "a/", "ab"].m
|
|
|
24520
24569
|
);
|
|
24521
24570
|
|
|
24522
24571
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
24523
|
-
import { existsSync as
|
|
24572
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, statSync } from "fs";
|
|
24524
24573
|
import { basename, dirname, isAbsolute, join as join7, sep as sep2 } from "path";
|
|
24525
24574
|
|
|
24526
24575
|
// ../../packages/plugin-sdk/src/events.ts
|
|
@@ -24549,7 +24598,7 @@ function applyCategoryPosture(posture, repo, mode = "fill-gaps") {
|
|
|
24549
24598
|
|
|
24550
24599
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
24551
24600
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
24552
|
-
import { existsSync as
|
|
24601
|
+
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync6 } from "fs";
|
|
24553
24602
|
import { basename as basename4, join as join10, relative, sep as sep4 } from "path";
|
|
24554
24603
|
|
|
24555
24604
|
// ../../packages/plugin-sdk/src/runtime.ts
|
package/scripts/post-tool-use.js
CHANGED
|
@@ -492,7 +492,7 @@ var require_ignore = __commonJS({
|
|
|
492
492
|
});
|
|
493
493
|
|
|
494
494
|
// ../../packages/plugin-sdk/src/config.ts
|
|
495
|
-
import { existsSync as
|
|
495
|
+
import { existsSync as existsSync4 } from "fs";
|
|
496
496
|
import { join as join6 } from "path";
|
|
497
497
|
|
|
498
498
|
// ../../packages/persistence/src/database.ts
|
|
@@ -23389,11 +23389,22 @@ function purgeSampleData(db) {
|
|
|
23389
23389
|
function linkHost(input, hostId) {
|
|
23390
23390
|
return hostId ? { ...input, hostId } : input;
|
|
23391
23391
|
}
|
|
23392
|
+
function closeQuietly(db) {
|
|
23393
|
+
try {
|
|
23394
|
+
db.close();
|
|
23395
|
+
} catch {
|
|
23396
|
+
}
|
|
23397
|
+
}
|
|
23392
23398
|
function openWithPragmas(file2) {
|
|
23393
23399
|
const db = new DatabaseSync(file2);
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23400
|
+
try {
|
|
23401
|
+
db.exec("PRAGMA journal_mode = WAL");
|
|
23402
|
+
db.exec("PRAGMA busy_timeout = 2000");
|
|
23403
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
23404
|
+
} catch (err) {
|
|
23405
|
+
closeQuietly(db);
|
|
23406
|
+
throw err;
|
|
23407
|
+
}
|
|
23397
23408
|
return db;
|
|
23398
23409
|
}
|
|
23399
23410
|
function backupLegacyStore(file2) {
|
|
@@ -23405,43 +23416,80 @@ function backupLegacyStore(file2) {
|
|
|
23405
23416
|
}
|
|
23406
23417
|
return backup;
|
|
23407
23418
|
}
|
|
23419
|
+
function openAndInitialize(file2) {
|
|
23420
|
+
let db = openWithPragmas(file2);
|
|
23421
|
+
try {
|
|
23422
|
+
if (isForeignSqliteLineage(db)) {
|
|
23423
|
+
db.close();
|
|
23424
|
+
const backup = backupLegacyStore(file2);
|
|
23425
|
+
db = openWithPragmas(file2);
|
|
23426
|
+
akaWarn(
|
|
23427
|
+
`Detected an older, incompatible (tenant-bearing) ${DB_FILENAME}; backed it up to ${backup} and created a fresh store.`
|
|
23428
|
+
);
|
|
23429
|
+
}
|
|
23430
|
+
applyMigrations(db, file2);
|
|
23431
|
+
tightenPerms(file2);
|
|
23432
|
+
const policies = new SqlitePoliciesRepository(db);
|
|
23433
|
+
const installedPacks = new SqliteInstalledPacksRepository(db);
|
|
23434
|
+
const repositories = {
|
|
23435
|
+
events: new SqliteEventsRepository(db),
|
|
23436
|
+
findings: new SqliteFindingsRepository(db),
|
|
23437
|
+
policies,
|
|
23438
|
+
installedPacks,
|
|
23439
|
+
scanLedger: new SqliteScanLedgerRepository(db),
|
|
23440
|
+
exceptions: new SqliteExceptionsRepository(db),
|
|
23441
|
+
resolutions: new SqliteResolutionsRepository(db),
|
|
23442
|
+
ruleProbeCache: new SqliteRuleProbeCacheRepository(db),
|
|
23443
|
+
security: new SqliteSecurityRepository(db),
|
|
23444
|
+
detections: new SqliteDetectionsRepository(db),
|
|
23445
|
+
shares: new SqliteSharesRepository(db),
|
|
23446
|
+
policyCatalog: new SqlitePolicyCatalogRepository(installedPacks),
|
|
23447
|
+
inventory: new SqliteInventoryRepository(db),
|
|
23448
|
+
inventoryAssets: new SqliteInventoryAssetsRepository(db),
|
|
23449
|
+
projectFiles: new SqliteProjectFilesRepository(db),
|
|
23450
|
+
activity: new SqliteActivityRepository(db),
|
|
23451
|
+
sourceProject: new SqliteSourceProjectRepository(db),
|
|
23452
|
+
auditEvents: new SqliteAuditEventsRepository(db),
|
|
23453
|
+
classifiedData: new SqliteClassifiedDataRepository(db),
|
|
23454
|
+
inspectionDefinitions: new SqliteInspectionDefinitionsRepository(db),
|
|
23455
|
+
inspectionFindings: new SqliteInspectionFindingsRepository(db),
|
|
23456
|
+
configInventory: new SqliteConfigInventoryRepository(db)
|
|
23457
|
+
};
|
|
23458
|
+
policies.seedDefaults();
|
|
23459
|
+
return { db, ...repositories };
|
|
23460
|
+
} catch (err) {
|
|
23461
|
+
closeQuietly(db);
|
|
23462
|
+
throw err;
|
|
23463
|
+
}
|
|
23464
|
+
}
|
|
23408
23465
|
function openLocalDatabase(dir) {
|
|
23409
23466
|
ensureDataDirSync(dir);
|
|
23410
23467
|
const file2 = join(dir, DB_FILENAME);
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
|
|
23424
|
-
|
|
23425
|
-
|
|
23426
|
-
|
|
23427
|
-
|
|
23428
|
-
|
|
23429
|
-
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
|
|
23436
|
-
const projectFiles = new SqliteProjectFilesRepository(db);
|
|
23437
|
-
const activity = new SqliteActivityRepository(db);
|
|
23438
|
-
const sourceProject = new SqliteSourceProjectRepository(db);
|
|
23439
|
-
const auditEvents = new SqliteAuditEventsRepository(db);
|
|
23440
|
-
const classifiedData = new SqliteClassifiedDataRepository(db);
|
|
23441
|
-
const inspectionDefinitions = new SqliteInspectionDefinitionsRepository(db);
|
|
23442
|
-
const inspectionFindings = new SqliteInspectionFindingsRepository(db);
|
|
23443
|
-
const configInventory = new SqliteConfigInventoryRepository(db);
|
|
23444
|
-
policies.seedDefaults();
|
|
23468
|
+
const {
|
|
23469
|
+
db,
|
|
23470
|
+
events,
|
|
23471
|
+
findings,
|
|
23472
|
+
policies,
|
|
23473
|
+
installedPacks,
|
|
23474
|
+
scanLedger,
|
|
23475
|
+
exceptions,
|
|
23476
|
+
resolutions,
|
|
23477
|
+
ruleProbeCache,
|
|
23478
|
+
security,
|
|
23479
|
+
detections,
|
|
23480
|
+
shares,
|
|
23481
|
+
policyCatalog,
|
|
23482
|
+
inventory,
|
|
23483
|
+
inventoryAssets,
|
|
23484
|
+
projectFiles,
|
|
23485
|
+
activity,
|
|
23486
|
+
sourceProject,
|
|
23487
|
+
auditEvents,
|
|
23488
|
+
classifiedData,
|
|
23489
|
+
inspectionDefinitions,
|
|
23490
|
+
inspectionFindings,
|
|
23491
|
+
configInventory
|
|
23492
|
+
} = openAndInitialize(file2);
|
|
23445
23493
|
function recordCapture(event, detected) {
|
|
23446
23494
|
failOpenTransaction(db, () => {
|
|
23447
23495
|
const sessionId = event.metadata?.sessionId;
|
|
@@ -23653,8 +23701,9 @@ function computeFindingKey(input) {
|
|
|
23653
23701
|
|
|
23654
23702
|
// ../../packages/persistence/src/fingerprint.ts
|
|
23655
23703
|
import { createHmac, randomBytes } from "crypto";
|
|
23656
|
-
import { readFileSync } from "fs";
|
|
23704
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
23657
23705
|
import { join as join2 } from "path";
|
|
23706
|
+
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
23658
23707
|
var KEY_FILENAME = "exception.key";
|
|
23659
23708
|
var KEY_MATERIAL_BYTES = 32;
|
|
23660
23709
|
function keyFilePath(dataDir2) {
|
|
@@ -23678,6 +23727,46 @@ function parseKeyFile(raw) {
|
|
|
23678
23727
|
}
|
|
23679
23728
|
return { version: version2, material: bytes };
|
|
23680
23729
|
}
|
|
23730
|
+
var KEY_VERSION_TABLES = ["exceptions", "blocked_detections"];
|
|
23731
|
+
var SQLITE_ERROR = 1;
|
|
23732
|
+
var FLOOR_BUSY_TIMEOUT_MS = 250;
|
|
23733
|
+
var FloorUnreadableError = class extends Error {
|
|
23734
|
+
code = "floor-unreadable";
|
|
23735
|
+
constructor(cause) {
|
|
23736
|
+
super(
|
|
23737
|
+
`cannot read the stored fingerprint key versions: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
23738
|
+
{ cause }
|
|
23739
|
+
);
|
|
23740
|
+
this.name = "FloorUnreadableError";
|
|
23741
|
+
}
|
|
23742
|
+
};
|
|
23743
|
+
function storedKeyVersionFloor(dataDir2) {
|
|
23744
|
+
const file2 = join2(dataDir2, DB_FILENAME);
|
|
23745
|
+
if (!existsSync2(file2)) return 0;
|
|
23746
|
+
let db;
|
|
23747
|
+
try {
|
|
23748
|
+
db = new DatabaseSync2(file2, { readOnly: true });
|
|
23749
|
+
db.exec(`PRAGMA busy_timeout = ${String(FLOOR_BUSY_TIMEOUT_MS)}`);
|
|
23750
|
+
let floor = 0;
|
|
23751
|
+
for (const table of KEY_VERSION_TABLES) {
|
|
23752
|
+
try {
|
|
23753
|
+
const row = getRow(
|
|
23754
|
+
db.prepare(`SELECT MAX(key_version) AS v FROM ${table}`)
|
|
23755
|
+
);
|
|
23756
|
+
floor = Math.max(floor, row?.v ?? 0);
|
|
23757
|
+
} catch (err) {
|
|
23758
|
+
if (err.errcode !== SQLITE_ERROR) {
|
|
23759
|
+
throw new FloorUnreadableError(err);
|
|
23760
|
+
}
|
|
23761
|
+
}
|
|
23762
|
+
}
|
|
23763
|
+
return floor;
|
|
23764
|
+
} catch (err) {
|
|
23765
|
+
throw err instanceof FloorUnreadableError ? err : new FloorUnreadableError(err);
|
|
23766
|
+
} finally {
|
|
23767
|
+
db?.close();
|
|
23768
|
+
}
|
|
23769
|
+
}
|
|
23681
23770
|
function writeKeyFile(dataDir2, key) {
|
|
23682
23771
|
ensureDataDirSync(dataDir2);
|
|
23683
23772
|
const file2 = keyFilePath(dataDir2);
|
|
@@ -23702,7 +23791,10 @@ function loadOrCreateFingerprintKey(dataDir2) {
|
|
|
23702
23791
|
tightenFile(keyFilePath(dataDir2));
|
|
23703
23792
|
return existing;
|
|
23704
23793
|
}
|
|
23705
|
-
return writeKeyFile(dataDir2, {
|
|
23794
|
+
return writeKeyFile(dataDir2, {
|
|
23795
|
+
version: storedKeyVersionFloor(dataDir2) + 1,
|
|
23796
|
+
material: randomBytes(KEY_MATERIAL_BYTES)
|
|
23797
|
+
});
|
|
23706
23798
|
}
|
|
23707
23799
|
function fingerprintValue(key, raw) {
|
|
23708
23800
|
return createHmac("sha256", key.material).update(raw, "utf8").digest("hex");
|
|
@@ -23767,13 +23859,13 @@ function readJson(file2) {
|
|
|
23767
23859
|
}
|
|
23768
23860
|
|
|
23769
23861
|
// ../../packages/persistence/src/warn-era-cap.ts
|
|
23770
|
-
import { existsSync as
|
|
23862
|
+
import { existsSync as existsSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
23771
23863
|
import { join as join5 } from "path";
|
|
23772
23864
|
var MARKER = "warn-era-capped";
|
|
23773
23865
|
function capWarnEraEnforcementOnce(db, policyMode, dataDir2) {
|
|
23774
23866
|
if (policyMode !== "warn") return { capped: 0, skipped: "not-warn" };
|
|
23775
23867
|
const marker = join5(dataDir2, MARKER);
|
|
23776
|
-
if (
|
|
23868
|
+
if (existsSync3(marker)) return { capped: 0, skipped: "already-run" };
|
|
23777
23869
|
const capped = db.policies.capCategoryActions();
|
|
23778
23870
|
writeFileSync2(marker, `${new Date(Date.now()).toISOString()}
|
|
23779
23871
|
`, { mode: DATA_FILE_MODE });
|
|
@@ -23833,7 +23925,7 @@ function loadConfig(base = defaultDataDir()) {
|
|
|
23833
23925
|
try {
|
|
23834
23926
|
ensureLayoutDirSync(base);
|
|
23835
23927
|
const settingsFile = join6(settingsDir(base), "settings.json");
|
|
23836
|
-
if (
|
|
23928
|
+
if (existsSync4(settingsFile)) tightenFile(settingsFile);
|
|
23837
23929
|
} catch {
|
|
23838
23930
|
}
|
|
23839
23931
|
migrateLegacyLayout(base);
|
|
@@ -26879,7 +26971,7 @@ function uniqueRuleIds(findings) {
|
|
|
26879
26971
|
}
|
|
26880
26972
|
|
|
26881
26973
|
// ../../packages/plugin-sdk/src/repo.ts
|
|
26882
|
-
import { existsSync as
|
|
26974
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, statSync } from "fs";
|
|
26883
26975
|
import { basename, dirname, isAbsolute, join as join7, sep as sep2 } from "path";
|
|
26884
26976
|
function resolveRepo(cwd) {
|
|
26885
26977
|
try {
|
|
@@ -26895,7 +26987,7 @@ function resolveRepo(cwd) {
|
|
|
26895
26987
|
function findGitRoot(start) {
|
|
26896
26988
|
let dir = start;
|
|
26897
26989
|
for (; ; ) {
|
|
26898
|
-
if (
|
|
26990
|
+
if (existsSync5(join7(dir, ".git"))) return dir;
|
|
26899
26991
|
const parent = dirname(dir);
|
|
26900
26992
|
if (parent === dir) return void 0;
|
|
26901
26993
|
dir = parent;
|
|
@@ -26913,7 +27005,7 @@ function resolveGitContext(root) {
|
|
|
26913
27005
|
const target = /^gitdir:\s*(.+?)\s*$/m.exec(safeRead(dotGit) ?? "")?.[1];
|
|
26914
27006
|
if (!target) return void 0;
|
|
26915
27007
|
const gitdir = isAbsolute(target) ? target : join7(root, target);
|
|
26916
|
-
if (
|
|
27008
|
+
if (existsSync5(join7(gitdir, "config"))) {
|
|
26917
27009
|
return { configPath: join7(gitdir, "config"), headRoot: root };
|
|
26918
27010
|
}
|
|
26919
27011
|
const commonRaw = safeRead(join7(gitdir, "commondir"))?.trim();
|
|
@@ -26997,7 +27089,7 @@ import { basename as basename3, dirname as dirname2, sep as sep3 } from "path";
|
|
|
26997
27089
|
|
|
26998
27090
|
// ../../packages/plugin-sdk/src/project-files.ts
|
|
26999
27091
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
27000
|
-
import { existsSync as
|
|
27092
|
+
import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync6 } from "fs";
|
|
27001
27093
|
import { basename as basename4, join as join10, relative, sep as sep4 } from "path";
|
|
27002
27094
|
|
|
27003
27095
|
// ../../packages/plugin-sdk/src/rule-quarantine.ts
|