@indigoai-us/hq-cli 5.345.219 → 5.345.221
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/CHANGELOG.md +170 -0
- package/dist/command-catalog.generated.d.ts +169 -3
- package/dist/command-catalog.generated.js +206 -3
- package/dist/commands/auth.js +4 -1
- package/dist/commands/bot-runtime.d.ts +18 -5
- package/dist/commands/bot-runtime.js +29 -12
- package/dist/commands/bot.d.ts +85 -0
- package/dist/commands/bot.js +245 -16
- package/dist/commands/cloud.d.ts +16 -0
- package/dist/commands/cloud.js +112 -102
- package/dist/commands/core-checkpoint-native.d.ts +13 -0
- package/dist/commands/core-checkpoint-native.js +167 -52
- package/dist/commands/core-hook-registration-plan.js +5 -4
- package/dist/commands/core-stop-autosave.d.ts +21 -0
- package/dist/commands/core-stop-autosave.js +300 -0
- package/dist/commands/core.js +2 -0
- package/dist/commands/daemon.d.ts +5 -0
- package/dist/commands/daemon.js +52 -9
- package/dist/commands/doctor-usage.d.ts +5 -0
- package/dist/commands/doctor-usage.js +25 -0
- package/dist/commands/env.d.ts +49 -4
- package/dist/commands/env.js +355 -5
- package/dist/commands/integrations.js +84 -3
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +87 -3
- package/dist/commands/packs.js +23 -0
- package/dist/commands/pkg-update.d.ts +6 -0
- package/dist/commands/pkg-update.js +15 -7
- package/dist/commands/run.js +55 -45
- package/dist/commands/sources.js +4 -3
- package/dist/commands/sync-core.d.ts +1 -0
- package/dist/commands/sync-core.js +77 -3
- package/dist/commands/whoami.js +96 -80
- package/dist/lib/bot/config.d.ts +17 -0
- package/dist/lib/bot/config.js +13 -0
- package/dist/lib/bot/fleet-cron.js +29 -4
- package/dist/lib/bot/fleet-local.d.ts +30 -2
- package/dist/lib/bot/fleet-local.js +60 -1
- package/dist/lib/bot/grok-login-scope.d.ts +36 -0
- package/dist/lib/bot/grok-login-scope.js +93 -0
- package/dist/lib/bot/inflight.d.ts +9 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +51 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +90 -9
- package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
- package/dist/lib/bot/legacy-provider-login.js +28 -22
- package/dist/lib/bot/run.d.ts +29 -5
- package/dist/lib/bot/run.js +203 -1
- package/dist/lib/bot/runtime-sign-in-check.js +6 -1
- package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
- package/dist/lib/bot/signals-try-now.d.ts +76 -0
- package/dist/lib/bot/signals-try-now.js +111 -0
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +22 -3
- package/dist/lib/capacity/collectors/claude-oauth.js +78 -22
- package/dist/lib/capacity/scheduler.d.ts +8 -0
- package/dist/lib/capacity/scheduler.js +5 -2
- package/dist/lib/core-utils/sentry-report.js +2 -0
- package/dist/lib/daemon/machine-checks.d.ts +22 -1
- package/dist/lib/daemon/machine-checks.js +54 -12
- package/dist/lib/daemon/run.js +71 -8
- package/dist/lib/daemon/runtime-notifications.d.ts +7 -0
- package/dist/lib/daemon/runtime-notifications.js +50 -0
- package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
- package/dist/lib/daemon/stop-autosave-lock.js +166 -0
- package/dist/lib/daemon/stop-autosave.d.ts +28 -0
- package/dist/lib/daemon/stop-autosave.js +111 -0
- package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
- package/dist/lib/daemon/stop-diagnostics.js +136 -0
- package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
- package/dist/lib/daemon/stop-job-executor.js +126 -0
- package/dist/lib/daemon/stop-jobs.d.ts +93 -0
- package/dist/lib/daemon/stop-jobs.js +599 -0
- package/dist/lib/doctor/checks/fleet-hook-core.d.ts +9 -1
- package/dist/lib/doctor/checks/fleet-hook-core.js +39 -15
- package/dist/lib/doctor/checks/host-core.js +1 -1
- package/dist/lib/environment/access-probes.d.ts +234 -0
- package/dist/lib/environment/access-probes.js +918 -0
- package/dist/lib/environment/profile.d.ts +15 -2
- package/dist/lib/environment/profile.js +55 -20
- package/dist/lib/environment/rfc3339.d.ts +8 -0
- package/dist/lib/environment/rfc3339.js +26 -0
- package/dist/lib/environment/work-requirements.d.ts +169 -0
- package/dist/lib/environment/work-requirements.js +389 -0
- package/dist/lib/hook-engine/coverage.d.ts +137 -7
- package/dist/lib/hook-engine/coverage.js +1424 -4
- package/dist/lib/hook-engine/fleet-registration.d.ts +17 -5
- package/dist/lib/hook-engine/fleet-registration.js +53 -17
- package/dist/lib/hook-engine/git-stop-config.json +513 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +311 -0
- package/dist/lib/hook-engine/reconcile.js +2 -2
- package/dist/lib/hot-channels/alert.d.ts +10 -1
- package/dist/lib/hot-channels/alert.js +38 -8
- package/dist/lib/hot-channels/signals-claude-login.d.ts +53 -0
- package/dist/lib/hot-channels/signals-claude-login.js +96 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +143 -17
- package/dist/lib/hot-channels/signals-pass.js +324 -17
- package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
- package/dist/lib/hot-channels/signals-runtime.js +82 -0
- package/dist/lib/install/hook-target.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +26 -2
- package/dist/lib/lanes/host-capacity.js +17 -2
- package/dist/lib/lanes/host-compute.d.ts +90 -0
- package/dist/lib/lanes/host-compute.js +185 -0
- package/dist/lib/lanes/index.d.ts +2 -0
- package/dist/lib/lanes/index.js +1 -0
- package/dist/lib/lanes/reconcile.js +22 -1
- package/dist/lib/lanes/resource-usage.d.ts +155 -0
- package/dist/lib/lanes/resource-usage.js +589 -0
- package/dist/lib/lanes/run-size.d.ts +46 -0
- package/dist/lib/lanes/run-size.js +197 -0
- package/dist/lib/lanes/store.js +27 -0
- package/dist/lib/lanes/throttle.d.ts +36 -1
- package/dist/lib/lanes/throttle.js +47 -10
- package/dist/lib/lanes/types.d.ts +40 -0
- package/dist/lib/lanes/types.js +2 -2
- package/dist/lib/lanes/watcher.js +13 -4
- package/dist/lib/lanes/worker-process.d.ts +25 -2
- package/dist/lib/lanes/worker-process.js +71 -19
- package/dist/lib/placement/match.d.ts +192 -0
- package/dist/lib/placement/match.js +667 -0
- package/dist/lib/safe-store.d.ts +14 -0
- package/dist/lib/safe-store.js +77 -4
- package/dist/lib/search-index/index.d.ts +88 -4
- package/dist/lib/search-index/index.js +299 -25
- package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
- package/dist/lib/search-index/max-doc-bytes.js +48 -23
- package/dist/lib/signals/codex-lockdown.d.ts +79 -0
- package/dist/lib/signals/codex-lockdown.js +271 -0
- package/dist/lib/signals/codex-login.d.ts +37 -0
- package/dist/lib/signals/codex-login.js +83 -0
- package/dist/lib/signals/engine.d.ts +28 -0
- package/dist/lib/signals/engine.js +77 -0
- package/dist/lib/signals/reply.d.ts +48 -0
- package/dist/lib/signals/reply.js +94 -12
- package/dist/lib/signals/run-record.js +6 -1
- package/dist/lib/signals/settings.d.ts +5 -0
- package/dist/lib/signals/settings.js +2 -0
- package/dist/lib/signals/steps/adapters.js +6 -0
- package/dist/lib/signals/steps/extract.d.ts +135 -12
- package/dist/lib/signals/steps/extract.js +416 -84
- package/dist/lib/signals/steps/types.d.ts +21 -0
- package/dist/lib/sync-core/engine-home.d.ts +41 -2
- package/dist/lib/sync-core/engine-home.js +132 -19
- package/dist/lib/sync-core/reconcile.js +1 -1
- package/dist/lib/sync-core/release-compare.d.ts +7 -0
- package/dist/lib/sync-core/release-compare.js +16 -0
- package/dist/lib/sync-core/release.d.ts +2 -1
- package/dist/lib/sync-core/release.js +2 -10
- package/dist/lib/sync-core/rollout-state.d.ts +2 -1
- package/dist/lib/sync-core/rollout-state.js +5 -2
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/run/schema-env-overrides.d.ts +24 -0
- package/dist/run/schema-env-overrides.js +72 -0
- package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
- package/dist/utils/auth-session-check.d.ts +16 -0
- package/dist/utils/auth-session-check.js +16 -0
- package/dist/utils/client-health-contract.d.ts +6 -0
- package/dist/utils/client-health-contract.js +13 -0
- package/dist/utils/client-health.d.ts +7 -0
- package/dist/utils/client-health.js +22 -1
- package/dist/utils/command-usage.d.ts +40 -0
- package/dist/utils/command-usage.js +61 -0
- package/dist/utils/duplicate-command-usage.d.ts +72 -0
- package/dist/utils/duplicate-command-usage.js +125 -0
- package/dist/utils/host-registration.d.ts +1 -1
- package/dist/utils/host-registration.js +6 -1
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/sentry-fingerprint.js +9 -0
- package/dist/utils/windows-bash.d.ts +2 -0
- package/dist/utils/windows-bash.js +2 -1
- package/package.json +15 -10
- package/scripts/bench-core-compare.mjs +313 -0
- package/scripts/bench-core.mjs +399 -12
- package/scripts/check-function-manifest.mjs +121 -7
- package/dist/commands/__fixtures__/access-vault.d.ts +0 -95
- package/dist/commands/__fixtures__/access-vault.js +0 -166
- package/dist/commands/__fixtures__/make-tar.d.ts +0 -38
- package/dist/commands/__fixtures__/make-tar.js +0 -102
- package/dist/commands/secrets-public-types.test-d.d.ts +0 -2
- package/dist/commands/secrets-public-types.test-d.js +0 -18
- package/dist/lib/decisions/fixtures/us001.d.ts +0 -137
- package/dist/lib/decisions/fixtures/us001.js +0 -21
- package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +0 -226
- package/dist/lib/doctor/__testing__/fake-hq-tree.js +0 -408
- package/dist/lib/doctor/__testing__/run-doctor.d.ts +0 -8
- package/dist/lib/doctor/__testing__/run-doctor.js +0 -69
- package/dist/lib/fingerprint/fixtures.d.ts +0 -19
- package/dist/lib/fingerprint/fixtures.js +0 -61
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.d.ts +0 -33
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.js +0 -53
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.d.ts +0 -38
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.js +0 -64
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.d.ts +0 -2
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.js +0 -10
- package/dist/lib/test-utils/isolated-flag-company-context.d.ts +0 -3
- package/dist/lib/test-utils/isolated-flag-company-context.js +0 -18
- package/scripts/hook-engine-manifest.mjs +0 -22
- package/scripts/mesh-daemon-if-stale.mjs +0 -20
|
@@ -29,6 +29,18 @@
|
|
|
29
29
|
// --no-manifest run without a manifest (hq-cli pull request job: the
|
|
30
30
|
// manifest lives in another repository). Only the
|
|
31
31
|
// command-states file is checked against the hq-cli tree
|
|
32
|
+
// --installed-core <dir> an installed HQ core (the folder an install or
|
|
33
|
+
// update writes). Reports every test or tooling file in
|
|
34
|
+
// it; see "Installed core" below. Runs alone (no
|
|
35
|
+
// manifest needed) or beside the other rules
|
|
36
|
+
// --keep <path> with --installed-core: a path (relative to that
|
|
37
|
+
// folder) that is kept although it matches; end it with
|
|
38
|
+
// / to keep a whole folder. Repeatable
|
|
39
|
+
// --keep-file <file> with --installed-core: --keep entries, one per line
|
|
40
|
+
// (blank lines and lines starting with # are skipped)
|
|
41
|
+
// --tooling <glob> with --installed-core: a CI or release script glob
|
|
42
|
+
// the release leaves out (* within a folder, ** across
|
|
43
|
+
// folders, ?). Repeatable; none are built in
|
|
32
44
|
// --json print the result as JSON
|
|
33
45
|
//
|
|
34
46
|
// Exit 0: no problem. Exit 1: at least one problem. Exit 2: usage error.
|
|
@@ -68,6 +80,18 @@
|
|
|
68
80
|
// src/lib/daemon. Other daemon functions: the owner path as text, or an
|
|
69
81
|
// import of the owner (a relative import is resolved from the importing
|
|
70
82
|
// file), in any file including other daemon files.
|
|
83
|
+
//
|
|
84
|
+
// Installed core (--installed-core)
|
|
85
|
+
// Walks every file and symlink under the folder; symlinks are not followed,
|
|
86
|
+
// and a symlink whose own path matches is reported. A path (relative, forward
|
|
87
|
+
// slashes) is reported as installed-test-file when any of these match:
|
|
88
|
+
// core/scripts/tests/...; any path part named tests, __tests__, __fixtures__
|
|
89
|
+
// or __snapshots__; test/... at the root; core/scripts/hook-corpus/...;
|
|
90
|
+
// a file name *.test.<ext> or *.spec.<ext> with ext sh, bash, js, mjs, cjs,
|
|
91
|
+
// ts, mts, cts or py; a file name test_*.py.
|
|
92
|
+
// and as installed-tooling-file when it matches a --tooling glob. Names that
|
|
93
|
+
// only contain -test. or test- (keyboard-test.md) and core/hook-tests/ (an
|
|
94
|
+
// install reads it) are not test files here. --keep paths are not reported.
|
|
71
95
|
|
|
72
96
|
import { execFileSync } from "node:child_process";
|
|
73
97
|
import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
@@ -456,10 +480,11 @@ function refExcluded(file) {
|
|
|
456
480
|
}
|
|
457
481
|
|
|
458
482
|
/** Lines in the tree that name a retiring or removed function. */
|
|
459
|
-
export function findReferences(targets, root, { allFiles } = {}) {
|
|
483
|
+
export function findReferences(targets, root, { allFiles, manifest } = {}) {
|
|
460
484
|
const problems = [];
|
|
461
485
|
if (!targets.length) return { problems, files: 0 };
|
|
462
|
-
const files = (allFiles || listFiles(root, ["."])).filter((f) => !refExcluded(f)
|
|
486
|
+
const files = (allFiles || listFiles(root, ["."])).filter((f) => !refExcluded(f)
|
|
487
|
+
&& (!manifest || path.resolve(root, f) !== path.resolve(manifest)));
|
|
463
488
|
let scanned = 0;
|
|
464
489
|
for (const file of files) {
|
|
465
490
|
let stat;
|
|
@@ -563,9 +588,85 @@ export function checkCliStates(entries, states, file) {
|
|
|
563
588
|
return { problems, notices };
|
|
564
589
|
}
|
|
565
590
|
|
|
591
|
+
// ---------- installed core: no test or tooling files ----------
|
|
592
|
+
const INSTALLED_TEST_PREFIX = ["core/scripts/tests/", "test/", "core/scripts/hook-corpus/"];
|
|
593
|
+
const INSTALLED_TEST_PART = new Set(["tests", "__tests__", "__fixtures__", "__snapshots__"]);
|
|
594
|
+
const INSTALLED_TEST_NAME_RE = /\.(test|spec)\.(sh|bash|js|mjs|cjs|ts|mts|cts|py)$|^test_[^/]*\.py$/;
|
|
595
|
+
|
|
596
|
+
/** The reason a path is a test file in an installed core, or null. */
|
|
597
|
+
export function installedTestReason(rel) {
|
|
598
|
+
const prefix = INSTALLED_TEST_PREFIX.find((p) => rel.startsWith(p));
|
|
599
|
+
if (prefix) return `under ${prefix}`;
|
|
600
|
+
const parts = rel.split("/");
|
|
601
|
+
const part = parts.find((x) => INSTALLED_TEST_PART.has(x));
|
|
602
|
+
if (part) return `a "${part}" folder`;
|
|
603
|
+
if (INSTALLED_TEST_NAME_RE.test(parts[parts.length - 1])) return "a test file name";
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/** A glob (* within a folder, ** across folders, ?) as an anchored regex. */
|
|
608
|
+
export function globToRegExp(glob) {
|
|
609
|
+
let re = "";
|
|
610
|
+
for (let i = 0; i < glob.length; i++) {
|
|
611
|
+
const c = glob[i];
|
|
612
|
+
if (c === "*" && glob[i + 1] === "*") {
|
|
613
|
+
i++;
|
|
614
|
+
if (glob[i + 1] === "/") { i++; re += "(?:.*/)?"; } else re += ".*";
|
|
615
|
+
} else if (c === "*") re += "[^/]*";
|
|
616
|
+
else if (c === "?") re += "[^/]";
|
|
617
|
+
else re += esc(c);
|
|
618
|
+
}
|
|
619
|
+
return new RegExp(`^${re}$`);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const normalRel = (p) => p.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
|
|
623
|
+
|
|
624
|
+
/** Every test or tooling file in an installed core, minus the kept paths. */
|
|
625
|
+
export function checkInstalledCore(root, { keep = [], tooling = [] } = {}) {
|
|
626
|
+
const problems = [];
|
|
627
|
+
const keepExact = new Set();
|
|
628
|
+
const keepDirs = [];
|
|
629
|
+
for (const k of keep.map(normalRel).filter(Boolean)) {
|
|
630
|
+
if (k.endsWith("/")) keepDirs.push(k);
|
|
631
|
+
else keepExact.add(k);
|
|
632
|
+
}
|
|
633
|
+
const kept = (rel, isDir) => (!isDir && keepExact.has(rel)) || keepDirs.some((d) => (isDir ? `${rel}/` : rel).startsWith(d));
|
|
634
|
+
const toolingRes = tooling.map((g) => ({ glob: g, re: globToRegExp(normalRel(g)) }));
|
|
635
|
+
let walked = 0;
|
|
636
|
+
const walk = (rel) => {
|
|
637
|
+
const entries = readdirSync(rel ? path.join(root, rel) : root, { withFileTypes: true });
|
|
638
|
+
entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
639
|
+
for (const entry of entries) {
|
|
640
|
+
const child = rel ? `${rel}/${entry.name}` : entry.name;
|
|
641
|
+
// Dirent types come from lstat: a symlink is never a directory here.
|
|
642
|
+
if (entry.isDirectory()) {
|
|
643
|
+
if (!kept(child, true)) walk(child);
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
walked++;
|
|
647
|
+
if (kept(child, false)) continue;
|
|
648
|
+
const link = entry.isSymbolicLink() ? " (a symlink)" : "";
|
|
649
|
+
const reason = installedTestReason(child);
|
|
650
|
+
if (reason) {
|
|
651
|
+
problems.push({ rule: "installed-test-file", file: child, message: `${child}${link} is a test file in the installed core (${reason}). The release must leave it out; pass --keep ${child} if an install needs it.` });
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
const tool = toolingRes.find((t) => t.re.test(child));
|
|
655
|
+
if (tool) problems.push({ rule: "installed-tooling-file", file: child, message: `${child}${link} is a tooling file in the installed core (matches --tooling ${tool.glob}). The release must leave it out; pass --keep ${child} if an install needs it.` });
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
walk("");
|
|
659
|
+
return { problems, files: walked };
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
function readKeepFile(file) {
|
|
663
|
+
if (!existsSync(file)) usage(`--keep-file ${file} does not exist`);
|
|
664
|
+
return readFileSync(file, "utf8").split("\n").map((l) => l.replace(/\r$/, "").trim()).filter((l) => l && !l.startsWith("#"));
|
|
665
|
+
}
|
|
666
|
+
|
|
566
667
|
// ---------- main ----------
|
|
567
668
|
function parseArgs(argv) {
|
|
568
|
-
const opt = { json: false, noManifest: false };
|
|
669
|
+
const opt = { json: false, noManifest: false, keep: [], tooling: [] };
|
|
569
670
|
const value = (i) => {
|
|
570
671
|
if (argv[i + 1] === undefined) usage(`${argv[i]} needs a value`);
|
|
571
672
|
return argv[i + 1];
|
|
@@ -579,6 +680,10 @@ function parseArgs(argv) {
|
|
|
579
680
|
else if (a === "--cli-states") opt.cliStates = path.resolve(value(i++));
|
|
580
681
|
else if (a === "--require-cli-states") opt.requireCliStates = true;
|
|
581
682
|
else if (a === "--no-manifest") opt.noManifest = true;
|
|
683
|
+
else if (a === "--installed-core") opt.installedCore = path.resolve(value(i++));
|
|
684
|
+
else if (a === "--keep") opt.keep.push(value(i++));
|
|
685
|
+
else if (a === "--keep-file") opt.keep.push(...readKeepFile(path.resolve(value(i++))));
|
|
686
|
+
else if (a === "--tooling") opt.tooling.push(value(i++));
|
|
582
687
|
else if (a === "--json") opt.json = true;
|
|
583
688
|
else if (a === "--help" || a === "-h") usage();
|
|
584
689
|
else usage(`unknown argument: ${a}`);
|
|
@@ -587,7 +692,7 @@ function parseArgs(argv) {
|
|
|
587
692
|
}
|
|
588
693
|
function usage(error) {
|
|
589
694
|
if (error) console.error(`check-function-manifest: ${error}`);
|
|
590
|
-
console.error("usage: node scripts/check-function-manifest.mjs [--manifest <file>] [--core-root <dir>] [--cli-root <dir> | --cli-package <dir>] [--cli-states <file> [--require-cli-states]] [--no-manifest] [--json]");
|
|
695
|
+
console.error("usage: node scripts/check-function-manifest.mjs [--manifest <file>] [--core-root <dir>] [--cli-root <dir> | --cli-package <dir>] [--cli-states <file> [--require-cli-states]] [--no-manifest] [--installed-core <dir> [--keep <path>]... [--keep-file <file>] [--tooling <glob>]...] [--json]");
|
|
591
696
|
process.exit(2);
|
|
592
697
|
}
|
|
593
698
|
|
|
@@ -605,7 +710,11 @@ export async function run(argv) {
|
|
|
605
710
|
}
|
|
606
711
|
if (!opt.manifest && opt.coreRoot) opt.manifest = path.join(opt.coreRoot, MANIFEST_REL);
|
|
607
712
|
if (opt.noManifest && (opt.manifest || opt.coreRoot)) usage("--no-manifest cannot be combined with --manifest or --core-root");
|
|
608
|
-
if (
|
|
713
|
+
if (opt.installedCore && !(existsSync(opt.installedCore) && statSync(opt.installedCore).isDirectory())) usage(`--installed-core ${opt.installedCore} is not a folder`);
|
|
714
|
+
if (!opt.installedCore && (opt.keep.length || opt.tooling.length)) usage("--keep, --keep-file and --tooling need --installed-core");
|
|
715
|
+
// --installed-core alone needs no manifest.
|
|
716
|
+
const installedOnly = opt.installedCore && !opt.manifest && !opt.coreRoot && !opt.noManifest && !opt.cliStates;
|
|
717
|
+
if (!opt.noManifest && !opt.manifest && !installedOnly) usage("no manifest: pass --core-root or --manifest (or --no-manifest in the hq-cli pull request job)");
|
|
609
718
|
if (opt.manifest && !existsSync(opt.manifest)) usage(`manifest ${opt.manifest} does not exist`);
|
|
610
719
|
|
|
611
720
|
const problems = [];
|
|
@@ -628,14 +737,14 @@ export async function run(argv) {
|
|
|
628
737
|
if (opt.coreRoot) {
|
|
629
738
|
const tree = checkCoreTree(entries, opt.coreRoot);
|
|
630
739
|
problems.push(...tree.problems);
|
|
631
|
-
const refs = findReferences(targets, opt.coreRoot);
|
|
740
|
+
const refs = findReferences(targets, opt.coreRoot, { manifest: opt.manifest });
|
|
632
741
|
problems.push(...refs.problems);
|
|
633
742
|
checked.push(`core tree ${opt.coreRoot}: ${tree.files} hook and script files; references searched in ${refs.files} files`);
|
|
634
743
|
} else notices.push("no --core-root: hooks and scripts on disk were not compared with the manifest");
|
|
635
744
|
if (opt.cliRoot) {
|
|
636
745
|
const tree = checkCliTree(entries, opt.cliRoot, catalog);
|
|
637
746
|
problems.push(...tree.problems);
|
|
638
|
-
const refs = findReferences(targets, opt.cliRoot);
|
|
747
|
+
const refs = findReferences(targets, opt.cliRoot, { manifest: opt.manifest });
|
|
639
748
|
problems.push(...refs.problems);
|
|
640
749
|
checked.push(`hq-cli source ${opt.cliRoot}: ${tree.commands} commands, ${tree.daemonFiles} daemon files; references searched in ${refs.files} files`);
|
|
641
750
|
} else if (opt.cliPackage) {
|
|
@@ -671,6 +780,11 @@ export async function run(argv) {
|
|
|
671
780
|
}
|
|
672
781
|
}
|
|
673
782
|
}
|
|
783
|
+
if (opt.installedCore) {
|
|
784
|
+
const inst = checkInstalledCore(opt.installedCore, { keep: opt.keep, tooling: opt.tooling });
|
|
785
|
+
problems.push(...inst.problems);
|
|
786
|
+
checked.push(`installed core ${opt.installedCore}: ${inst.files} files and links checked for test and tooling files (${opt.keep.length} kept paths, ${opt.tooling.length} tooling globs)`);
|
|
787
|
+
}
|
|
674
788
|
if (opt.noManifest) notices.push("--no-manifest: the manifest rules did not run here; they run where the manifest is (hq-core-staging pull requests and a local run with --core-root)");
|
|
675
789
|
|
|
676
790
|
const seconds = ((Date.now() - started) / 1000).toFixed(1);
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory vault / ACL / DM harness for the `hq access` command.
|
|
3
|
-
* No network I/O — listings, GetObject, STS vend, and DMs stay in process
|
|
4
|
-
* (or under a tmp hqRoot the caller supplies).
|
|
5
|
-
*/
|
|
6
|
-
import { vi } from "vitest";
|
|
7
|
-
import type { CompanyBrowseClientFactory, FilesBrowseVaultClient } from "../files-browse.js";
|
|
8
|
-
export type AccessVaultState = "missing" | "present-local" | "present-not-local" | "present-denied";
|
|
9
|
-
export interface FakeDmMessage {
|
|
10
|
-
recipient: string;
|
|
11
|
-
message: string;
|
|
12
|
-
prompt?: string;
|
|
13
|
-
details?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface FakeDmTransport {
|
|
16
|
-
sent: FakeDmMessage[];
|
|
17
|
-
send(msg: FakeDmMessage): Promise<{
|
|
18
|
-
eventId: string;
|
|
19
|
-
}>;
|
|
20
|
-
}
|
|
21
|
-
export declare function makeFakeDmTransport(): FakeDmTransport;
|
|
22
|
-
export interface AclEntry {
|
|
23
|
-
granteeType: string;
|
|
24
|
-
granteeId: string;
|
|
25
|
-
permission: string;
|
|
26
|
-
grantedBy: string;
|
|
27
|
-
grantedAt: string;
|
|
28
|
-
}
|
|
29
|
-
export interface AccessAclTree {
|
|
30
|
-
prefix: string;
|
|
31
|
-
direct: AclEntry[];
|
|
32
|
-
inherited: Array<AclEntry & {
|
|
33
|
-
sourcePrefix: string;
|
|
34
|
-
}>;
|
|
35
|
-
children: Array<AclEntry & {
|
|
36
|
-
sourcePrefix: string;
|
|
37
|
-
}>;
|
|
38
|
-
directRow: {
|
|
39
|
-
creatorUid: string;
|
|
40
|
-
open: boolean;
|
|
41
|
-
createdAt: string;
|
|
42
|
-
updatedAt: string;
|
|
43
|
-
} | null;
|
|
44
|
-
effectivePermission: string | null;
|
|
45
|
-
}
|
|
46
|
-
export interface AccessMember {
|
|
47
|
-
personUid: string;
|
|
48
|
-
personEmail: string;
|
|
49
|
-
personName?: string;
|
|
50
|
-
role: "owner" | "admin" | "member" | "guest";
|
|
51
|
-
}
|
|
52
|
-
export interface AccessVaultFixture {
|
|
53
|
-
state: AccessVaultState;
|
|
54
|
-
hqRoot: string;
|
|
55
|
-
companySlug: string;
|
|
56
|
-
companyUid: string;
|
|
57
|
-
/** Company-anchored e.g. companies/acme/knowledge/report.md */
|
|
58
|
-
key: string;
|
|
59
|
-
/** Company-relative e.g. knowledge/report.md */
|
|
60
|
-
bucketKey: string;
|
|
61
|
-
vaultClient: FilesBrowseVaultClient;
|
|
62
|
-
companyClient: CompanyBrowseClientFactory;
|
|
63
|
-
vend: ReturnType<typeof vi.fn>;
|
|
64
|
-
acl: AccessAclTree | null;
|
|
65
|
-
members: AccessMember[];
|
|
66
|
-
dm: FakeDmTransport;
|
|
67
|
-
listedKeys: string[];
|
|
68
|
-
region: string;
|
|
69
|
-
}
|
|
70
|
-
export interface MakeAccessFixtureOptions {
|
|
71
|
-
state: AccessVaultState;
|
|
72
|
-
hqRoot: string;
|
|
73
|
-
companySlug?: string;
|
|
74
|
-
key?: string;
|
|
75
|
-
extraKeys?: string[];
|
|
76
|
-
acl?: AccessAclTree | null;
|
|
77
|
-
members?: AccessMember[];
|
|
78
|
-
content?: string;
|
|
79
|
-
/**
|
|
80
|
-
* `present-denied` only: make the LIST call itself fail with 403 (the
|
|
81
|
-
* `/v1/files/list` shape) instead of returning the key. Models a caller
|
|
82
|
-
* without read on the prefix — the server refuses to enumerate.
|
|
83
|
-
*/
|
|
84
|
-
listDenied?: boolean;
|
|
85
|
-
/** present-denied only: let a test isolate list denial from vend denial. */
|
|
86
|
-
vendDenied?: boolean;
|
|
87
|
-
/** Deny only the ROOT (prefix "") list — the caller can read the prefix but not enumerate the bucket. */
|
|
88
|
-
rootListDenied?: boolean;
|
|
89
|
-
}
|
|
90
|
-
export declare function vendStatusForState(state: AccessVaultState): {
|
|
91
|
-
status: number;
|
|
92
|
-
message?: string;
|
|
93
|
-
};
|
|
94
|
-
export declare function makeAccessFixture(opts: MakeAccessFixtureOptions): AccessVaultFixture;
|
|
95
|
-
//# sourceMappingURL=access-vault.d.ts.map
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory vault / ACL / DM harness for the `hq access` command.
|
|
3
|
-
* No network I/O — listings, GetObject, STS vend, and DMs stay in process
|
|
4
|
-
* (or under a tmp hqRoot the caller supplies).
|
|
5
|
-
*/
|
|
6
|
-
import * as fs from "node:fs";
|
|
7
|
-
import * as path from "node:path";
|
|
8
|
-
import { Readable } from "node:stream";
|
|
9
|
-
import { vi } from "vitest";
|
|
10
|
-
import { ListObjectsV2Command, GetObjectCommand, } from "@aws-sdk/client-s3";
|
|
11
|
-
export function makeFakeDmTransport() {
|
|
12
|
-
const sent = [];
|
|
13
|
-
let n = 0;
|
|
14
|
-
return {
|
|
15
|
-
sent,
|
|
16
|
-
async send(msg) {
|
|
17
|
-
sent.push(msg);
|
|
18
|
-
n += 1;
|
|
19
|
-
return { eventId: `evt_${n}` };
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const FAKE_VEND = {
|
|
24
|
-
credentials: {
|
|
25
|
-
accessKeyId: "ASIA-test",
|
|
26
|
-
secretAccessKey: "secret-test",
|
|
27
|
-
sessionToken: "session-test",
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
const DEFAULT_MEMBERS = [
|
|
31
|
-
{
|
|
32
|
-
personUid: "prs_owner",
|
|
33
|
-
personEmail: "owner@example.com",
|
|
34
|
-
personName: "Olive Owner",
|
|
35
|
-
role: "owner",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
personUid: "prs_admin",
|
|
39
|
-
personEmail: "admin@example.com",
|
|
40
|
-
personName: "Adam Admin",
|
|
41
|
-
role: "admin",
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
personUid: "prs_me",
|
|
45
|
-
personEmail: "me@example.com",
|
|
46
|
-
personName: "Mia Member",
|
|
47
|
-
role: "member",
|
|
48
|
-
},
|
|
49
|
-
];
|
|
50
|
-
export function vendStatusForState(state) {
|
|
51
|
-
if (state === "missing")
|
|
52
|
-
return { status: 404 };
|
|
53
|
-
if (state === "present-denied") {
|
|
54
|
-
return { status: 403, message: "caller lacks read on this prefix" };
|
|
55
|
-
}
|
|
56
|
-
return { status: 200 };
|
|
57
|
-
}
|
|
58
|
-
function attachStatus(err, status) {
|
|
59
|
-
const tagged = err;
|
|
60
|
-
tagged.status = status;
|
|
61
|
-
return tagged;
|
|
62
|
-
}
|
|
63
|
-
function attachHttpStatus(err, httpStatusCode) {
|
|
64
|
-
const tagged = err;
|
|
65
|
-
tagged.$metadata = { httpStatusCode };
|
|
66
|
-
return tagged;
|
|
67
|
-
}
|
|
68
|
-
function toBucketKey(key, slug) {
|
|
69
|
-
const prefix = `companies/${slug}/`;
|
|
70
|
-
const trimmed = key.replace(/^\/+/, "");
|
|
71
|
-
if (trimmed.startsWith(prefix))
|
|
72
|
-
return trimmed.slice(prefix.length);
|
|
73
|
-
return trimmed;
|
|
74
|
-
}
|
|
75
|
-
export function makeAccessFixture(opts) {
|
|
76
|
-
const companySlug = opts.companySlug ?? "acme";
|
|
77
|
-
const key = opts.key ?? `companies/${companySlug}/knowledge/report.md`;
|
|
78
|
-
const bucketKey = toBucketKey(key, companySlug);
|
|
79
|
-
const companyUid = `cmp_${companySlug}`;
|
|
80
|
-
const content = opts.content ?? "hello";
|
|
81
|
-
const extraKeys = opts.extraKeys ?? [];
|
|
82
|
-
const listedKeys = opts.state === "missing" ? [...extraKeys] : [...extraKeys, bucketKey];
|
|
83
|
-
const members = opts.members ?? DEFAULT_MEMBERS;
|
|
84
|
-
const acl = opts.acl === undefined ? null : opts.acl;
|
|
85
|
-
const region = "us-east-1";
|
|
86
|
-
const dm = makeFakeDmTransport();
|
|
87
|
-
if (opts.state === "present-local") {
|
|
88
|
-
const dest = path.join(opts.hqRoot, key);
|
|
89
|
-
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
90
|
-
fs.writeFileSync(dest, content, "utf-8");
|
|
91
|
-
}
|
|
92
|
-
const vend = vi.fn(async () => {
|
|
93
|
-
if (opts.state === "missing") {
|
|
94
|
-
throw attachStatus(new Error("not found (404)"), 404);
|
|
95
|
-
}
|
|
96
|
-
if (opts.state === "present-denied" && opts.vendDenied !== false) {
|
|
97
|
-
throw attachStatus(new Error("caller lacks read on this prefix (403)"), 403);
|
|
98
|
-
}
|
|
99
|
-
return FAKE_VEND;
|
|
100
|
-
});
|
|
101
|
-
const vendSelf = vi.fn(async () => FAKE_VEND);
|
|
102
|
-
const listMyExplicitGrants = vi.fn(async () => []);
|
|
103
|
-
const entityShape = {
|
|
104
|
-
uid: companyUid,
|
|
105
|
-
slug: companySlug,
|
|
106
|
-
name: companySlug,
|
|
107
|
-
bucketName: `hq-vault-cmp-${companySlug}`,
|
|
108
|
-
};
|
|
109
|
-
const findInMyNamespace = vi.fn(async () => entityShape);
|
|
110
|
-
const get = vi.fn(async () => entityShape);
|
|
111
|
-
const vaultClient = {
|
|
112
|
-
sts: { vend, vendSelf },
|
|
113
|
-
listMyExplicitGrants,
|
|
114
|
-
entity: { get, findInMyNamespace },
|
|
115
|
-
};
|
|
116
|
-
const listDenied = opts.state === "present-denied" && opts.listDenied === true;
|
|
117
|
-
const send = vi.fn(async (cmd) => {
|
|
118
|
-
if (cmd instanceof ListObjectsV2Command) {
|
|
119
|
-
const prefix = cmd.input.Prefix ?? "";
|
|
120
|
-
if (listDenied || (opts.rootListDenied === true && prefix === "")) {
|
|
121
|
-
throw Object.assign(new Error("files list failed (403)"), {
|
|
122
|
-
status: 403,
|
|
123
|
-
key: prefix,
|
|
124
|
-
company: companySlug,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
const Contents = listedKeys
|
|
128
|
-
.filter((k) => (prefix === "" ? true : k.startsWith(prefix)))
|
|
129
|
-
.map((Key) => ({
|
|
130
|
-
Key,
|
|
131
|
-
Size: content.length,
|
|
132
|
-
LastModified: new Date(),
|
|
133
|
-
}));
|
|
134
|
-
return { Contents };
|
|
135
|
-
}
|
|
136
|
-
if (cmd instanceof GetObjectCommand) {
|
|
137
|
-
const requested = cmd.input.Key ?? "";
|
|
138
|
-
if (opts.state === "missing" || requested !== bucketKey) {
|
|
139
|
-
throw attachHttpStatus(new Error("Not found (404)"), 404);
|
|
140
|
-
}
|
|
141
|
-
if (opts.state === "present-denied") {
|
|
142
|
-
throw attachHttpStatus(new Error("caller lacks read on this prefix"), 403);
|
|
143
|
-
}
|
|
144
|
-
return { Body: Readable.from([content]) };
|
|
145
|
-
}
|
|
146
|
-
throw new Error(`unexpected command: ${cmd}`);
|
|
147
|
-
});
|
|
148
|
-
const companyClient = vi.fn(() => ({ send }));
|
|
149
|
-
return {
|
|
150
|
-
state: opts.state,
|
|
151
|
-
hqRoot: opts.hqRoot,
|
|
152
|
-
companySlug,
|
|
153
|
-
companyUid,
|
|
154
|
-
key,
|
|
155
|
-
bucketKey,
|
|
156
|
-
vaultClient,
|
|
157
|
-
companyClient,
|
|
158
|
-
vend,
|
|
159
|
-
acl,
|
|
160
|
-
members,
|
|
161
|
-
dm,
|
|
162
|
-
listedKeys,
|
|
163
|
-
region,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
//# sourceMappingURL=access-vault.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic, platform-independent malicious-tar fixture builder.
|
|
3
|
-
*
|
|
4
|
-
* WHY THIS EXISTS (cross-platform zip-slip coverage). The adversarial
|
|
5
|
-
* safe-extract / marketplace-security suites need archives that GENUINELY carry
|
|
6
|
-
* hostile entries — a `../` traversal name, an absolute path, an escaping
|
|
7
|
-
* symlink/hardlink. The obvious approach (shell out to the system `tar` to
|
|
8
|
-
* CREATE the archive) is NOT portable: GNU tar (Linux / CI / prod Lambdas)
|
|
9
|
-
* STRIPS the leading `../` and absolute `/` when it WRITES an archive, so the
|
|
10
|
-
* resulting "malicious" fixture contains a benign `evil-escape` entry and the
|
|
11
|
-
* guard has nothing to reject — the test passes on macOS bsdtar (which
|
|
12
|
-
* preserves them) but fails on Linux. The guard itself is correct; only the
|
|
13
|
-
* fixture construction was platform-dependent.
|
|
14
|
-
*
|
|
15
|
-
* Fix: WRITE THE TAR BYTES DIRECTLY here. A tar archive is just a sequence of
|
|
16
|
-
* 512-byte ustar headers, each optionally followed by the file's content padded
|
|
17
|
-
* to a 512-byte boundary, terminated by two zero blocks. By emitting the bytes
|
|
18
|
-
* ourselves we control the recorded entry names verbatim — `../evil-escape`,
|
|
19
|
-
* `/tmp/evil`, a symlink with linkname `../../etc/passwd` — identically on every
|
|
20
|
-
* platform, with no create-time stripping. The reading side (`tar -tvf`, which
|
|
21
|
-
* safeExtractTarball's pre-flight uses) does NOT strip anything; it faithfully
|
|
22
|
-
* lists whatever bytes we wrote, so the guard sees the real attack everywhere.
|
|
23
|
-
*/
|
|
24
|
-
/** ustar typeflag values we use. */
|
|
25
|
-
type TarType = 'file' | 'symlink' | 'hardlink';
|
|
26
|
-
export interface TarEntrySpec {
|
|
27
|
-
/** Recorded entry name — written VERBATIM (may contain `..`, be absolute…). */
|
|
28
|
-
name: string;
|
|
29
|
-
type?: TarType;
|
|
30
|
-
/** For sym/hardlinks: the recorded link target (also written verbatim). */
|
|
31
|
-
linkname?: string;
|
|
32
|
-
/** File content (regular files only). */
|
|
33
|
-
content?: string | Buffer;
|
|
34
|
-
}
|
|
35
|
-
/** Build the tar, gzip it, and write it to `outPath`. Returns `outPath`. */
|
|
36
|
-
export declare function writeMaliciousTarGz(outPath: string, entries: TarEntrySpec[]): string;
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=make-tar.d.ts.map
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic, platform-independent malicious-tar fixture builder.
|
|
3
|
-
*
|
|
4
|
-
* WHY THIS EXISTS (cross-platform zip-slip coverage). The adversarial
|
|
5
|
-
* safe-extract / marketplace-security suites need archives that GENUINELY carry
|
|
6
|
-
* hostile entries — a `../` traversal name, an absolute path, an escaping
|
|
7
|
-
* symlink/hardlink. The obvious approach (shell out to the system `tar` to
|
|
8
|
-
* CREATE the archive) is NOT portable: GNU tar (Linux / CI / prod Lambdas)
|
|
9
|
-
* STRIPS the leading `../` and absolute `/` when it WRITES an archive, so the
|
|
10
|
-
* resulting "malicious" fixture contains a benign `evil-escape` entry and the
|
|
11
|
-
* guard has nothing to reject — the test passes on macOS bsdtar (which
|
|
12
|
-
* preserves them) but fails on Linux. The guard itself is correct; only the
|
|
13
|
-
* fixture construction was platform-dependent.
|
|
14
|
-
*
|
|
15
|
-
* Fix: WRITE THE TAR BYTES DIRECTLY here. A tar archive is just a sequence of
|
|
16
|
-
* 512-byte ustar headers, each optionally followed by the file's content padded
|
|
17
|
-
* to a 512-byte boundary, terminated by two zero blocks. By emitting the bytes
|
|
18
|
-
* ourselves we control the recorded entry names verbatim — `../evil-escape`,
|
|
19
|
-
* `/tmp/evil`, a symlink with linkname `../../etc/passwd` — identically on every
|
|
20
|
-
* platform, with no create-time stripping. The reading side (`tar -tvf`, which
|
|
21
|
-
* safeExtractTarball's pre-flight uses) does NOT strip anything; it faithfully
|
|
22
|
-
* lists whatever bytes we wrote, so the guard sees the real attack everywhere.
|
|
23
|
-
*/
|
|
24
|
-
import { gzipSync } from 'node:zlib';
|
|
25
|
-
import * as fs from 'node:fs';
|
|
26
|
-
const BLOCK = 512;
|
|
27
|
-
const TYPEFLAG = {
|
|
28
|
-
file: '0', // regular file
|
|
29
|
-
symlink: '2', // symbolic link
|
|
30
|
-
hardlink: '1', // hard link
|
|
31
|
-
};
|
|
32
|
-
/** Write an ASCII string into a fixed-width field at `offset`, NUL-padded. */
|
|
33
|
-
function writeField(buf, offset, width, value) {
|
|
34
|
-
// Truncate defensively; ustar fields are fixed-width.
|
|
35
|
-
const s = value.slice(0, width);
|
|
36
|
-
buf.write(s, offset, 'ascii');
|
|
37
|
-
// Remaining bytes are already 0 from Buffer.alloc.
|
|
38
|
-
}
|
|
39
|
-
/** Write an octal numeric field: `width-1` octal digits, space-or-NUL terminated. */
|
|
40
|
-
function writeOctal(buf, offset, width, value) {
|
|
41
|
-
// Classic ustar numeric field: zero-padded octal in (width-1) chars + NUL.
|
|
42
|
-
const digits = width - 1;
|
|
43
|
-
const oct = value.toString(8).padStart(digits, '0').slice(-digits);
|
|
44
|
-
buf.write(oct, offset, 'ascii');
|
|
45
|
-
buf[offset + digits] = 0; // NUL terminator
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Build one 512-byte ustar header (plus content blocks for regular files) for a
|
|
49
|
-
* single entry. The header checksum is computed exactly per spec: sum every
|
|
50
|
-
* header byte treating the 8 checksum bytes themselves as ASCII spaces, then
|
|
51
|
-
* write that sum as 6 octal digits + NUL + space.
|
|
52
|
-
*/
|
|
53
|
-
function makeTarEntry(spec) {
|
|
54
|
-
const type = spec.type ?? 'file';
|
|
55
|
-
const content = type === 'file'
|
|
56
|
-
? Buffer.isBuffer(spec.content)
|
|
57
|
-
? spec.content
|
|
58
|
-
: Buffer.from(spec.content ?? '', 'utf-8')
|
|
59
|
-
: Buffer.alloc(0); // links carry no content payload
|
|
60
|
-
const header = Buffer.alloc(BLOCK); // zero-filled
|
|
61
|
-
writeField(header, 0, 100, spec.name); // name
|
|
62
|
-
writeOctal(header, 100, 8, 0o644); // mode
|
|
63
|
-
writeOctal(header, 108, 8, 0); // uid
|
|
64
|
-
writeOctal(header, 116, 8, 0); // gid
|
|
65
|
-
writeOctal(header, 124, 12, content.length); // size (0 for links)
|
|
66
|
-
writeOctal(header, 136, 12, 0); // mtime (deterministic: epoch)
|
|
67
|
-
// checksum field (148, 8) — filled below; start as spaces for the sum.
|
|
68
|
-
header.fill(' '.charCodeAt(0), 148, 156);
|
|
69
|
-
writeField(header, 156, 1, TYPEFLAG[type]); // typeflag
|
|
70
|
-
if (spec.linkname !== undefined) {
|
|
71
|
-
writeField(header, 157, 100, spec.linkname); // linkname (verbatim)
|
|
72
|
-
}
|
|
73
|
-
writeField(header, 257, 6, 'ustar'); // magic "ustar\0"
|
|
74
|
-
writeField(header, 263, 2, '00'); // version "00"
|
|
75
|
-
// uname/gname left empty; devmajor/devminor zero (already NUL).
|
|
76
|
-
// Header checksum: unsigned sum of all 512 bytes (with the checksum field as
|
|
77
|
-
// spaces, which we set above). Written as 6 octal digits, NUL, space.
|
|
78
|
-
let sum = 0;
|
|
79
|
-
for (let i = 0; i < BLOCK; i++)
|
|
80
|
-
sum += header[i];
|
|
81
|
-
const cksum = sum.toString(8).padStart(6, '0').slice(-6);
|
|
82
|
-
header.write(cksum, 148, 'ascii');
|
|
83
|
-
header[154] = 0; // NUL
|
|
84
|
-
header[155] = ' '.charCodeAt(0); // space
|
|
85
|
-
if (type !== 'file' || content.length === 0)
|
|
86
|
-
return header;
|
|
87
|
-
// Content padded up to a 512-byte boundary.
|
|
88
|
-
const pad = (BLOCK - (content.length % BLOCK)) % BLOCK;
|
|
89
|
-
return Buffer.concat([header, content, Buffer.alloc(pad)]);
|
|
90
|
-
}
|
|
91
|
-
/** Concatenate entries and append the two zero blocks that end every tar. */
|
|
92
|
-
function makeTar(entries) {
|
|
93
|
-
const blocks = entries.map(makeTarEntry);
|
|
94
|
-
blocks.push(Buffer.alloc(BLOCK * 2)); // end-of-archive marker
|
|
95
|
-
return Buffer.concat(blocks);
|
|
96
|
-
}
|
|
97
|
-
/** Build the tar, gzip it, and write it to `outPath`. Returns `outPath`. */
|
|
98
|
-
export function writeMaliciousTarGz(outPath, entries) {
|
|
99
|
-
fs.writeFileSync(outPath, gzipSync(makeTar(entries)));
|
|
100
|
-
return outPath;
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=make-tar.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const scriptUsage = {
|
|
2
|
-
scriptId: "fixture-script",
|
|
3
|
-
path: "scripts/example.sh",
|
|
4
|
-
sha256: "0".repeat(64),
|
|
5
|
-
attestationLevel: "verified",
|
|
6
|
-
};
|
|
7
|
-
const metadata = {
|
|
8
|
-
tier: "standard",
|
|
9
|
-
cacheTtlMs: 1_000,
|
|
10
|
-
};
|
|
11
|
-
const loadedSecret = {
|
|
12
|
-
...metadata,
|
|
13
|
-
name: "FIXTURE_NAME",
|
|
14
|
-
value: "fixture-only",
|
|
15
|
-
};
|
|
16
|
-
void [scriptUsage, metadata, loadedSecret];
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=secrets-public-types.test-d.js.map
|