@agenticcli/shipguard 0.7.0 → 0.7.1

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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "secrets": "a841f9b4db785bb555205bf73de0f3a1390a5e6676d17f5125e1e3898f3cc55b",
3
- "auth": "a841f9b4db785bb555205bf73de0f3a1390a5e6676d17f5125e1e3898f3cc55b",
4
- "database": "a841f9b4db785bb555205bf73de0f3a1390a5e6676d17f5125e1e3898f3cc55b",
5
- "deployment": "a841f9b4db785bb555205bf73de0f3a1390a5e6676d17f5125e1e3898f3cc55b",
6
- "payments": "a841f9b4db785bb555205bf73de0f3a1390a5e6676d17f5125e1e3898f3cc55b"
2
+ "secrets": "8ab3281c5b2454290a3399e482cf8afe0f05794ab60ef26c5c2b9942b4fb1b1b",
3
+ "auth": "8ab3281c5b2454290a3399e482cf8afe0f05794ab60ef26c5c2b9942b4fb1b1b",
4
+ "database": "8ab3281c5b2454290a3399e482cf8afe0f05794ab60ef26c5c2b9942b4fb1b1b",
5
+ "deployment": "8ab3281c5b2454290a3399e482cf8afe0f05794ab60ef26c5c2b9942b4fb1b1b",
6
+ "payments": "8ab3281c5b2454290a3399e482cf8afe0f05794ab60ef26c5c2b9942b4fb1b1b"
7
7
  }
@@ -18,12 +18,10 @@ import * as os from "os";
18
18
  // src/core/auth.ts
19
19
  import {
20
20
  readFileSync,
21
- writeFileSync,
22
- mkdirSync,
21
+ writeFileSync as writeFileSync2,
23
22
  rmSync,
24
23
  existsSync,
25
- statSync,
26
- chmodSync
24
+ statSync as statSync2
27
25
  } from "fs";
28
26
  import { join, dirname } from "path";
29
27
  import { homedir } from "os";
@@ -59,17 +57,30 @@ function assertTrustedApiUrl(url) {
59
57
  );
60
58
  }
61
59
 
60
+ // src/utils/secure-fs.ts
61
+ import { chmodSync, mkdirSync, statSync, writeFileSync } from "fs";
62
+ var SECURE_DIR_MODE = 448;
63
+ var SECURE_FILE_MODE = 384;
64
+ var isPosix = process.platform !== "win32";
65
+ function ensureSecureDir(dir) {
66
+ mkdirSync(dir, { recursive: true, mode: SECURE_DIR_MODE });
67
+ if (isPosix && statSync(dir).uid === process.getuid?.()) chmodSync(dir, SECURE_DIR_MODE);
68
+ }
69
+ function writeSecureFileSync(file, data) {
70
+ writeFileSync(file, data, { mode: SECURE_FILE_MODE });
71
+ if (isPosix) chmodSync(file, SECURE_FILE_MODE);
72
+ }
73
+
62
74
  // src/core/auth.ts
63
- var DIR_MODE = 448;
64
75
  var FILE_MODE = 384;
65
76
  var UNSAFE_PERM_MASK = 63;
66
- var isPosix = process.platform !== "win32";
77
+ var isPosix2 = process.platform !== "win32";
67
78
  function getCredentialsPath() {
68
79
  return join(homedir(), ".config", "shipguard", "credentials.json");
69
80
  }
70
81
  function hasUnsafePermissions(path3) {
71
- if (!isPosix) return false;
72
- const mode = statSync(path3).mode & 511;
82
+ if (!isPosix2) return false;
83
+ const mode = statSync2(path3).mode & 511;
73
84
  return (mode & UNSAFE_PERM_MASK) !== 0;
74
85
  }
75
86
  function loadCredentials() {
@@ -91,17 +102,15 @@ function loadCredentials() {
91
102
  async function saveCredentials(creds) {
92
103
  const p = getCredentialsPath();
93
104
  const dir = dirname(p);
94
- mkdirSync(dir, { recursive: true, mode: DIR_MODE });
95
- if (isPosix) chmodSync(dir, DIR_MODE);
96
- writeFileSync(p, JSON.stringify(creds, null, 2), { mode: FILE_MODE });
97
- if (isPosix) chmodSync(p, FILE_MODE);
105
+ ensureSecureDir(dir);
106
+ writeSecureFileSync(p, JSON.stringify(creds, null, 2));
98
107
  }
99
108
  function clearCredentials() {
100
109
  const p = getCredentialsPath();
101
110
  if (!existsSync(p)) return;
102
111
  try {
103
- const size = statSync(p).size;
104
- if (size > 0) writeFileSync(p, Buffer.alloc(size, 0), { mode: FILE_MODE });
112
+ const size = statSync2(p).size;
113
+ if (size > 0) writeFileSync2(p, Buffer.alloc(size, 0), { mode: FILE_MODE });
105
114
  } catch {
106
115
  }
107
116
  rmSync(p, { force: true });
@@ -365,7 +374,7 @@ function acquireFloorLock(lockPath, timeoutMs = 5e3) {
365
374
  const deadline = Date.now() + timeoutMs;
366
375
  while (Date.now() < deadline) {
367
376
  try {
368
- const fd = fs.openSync(lockPath, "wx");
377
+ const fd = fs.openSync(lockPath, "wx", SECURE_FILE_MODE);
369
378
  fs.closeSync(fd);
370
379
  return () => {
371
380
  try {
@@ -387,6 +396,7 @@ function atomicAcceptFloor(floorPath, incoming) {
387
396
  const lockPath = `${floorPath}.lock`;
388
397
  const dir = path.dirname(floorPath);
389
398
  const tmpPath = path.join(dir, `.floor-tmp-${process.pid}-${Date.now()}.json`);
399
+ ensureSecureDir(dir);
390
400
  const releaseLock = acquireFloorLock(lockPath);
391
401
  try {
392
402
  let lockedFloor = null;
@@ -439,7 +449,7 @@ function atomicAcceptFloor(floorPath, incoming) {
439
449
  return { accepted: true, wrote: false };
440
450
  }
441
451
  }
442
- fs.writeFileSync(tmpPath, JSON.stringify(incoming), "utf-8");
452
+ writeSecureFileSync(tmpPath, JSON.stringify(incoming));
443
453
  const tmpFd = fs.openSync(tmpPath, "r+");
444
454
  try {
445
455
  fs.fsyncSync(tmpFd);
@@ -3621,6 +3631,8 @@ export {
3621
3631
  payments,
3622
3632
  deploymentCheck,
3623
3633
  assertTrustedApiUrl,
3634
+ ensureSecureDir,
3635
+ writeSecureFileSync,
3624
3636
  loadCredentials,
3625
3637
  saveCredentials,
3626
3638
  clearCredentials,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.0",
2
+ "version": "0.7.1",
3
3
  "packageName": "@agenticcli/shipguard",
4
4
  "license": "Elastic-2.0",
5
5
  "licenseDisplay": "ELv2",
@@ -142,5 +142,5 @@
142
142
  ],
143
143
  "installSnippet": "npx @agenticcli/shipguard scan --changed --strict --json",
144
144
  "re2Engine": true,
145
- "generatedAt": "2026-10-01T12:43:43.901Z"
145
+ "generatedAt": "2026-10-02T06:06:11.087Z"
146
146
  }
package/dist/cli.js CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  databaseCheck,
8
8
  deploymentCheck,
9
9
  deriveBlocking,
10
+ ensureSecureDir,
10
11
  getAuthToken,
11
12
  getFindingKey,
12
13
  isLineSuppressed,
@@ -20,8 +21,9 @@ import {
20
21
  runProRulesWithDispatch,
21
22
  saveCredentials,
22
23
  secretsCheck,
23
- validateBundleCompile
24
- } from "./chunk-BVWCA2VJ.js";
24
+ validateBundleCompile,
25
+ writeSecureFileSync
26
+ } from "./chunk-A63X4LUJ.js";
25
27
  import {
26
28
  DEFAULT_MAX_FILES,
27
29
  DEFAULT_MAX_FILE_SIZE_BYTES,
@@ -2505,7 +2507,7 @@ function toSarif(result) {
2505
2507
 
2506
2508
  // src/core/render.ts
2507
2509
  import chalk from "chalk";
2508
- import { existsSync as existsSync2, mkdirSync, writeFileSync } from "fs";
2510
+ import { existsSync as existsSync2 } from "fs";
2509
2511
  import { join as join4, basename as basename2 } from "path";
2510
2512
  import { homedir } from "os";
2511
2513
  var DOCS_URL = "https://agenticcli.dev/docs";
@@ -2852,8 +2854,8 @@ function welcomeBanner(configDir) {
2852
2854
  return "";
2853
2855
  }
2854
2856
  try {
2855
- mkdirSync(dir, { recursive: true });
2856
- writeFileSync(marker, "1", "utf-8");
2857
+ ensureSecureDir(dir);
2858
+ writeSecureFileSync(marker, "1");
2857
2859
  } catch {
2858
2860
  }
2859
2861
  const BANNER_INNER = BOX_WIDTH - 2;
@@ -3063,7 +3065,7 @@ function resolveHistoryPath(cwd, policy) {
3063
3065
  // src/core/history/identity.ts
3064
3066
  import { execFileSync as execFileSync2 } from "child_process";
3065
3067
  import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
3066
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync, writeFileSync as writeFileSync2 } from "fs";
3068
+ import { existsSync as existsSync3, mkdirSync, readFileSync, writeFileSync } from "fs";
3067
3069
  import { dirname as dirname3, join as join5 } from "path";
3068
3070
  function tryGit(cwd, args) {
3069
3071
  try {
@@ -3079,7 +3081,7 @@ function ensureGitignored(cwd, entry) {
3079
3081
  const alreadyPresent = existing.split("\n").map((l) => l.trim()).some((l) => l === entry || l === entry.replace(/\/$/, ""));
3080
3082
  if (alreadyPresent) return;
3081
3083
  const prefix = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
3082
- writeFileSync2(gitignorePath, `${existing}${prefix}${entry}
3084
+ writeFileSync(gitignorePath, `${existing}${prefix}${entry}
3083
3085
  `, "utf-8");
3084
3086
  } catch (err) {
3085
3087
  logger.warn(`Could not update .gitignore for history store: ${err instanceof Error ? err.message : err}`);
@@ -3103,8 +3105,8 @@ function resolveRepoIdentity(cwd) {
3103
3105
  }
3104
3106
  }
3105
3107
  const id = randomUUID2();
3106
- mkdirSync2(dirname3(fallbackPath), { recursive: true });
3107
- writeFileSync2(fallbackPath, `${id}
3108
+ mkdirSync(dirname3(fallbackPath), { recursive: true });
3109
+ writeFileSync(fallbackPath, `${id}
3108
3110
  `, "utf-8");
3109
3111
  ensureGitignored(cwd, ".shipguard/");
3110
3112
  return { repoId: id, repoIdKind: "fallback-uuid", remoteLabel };
@@ -3143,7 +3145,7 @@ function computeScopeFingerprint(input) {
3143
3145
 
3144
3146
  // src/core/history/store.ts
3145
3147
  import { randomUUID as randomUUID3 } from "crypto";
3146
- import { existsSync as existsSync4, mkdirSync as mkdirSync3 } from "fs";
3148
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2 } from "fs";
3147
3149
  import { dirname as dirname4 } from "path";
3148
3150
  var sqliteModulePromise;
3149
3151
  var warningFilterInstalled = false;
@@ -3196,7 +3198,7 @@ var HistoryStore = class _HistoryStore {
3196
3198
  }
3197
3199
  const preExisted = existsSync4(dbPath);
3198
3200
  try {
3199
- mkdirSync3(dirname4(dbPath), { recursive: true });
3201
+ mkdirSync2(dirname4(dbPath), { recursive: true });
3200
3202
  } catch (err) {
3201
3203
  return {
3202
3204
  ok: false,
@@ -3744,7 +3746,7 @@ import { randomUUID as randomUUID6 } from "crypto";
3744
3746
 
3745
3747
  // src/core/telemetry-config.ts
3746
3748
  import { randomUUID as randomUUID5 } from "crypto";
3747
- import { chmodSync, existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
3749
+ import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
3748
3750
  import { homedir as homedir2 } from "os";
3749
3751
  import { join as join6 } from "path";
3750
3752
  import YAML2 from "yaml";
@@ -3780,9 +3782,8 @@ function userConfigUnreadable(dir = getConfigDir()) {
3780
3782
  var UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
3781
3783
  function writeConfig(dir, next) {
3782
3784
  const file = configFilePath(dir);
3783
- mkdirSync4(dir, { recursive: true, mode: 448 });
3784
- writeFileSync3(file, JSON.stringify(next, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
3785
- chmodSync(file, 384);
3785
+ ensureSecureDir(dir);
3786
+ writeSecureFileSync(file, JSON.stringify(next, null, 2) + "\n");
3786
3787
  return file;
3787
3788
  }
3788
3789
  function readInstallId(dir = getConfigDir()) {
@@ -3819,8 +3820,8 @@ function noticeShown(dir = getConfigDir()) {
3819
3820
  }
3820
3821
  function markNoticeShown(dir = getConfigDir()) {
3821
3822
  try {
3822
- mkdirSync4(dir, { recursive: true, mode: 448 });
3823
- writeFileSync3(join6(dir, NOTICE_MARKER), "1\n", { encoding: "utf-8", mode: 384 });
3823
+ ensureSecureDir(dir);
3824
+ writeSecureFileSync(join6(dir, NOTICE_MARKER), "1\n");
3824
3825
  } catch (err) {
3825
3826
  logger.debug(`telemetry: could not persist the notice marker: ${err instanceof Error ? err.message : String(err)}`);
3826
3827
  }
@@ -4053,7 +4054,7 @@ function sendTelemetry(input, opts = {}) {
4053
4054
 
4054
4055
  // src/commands/scan.ts
4055
4056
  var LEARN_MORE = "Docs https://agenticcli.dev/docs \xB7 Site https://agenticcli.dev \xB7 Pricing https://agenticcli.dev/pricing \xB7 Issues https://github.com/agenticcli/shipguard/issues";
4056
- var CLI_VERSION = true ? "0.7.0" : process.env.npm_package_version ?? "0.0.0-dev";
4057
+ var CLI_VERSION = true ? "0.7.1" : process.env.npm_package_version ?? "0.0.0-dev";
4057
4058
  function resolveExitCode(opts) {
4058
4059
  if (opts.strict && (opts.blockingCount > 0 || opts.degraded === true || opts.recommendation === "DO_NOT_SHIP")) {
4059
4060
  return EXIT_CODES.BLOCKED;
@@ -4219,7 +4220,7 @@ async function runScan(ctx) {
4219
4220
  logger.info("Detecting stack...");
4220
4221
  }
4221
4222
  try {
4222
- const { fetchProRules } = await import("./pro-scanner-SFOR7SGK.js");
4223
+ const { fetchProRules } = await import("./pro-scanner-QDOFUEXZ.js");
4223
4224
  const { hasConfig, generateConfig } = await import("./config-generator-2BVUZGEU.js");
4224
4225
  const frameworks = detectedFrameworks;
4225
4226
  if (!hasConfig(cwd)) {
@@ -4632,7 +4633,7 @@ function statusCommand() {
4632
4633
  // src/commands/history.ts
4633
4634
  import { Command as Command6 } from "commander";
4634
4635
  import { resolve as resolve5 } from "path";
4635
- var CLI_VERSION2 = true ? "0.7.0" : process.env.npm_package_version ?? "0.0.0-dev";
4636
+ var CLI_VERSION2 = true ? "0.7.1" : process.env.npm_package_version ?? "0.0.0-dev";
4636
4637
  function historyCommand() {
4637
4638
  return new Command6("history").description("Show recent local scan history for this repo (read-only; --json for machine output)").argument("[path]", "Path to project root (defaults to current directory)").option("--json", "Output as JSON").option("--limit <n>", "Number of recent scans to show", (v) => Number.parseInt(v, 10) || 10, 10).action(async (scanPath, opts) => {
4638
4639
  const cwd = scanPath ? resolve5(scanPath) : process.cwd();
@@ -4696,7 +4697,7 @@ function historyCommand() {
4696
4697
  // src/commands/hook.ts
4697
4698
  import { Command as Command7 } from "commander";
4698
4699
  import { execFileSync as execFileSync3 } from "child_process";
4699
- import { chmodSync as chmodSync2, existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync4 } from "fs";
4700
+ import { chmodSync, existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
4700
4701
  import { dirname as dirname5, isAbsolute, join as join8, relative as relative2, resolve as resolve6 } from "path";
4701
4702
 
4702
4703
  // src/core/hook-templates.ts
@@ -4790,9 +4791,9 @@ function isManaged(content) {
4790
4791
  // src/commands/hook.ts
4791
4792
  function writeManaged(path, whole, block, executable) {
4792
4793
  if (!existsSync7(path)) {
4793
- mkdirSync5(dirname5(path), { recursive: true });
4794
- writeFileSync4(path, whole, "utf-8");
4795
- if (executable) chmodSync2(path, 493);
4794
+ mkdirSync3(dirname5(path), { recursive: true });
4795
+ writeFileSync2(path, whole, "utf-8");
4796
+ if (executable) chmodSync(path, 493);
4796
4797
  return { path, status: "created" };
4797
4798
  }
4798
4799
  const current = readFileSync3(path, "utf-8");
@@ -4805,8 +4806,8 @@ function writeManaged(path, whole, block, executable) {
4805
4806
  }
4806
4807
  const merged = replaceManagedBlock(current, block) ?? whole;
4807
4808
  if (merged === current) return { path, status: "unchanged" };
4808
- writeFileSync4(path, merged, "utf-8");
4809
- if (executable) chmodSync2(path, 493);
4809
+ writeFileSync2(path, merged, "utf-8");
4810
+ if (executable) chmodSync(path, 493);
4810
4811
  return { path, status: "updated" };
4811
4812
  }
4812
4813
  function resolveGitHooksDir(cwd) {
@@ -4827,8 +4828,8 @@ function installClaude(cwd) {
4827
4828
  const path = join8(cwd, ".claude", "settings.json");
4828
4829
  const entry = { matcher: "Bash", hooks: [{ type: "command", command: CLAUDE_HOOK_COMMAND }] };
4829
4830
  if (!existsSync7(path)) {
4830
- mkdirSync5(dirname5(path), { recursive: true });
4831
- writeFileSync4(path, JSON.stringify({ hooks: { PreToolUse: [entry] } }, null, 2) + "\n", "utf-8");
4831
+ mkdirSync3(dirname5(path), { recursive: true });
4832
+ writeFileSync2(path, JSON.stringify({ hooks: { PreToolUse: [entry] } }, null, 2) + "\n", "utf-8");
4832
4833
  return [{ path, status: "created" }];
4833
4834
  }
4834
4835
  const raw2 = readFileSync3(path, "utf-8");
@@ -4861,7 +4862,7 @@ function installClaude(cwd) {
4861
4862
  ...settings,
4862
4863
  hooks: { ...settings.hooks ?? {}, PreToolUse: next }
4863
4864
  };
4864
- writeFileSync4(path, JSON.stringify(merged, null, 2) + "\n", "utf-8");
4865
+ writeFileSync2(path, JSON.stringify(merged, null, 2) + "\n", "utf-8");
4865
4866
  }
4866
4867
  return [{ path, status }];
4867
4868
  }
@@ -4952,7 +4953,7 @@ Exit codes:
4952
4953
 
4953
4954
  // src/commands/schema.ts
4954
4955
  import { Command as Command8 } from "commander";
4955
- var CLI_VERSION3 = true ? "0.7.0" : process.env.npm_package_version ?? "0.0.0-dev";
4956
+ var CLI_VERSION3 = true ? "0.7.1" : process.env.npm_package_version ?? "0.0.0-dev";
4956
4957
  var CURRENT_SCHEMA_VERSION2 = "5";
4957
4958
  function buildSchemaContract(limits) {
4958
4959
  const src = (value, fallback) => value === fallback ? "default" : "policy";
@@ -5305,7 +5306,7 @@ if (rawArgs[0] === "?") {
5305
5306
  process.argv = [process.argv[0], process.argv[1], "help"];
5306
5307
  }
5307
5308
  program.name("shipguard").description("CLI-first release gate for AI-built apps").version(
5308
- true ? "0.7.0" : process.env.npm_package_version ?? "0.0.0-dev"
5309
+ true ? "0.7.1" : process.env.npm_package_version ?? "0.0.0-dev"
5309
5310
  ).helpCommand(false).addHelpText("after", `
5310
5311
  Learn more:
5311
5312
  Docs https://agenticcli.dev/docs
@@ -7,7 +7,7 @@ import {
7
7
  runProRules,
8
8
  runProRulesWithDispatch,
9
9
  validateBundleCompile
10
- } from "./chunk-BVWCA2VJ.js";
10
+ } from "./chunk-A63X4LUJ.js";
11
11
  import "./chunk-MPQ42F54.js";
12
12
  export {
13
13
  NoRulesAppliedError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticcli/shipguard",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "CLI-first release gate for AI-built apps",
5
5
  "type": "module",
6
6
  "main": "./dist/cli.js",