@optimuslabs/harness-map-staging 1.5.23 → 1.5.25
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.
|
@@ -214,6 +214,7 @@ async function collectAllConfigFiles(endpointBase) {
|
|
|
214
214
|
hookRunLog(`worktree_scan: active=${worktreeReport.length} config_files ${beforeFilter}→${filtered.length}`);
|
|
215
215
|
return { configFiles: filtered, worktreeReport };
|
|
216
216
|
}
|
|
217
|
+
/** Adds the sensitive paths audit to the batch; false when it could not be run (nothing added). */
|
|
217
218
|
async function addSensitivePathsAudit(endpointBase, configFiles) {
|
|
218
219
|
hookRunLog(`running sensitive paths audit`);
|
|
219
220
|
const auditOutputDir = join(homedir(), OPTIMUSLABS_LOGS_REL, LOG_GROUP_AUDIT);
|
|
@@ -221,11 +222,14 @@ async function addSensitivePathsAudit(endpointBase, configFiles) {
|
|
|
221
222
|
const auditResult = await runSensitivePathsAudit(endpointBase, auditOutputDir, PROJECT_ROOT);
|
|
222
223
|
hookRunLog(`sensitive_paths_audit: ${auditResult.paths.length} path(s)`);
|
|
223
224
|
configFiles.push({ file_type: 'sensitive_paths_audit', file_path: 'sensitive_paths_audit.txt', raw_content: { paths: auditResult.paths } });
|
|
225
|
+
return true;
|
|
224
226
|
}
|
|
225
227
|
catch (err) {
|
|
226
|
-
|
|
228
|
+
// Send no audit rather than an empty one: the backend keeps the machine's last good audit.
|
|
229
|
+
hookRunLog(`sensitive_paths_audit_error: ${err instanceof Error ? err.message : String(err)} (audit not sent)`);
|
|
227
230
|
hookLogError('sensitive_paths_audit', err, { endpoint: endpointBase, output_dir: auditOutputDir });
|
|
228
|
-
|
|
231
|
+
await reportFunctionalFailureAwait('inventory', 'sensitive_paths_audit', err);
|
|
232
|
+
return false;
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
/** POSIX mode of every collected file, plus granted folders (and their ancestors) and sensitive audit hits within a budget. stat() only. */
|
|
@@ -333,9 +337,16 @@ async function main() {
|
|
|
333
337
|
hookRunLog(`patterns_error: ${err instanceof Error ? err.message : String(err)}`);
|
|
334
338
|
throw err;
|
|
335
339
|
}
|
|
336
|
-
await addSensitivePathsAudit(endpointBase, configFiles);
|
|
340
|
+
const sensitiveAudited = await addSensitivePathsAudit(endpointBase, configFiles);
|
|
337
341
|
ensureCursorUserSettingsSnapshotInBatch(configFiles);
|
|
338
|
-
|
|
342
|
+
if (sensitiveAudited) {
|
|
343
|
+
addPathPermissionsAudit(configFiles);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
// Built without the sensitive paths, it would replace the backend's last good permissions
|
|
347
|
+
// audit and drop those paths' modes; skip it so both audits stay as last sent.
|
|
348
|
+
hookRunLog('path_permissions_audit: skipped (no sensitive paths audit this run)');
|
|
349
|
+
}
|
|
339
350
|
const fileTypes = [...new Set(configFiles.map((c) => c.file_type))].join(', ');
|
|
340
351
|
hookRunLog(`collected ${configFiles.length} config file(s) file_types=${fileTypes}`);
|
|
341
352
|
for (const c of configFiles) {
|
|
@@ -62,14 +62,16 @@ export function writeSensitivePathsAudit(outputDir, pathTemplates, cwd = process
|
|
|
62
62
|
/**
|
|
63
63
|
* Run audit: fetch candidates from backend, check existence, write file. Returns paths for sending.
|
|
64
64
|
* Used by log_config_files to include the audit in the same batch (same auth).
|
|
65
|
+
*
|
|
66
|
+
* Throws when the candidates can't be fetched: an audit run without them would report no
|
|
67
|
+
* sensitive paths, and sending it would replace the machine's last good audit on the backend.
|
|
65
68
|
*/
|
|
66
69
|
export async function runSensitivePathsAudit(endpointBase, outputDir = join(homedir(), OPTIMUSLABS_LOGS_REL, LOG_GROUP_AUDIT), cwd = process.cwd()) {
|
|
67
70
|
const response = await getSensitivePathsAuditCandidates(endpointBase);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
console.warn('Could not fetch sensitive path candidates from backend; writing empty audit.');
|
|
71
|
+
if (!response) {
|
|
72
|
+
throw new Error(`could not fetch sensitive path candidates from ${endpointBase}`);
|
|
71
73
|
}
|
|
72
|
-
const paths = writeSensitivePathsAudit(outputDir,
|
|
74
|
+
const paths = writeSensitivePathsAudit(outputDir, response.paths, cwd);
|
|
73
75
|
const outPath = join(outputDir, AUDIT_FILENAME);
|
|
74
76
|
console.log(`Sensitive paths audit written to ${outPath} (${paths.length} path(s) present).`);
|
|
75
77
|
return { paths };
|