@aaa-sentinel/iac-cost 0.6.0 → 0.6.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.
Files changed (3) hide show
  1. package/README.md +21 -8
  2. package/dist/cli.js +99 -26
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,6 +7,12 @@ internet is caught in review instead of after the deploy. With `iac-cost fix`, t
7
7
  your last scan on resources this Terraform manages come back to you as **pull requests**, not as
8
8
  console changes (see [Fixes as pull requests](#fixes-as-pull-requests)).
9
9
 
10
+ > **Changed in 0.6.1:** `fix` says when the security add-on is not active on the account, names the
11
+ > fixes whose pull or merge request was closed without merging (they are not reopened), and says
12
+ > "merge request" on GitLab. The fix jobs below no longer end in `|| true` or `continue-on-error`, so a
13
+ > setup error (exit code 2) fails the job instead of passing unseen. Rejected OAuth app credentials
14
+ > (401) or an app without the `security:fix` scope (403) are now setup errors too: exit code 2.
15
+
10
16
  > **New in 0.6.0:** GitLab CI, on gitlab.com and self-managed GitLab. The `comment` subcommand posts
11
17
  > the output as a note on the merge request and updates it on later pushes (see [GitLab CI](#gitlab-ci)),
12
18
  > and `fix` opens merge requests (see [GitLab CI](#gitlab-ci-1) under fixes). Nothing changes on GitHub
@@ -569,9 +575,16 @@ review its `terraform plan` before merging. The finding closes after `terraform
569
575
  | `--allow-public-repo` | Opens pull requests on a public repository too |
570
576
  | `--format <text\|json>` | Output format |
571
577
 
572
- Exit code: `2` for a usage error (no account, no git host, the run is a pull request build, the input
573
- is not a plan); otherwise `0`, also when the API or the git host fails — the step prints a warning
574
- and the findings stay `pending`.
578
+ Exit code: `2` for a setup error (no account, no git host or token, the run is a pull request build,
579
+ on GitLab a branch that is not protected, the input is not a plan; `IAC_FIX_CLIENT_ID` or
580
+ `IAC_FIX_CLIENT_SECRET` missing or rejected (401); an app without the `security:fix` scope or not allowed
581
+ on the account (403)); otherwise `0`, also when there is nothing to fix, when the security add-on is not
582
+ active on the account (402), and when the API is down (5xx), the network fails or the git host fails —
583
+ the step prints a warning and the findings stay `pending`. That is why the
584
+ jobs below do not end in `|| true` (or `continue-on-error` on GitHub): a `2` needs someone to fix the
585
+ pipeline and must show as a failed job, while an outage on our side never fails it. Run fixes in their
586
+ own workflow or job; if the job shares a GitLab pipeline with your deploy, add `allow_failure: true` to
587
+ it so a setup error shows as a warning without holding the later stages.
575
588
 
576
589
  ### GitHub Actions
577
590
 
@@ -606,7 +619,6 @@ jobs:
606
619
  - run: terraform plan -out=plan.tfplan
607
620
  - run: terraform show -json plan.tfplan > plan.json
608
621
  - name: Open security fixes as pull requests
609
- continue-on-error: true
610
622
  env:
611
623
  GITHUB_TOKEN: ${{ github.token }}
612
624
  IAC_FIX_CLIENT_ID: ${{ secrets.IAC_FIX_CLIENT_ID }}
@@ -632,7 +644,7 @@ pipelines:
632
644
  - terraform init
633
645
  - terraform plan -out=plan.tfplan
634
646
  - terraform show -json plan.tfplan > plan.json
635
- - npx --yes @aaa-sentinel/iac-cost fix plan.json --account "$AAA_SENTINEL_ACCOUNT_ID" || true
647
+ - npx --yes @aaa-sentinel/iac-cost fix plan.json --account "$AAA_SENTINEL_ACCOUNT_ID"
636
648
  ```
637
649
 
638
650
  The commit is created through the Bitbucket API (`POST /src`), so the clone needs no push access.
@@ -660,15 +672,16 @@ security-fixes:
660
672
  - terraform plan -out=plan.tfplan
661
673
  - terraform show -json plan.tfplan > plan.json
662
674
  # GITLAB_FIX_TOKEN (Developer, api), IAC_FIX_CLIENT_ID and IAC_FIX_CLIENT_SECRET: masked, protected variables.
663
- - npx --yes @aaa-sentinel/iac-cost fix plan.json --account "$AAA_SENTINEL_ACCOUNT_ID" || true
675
+ - npx --yes @aaa-sentinel/iac-cost fix plan.json --account "$AAA_SENTINEL_ACCOUNT_ID"
664
676
  ```
665
677
 
666
678
  The branch and the commit are created in one call to the GitLab API (`POST /repository/commits` from
667
679
  the deployed commit), so the clone needs no push access. A project with **internal** visibility counts
668
680
  as public (every user of the server, or of gitlab.com, can read it): pass `--allow-public-repo` if
669
681
  that is acceptable. It refuses to run on a merge request or tag pipeline, and on a branch that is not
670
- protected (`CI_COMMIT_REF_PROTECTED` is not `true`): the token that can push lives in a protected
671
- variable, so an unprotected branch means the setup is wrong. Protect the branch you deploy.
682
+ protected (`CI_COMMIT_REF_PROTECTED` is not `true`) with exit code `2`, so the job fails: the token
683
+ that can push lives in a protected variable, so an unprotected branch means the setup is wrong.
684
+ Protect the branch you deploy.
672
685
 
673
686
  ## Posture over time
674
687
 
package/dist/cli.js CHANGED
@@ -6711,6 +6711,21 @@ function aggregateEstimates(estimates) {
6711
6711
  catalogs: [...catalogs.values()]
6712
6712
  };
6713
6713
  }
6714
+ var TokenHttpError = class extends Error {
6715
+ constructor(status, code2) {
6716
+ super(`iac_cost_token_http_${status}`);
6717
+ this.status = status;
6718
+ this.code = code2;
6719
+ }
6720
+ };
6721
+ async function apiErrorCode(response) {
6722
+ try {
6723
+ const body2 = await response.json();
6724
+ return typeof body2.code === "string" && /^[A-Z][A-Z0-9_]{0,63}$/.test(body2.code) ? body2.code : null;
6725
+ } catch {
6726
+ return null;
6727
+ }
6728
+ }
6714
6729
  async function fetchToken(config2, scope = TOKEN_SCOPE) {
6715
6730
  const fetchImpl = config2.fetchImpl ?? fetch;
6716
6731
  const response = await fetchImpl(`${config2.baseUrl}/v1/oauth/token`, {
@@ -6724,7 +6739,7 @@ async function fetchToken(config2, scope = TOKEN_SCOPE) {
6724
6739
  scope
6725
6740
  })
6726
6741
  });
6727
- if (!response.ok) throw new Error(`iac_cost_token_http_${response.status}`);
6742
+ if (!response.ok) throw new TokenHttpError(response.status, await apiErrorCode(response));
6728
6743
  const body2 = await response.json();
6729
6744
  if (typeof body2.access_token !== "string") throw new Error("iac_cost_token_missing");
6730
6745
  return body2.access_token;
@@ -6791,18 +6806,31 @@ import { parseArgs as parseArgs3 } from "node:util";
6791
6806
  // src/fix/api.ts
6792
6807
  var SCOPE = "security:fix";
6793
6808
  var TIMEOUT_MS2 = 35e3;
6809
+ var CodeFixApiError = class extends Error {
6810
+ constructor(status, code2, stage = "findings") {
6811
+ super(`${stage === "token" ? "iac_cost_token_http_" : "code_fixes_http_"}${status}${code2 ? ` ${code2}` : ""}`);
6812
+ this.status = status;
6813
+ this.code = code2;
6814
+ this.stage = stage;
6815
+ }
6816
+ };
6794
6817
  function codeFixApi(config2) {
6795
6818
  const fetchImpl = config2.fetchImpl ?? fetch;
6796
6819
  const url = `${config2.baseUrl}/v1/security/code-fixes?accountId=${encodeURIComponent(config2.accountId)}`;
6797
6820
  let token = null;
6798
6821
  const bearer = async () => {
6799
- token ??= await fetchToken(config2, SCOPE);
6822
+ try {
6823
+ token ??= await fetchToken(config2, SCOPE);
6824
+ } catch (error2) {
6825
+ if (error2 instanceof TokenHttpError) throw new CodeFixApiError(error2.status, error2.code, "token");
6826
+ throw error2;
6827
+ }
6800
6828
  return token;
6801
6829
  };
6802
6830
  return {
6803
6831
  async load() {
6804
6832
  const response = await fetchImpl(url, { headers: { authorization: `Bearer ${await bearer()}` }, signal: AbortSignal.timeout(TIMEOUT_MS2) });
6805
- if (!response.ok) throw new Error(`code_fixes_http_${response.status}`);
6833
+ if (!response.ok) throw new CodeFixApiError(response.status, await apiErrorCode(response));
6806
6834
  const body2 = await response.json();
6807
6835
  const findings = (body2.findings ?? []).flatMap(
6808
6836
  (f) => typeof f.findingId === "string" && typeof f.ruleId === "string" && typeof f.resourceId === "string" ? [{
@@ -9088,7 +9116,7 @@ function title(ruleId) {
9088
9116
  function pullRequestTitle(ruleId, address) {
9089
9117
  return `fix(security): ${title(ruleId)} on ${address}`.slice(0, 250);
9090
9118
  }
9091
- function pullRequestBody(finding, outcome, accountId) {
9119
+ function pullRequestBody(finding, outcome, accountId, kind = "pull request") {
9092
9120
  return [
9093
9121
  `<!-- aaa-sentinel:code-fix ${finding.findingId} -->`,
9094
9122
  "### \u{1F512} Security fix from AAA Sentinel",
@@ -9102,7 +9130,7 @@ function pullRequestBody(finding, outcome, accountId) {
9102
9130
  `Files: ${outcome.patches.map((patch) => `\`${patch.file}\``).join(", ")}`,
9103
9131
  "",
9104
9132
  "Only literal values in the resource block were edited. Review the `terraform plan` of this branch before merging;",
9105
- "the finding closes after `terraform apply` and the next scan. Close this pull request to decline the fix."
9133
+ `the finding closes after \`terraform apply\` and the next scan. Close this ${kind} to decline the fix.`
9106
9134
  ].join("\n");
9107
9135
  }
9108
9136
  function allObservations(index) {
@@ -9131,6 +9159,31 @@ function anchorFor(index, observations, finding, input) {
9131
9159
  const scope = cloudScopeOf(resource);
9132
9160
  return scope === null || scope.toLowerCase() === input.cloudAccountId.toLowerCase() ? resource : null;
9133
9161
  }
9162
+ function loadFailure(error2, accountId) {
9163
+ if (!(error2 instanceof CodeFixApiError)) return { message: `could not read the open findings, nothing to fix: ${error2.message}`, setup: false };
9164
+ const { status, code: code2, stage } = error2;
9165
+ const tag = `${status}${code2 ? ` ${code2}` : ""}`;
9166
+ if (stage === "token" && status === 401) {
9167
+ return { message: `AAA Sentinel rejected the OAuth app credentials (${tag}): check IAC_FIX_CLIENT_ID and IAC_FIX_CLIENT_SECRET`, setup: true };
9168
+ }
9169
+ if (stage === "token" && code2 === "INVALID_SCOPE") {
9170
+ return { message: `the OAuth app in IAC_FIX_CLIENT_ID does not have the security:fix scope (${tag}): create an app with that scope`, setup: true };
9171
+ }
9172
+ if (stage === "findings" && status === 401) {
9173
+ return { message: `AAA Sentinel rejected the access token of the OAuth app (${tag}): check IAC_FIX_CLIENT_ID and IAC_FIX_CLIENT_SECRET`, setup: true };
9174
+ }
9175
+ if (stage === "findings" && status === 403) {
9176
+ const detail = code2 === "INSUFFICIENT_SCOPE" ? "the OAuth app in IAC_FIX_CLIENT_ID does not have the security:fix scope: create an app with that scope" : `the OAuth app in IAC_FIX_CLIENT_ID cannot use account ${accountId}: check --account and the accounts the app is limited to`;
9177
+ return { message: `${detail} (${tag})`, setup: true };
9178
+ }
9179
+ if (code2 === "SECURITY_ADDON_INACTIVE") {
9180
+ return { message: `the security add-on is not active on account ${accountId} (402 SECURITY_ADDON_INACTIVE): activate it in AAA Sentinel to get fixes; nothing to fix`, setup: false };
9181
+ }
9182
+ if (code2 === "PLAN_SECURITY_ADDON") {
9183
+ return { message: `the plan of this organization does not include the security add-on (402 PLAN_SECURITY_ADDON): fixes need the Pro or Business plan with the add-on; nothing to fix`, setup: false };
9184
+ }
9185
+ return { message: `could not read the open findings, nothing to fix: ${error2.message}`, setup: false };
9186
+ }
9134
9187
  function prState(state) {
9135
9188
  return state === "open" ? "pr_open" : state;
9136
9189
  }
@@ -9141,14 +9194,20 @@ function carry(findingId, fix2, state) {
9141
9194
  async function runFix(options, deps) {
9142
9195
  const warnings = [];
9143
9196
  const lines2 = [];
9197
+ const declined = [];
9144
9198
  const reports = [];
9145
9199
  const { host } = deps;
9200
+ const mr = host?.kind === "gitlab";
9201
+ const kind = mr ? "merge request" : "pull request";
9202
+ const ref = (n) => mr ? `!${n}` : `#${n}`;
9203
+ const hostTag = host ? { host: host.kind } : {};
9146
9204
  let input;
9147
9205
  try {
9148
9206
  input = await deps.api.load();
9149
9207
  } catch (error2) {
9150
- warnings.push(`could not read the open findings, nothing to fix: ${error2.message}`);
9151
- return { stdout: render(options, lines2, deps.accountId, null), warnings, lines: lines2, reported: 0 };
9208
+ const failure2 = loadFailure(error2, deps.accountId);
9209
+ warnings.push(failure2.message);
9210
+ return { stdout: render(options, { lines: lines2, declined, mr }, deps.accountId, null), warnings, lines: lines2, declined, reported: 0, setupError: failure2.setup };
9152
9211
  }
9153
9212
  if (input.truncated) warnings.push("the account has more open findings than the API returns (500 most severe): the rest are left for a later run");
9154
9213
  let publicRepo = false;
@@ -9158,9 +9217,9 @@ async function runFix(options, deps) {
9158
9217
  publicRepo = !await host.isPrivate();
9159
9218
  } catch (error2) {
9160
9219
  publicRepo = true;
9161
- warnings.push(`could not tell whether the repository is private, no pull request opened: ${error2.message}`);
9220
+ warnings.push(`could not tell whether the repository is private, no ${kind} opened: ${error2.message}`);
9162
9221
  }
9163
- if (publicRepo) warnings.push("the repository is public: no pull request opened (pass --allow-public-repo to open them anyway)");
9222
+ if (publicRepo) warnings.push(`the repository is public: no ${kind} opened (pass --allow-public-repo to open them anyway)`);
9164
9223
  }
9165
9224
  const index = new PlanIndex(deps.plan);
9166
9225
  const observations = allObservations(index);
@@ -9169,13 +9228,18 @@ async function runFix(options, deps) {
9169
9228
  const existing = input.fixes.get(finding.findingId);
9170
9229
  const sameRepo = Boolean(existing && host && existing.host === host.kind && existing.repository === host.repository && existing.server === host.server);
9171
9230
  if (existing && CODE_FIX_PR_STATES.includes(existing.state) && !sameRepo) continue;
9172
- if (existing?.state === "closed") continue;
9231
+ if (existing?.state === "closed") {
9232
+ if (anchorFor(index, observations, finding, input)) {
9233
+ declined.push({ findingId: finding.findingId, ruleId: finding.ruleId, address: existing.address, ...existing.pullRequest ? { pullRequest: existing.pullRequest.url } : {} });
9234
+ }
9235
+ continue;
9236
+ }
9173
9237
  if (existing && host && sameRepo && existing.state === "pr_open" && existing.pullRequest) {
9174
9238
  let state = "pr_open";
9175
9239
  try {
9176
9240
  state = prState(await host.pullRequestState(existing.pullRequest.number));
9177
9241
  } catch (error2) {
9178
- warnings.push(`could not read pull request #${existing.pullRequest.number}: ${error2.message}`);
9242
+ warnings.push(`could not read ${kind} ${ref(existing.pullRequest.number)}: ${error2.message}`);
9179
9243
  }
9180
9244
  if (state !== "merged") {
9181
9245
  reports.push(carry(finding.findingId, existing, state));
@@ -9212,19 +9276,20 @@ async function runFix(options, deps) {
9212
9276
  reason: outcome.reason,
9213
9277
  address: outcome.address,
9214
9278
  ...outcome.file !== void 0 ? { file: outcome.file } : {},
9215
- ...outcome.attribute !== void 0 ? { attribute: outcome.attribute } : {}
9279
+ ...outcome.attribute !== void 0 ? { attribute: outcome.attribute } : {},
9280
+ ...hostTag
9216
9281
  });
9217
9282
  lines2.push({ ...base, outcome: "suggested", reason: outcome.reason, ...outcome.file !== void 0 ? { file: outcome.file } : {} });
9218
9283
  continue;
9219
9284
  }
9220
9285
  if (outcome.kind === "fixed_in_code") {
9221
- reports.push({ findingId: finding.findingId, state: "pending", reason: "fixed_in_code", address: outcome.address, file: outcome.file, attribute: outcome.attribute });
9286
+ reports.push({ findingId: finding.findingId, state: "pending", reason: "fixed_in_code", address: outcome.address, file: outcome.file, attribute: outcome.attribute, ...hostTag });
9222
9287
  lines2.push({ ...base, outcome: "pending", reason: "fixed_in_code", file: outcome.file });
9223
9288
  continue;
9224
9289
  }
9225
9290
  const patch = outcome;
9226
9291
  const pending = (reason) => {
9227
- reports.push({ findingId: finding.findingId, state: "pending", reason, address: patch.address, file: patch.file, attribute: patch.attribute });
9292
+ reports.push({ findingId: finding.findingId, state: "pending", reason, address: patch.address, file: patch.file, attribute: patch.attribute, ...hostTag });
9228
9293
  lines2.push({ ...base, outcome: "pending", reason, file: patch.file, changes: patch.changes });
9229
9294
  };
9230
9295
  if (options.dryRun || !host) {
@@ -9232,7 +9297,7 @@ async function runFix(options, deps) {
9232
9297
  continue;
9233
9298
  }
9234
9299
  if (host.unsupported) {
9235
- reports.push({ findingId: finding.findingId, state: "suggested", reason: "unsupported_host", address: patch.address, file: patch.file, attribute: patch.attribute });
9300
+ reports.push({ findingId: finding.findingId, state: "suggested", reason: "unsupported_host", address: patch.address, file: patch.file, attribute: patch.attribute, ...hostTag });
9236
9301
  lines2.push({ ...base, outcome: "suggested", reason: "unsupported_host", file: patch.file, changes: patch.changes });
9237
9302
  continue;
9238
9303
  }
@@ -9267,7 +9332,7 @@ async function runFix(options, deps) {
9267
9332
  record2(pr2, prState(pr2.state));
9268
9333
  continue;
9269
9334
  }
9270
- const reopened = await host.openPullRequest(branch, title2, pullRequestBody(finding, patch, deps.accountId));
9335
+ const reopened = await host.openPullRequest(branch, title2, pullRequestBody(finding, patch, deps.accountId, kind));
9271
9336
  opened += 1;
9272
9337
  record2(reopened, "pr_open");
9273
9338
  continue;
@@ -9287,12 +9352,12 @@ async function runFix(options, deps) {
9287
9352
  return { path: file.file, content: atBase === file.original ? patched : likeBase(patched, atBase) };
9288
9353
  });
9289
9354
  await host.createBranchWithCommit(branch, title2, files);
9290
- const pr = await host.openPullRequest(branch, title2, pullRequestBody(finding, patch, deps.accountId));
9355
+ const pr = await host.openPullRequest(branch, title2, pullRequestBody(finding, patch, deps.accountId, kind));
9291
9356
  opened += 1;
9292
9357
  record2(pr, "pr_open");
9293
9358
  } catch (error2) {
9294
9359
  if (error2 instanceof SkipFinding) continue;
9295
- warnings.push(`could not open the pull request for ${patch.address}: ${error2.message}`);
9360
+ warnings.push(`could not open the ${kind} for ${patch.address}: ${error2.message}`);
9296
9361
  pending("pr_failed");
9297
9362
  }
9298
9363
  }
@@ -9303,12 +9368,12 @@ async function runFix(options, deps) {
9303
9368
  reported = result.accepted;
9304
9369
  if (result.notFound > 0) warnings.push(`${result.notFound} fixes were not recorded: their findings are no longer open`);
9305
9370
  if (result.duplicates > 0) warnings.push(`${result.duplicates} fixes were not recorded: the same finding was reported twice in one run`);
9306
- if (result.stale > 0) warnings.push(`${result.stale} fixes were not recorded: AAA Sentinel already has a newer pull request state for them`);
9371
+ if (result.stale > 0) warnings.push(`${result.stale} fixes were not recorded: AAA Sentinel already has a newer ${kind} state for them`);
9307
9372
  } catch (error2) {
9308
9373
  warnings.push(`could not record the fixes in AAA Sentinel: ${error2.message}`);
9309
9374
  }
9310
9375
  }
9311
- return { stdout: render(options, lines2, deps.accountId, input.scanAt), warnings, lines: lines2, reported };
9376
+ return { stdout: render(options, { lines: lines2, declined, mr }, deps.accountId, input.scanAt), warnings, lines: lines2, declined, reported, setupError: false };
9312
9377
  }
9313
9378
  var SkipFinding = class extends Error {
9314
9379
  };
@@ -9327,15 +9392,23 @@ var OUTCOME_TEXT = {
9327
9392
  pending: "pending",
9328
9393
  suggested: "change suggested, no pull request"
9329
9394
  };
9330
- function render(options, lines2, accountId, scanAt) {
9331
- if (options.format === "json") return JSON.stringify({ formatVersion: "1", accountId, scanAt, dryRun: options.dryRun, fixes: lines2 }, null, 2);
9332
- if (lines2.length === 0) return `No open finding of account ${accountId} matches a resource of this plan.`;
9333
- const out = [`Security fixes for account ${accountId}${options.dryRun ? " (dry run: nothing opened or recorded)" : ""}`];
9395
+ function render(options, { lines: lines2, declined, mr }, accountId, scanAt) {
9396
+ if (options.format === "json") return JSON.stringify({ formatVersion: "1", accountId, scanAt, dryRun: options.dryRun, fixes: lines2, declined }, null, 2);
9397
+ const kind = mr ? "merge request" : "pull request";
9398
+ const out = [];
9399
+ if (lines2.length === 0 && declined.length === 0) return `No open finding of account ${accountId} matches a resource of this plan.`;
9400
+ const dryRun = options.dryRun ? " (dry run: nothing opened or recorded)" : "";
9401
+ if (lines2.length === 0) out.push(`No new fix for account ${accountId}${dryRun}.`);
9402
+ else out.push(`Security fixes for account ${accountId}${dryRun}`);
9334
9403
  for (const line of lines2) {
9335
9404
  const detail = [line.reason, line.file, line.pullRequest].filter(Boolean).join(", ");
9336
- out.push(` ${line.address} \u2014 ${title(line.ruleId)}: ${OUTCOME_TEXT[line.outcome]}${detail ? ` (${detail})` : ""}`);
9405
+ out.push(` ${line.address} \u2014 ${title(line.ruleId)}: ${OUTCOME_TEXT[line.outcome].replace("pull request", kind)}${detail ? ` (${detail})` : ""}`);
9337
9406
  for (const change of line.changes ?? []) out.push(` ${change}`);
9338
9407
  }
9408
+ if (declined.length > 0) {
9409
+ out.push(`${declined.length} earlier ${declined.length === 1 ? "fix was" : "fixes were"} declined: ${declined.length === 1 ? "its" : "their"} ${kind}${declined.length === 1 ? " was" : "s were"} closed without merging and no new one is opened:`);
9410
+ for (const fix2 of declined) out.push(` ${fix2.findingId.slice(0, 12)} ${fix2.address} \u2014 ${title(fix2.ruleId)}${fix2.pullRequest ? `: ${fix2.pullRequest}` : ""}`);
9411
+ }
9339
9412
  return out.join("\n");
9340
9413
  }
9341
9414
 
@@ -9439,7 +9512,7 @@ ${FIX_USAGE}`);
9439
9512
  }
9440
9513
  const locator = new SourceLocator(configurationOf(plan), workDir, repoRoot ?? workDir);
9441
9514
  const result = await runFix({ dryRun, maxPrs, format, allowPublicRepo: values["allow-public-repo"] === true }, { plan, api, host, locator, accountId: account });
9442
- return { stdout: result.stdout, warnings: [...warnings, ...result.warnings], exitCode: 0 };
9515
+ return { stdout: result.stdout, warnings: [...warnings, ...result.warnings], exitCode: result.setupError ? 2 : 0 };
9443
9516
  }
9444
9517
 
9445
9518
  // src/posture/posture.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aaa-sentinel/iac-cost",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Estimate the monthly cost delta of a Terraform plan, check it against the AAA Sentinel security rules, open security fixes as pull requests and report how the security posture changed, from your CI",
5
5
  "license": "MIT",
6
6
  "type": "module",