@optimuslabs/harness-map-staging 1.5.22 → 1.5.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.
@@ -223,9 +223,10 @@ async function addSensitivePathsAudit(endpointBase, configFiles) {
223
223
  configFiles.push({ file_type: 'sensitive_paths_audit', file_path: 'sensitive_paths_audit.txt', raw_content: { paths: auditResult.paths } });
224
224
  }
225
225
  catch (err) {
226
- hookRunLog(`sensitive_paths_audit_error: ${err instanceof Error ? err.message : String(err)}`);
226
+ // Send no audit rather than an empty one: the backend keeps the machine's last good audit.
227
+ hookRunLog(`sensitive_paths_audit_error: ${err instanceof Error ? err.message : String(err)} (audit not sent)`);
227
228
  hookLogError('sensitive_paths_audit', err, { endpoint: endpointBase, output_dir: auditOutputDir });
228
- configFiles.push({ file_type: 'sensitive_paths_audit', file_path: 'sensitive_paths_audit.txt', raw_content: { paths: [] } });
229
+ await reportFunctionalFailureAwait('inventory', 'sensitive_paths_audit', err);
229
230
  }
230
231
  }
231
232
  /** POSIX mode of every collected file, plus granted folders (and their ancestors) and sensitive audit hits within a budget. stat() only. */
@@ -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
- const pathTemplates = response?.paths ?? [];
69
- if (pathTemplates.length === 0 && !response) {
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, pathTemplates, cwd);
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 };
@@ -64,8 +64,14 @@ const getMetadata = () => ({
64
64
  hook_manifest: { ...parseHookManifest(), ...collectInstalledHookHashes() },
65
65
  });
66
66
  function buildRequestBody(hardwareUuid, timestamp) {
67
- const payloadSummary = { timestamp, directory: process.cwd(), hardware_uuid: hardwareUuid };
68
- const requestBody = { hardware_uuid: hardwareUuid, payload: payloadSummary, metadata: getMetadata(), scan_timestamp: timestamp };
67
+ const metadata = getMetadata();
68
+ const payloadSummary = {
69
+ timestamp,
70
+ directory: process.cwd(),
71
+ hardware_uuid: hardwareUuid,
72
+ hook_manifest: metadata.hook_manifest,
73
+ };
74
+ const requestBody = { hardware_uuid: hardwareUuid, payload: payloadSummary, metadata, scan_timestamp: timestamp };
69
75
  const storedKey = readStoredAuthKey();
70
76
  if (storedKey?.key && storedKey.hardware_uuid === hardwareUuid) {
71
77
  requestBody.signature = createSignature(payloadSummary, storedKey.key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimuslabs/harness-map-staging",
3
- "version": "1.5.22",
3
+ "version": "1.5.24",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {