@aaa-sentinel/iac-cost 0.10.0 → 0.11.0

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 +29 -6
  2. package/dist/cli.js +777 -109
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,6 +7,17 @@ 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
+ > **New in 0.11.0:** `--format text` shows the estimate in your organization's currency (`≈`) when the API
11
+ > converted it, and keeps `(list price, USD)` when it did not. A total that leaves out unpriced resources is
12
+ > labelled partial (`cost.totalIsPartial` in JSON). API errors (401, 402, 403, 429, 5xx) say what to do.
13
+ >
14
+ > **Compatibility in 0.11.0:** if you parse the text output or the warnings, three things change. With an
15
+ > organization currency other than USD, the `Estimated change` line shows the amount with `≈` in that
16
+ > currency (the USD amount follows in brackets). A partial total adds a `Total is partial: …` line. Warnings
17
+ > for API errors carry the API code after the status (`iac_cost_estimate_http_402 PLAN_IAC_ESTIMATE`) and
18
+ > then the advice. To automate, read `--format json` (`cost.totalMonthlyDeltaUsd`, `cost.totalIsPartial`)
19
+ > instead of the text.
20
+ >
10
21
  > **New in 0.10.0:** `iac-cost owners sync` sends which team owns what, from Backstage `catalog-info.yaml` files and from CODEOWNERS plus the Terraform state, so AAA Sentinel can split the bill by team (see [Owners from code](#owners-from-code)).
11
22
  >
12
23
  > **In 0.9.0:** `iac-cost env-cost --env <name>` prints what an ephemeral environment has cost so far, resource by resource, with when its lease expires, and `--comment` posts it on the merge request (see [Environment cost](#environment-cost)).
@@ -98,7 +109,7 @@ say, stdout is empty.
98
109
  | --- | --- |
99
110
  | `--format markdown` | The pull request comment (default) |
100
111
  | `--format text` | Plain lines for a terminal or a CI log |
101
- | `--format json` | `{ formatVersion, cost, security, warnings }` (plus `budgets` with `--fail-on-budget`), with the full evidence of each finding. It is evidence for you, not for a pull request: it keeps the Terraform addresses as written (for_each keys included) and the evidence as the rules see it — ARNs, subscription ids, emails or internal CIDRs of resources that already exist. Do not post it as a comment |
112
+ | `--format json` | `{ formatVersion, cost, security, warnings }` (plus `budgets` with `--fail-on-budget`; `cost.totalIsPartial` is `true` when the total leaves out billable resources that could not be priced), with the full evidence of each finding. It is evidence for you, not for a pull request: it keeps the Terraform addresses as written (for_each keys included) and the evidence as the rules see it — ARNs, subscription ids, emails or internal CIDRs of resources that already exist. Do not post it as a comment |
102
113
  | `--fail-on <critical\|high\|medium\|low>` | Exit 1 when a security finding or toxic combination is at that severity or worse. Also `IAC_SECURITY_FAIL_ON` |
103
114
  | `--no-security` | Cost only, exactly as in 0.1 |
104
115
  | `--no-cost` | Security only and no credentials needed. Nothing leaves your machine unless you also pass `--drift-account` explicitly: with `--no-cost`, `IAC_SECURITY_ACCOUNT_ID` in the environment is ignored |
@@ -112,6 +123,12 @@ Without `--fail-on` the exit code is **always 0**. A missing credential, a netwo
112
123
  unreadable plan or an outage on our side prints a one-line warning and stops. A cost comment is
113
124
  not a quality gate, and our availability must not become a dependency of your deployments.
114
125
 
126
+ When the API answers with an error, the warning keeps the error (`iac_cost_token_http_401`,
127
+ `iac_cost_estimate_http_402 PLAN_IAC_ESTIMATE`…) and adds what to do: for 401, which variables
128
+ hold the rejected credentials and how to try them locally; for 403, which scope the app is
129
+ missing; for 402, which plan is needed or that the trial has ended, and where to change it; for
130
+ 429, to wait and run again; for 5xx, to run again and then write to support.
131
+
115
132
  With `--fail-on high` you are asking for a gate, and the exit code becomes:
116
133
 
117
134
  | Code | When |
@@ -130,7 +147,8 @@ neither can change it. A check that **could not be decided** (see below) never b
130
147
  With `--fail-on-budget` the CLI sends the estimated monthly change (`totalMonthlyDeltaUsd`, one
131
148
  number) to AAA Sentinel, which compares it with your budgets: for each budget that applies, this
132
149
  month's spend so far scaled to the whole month, plus the change. The budgets that apply are the
133
- organization ones, and those of the account in `--budget-account` (or `--drift-account`).
150
+ organization ones, those of the account in `--budget-account` (or `--drift-account`) and, when
151
+ that account belongs to one of your MSP clients, the budgets of that client.
134
152
 
135
153
  **Limitation of this version: budgets scoped to one billing service are not checked.** A
136
154
  Terraform plan names resource types, not the billing services they are charged under, so the CLI
@@ -322,10 +340,15 @@ or account ids. The JSON output does not: it is the complete evidence (see `--fo
322
340
  a reservation that already covers the new resource makes the real marginal cost zero.
323
341
  - **Priced in USD, shown in your organization's currency.** USD is what the providers publish, and
324
342
  the API always returns it (`...Usd` fields). If your AAA Sentinel organization displays amounts
325
- in EUR or GBP, the comment shows the converted amount instead, marked with `≈` and with the ECB
326
- reference rate and its date spelled out — it is an estimate on top of an estimate, and the same
327
- unchanged pull request can move a little as the exchange rate does. Organizations in USD, or a
328
- day with no exchange rate available, get plain USD.
343
+ in EUR or GBP, the comment and `--format text` show the converted amount instead, marked with `≈`
344
+ and with the ECB reference rate and its date spelled out — it is an estimate on top of an
345
+ estimate, and the same unchanged pull request can move a little as the exchange rate does.
346
+ Organizations in USD, or a day with no exchange rate available, get plain USD, marked
347
+ `(list price, USD)`.
348
+ - **A partial total says so.** When the total is published but some billable resources could not
349
+ be priced, the comment and the text output add `partial: N billable resources not priced`, and
350
+ the JSON output has `cost.totalIsPartial: true` next to `cost.coverage.unpricedResources`. The
351
+ real change can differ from the total.
329
352
  - **Coverage leads, not the total.** When fewer than half of the billable resources can be
330
353
  priced, the breakdown is published but the total is withheld. A total built from 2 resources
331
354
  out of 30 is not a partial estimate, it is noise — and it would end up quoted in the review as
package/dist/cli.js CHANGED
@@ -31,12 +31,13 @@ Options:
31
31
  --drift-account <accountId> Compare with the last scan of this AAA Sentinel
32
32
  account (needs IAC_SECURITY_CLIENT_ID/SECRET)
33
33
  --fail-on-budget[=strict] Exit 1 when the change takes an AAA Sentinel budget over
34
- (organization budgets, and the account ones with
35
- --budget-account). With =strict a budget without a
34
+ (organization budgets, and the account and client ones
35
+ with --budget-account). With =strict a budget without a
36
36
  forecast, or no budget at all, also fails. Needs the
37
37
  budgets:read scope on IAC_COST_CLIENT_ID. Service
38
38
  budgets are not checked in this version
39
- --budget-account <accountId> Account whose budgets also apply (default: --drift-account)
39
+ --budget-account <accountId> Account whose budgets, and its client's, also apply
40
+ (default: --drift-account)
40
41
  -h, --help Show this help`;
41
42
  function parseCliArgs(argv, env) {
42
43
  const warnings = [];
@@ -234,6 +235,17 @@ var REASON_TEXT = {
234
235
  price_not_found: "no matching price found in the catalog"
235
236
  };
236
237
  var fmtUsd = (n) => `${n < 0 ? "-" : "+"}$${Math.abs(n).toFixed(2)}/mo`;
238
+ function isPartialTotal(estimate) {
239
+ return estimate.totalMonthlyDeltaUsd !== null && estimate.coverage.unpricedResources > 0;
240
+ }
241
+ function partialTotalLabel(estimate) {
242
+ if (!isPartialTotal(estimate)) return "";
243
+ const n = estimate.coverage.unpricedResources;
244
+ return `partial: ${n} billable resource${n === 1 ? "" : "s"} not priced`;
245
+ }
246
+ function orgCurrency(estimate) {
247
+ return estimate.displayCurrency?.approximate ? estimate.displayCurrency : null;
248
+ }
237
249
  function fmtConverted(n, currency) {
238
250
  const amount = new Intl.NumberFormat("en-US", { style: "currency", currency }).format(Math.abs(n));
239
251
  return `\u2248 ${n < 0 ? "-" : "+"}${amount}/mo`;
@@ -250,12 +262,13 @@ function renderComment(estimate) {
250
262
  `**Coverage: ${coverage.pricedResources} of ${coverage.pricedResources + coverage.unpricedResources} billable resources priced** (${coverage.freeResources} more have no cost by design).`
251
263
  );
252
264
  lines2.push("");
253
- const display = estimate.displayCurrency?.approximate ? estimate.displayCurrency : null;
265
+ const display = orgCurrency(estimate);
254
266
  const delta = (usd, converted) => display && typeof converted === "number" ? fmtConverted(converted, display.code) : fmtUsd(usd);
255
267
  if (estimate.totalMonthlyDeltaUsd !== null) {
256
268
  const total2 = delta(estimate.totalMonthlyDeltaUsd, estimate.totalMonthlyDelta);
269
+ const partial2 = isPartialTotal(estimate) ? ` \u2014 **${partialTotalLabel(estimate)}**: the real change can differ` : "";
257
270
  lines2.push(
258
- display ? `**Estimated change: ${total2}** (list price, ${fmtUsd(estimate.totalMonthlyDeltaUsd)} in USD)` : `**Estimated change: ${total2}** (list price, USD)`
271
+ display ? `**Estimated change: ${total2}** (list price, ${fmtUsd(estimate.totalMonthlyDeltaUsd)} in USD)${partial2}` : `**Estimated change: ${total2}** (list price, USD)${partial2}`
259
272
  );
260
273
  } else {
261
274
  lines2.push(
@@ -6824,7 +6837,8 @@ async function estimateChunk(projection, token, config2) {
6824
6837
  continue;
6825
6838
  }
6826
6839
  }
6827
- throw new Error(`iac_cost_estimate_http_${response.status}`);
6840
+ const code2 = await apiErrorCode(response);
6841
+ throw new Error(`iac_cost_estimate_http_${response.status}${code2 ? ` ${code2}` : ""}`);
6828
6842
  }
6829
6843
  throw new Error("iac_cost_estimate_exhausted_retries");
6830
6844
  }
@@ -6850,6 +6864,71 @@ async function estimatePlan(projection, config2) {
6850
6864
  return aggregateEstimates(estimates);
6851
6865
  }
6852
6866
 
6867
+ // src/http-hints.ts
6868
+ var APPS_URL = "https://app.aaa-sentinel.com/developer/apps";
6869
+ var BILLING_URL = "https://app.aaa-sentinel.com/billing";
6870
+ var COST_ACCESS = {
6871
+ idVar: "IAC_COST_CLIENT_ID",
6872
+ secretVar: "IAC_COST_CLIENT_SECRET",
6873
+ scope: "iac:estimate",
6874
+ planNeed: "the cost estimate needs the Pro plan or above"
6875
+ };
6876
+ var BUDGET_ACCESS = { ...COST_ACCESS, scope: "budgets:read", planNeed: null };
6877
+ var DRIFT_ACCESS = {
6878
+ idVar: "IAC_SECURITY_CLIENT_ID",
6879
+ secretVar: "IAC_SECURITY_CLIENT_SECRET",
6880
+ scope: "security:read",
6881
+ planNeed: null
6882
+ };
6883
+ var ENV_COST_ACCESS = { ...COST_ACCESS, scope: "leases:read", planNeed: "the environment cost needs the Pro plan or above" };
6884
+ var OWNERS_ACCESS = { ...COST_ACCESS, scope: "owners:write", planNeed: "syncing owners needs the Business plan" };
6885
+ function httpFailure(error2) {
6886
+ if (error2 instanceof TokenHttpError) return { stage: "token", status: error2.status, code: error2.code };
6887
+ const message = error2 instanceof Error ? error2.message : String(error2);
6888
+ const match = /(token_)?http_(\d{3})(?: ([A-Z][A-Z0-9_]{0,63}))?$/.exec(message);
6889
+ if (!match) return null;
6890
+ return { stage: match[1] ? "token" : "api", status: Number(match[2]), code: match[3] ?? null };
6891
+ }
6892
+ function httpHint(error2, access) {
6893
+ const failure2 = httpFailure(error2);
6894
+ if (!failure2) return null;
6895
+ const { stage, status, code: code2 } = failure2;
6896
+ const creds = `${access.idVar}/${access.secretVar}`;
6897
+ if (stage === "token" && status === 400 && code2 === "INVALID_SCOPE") {
6898
+ return `the app in ${access.idVar} does not have the ${access.scope} scope: add it to the app in ${APPS_URL} (or create an app with it and update ${creds}), then run the job again.`;
6899
+ }
6900
+ if (stage === "token" && (status === 400 || status === 401)) {
6901
+ return `the API rejected ${creds}: check that they hold the client id and the current secret of an app that is not revoked (${APPS_URL}), without quotes or spaces. To try it locally: export ${access.idVar}=<client id> ${access.secretVar}=<secret> and run the same command.`;
6902
+ }
6903
+ if (status === 401) {
6904
+ return `the API rejected the access token: run the job again; if it keeps failing, check ${creds} in ${APPS_URL}.`;
6905
+ }
6906
+ if (status === 403) {
6907
+ if (code2 === "INSUFFICIENT_SCOPE") {
6908
+ return `the app in ${access.idVar} does not have the ${access.scope} scope: add it to the app in ${APPS_URL}, then run the job again.`;
6909
+ }
6910
+ return `the app in ${access.idVar} is not allowed to do this: check that it has the ${access.scope} scope and, if it is limited to some clients, that the account belongs to one of them (${APPS_URL}).`;
6911
+ }
6912
+ if (status === 402) {
6913
+ if (code2 === "TRIAL_EXPIRED" || code2 === "SUBSCRIPTION_EXPIRED") {
6914
+ return `the organization's ${code2 === "TRIAL_EXPIRED" ? "trial" : "subscription"} has ended, so the API issues no tokens: choose a plan in ${BILLING_URL}, then run the job again.`;
6915
+ }
6916
+ return `the organization's plan does not include this${access.planNeed ? ` (${access.planNeed})` : ""}: change the plan in ${BILLING_URL}, then run the job again.`;
6917
+ }
6918
+ if (status === 429) {
6919
+ return stage === "token" ? `too many token requests, or too many failed attempts with this client id: wait a few minutes, check ${creds}, and run the job again.` : "the API rate limit was reached even after retrying: wait a minute and run the job again, or run fewer jobs in parallel with the same app.";
6920
+ }
6921
+ if (status >= 500) {
6922
+ return "the AAA Sentinel API failed on our side: run the job again in a few minutes; if it keeps failing, write to support@aaa-sentinel.com with the time of the run.";
6923
+ }
6924
+ return null;
6925
+ }
6926
+ function describeApiError(error2, access) {
6927
+ const message = error2 instanceof Error ? error2.message : String(error2);
6928
+ const hint = httpHint(error2, access);
6929
+ return hint ? `${message}. ${hint[0].toUpperCase()}${hint.slice(1)}` : message;
6930
+ }
6931
+
6853
6932
  // src/env-cost.ts
6854
6933
  var ENV_COST_USAGE = `Usage: iac-cost env-cost --env <name> [--comment] [--format text|markdown|json]
6855
6934
 
@@ -7051,7 +7130,7 @@ ${ENV_COST_USAGE}`], exitCode: 2 };
7051
7130
  env
7052
7131
  );
7053
7132
  } catch (error2) {
7054
- return skip(`could not read the environment cost, continuing: ${error2.message}`);
7133
+ return skip(`could not read the environment cost, continuing: ${describeApiError(error2, ENV_COST_ACCESS)}`);
7055
7134
  }
7056
7135
  if (data === "not_found") return skip(`environment "${env}" not found: no lease or tagged resource uses it yet (tags show up after the next daily scan)`);
7057
7136
  const now = (io.now ?? (() => /* @__PURE__ */ new Date()))();
@@ -13040,6 +13119,7 @@ var signed = (n, currency) => `${n < 0 ? "-" : "+"}${money2(Math.abs(n), currenc
13040
13119
  function scopeText(scope) {
13041
13120
  if (scope.kind === "org") return "organization";
13042
13121
  if (scope.kind === "account") return `account ${scope.accountId}`;
13122
+ if (scope.kind === "client") return `client ${scope.clientId}`;
13043
13123
  return scope.accountId ? `${scope.service} in ${scope.accountId}` : scope.service;
13044
13124
  }
13045
13125
  var STATUS_TEXT = {
@@ -13052,7 +13132,7 @@ function renderBudgetMarkdown(response, mode) {
13052
13132
  const lines2 = ["### \u{1F3AF} Budgets", ""];
13053
13133
  if (response.results.length === 0) {
13054
13134
  lines2.push(
13055
- mode === "strict" ? "No budget applies to this change (organization budgets, or account budgets with `--budget-account`). Strict mode fails the check." : "No budget applies to this change (organization budgets, or account budgets with `--budget-account`)."
13135
+ mode === "strict" ? "No budget applies to this change (organization budgets, or account and client budgets with `--budget-account`). Strict mode fails the check." : "No budget applies to this change (organization budgets, or account and client budgets with `--budget-account`)."
13056
13136
  );
13057
13137
  return lines2.join("\n");
13058
13138
  }
@@ -13420,6 +13500,181 @@ var AWS_SECURITY_COMBOS = [
13420
13500
  }
13421
13501
  ];
13422
13502
 
13503
+ // ../../services/security/src/collectors/aws/check-ids.ts
13504
+ var CLOUDTRAIL_CHECKS = {
13505
+ describeTrails: "aws:cloudtrail:DescribeTrails",
13506
+ trailStatus: "aws:cloudtrail:GetTrailStatus",
13507
+ eventSelectors: "aws:cloudtrail:GetEventSelectors"
13508
+ };
13509
+ var EC2_CHECKS = {
13510
+ securityGroups: "aws:ec2:DescribeSecurityGroups",
13511
+ networkAcls: "aws:ec2:DescribeNetworkAcls",
13512
+ snapshots: "aws:ec2:DescribeSnapshots",
13513
+ publicSnapshots: "aws:ec2:DescribeSnapshots#public",
13514
+ vpcs: "aws:ec2:DescribeVpcs",
13515
+ subnets: "aws:ec2:DescribeSubnets",
13516
+ flowLogs: "aws:ec2:DescribeFlowLogs",
13517
+ prefixListEntries: "aws:ec2:GetManagedPrefixListEntries",
13518
+ flowLogInterfaces: "aws:ec2:DescribeNetworkInterfaces#flowLogs"
13519
+ };
13520
+ var ALL_PROTOCOLS = "-1";
13521
+ var ELB_CHECKS = {
13522
+ loadBalancers: "aws:elasticloadbalancing:DescribeLoadBalancers",
13523
+ listeners: "aws:elasticloadbalancing:DescribeListeners",
13524
+ targetGroups: "aws:elasticloadbalancing:DescribeTargetGroups",
13525
+ targetGroupAttributes: "aws:elasticloadbalancing:DescribeTargetGroupAttributes",
13526
+ targetHealth: "aws:elasticloadbalancing:DescribeTargetHealth"
13527
+ };
13528
+ var IAM_CHECKS = {
13529
+ accountSummary: "aws:iam:GetAccountSummary",
13530
+ passwordPolicy: "aws:iam:GetAccountPasswordPolicy",
13531
+ listUsers: "aws:iam:ListUsers",
13532
+ loginProfile: "aws:iam:GetLoginProfile",
13533
+ mfaDevices: "aws:iam:ListMFADevices",
13534
+ accessKeys: "aws:iam:ListAccessKeys",
13535
+ accessKeyLastUsed: "aws:iam:GetAccessKeyLastUsed",
13536
+ attachedPolicies: "aws:iam:ListAttachedUserPolicies"
13537
+ };
13538
+ var KMS_CHECKS = {
13539
+ listKeys: "aws:kms:ListKeys",
13540
+ listAliases: "aws:kms:ListAliases",
13541
+ describeKey: "aws:kms:DescribeKey",
13542
+ rotation: "aws:kms:GetKeyRotationStatus"
13543
+ };
13544
+ var LAMBDA_CHECKS = {
13545
+ functions: "aws:lambda:ListFunctions",
13546
+ functionUrl: "aws:lambda:GetFunctionUrlConfig",
13547
+ policy: "aws:lambda:GetPolicy"
13548
+ };
13549
+ var LIGHTSAIL_CHECKS = {
13550
+ regions: "aws:lightsail:GetRegions",
13551
+ instances: "aws:lightsail:GetInstances"
13552
+ };
13553
+ var MONITORING_CHECKS = {
13554
+ metricFilters: "aws:logs:DescribeMetricFilters",
13555
+ alarms: "aws:cloudwatch:DescribeAlarms",
13556
+ topicSubscriptions: "aws:sns:ListSubscriptionsByTopic"
13557
+ };
13558
+ var RDS_CHECKS = {
13559
+ instances: "aws:rds:DescribeDBInstances",
13560
+ clusters: "aws:rds:DescribeDBClusters",
13561
+ snapshots: "aws:rds:DescribeDBSnapshots",
13562
+ snapshotAttributes: "aws:rds:DescribeDBSnapshotAttributes",
13563
+ clusterSnapshots: "aws:rds:DescribeDBClusterSnapshots",
13564
+ clusterSnapshotAttributes: "aws:rds:DescribeDBClusterSnapshotAttributes"
13565
+ };
13566
+ var REGION_CHECKS = {
13567
+ listRegions: "aws:ec2:DescribeRegions"
13568
+ };
13569
+ var S3_CHECKS = {
13570
+ listBuckets: "aws:s3:ListBuckets",
13571
+ accountPublicAccessBlock: "aws:s3control:GetPublicAccessBlock",
13572
+ publicAccessBlock: "aws:s3:GetPublicAccessBlock",
13573
+ policyStatus: "aws:s3:GetBucketPolicyStatus",
13574
+ acl: "aws:s3:GetBucketAcl",
13575
+ encryption: "aws:s3:GetBucketEncryption",
13576
+ // La misma acción que lee el bucket de CloudTrail, aquí por cada bucket: id propio para que un fallo no se cruce.
13577
+ versioning: "aws:s3:GetBucketVersioning#bucket"
13578
+ };
13579
+ var DYNAMODB_CHECKS = {
13580
+ tables: "aws:dynamodb:ListTables",
13581
+ describeTable: "aws:dynamodb:DescribeTable",
13582
+ continuousBackups: "aws:dynamodb:DescribeContinuousBackups"
13583
+ };
13584
+ var ACM_CHECKS = {
13585
+ certificates: "aws:acm:ListCertificates"
13586
+ };
13587
+ var TRAIL_BUCKET_CHECKS = {
13588
+ lifecycle: "aws:s3:GetBucketLifecycleConfiguration",
13589
+ versioning: "aws:s3:GetBucketVersioning",
13590
+ objectLock: "aws:s3:GetObjectLockConfiguration"
13591
+ };
13592
+ var IAM_ACCESS_CHECKS = {
13593
+ authorizationDetails: "aws:iam:GetAccountAuthorizationDetails",
13594
+ generateLastAccessed: "aws:iam:GenerateServiceLastAccessedDetails",
13595
+ lastAccessed: "aws:iam:GetServiceLastAccessedDetails",
13596
+ analyzers: "aws:access-analyzer:ListAnalyzers",
13597
+ analyzerFindings: "aws:access-analyzer:ListFindings",
13598
+ analyzerFinding: "aws:access-analyzer:GetFinding",
13599
+ // Solo para reconocer los roles de la cuenta de gestión; ninguna regla depende de ella.
13600
+ organization: "aws:organizations:DescribeOrganization"
13601
+ };
13602
+ var CIEM_WINDOW_DAYS = 90;
13603
+
13604
+ // ../../services/security/src/rules/aws/backup.ts
13605
+ function rdsSinCopiasEvaluate(observation) {
13606
+ if (typeof observation.attributes.clusterId === "string") return { status: "ok" };
13607
+ if (typeof observation.attributes.readReplicaSource === "string") return { status: "ok" };
13608
+ const dias = observation.attributes.backupRetentionDays;
13609
+ if (typeof dias !== "number") return { status: "unknown", check: RDS_CHECKS.instances, attribute: "backupRetentionDays" };
13610
+ if (dias > 0) return { status: "ok" };
13611
+ return { status: "finding", evidence: { backupRetentionDays: 0, engine: observation.attributes.engine ?? null } };
13612
+ }
13613
+ var rdsSinCopias = {
13614
+ id: "SEC_AWS_BACKUP_RDS_SIN_COPIAS",
13615
+ scope: "resource",
13616
+ category: "security_backup",
13617
+ severity: "high",
13618
+ provider: "aws",
13619
+ kinds: ["rds_instance"],
13620
+ requires: [REGION_CHECKS.listRegions, RDS_CHECKS.instances],
13621
+ evaluate: rdsSinCopiasEvaluate,
13622
+ // Se juzga en la cuenta: el adaptador de planes de Terraform aún no traduce las copias.
13623
+ runtimeOnly: true
13624
+ };
13625
+ function dynamoSinRecuperacionPuntualEvaluate(observation) {
13626
+ if (observation.attributes.sampleCapped === true) return { status: "unknown", check: DYNAMODB_CHECKS.continuousBackups, attribute: "pointInTimeRecovery", reason: "sample_capped" };
13627
+ const pitr = observation.attributes.pointInTimeRecovery;
13628
+ if (typeof pitr !== "boolean") return { status: "unknown", check: DYNAMODB_CHECKS.continuousBackups, attribute: "pointInTimeRecovery" };
13629
+ if (pitr) return { status: "ok" };
13630
+ return { status: "finding", evidence: { pointInTimeRecovery: false } };
13631
+ }
13632
+ var dynamoSinRecuperacionPuntual = {
13633
+ id: "SEC_AWS_BACKUP_DYNAMODB_SIN_RECUPERACION_PUNTUAL",
13634
+ scope: "resource",
13635
+ category: "security_backup",
13636
+ severity: "medium",
13637
+ provider: "aws",
13638
+ kinds: ["dynamodb_table"],
13639
+ requires: [REGION_CHECKS.listRegions, DYNAMODB_CHECKS.tables, DYNAMODB_CHECKS.continuousBackups],
13640
+ evaluate: dynamoSinRecuperacionPuntualEvaluate,
13641
+ runtimeOnly: true
13642
+ };
13643
+
13644
+ // ../../services/security/src/rules/aws/log-retention.ts
13645
+ var LOG_RETENTION_MIN_DAYS = 365;
13646
+ function retencionCortaEvaluate(observation) {
13647
+ const bucket = observation.attributes.s3BucketName;
13648
+ if (bucket === null) return { status: "ok" };
13649
+ if (typeof bucket !== "string") return { status: "unknown", check: CLOUDTRAIL_CHECKS.describeTrails, attribute: "s3BucketName" };
13650
+ const dias = observation.attributes.logRetentionDays;
13651
+ if (dias === null) return { status: "ok" };
13652
+ if (typeof dias !== "number") return { status: "unknown", check: TRAIL_BUCKET_CHECKS.lifecycle, attribute: "logRetentionDays" };
13653
+ if (dias >= LOG_RETENTION_MIN_DAYS) return { status: "ok" };
13654
+ return {
13655
+ status: "finding",
13656
+ evidence: {
13657
+ logRetentionDays: dias,
13658
+ minimumDays: LOG_RETENTION_MIN_DAYS,
13659
+ bucket: observation.attributes.s3BucketName,
13660
+ objectLock: observation.attributes.logObjectLock ?? null,
13661
+ expirationDate: observation.attributes.logExpirationDate ?? null
13662
+ }
13663
+ };
13664
+ }
13665
+ var trailRetencionCorta = {
13666
+ id: "SEC_AWS_LOGGING_RETENCION_CORTA",
13667
+ scope: "resource",
13668
+ category: "security_logging",
13669
+ severity: "medium",
13670
+ provider: "aws",
13671
+ kinds: ["cloudtrail_trail"],
13672
+ requires: [REGION_CHECKS.listRegions, CLOUDTRAIL_CHECKS.describeTrails, TRAIL_BUCKET_CHECKS.lifecycle, TRAIL_BUCKET_CHECKS.versioning, TRAIL_BUCKET_CHECKS.objectLock],
13673
+ evaluate: retencionCortaEvaluate,
13674
+ // Se juzga en la cuenta: un plan de Terraform no trae el ciclo de vida efectivo del bucket del trail.
13675
+ runtimeOnly: true
13676
+ };
13677
+
13423
13678
  // ../../shared/src/security-rule-verdicts.ts
13424
13679
  var SECURITY_RULE_CHECKS = {
13425
13680
  securityGroups: "aws:ec2:DescribeSecurityGroups",
@@ -13430,7 +13685,7 @@ var SECURITY_RULE_CHECKS = {
13430
13685
  describeKey: "aws:kms:DescribeKey",
13431
13686
  rotation: "aws:kms:GetKeyRotationStatus"
13432
13687
  };
13433
- var ALL_PROTOCOLS = "-1";
13688
+ var ALL_PROTOCOLS2 = "-1";
13434
13689
  var FAMILIAS = [
13435
13690
  { atributo: "cidrs", maximo: 32, umbral: 7 },
13436
13691
  { atributo: "ipv6Cidrs", maximo: 128, umbral: 3 }
@@ -13476,7 +13731,7 @@ function abiertaAInternet(regla) {
13476
13731
  function puertosAlcanzados(regla) {
13477
13732
  if (typeof regla.protocol !== "string") return void 0;
13478
13733
  const protocolo = POR_NUMERO[regla.protocol] ?? regla.protocol;
13479
- if (protocolo === ALL_PROTOCOLS) return [...PUERTOS_DE_ADMINISTRACION];
13734
+ if (protocolo === ALL_PROTOCOLS2) return [...PUERTOS_DE_ADMINISTRACION];
13480
13735
  if (!CON_PUERTOS.includes(protocolo)) return [];
13481
13736
  const desde = numero(regla.fromPort);
13482
13737
  const hasta = numero(regla.toPort);
@@ -13614,92 +13869,6 @@ function evaluateSecAwsEncryptionKmsSinRotacion(attributes) {
13614
13869
  };
13615
13870
  }
13616
13871
 
13617
- // ../../services/security/src/collectors/aws/check-ids.ts
13618
- var CLOUDTRAIL_CHECKS = {
13619
- describeTrails: "aws:cloudtrail:DescribeTrails",
13620
- trailStatus: "aws:cloudtrail:GetTrailStatus",
13621
- eventSelectors: "aws:cloudtrail:GetEventSelectors"
13622
- };
13623
- var EC2_CHECKS = {
13624
- securityGroups: "aws:ec2:DescribeSecurityGroups",
13625
- networkAcls: "aws:ec2:DescribeNetworkAcls",
13626
- snapshots: "aws:ec2:DescribeSnapshots",
13627
- publicSnapshots: "aws:ec2:DescribeSnapshots#public",
13628
- vpcs: "aws:ec2:DescribeVpcs",
13629
- subnets: "aws:ec2:DescribeSubnets",
13630
- flowLogs: "aws:ec2:DescribeFlowLogs",
13631
- prefixListEntries: "aws:ec2:GetManagedPrefixListEntries",
13632
- flowLogInterfaces: "aws:ec2:DescribeNetworkInterfaces#flowLogs"
13633
- };
13634
- var ALL_PROTOCOLS2 = "-1";
13635
- var ELB_CHECKS = {
13636
- loadBalancers: "aws:elasticloadbalancing:DescribeLoadBalancers",
13637
- listeners: "aws:elasticloadbalancing:DescribeListeners",
13638
- targetGroups: "aws:elasticloadbalancing:DescribeTargetGroups",
13639
- targetGroupAttributes: "aws:elasticloadbalancing:DescribeTargetGroupAttributes",
13640
- targetHealth: "aws:elasticloadbalancing:DescribeTargetHealth"
13641
- };
13642
- var IAM_CHECKS = {
13643
- accountSummary: "aws:iam:GetAccountSummary",
13644
- passwordPolicy: "aws:iam:GetAccountPasswordPolicy",
13645
- listUsers: "aws:iam:ListUsers",
13646
- loginProfile: "aws:iam:GetLoginProfile",
13647
- mfaDevices: "aws:iam:ListMFADevices",
13648
- accessKeys: "aws:iam:ListAccessKeys",
13649
- accessKeyLastUsed: "aws:iam:GetAccessKeyLastUsed",
13650
- attachedPolicies: "aws:iam:ListAttachedUserPolicies"
13651
- };
13652
- var KMS_CHECKS = {
13653
- listKeys: "aws:kms:ListKeys",
13654
- listAliases: "aws:kms:ListAliases",
13655
- describeKey: "aws:kms:DescribeKey",
13656
- rotation: "aws:kms:GetKeyRotationStatus"
13657
- };
13658
- var LAMBDA_CHECKS = {
13659
- functions: "aws:lambda:ListFunctions",
13660
- functionUrl: "aws:lambda:GetFunctionUrlConfig",
13661
- policy: "aws:lambda:GetPolicy"
13662
- };
13663
- var LIGHTSAIL_CHECKS = {
13664
- regions: "aws:lightsail:GetRegions",
13665
- instances: "aws:lightsail:GetInstances"
13666
- };
13667
- var MONITORING_CHECKS = {
13668
- metricFilters: "aws:logs:DescribeMetricFilters",
13669
- alarms: "aws:cloudwatch:DescribeAlarms",
13670
- topicSubscriptions: "aws:sns:ListSubscriptionsByTopic"
13671
- };
13672
- var RDS_CHECKS = {
13673
- instances: "aws:rds:DescribeDBInstances",
13674
- clusters: "aws:rds:DescribeDBClusters",
13675
- snapshots: "aws:rds:DescribeDBSnapshots",
13676
- snapshotAttributes: "aws:rds:DescribeDBSnapshotAttributes",
13677
- clusterSnapshots: "aws:rds:DescribeDBClusterSnapshots",
13678
- clusterSnapshotAttributes: "aws:rds:DescribeDBClusterSnapshotAttributes"
13679
- };
13680
- var REGION_CHECKS = {
13681
- listRegions: "aws:ec2:DescribeRegions"
13682
- };
13683
- var S3_CHECKS = {
13684
- listBuckets: "aws:s3:ListBuckets",
13685
- accountPublicAccessBlock: "aws:s3control:GetPublicAccessBlock",
13686
- publicAccessBlock: "aws:s3:GetPublicAccessBlock",
13687
- policyStatus: "aws:s3:GetBucketPolicyStatus",
13688
- acl: "aws:s3:GetBucketAcl",
13689
- encryption: "aws:s3:GetBucketEncryption"
13690
- };
13691
- var IAM_ACCESS_CHECKS = {
13692
- authorizationDetails: "aws:iam:GetAccountAuthorizationDetails",
13693
- generateLastAccessed: "aws:iam:GenerateServiceLastAccessedDetails",
13694
- lastAccessed: "aws:iam:GetServiceLastAccessedDetails",
13695
- analyzers: "aws:access-analyzer:ListAnalyzers",
13696
- analyzerFindings: "aws:access-analyzer:ListFindings",
13697
- analyzerFinding: "aws:access-analyzer:GetFinding",
13698
- // Solo para reconocer los roles de la cuenta de gestión; ninguna regla depende de ella.
13699
- organization: "aws:organizations:DescribeOrganization"
13700
- };
13701
- var CIEM_WINDOW_DAYS = 90;
13702
-
13703
13872
  // ../../services/security/src/rules/aws/encryption.ts
13704
13873
  function falta2(check, attribute) {
13705
13874
  return { status: "unknown", check, attribute };
@@ -14537,7 +14706,7 @@ var adminAbiertoAInternet = {
14537
14706
  function puertosDeAdministracion(regla) {
14538
14707
  if (typeof regla.protocol !== "string") return void 0;
14539
14708
  const protocolo = protocolName(regla.protocol);
14540
- if (protocolo === ALL_PROTOCOLS2) return [...ADMIN_PORTS2];
14709
+ if (protocolo === ALL_PROTOCOLS) return [...ADMIN_PORTS2];
14541
14710
  if (protocolo !== "tcp" && protocolo !== "udp") return [];
14542
14711
  const desde = regla.fromPort;
14543
14712
  const hasta = regla.toPort;
@@ -14629,7 +14798,7 @@ function lightsailEvaluate(observation) {
14629
14798
  const protocolo = typeof regla.protocol === "string" ? protocolName(regla.protocol) : void 0;
14630
14799
  const alcanzados = puertosDeAdministracion({
14631
14800
  ...regla,
14632
- protocol: protocolo === "all" ? ALL_PROTOCOLS2 : protocolo
14801
+ protocol: protocolo === "all" ? ALL_PROTOCOLS : protocolo
14633
14802
  });
14634
14803
  if (alcanzados === void 0) {
14635
14804
  indecisa = true;
@@ -15121,6 +15290,202 @@ var rdsSinActualizacionMenor = {
15121
15290
  evaluate: rdsSinActualizacionMenorEvaluate
15122
15291
  };
15123
15292
 
15293
+ // ../../services/security/src/rules/runtime-dates.ts
15294
+ var RUNTIME_NOTICE_DAYS = 60;
15295
+ var RUNTIME_REVIEW_DUE_MS = 183 * 864e5;
15296
+ function runtimeDaysLeft(table, runtime, now) {
15297
+ const fecha = table[runtime];
15298
+ return fecha === void 0 ? null : Math.ceil((Date.parse(`${fecha}T00:00:00Z`) - now) / 864e5);
15299
+ }
15300
+ function runtimeRetirement(table, runtime, now) {
15301
+ const dias = runtimeDaysLeft(table, runtime, now);
15302
+ const fecha = table[runtime];
15303
+ if (dias === null || fecha === void 0 || dias > RUNTIME_NOTICE_DAYS) return null;
15304
+ return { runtime, deprecationDate: fecha, deprecated: dias <= 0 };
15305
+ }
15306
+
15307
+ // ../../services/security/src/rules/aws/lambda-runtimes.ts
15308
+ var LAMBDA_RUNTIME_DEPRECATION = {
15309
+ "nodejs24.x": "2028-04-30",
15310
+ "nodejs22.x": "2027-05-30",
15311
+ "python3.14": "2029-06-30",
15312
+ "python3.13": "2029-06-30",
15313
+ "python3.12": "2028-10-31",
15314
+ "python3.11": "2027-06-30",
15315
+ java25: "2029-06-30",
15316
+ java21: "2029-06-30",
15317
+ "java17.al2023": "2029-06-30",
15318
+ "java11.al2023": "2029-06-30",
15319
+ "java8.al2023": "2029-06-30",
15320
+ java17: "2027-06-30",
15321
+ java11: "2027-06-30",
15322
+ "java8.al2": "2027-06-30",
15323
+ dotnet10: "2028-11-14",
15324
+ "ruby4.0": "2029-03-31",
15325
+ "ruby3.4": "2028-03-31",
15326
+ "ruby3.3": "2027-03-31",
15327
+ "provided.al2023": "2029-06-30",
15328
+ dotnet8: "2026-11-10",
15329
+ "python3.10": "2026-10-31",
15330
+ "provided.al2": "2026-07-31",
15331
+ "nodejs20.x": "2026-04-30",
15332
+ "ruby3.2": "2026-03-31",
15333
+ "python3.9": "2025-12-15",
15334
+ "nodejs18.x": "2025-09-01",
15335
+ dotnet6: "2024-12-20",
15336
+ "python3.8": "2024-10-14",
15337
+ "nodejs16.x": "2024-06-12",
15338
+ java8: "2024-01-08",
15339
+ "go1.x": "2024-01-08",
15340
+ provided: "2024-01-08",
15341
+ "ruby2.7": "2023-12-07",
15342
+ "nodejs14.x": "2023-12-04",
15343
+ "python3.7": "2023-12-04",
15344
+ "dotnetcore3.1": "2023-04-03",
15345
+ "nodejs12.x": "2023-03-31",
15346
+ "python3.6": "2022-07-18",
15347
+ "dotnetcore2.1": "2022-01-05",
15348
+ "nodejs10.x": "2021-07-30",
15349
+ "ruby2.5": "2021-07-30",
15350
+ "python2.7": "2021-07-15",
15351
+ "nodejs8.10": "2020-03-06",
15352
+ "nodejs4.3": "2020-03-05",
15353
+ "nodejs4.3-edge": "2020-03-05",
15354
+ "nodejs6.10": "2019-08-12",
15355
+ "dotnetcore1.0": "2019-06-27",
15356
+ "dotnetcore2.0": "2019-05-30",
15357
+ nodejs: "2016-08-30"
15358
+ };
15359
+
15360
+ // ../../services/security/src/rules/aws/resilience.ts
15361
+ function propio(observation, attribute, deCluster) {
15362
+ const miembro = typeof observation.attributes.clusterId === "string";
15363
+ const valor = observation.attributes[miembro ? deCluster : attribute];
15364
+ if (typeof valor === "boolean") return valor;
15365
+ return { status: "unknown", check: miembro ? RDS_CHECKS.clusters : RDS_CHECKS.instances, attribute: miembro ? deCluster : attribute };
15366
+ }
15367
+ function evidencia(observation, attribute) {
15368
+ return { [attribute]: false, engine: observation.attributes.engine ?? null, clusterId: observation.attributes.clusterId ?? null };
15369
+ }
15370
+ function rdsSinMultiAzEvaluate(observation) {
15371
+ if (typeof observation.attributes.readReplicaSource === "string") return { status: "ok" };
15372
+ const multiAz = propio(observation, "multiAz", "clusterMultiAz");
15373
+ if (typeof multiAz !== "boolean") return multiAz;
15374
+ return multiAz ? { status: "ok" } : { status: "finding", evidence: evidencia(observation, "multiAz") };
15375
+ }
15376
+ var rdsSinMultiAz = {
15377
+ id: "SEC_AWS_RESILIENCE_RDS_SIN_MULTI_AZ",
15378
+ scope: "resource",
15379
+ category: "security_resilience",
15380
+ severity: "medium",
15381
+ provider: "aws",
15382
+ kinds: ["rds_instance"],
15383
+ requires: [REGION_CHECKS.listRegions, RDS_CHECKS.instances, RDS_CHECKS.clusters],
15384
+ evaluate: rdsSinMultiAzEvaluate,
15385
+ // Se juzga en la cuenta: el adaptador de planes de Terraform aún no distingue las réplicas.
15386
+ runtimeOnly: true
15387
+ };
15388
+ function rdsSinProteccionBorradoEvaluate(observation) {
15389
+ const protegida = propio(observation, "deletionProtection", "clusterDeletionProtection");
15390
+ if (typeof protegida !== "boolean") return protegida;
15391
+ return protegida ? { status: "ok" } : { status: "finding", evidence: evidencia(observation, "deletionProtection") };
15392
+ }
15393
+ var rdsSinProteccionBorrado = {
15394
+ id: "SEC_AWS_RESILIENCE_RDS_SIN_PROTECCION_BORRADO",
15395
+ scope: "resource",
15396
+ category: "security_resilience",
15397
+ severity: "low",
15398
+ provider: "aws",
15399
+ kinds: ["rds_instance"],
15400
+ requires: [REGION_CHECKS.listRegions, RDS_CHECKS.instances, RDS_CHECKS.clusters],
15401
+ evaluate: rdsSinProteccionBorradoEvaluate,
15402
+ runtimeOnly: true
15403
+ };
15404
+ function lambdaRuntimeRetiradoEvaluate(observation) {
15405
+ const runtime = observation.attributes.runtime;
15406
+ if (runtime === null) return { status: "ok" };
15407
+ if (typeof runtime !== "string") return { status: "unknown", check: LAMBDA_CHECKS.functions, attribute: "runtime" };
15408
+ const retirada = runtimeRetirement(LAMBDA_RUNTIME_DEPRECATION, runtime, Date.now());
15409
+ return retirada ? { status: "finding", evidence: retirada } : { status: "ok" };
15410
+ }
15411
+ var lambdaRuntimeRetirado = {
15412
+ id: "SEC_AWS_RESILIENCE_LAMBDA_RUNTIME_RETIRADO",
15413
+ scope: "resource",
15414
+ category: "security_resilience",
15415
+ severity: "medium",
15416
+ provider: "aws",
15417
+ kinds: ["lambda_function"],
15418
+ requires: [REGION_CHECKS.listRegions, LAMBDA_CHECKS.functions],
15419
+ evaluate: lambdaRuntimeRetiradoEvaluate,
15420
+ // El veredicto depende de la fecha del escaneo y el adaptador de planes no trae el runtime.
15421
+ runtimeOnly: true
15422
+ };
15423
+ function dynamoSinProteccionBorradoEvaluate(observation) {
15424
+ if (observation.attributes.sampleCapped === true) return { status: "unknown", check: DYNAMODB_CHECKS.describeTable, attribute: "deletionProtection", reason: "sample_capped" };
15425
+ const protegida = observation.attributes.deletionProtection;
15426
+ if (typeof protegida !== "boolean") return { status: "unknown", check: DYNAMODB_CHECKS.describeTable, attribute: "deletionProtection" };
15427
+ return protegida ? { status: "ok" } : { status: "finding", evidence: { deletionProtection: false } };
15428
+ }
15429
+ var dynamoSinProteccionBorrado = {
15430
+ id: "SEC_AWS_RESILIENCE_DYNAMODB_SIN_PROTECCION_BORRADO",
15431
+ scope: "resource",
15432
+ category: "security_resilience",
15433
+ severity: "low",
15434
+ provider: "aws",
15435
+ kinds: ["dynamodb_table"],
15436
+ requires: [REGION_CHECKS.listRegions, DYNAMODB_CHECKS.tables, DYNAMODB_CHECKS.describeTable],
15437
+ evaluate: dynamoSinProteccionBorradoEvaluate,
15438
+ runtimeOnly: true
15439
+ };
15440
+ function s3SinVersionadoEvaluate(observation) {
15441
+ const estado = observation.attributes.versioning;
15442
+ if (estado === void 0) return { status: "unknown", check: S3_CHECKS.versioning, attribute: "versioning" };
15443
+ if (estado === "Enabled") return { status: "ok" };
15444
+ return { status: "finding", evidence: { versioning: estado ?? "never" } };
15445
+ }
15446
+ var s3SinVersionado = {
15447
+ id: "SEC_AWS_RESILIENCE_S3_SIN_VERSIONADO",
15448
+ scope: "resource",
15449
+ category: "security_resilience",
15450
+ severity: "low",
15451
+ provider: "aws",
15452
+ kinds: ["s3_bucket"],
15453
+ requires: [S3_CHECKS.listBuckets, S3_CHECKS.versioning],
15454
+ evaluate: s3SinVersionadoEvaluate,
15455
+ runtimeOnly: true
15456
+ };
15457
+ var CERT_NOTICE_DAYS = 30;
15458
+ function acmCertificadoCaducaEvaluate(observation) {
15459
+ const enUso = observation.attributes.inUse;
15460
+ if (typeof enUso !== "boolean") return { status: "unknown", check: ACM_CHECKS.certificates, attribute: "inUse" };
15461
+ if (!enUso) return { status: "ok" };
15462
+ const fin = observation.attributes.notAfter;
15463
+ if (typeof fin !== "string") return { status: "ok" };
15464
+ const dias = Math.ceil((Date.parse(fin) - Date.now()) / 864e5);
15465
+ if (!Number.isFinite(dias) || dias > CERT_NOTICE_DAYS) return { status: "ok" };
15466
+ return {
15467
+ status: "finding",
15468
+ evidence: {
15469
+ notAfter: fin,
15470
+ expired: dias <= 0,
15471
+ type: observation.attributes.type ?? null,
15472
+ renewalEligibility: observation.attributes.renewalEligibility ?? null
15473
+ }
15474
+ };
15475
+ }
15476
+ var acmCertificadoCaduca = {
15477
+ id: "SEC_AWS_RESILIENCE_ACM_CERTIFICADO_CADUCA",
15478
+ scope: "resource",
15479
+ category: "security_resilience",
15480
+ severity: "medium",
15481
+ provider: "aws",
15482
+ kinds: ["acm_certificate"],
15483
+ requires: [REGION_CHECKS.listRegions, ACM_CHECKS.certificates],
15484
+ evaluate: acmCertificadoCaducaEvaluate,
15485
+ // El veredicto depende de la fecha del escaneo.
15486
+ runtimeOnly: true
15487
+ };
15488
+
15124
15489
  // ../../services/security/src/rules/aws/secrets.ts
15125
15490
  var SOSPECHOSAS = [
15126
15491
  "PASSWORD",
@@ -15181,7 +15546,16 @@ var AWS_SECURITY_RULES = [
15181
15546
  lambdaPublica,
15182
15547
  kmsSinRotacion,
15183
15548
  rdsSinCifrar,
15549
+ rdsSinCopias,
15550
+ trailRetencionCorta,
15184
15551
  rdsSinActualizacionMenor,
15552
+ rdsSinMultiAz,
15553
+ rdsSinProteccionBorrado,
15554
+ lambdaRuntimeRetirado,
15555
+ dynamoSinRecuperacionPuntual,
15556
+ dynamoSinProteccionBorrado,
15557
+ s3SinVersionado,
15558
+ acmCertificadoCaduca,
15185
15559
  rootSinMfa,
15186
15560
  usuarioSinMfa,
15187
15561
  claveAntigua,
@@ -15267,7 +15641,9 @@ var AZURE_NSG_CHECKS = {
15267
15641
  var AZURE_STORAGE_CHECKS = {
15268
15642
  list: "azure:storage:list",
15269
15643
  // Solo de las cuentas que permiten blobs públicos: dice a quien aprueba cerrarlo qué contenedores dejan de servirse.
15270
- containers: "azure:storage:containers"
15644
+ containers: "azure:storage:containers",
15645
+ // Propiedades del servicio de blobs de cada cuenta: borrado suave de blobs y de contenedores.
15646
+ blobService: "azure:storage:blobServices"
15271
15647
  };
15272
15648
  var AZURE_SQL_CHECKS = {
15273
15649
  list: "azure:sql:list",
@@ -15295,10 +15671,74 @@ var AZURE_IAM_CHECKS = {
15295
15671
  // Métodos de autenticación registrados: `UserAuthenticationMethod.Read.All` de aplicación, opcional.
15296
15672
  authMethods: "azure:graph:users.authentication.methods"
15297
15673
  };
15674
+ var AZURE_BACKUP_CHECKS = {
15675
+ virtualMachines: "azure:compute:virtualMachines",
15676
+ vaults: "azure:recoveryservices:vaults",
15677
+ protectedItems: "azure:recoveryservices:backupProtectedItems"
15678
+ };
15298
15679
  var AZURE_LOGGING_CHECKS = {
15299
15680
  diagnosticSettings: "azure:insights:diagnosticSettings"
15300
15681
  };
15301
15682
 
15683
+ // ../../services/security/src/rules/azure/backup.ts
15684
+ function vmSinCopiaEvaluate(observation) {
15685
+ const copia = observation.attributes.backedUp;
15686
+ if (typeof copia !== "boolean") return { status: "unknown", check: AZURE_BACKUP_CHECKS.protectedItems, attribute: "backedUp" };
15687
+ if (copia) return { status: "ok" };
15688
+ return {
15689
+ status: "finding",
15690
+ evidence: { protectionState: observation.attributes.protectionState ?? null, lastBackupStatus: observation.attributes.lastBackupStatus ?? null }
15691
+ };
15692
+ }
15693
+ var vmSinCopia = {
15694
+ id: "SEC_AZURE_BACKUP_VM_SIN_COPIA",
15695
+ scope: "resource",
15696
+ category: "security_backup",
15697
+ severity: "high",
15698
+ provider: "azure",
15699
+ kinds: ["virtual_machine"],
15700
+ requires: [AZURE_BACKUP_CHECKS.virtualMachines, AZURE_BACKUP_CHECKS.vaults, AZURE_BACKUP_CHECKS.protectedItems],
15701
+ evaluate: vmSinCopiaEvaluate,
15702
+ // Se juzga en la cuenta: el adaptador de planes de Terraform no puede saber en qué almacén de Recovery Services está la máquina.
15703
+ runtimeOnly: true
15704
+ };
15705
+ function sqlCopiasLocalesEvaluate(observation) {
15706
+ const redundancia = observation.attributes.backupStorageRedundancy;
15707
+ if (typeof redundancia !== "string") return { status: "unknown", check: AZURE_SQL_CHECKS.databases, attribute: "backupStorageRedundancy" };
15708
+ if (redundancia.toLowerCase() !== "local") return { status: "ok" };
15709
+ return { status: "finding", evidence: { backupStorageRedundancy: redundancia } };
15710
+ }
15711
+ var sqlCopiasLocales = {
15712
+ id: "SEC_AZURE_BACKUP_SQL_COPIAS_LOCALES",
15713
+ scope: "resource",
15714
+ category: "security_backup",
15715
+ severity: "low",
15716
+ provider: "azure",
15717
+ kinds: ["sql_database"],
15718
+ requires: [AZURE_SQL_CHECKS.list, AZURE_SQL_CHECKS.databases],
15719
+ evaluate: sqlCopiasLocalesEvaluate,
15720
+ runtimeOnly: true
15721
+ };
15722
+ function blobSinBorradoSuaveEvaluate(observation) {
15723
+ if (observation.attributes.kind === "FileStorage") return { status: "ok" };
15724
+ if (observation.attributes.managedResourceGroup === true) return { status: "ok" };
15725
+ const suave = observation.attributes.blobSoftDelete;
15726
+ if (typeof suave !== "boolean") return { status: "unknown", check: AZURE_STORAGE_CHECKS.blobService, attribute: "blobSoftDelete" };
15727
+ if (suave) return { status: "ok" };
15728
+ return { status: "finding", evidence: { blobSoftDelete: false } };
15729
+ }
15730
+ var blobSinBorradoSuave = {
15731
+ id: "SEC_AZURE_RESILIENCE_BLOB_SIN_BORRADO_SUAVE",
15732
+ scope: "resource",
15733
+ category: "security_resilience",
15734
+ severity: "low",
15735
+ provider: "azure",
15736
+ kinds: ["storage_account"],
15737
+ requires: [AZURE_STORAGE_CHECKS.list, AZURE_STORAGE_CHECKS.blobService],
15738
+ evaluate: blobSinBorradoSuaveEvaluate,
15739
+ runtimeOnly: true
15740
+ };
15741
+
15302
15742
  // ../../services/security/src/rules/azure/encryption.ts
15303
15743
  var TLS_DEBIL = /* @__PURE__ */ new Set(["tls1_0", "tls1.0", "1.0", "tls1_1", "tls1.1", "1.1"]);
15304
15744
  function storageTlsEvaluate(observation) {
@@ -15455,6 +15895,8 @@ function evaluate4(observation) {
15455
15895
  role,
15456
15896
  principalType: observation.attributes.principalType ?? null,
15457
15897
  scope: observation.attributes.scope ?? null,
15898
+ // Sin el permiso de Graph no hay nombre: el id del principal es lo único que permite saber a quién preguntar.
15899
+ principalId: observation.attributes.principalId ?? null,
15458
15900
  // Solo con el permiso opcional de Graph: quién es y, si es un grupo, quiénes entran por él.
15459
15901
  ...pick2(observation, ["principalName", "groupMemberCount", "groupMembersComplete"])
15460
15902
  }
@@ -15702,6 +16144,9 @@ var AZURE_SECURITY_RULES = [
15702
16144
  sqlTlsDebil,
15703
16145
  keyVaultSinPurga,
15704
16146
  sqlSinTde,
16147
+ vmSinCopia,
16148
+ sqlCopiasLocales,
16149
+ blobSinBorradoSuave,
15705
16150
  rolPrivilegiado,
15706
16151
  asignacionHuerfana,
15707
16152
  adminSinMfa,
@@ -15797,7 +16242,9 @@ var GCP_COMPUTE_CHECKS = {
15797
16242
  regions: "gcp:compute:regions",
15798
16243
  regionFirewallPolicies: "gcp:compute:regionNetworkFirewallPolicies",
15799
16244
  sharedVpcHost: "gcp:compute:sharedVpcHostFirewalls",
15800
- subnetworks: "gcp:compute:subnetworks"
16245
+ subnetworks: "gcp:compute:subnetworks",
16246
+ // Políticas de recursos del proyecto: distinguen una programación de snapshots de un grupo de consistencia.
16247
+ resourcePolicies: "gcp:compute:resourcePolicies"
15801
16248
  };
15802
16249
  var GCP_NETWORK_MANAGEMENT_CHECKS = {
15803
16250
  vpcFlowLogsConfigs: "gcp:networkmanagement:vpcFlowLogsConfigs"
@@ -15833,6 +16280,32 @@ var GCP_LOGGING_CHECKS = {
15833
16280
  };
15834
16281
  var GCP_CIEM_WINDOW_DAYS = 90;
15835
16282
 
16283
+ // ../../services/security/src/rules/gcp/backup.ts
16284
+ function interruptor(valor) {
16285
+ if (typeof valor === "boolean") return valor;
16286
+ return valor === null ? false : void 0;
16287
+ }
16288
+ function sqlSinCopiasEvaluate(observation) {
16289
+ const tipo = observation.attributes.instanceType;
16290
+ if (typeof tipo === "string" && tipo !== "CLOUD_SQL_INSTANCE") return { status: "ok" };
16291
+ const activas = interruptor(observation.attributes.backupEnabled);
16292
+ if (activas === void 0) return { status: "unknown", check: GCP_SQL_CHECKS.instances, attribute: "backupEnabled" };
16293
+ if (activas) return { status: "ok" };
16294
+ return { status: "finding", evidence: { backupEnabled: false } };
16295
+ }
16296
+ var sqlSinCopias = {
16297
+ id: "SEC_GCP_BACKUP_SQL_SIN_COPIAS",
16298
+ scope: "resource",
16299
+ category: "security_backup",
16300
+ severity: "high",
16301
+ provider: "gcp",
16302
+ kinds: ["cloud_sql_instance"],
16303
+ requires: [GCP_SQL_CHECKS.instances],
16304
+ evaluate: sqlSinCopiasEvaluate,
16305
+ // Se juzga en la cuenta: el adaptador de planes de Terraform aún no traduce las copias.
16306
+ runtimeOnly: true
16307
+ };
16308
+
15836
16309
  // ../../services/security/src/rules/gcp/encryption.ts
15837
16310
  function discoSinCmekEvaluate(observation) {
15838
16311
  const boot = observation.attributes.boot;
@@ -16392,6 +16865,186 @@ var firewallBdAbierto = {
16392
16865
  evaluate: (observation) => firewallAbierto(observation, databasePortsReached)
16393
16866
  };
16394
16867
 
16868
+ // ../../services/security/src/rules/gcp/function-runtimes.ts
16869
+ var FUNCTION_RUNTIME_DEPRECATION = {
16870
+ nodejs24: "2028-04-30",
16871
+ nodejs22: "2027-04-30",
16872
+ nodejs20: "2026-04-30",
16873
+ nodejs18: "2025-04-30",
16874
+ nodejs16: "2024-01-30",
16875
+ nodejs14: "2024-01-30",
16876
+ nodejs12: "2024-01-30",
16877
+ nodejs10: "2024-01-30",
16878
+ nodejs8: "2020-06-05",
16879
+ nodejs6: "2019-04-17",
16880
+ python314: "2030-10-10",
16881
+ python313: "2029-10-10",
16882
+ python312: "2028-10-02",
16883
+ python311: "2027-10-24",
16884
+ python310: "2026-10-04",
16885
+ python39: "2025-10-05",
16886
+ python38: "2024-10-14",
16887
+ python37: "2024-01-30",
16888
+ go125: "2026-10-01",
16889
+ go124: "2026-09-02",
16890
+ go123: "2026-02-21",
16891
+ go122: "2026-01-28",
16892
+ go121: "2025-09-03",
16893
+ go120: "2024-05-01",
16894
+ go119: "2024-04-30",
16895
+ go118: "2024-01-30",
16896
+ go116: "2024-01-30",
16897
+ go113: "2024-01-30",
16898
+ go111: "2020-08-05",
16899
+ java11: "2024-10-31",
16900
+ ruby40: "2029-03-31",
16901
+ ruby34: "2028-03-31",
16902
+ ruby33: "2027-03-31",
16903
+ ruby32: "2026-03-31",
16904
+ ruby30: "2024-03-31",
16905
+ ruby27: "2024-01-30",
16906
+ ruby26: "2024-01-30",
16907
+ php85: "2029-12-31",
16908
+ php84: "2028-12-31",
16909
+ php83: "2027-12-31",
16910
+ php82: "2026-12-31",
16911
+ php81: "2025-12-31",
16912
+ php74: "2024-01-30",
16913
+ dotnet10: "2028-11-14",
16914
+ dotnet8: "2026-11-10",
16915
+ dotnet6: "2024-11-12",
16916
+ dotnet3: "2024-01-30"
16917
+ };
16918
+
16919
+ // ../../services/security/src/rules/gcp/resilience.ts
16920
+ var noEsPrincipal = (observation) => {
16921
+ const tipo = observation.attributes.instanceType;
16922
+ return typeof tipo === "string" && tipo !== "CLOUD_SQL_INSTANCE";
16923
+ };
16924
+ var sinDato = (attribute) => ({ status: "unknown", check: GCP_SQL_CHECKS.instances, attribute });
16925
+ function sqlSinAltaDisponibilidadEvaluate(observation) {
16926
+ if (noEsPrincipal(observation)) return { status: "ok" };
16927
+ const tipo = observation.attributes.availabilityType;
16928
+ if (typeof tipo !== "string") return sinDato("availabilityType");
16929
+ if (tipo === "REGIONAL") return { status: "ok" };
16930
+ return { status: "finding", evidence: { availabilityType: tipo } };
16931
+ }
16932
+ var sqlSinAltaDisponibilidad = {
16933
+ id: "SEC_GCP_RESILIENCE_SQL_SIN_ALTA_DISPONIBILIDAD",
16934
+ scope: "resource",
16935
+ category: "security_resilience",
16936
+ severity: "medium",
16937
+ provider: "gcp",
16938
+ kinds: ["cloud_sql_instance"],
16939
+ requires: [GCP_SQL_CHECKS.instances],
16940
+ evaluate: sqlSinAltaDisponibilidadEvaluate,
16941
+ // Se juzga en la cuenta: el adaptador de planes de Terraform aún no traduce la disponibilidad.
16942
+ runtimeOnly: true
16943
+ };
16944
+ function sqlSinProteccionBorradoEvaluate(observation) {
16945
+ if (observation.attributes.instanceType === "ON_PREMISES_INSTANCE") return { status: "ok" };
16946
+ const protegida = interruptor(observation.attributes.deletionProtection);
16947
+ if (protegida === void 0) return sinDato("deletionProtection");
16948
+ if (protegida) return { status: "ok" };
16949
+ return { status: "finding", evidence: { deletionProtection: false } };
16950
+ }
16951
+ var sqlSinProteccionBorrado = {
16952
+ id: "SEC_GCP_RESILIENCE_SQL_SIN_PROTECCION_BORRADO",
16953
+ scope: "resource",
16954
+ category: "security_resilience",
16955
+ severity: "low",
16956
+ provider: "gcp",
16957
+ kinds: ["cloud_sql_instance"],
16958
+ requires: [GCP_SQL_CHECKS.instances],
16959
+ evaluate: sqlSinProteccionBorradoEvaluate,
16960
+ runtimeOnly: true
16961
+ };
16962
+ function sqlSinRecuperacionPuntualEvaluate(observation) {
16963
+ if (noEsPrincipal(observation)) return { status: "ok" };
16964
+ const copias = interruptor(observation.attributes.backupEnabled);
16965
+ if (copias === void 0) return sinDato("backupEnabled");
16966
+ if (!copias) return { status: "ok" };
16967
+ const version2 = observation.attributes.databaseVersion;
16968
+ if (typeof version2 !== "string") return sinDato("databaseVersion");
16969
+ const attribute = version2.startsWith("MYSQL") ? "binaryLogEnabled" : "pointInTimeRecoveryEnabled";
16970
+ const activa = interruptor(observation.attributes[attribute]);
16971
+ if (activa === void 0) return sinDato(attribute);
16972
+ if (activa) return { status: "ok" };
16973
+ return { status: "finding", evidence: { [attribute]: false, databaseVersion: version2 } };
16974
+ }
16975
+ var sqlSinRecuperacionPuntual = {
16976
+ id: "SEC_GCP_BACKUP_SQL_SIN_RECUPERACION_PUNTUAL",
16977
+ scope: "resource",
16978
+ category: "security_backup",
16979
+ severity: "medium",
16980
+ provider: "gcp",
16981
+ kinds: ["cloud_sql_instance"],
16982
+ requires: [GCP_SQL_CHECKS.instances],
16983
+ evaluate: sqlSinRecuperacionPuntualEvaluate,
16984
+ runtimeOnly: true
16985
+ };
16986
+ function functionRuntimeRetiradoEvaluate(observation) {
16987
+ const runtime = observation.attributes.runtime;
16988
+ if (typeof runtime !== "string") return { status: "unknown", check: GCP_FUNCTIONS_CHECKS.list, attribute: "runtime" };
16989
+ const retirada = runtimeRetirement(FUNCTION_RUNTIME_DEPRECATION, runtime, Date.now());
16990
+ return retirada ? { status: "finding", evidence: retirada } : { status: "ok" };
16991
+ }
16992
+ var functionRuntimeRetirado = {
16993
+ id: "SEC_GCP_RESILIENCE_FUNCTION_RUNTIME_RETIRADO",
16994
+ scope: "resource",
16995
+ category: "security_resilience",
16996
+ severity: "medium",
16997
+ provider: "gcp",
16998
+ kinds: ["cloud_function"],
16999
+ requires: [GCP_FUNCTIONS_CHECKS.list],
17000
+ evaluate: functionRuntimeRetiradoEvaluate,
17001
+ // El veredicto depende de la fecha del escaneo y el adaptador de planes no trae el runtime.
17002
+ runtimeOnly: true
17003
+ };
17004
+ function gcsSinVersionadoEvaluate(observation) {
17005
+ const versionado = observation.attributes.versioning;
17006
+ if (versionado === void 0) return { status: "unknown", check: GCP_STORAGE_CHECKS.buckets, attribute: "versioning" };
17007
+ if (versionado === true) return { status: "ok" };
17008
+ const suave = observation.attributes.softDeleteSeconds;
17009
+ if (typeof suave !== "number") return { status: "unknown", check: GCP_STORAGE_CHECKS.buckets, attribute: "softDeleteSeconds" };
17010
+ if (suave > 0) return { status: "ok" };
17011
+ return { status: "finding", evidence: { versioning: versionado === false ? "disabled" : "never", softDeleteSeconds: 0 } };
17012
+ }
17013
+ var gcsSinVersionado = {
17014
+ id: "SEC_GCP_RESILIENCE_GCS_SIN_VERSIONADO",
17015
+ scope: "resource",
17016
+ category: "security_resilience",
17017
+ severity: "low",
17018
+ provider: "gcp",
17019
+ kinds: ["gcs_bucket"],
17020
+ requires: [GCP_STORAGE_CHECKS.buckets],
17021
+ evaluate: gcsSinVersionadoEvaluate,
17022
+ runtimeOnly: true
17023
+ };
17024
+ function discoSinSnapshotsEvaluate(observation) {
17025
+ const estado = observation.attributes.status;
17026
+ if (typeof estado === "string" && ["FAILED", "DELETING"].includes(estado)) return { status: "ok" };
17027
+ const programado = observation.attributes.snapshotSchedule;
17028
+ if (programado === true) return { status: "ok" };
17029
+ const arranque = typeof observation.attributes.boot === "boolean" ? observation.attributes.boot : observation.attributes.fromImage === true ? true : void 0;
17030
+ if (arranque === void 0) return { status: "unknown", check: GCP_COMPUTE_CHECKS.disks, attribute: "boot" };
17031
+ if (arranque) return { status: "ok" };
17032
+ if (programado !== false) return { status: "unknown", check: GCP_COMPUTE_CHECKS.resourcePolicies, attribute: "snapshotSchedule" };
17033
+ return { status: "finding", evidence: { snapshotSchedule: false } };
17034
+ }
17035
+ var discoSinSnapshots = {
17036
+ id: "SEC_GCP_BACKUP_DISCO_SIN_SNAPSHOTS",
17037
+ scope: "resource",
17038
+ category: "security_backup",
17039
+ severity: "low",
17040
+ provider: "gcp",
17041
+ kinds: ["persistent_disk"],
17042
+ // Sin la lista de instancias se decide por la imagen de origen: no se exige, para que su fallo no ciegue la categoría.
17043
+ requires: [GCP_COMPUTE_CHECKS.disks, GCP_COMPUTE_CHECKS.resourcePolicies],
17044
+ evaluate: discoSinSnapshotsEvaluate,
17045
+ runtimeOnly: true
17046
+ };
17047
+
16395
17048
  // ../../services/security/src/rules/gcp/secrets.ts
16396
17049
  var SOSPECHOSAS2 = ["PASSWORD", "PASSWD", "SECRET", "TOKEN", "APIKEY", "API_KEY", "PRIVATE_KEY", "CREDENTIAL"];
16397
17050
  var REFERENCIAS2 = ["_ARN", "_NAME", "_ID", "_PATH", "_URL", "_URI", "_TABLE", "_BUCKET"];
@@ -16432,6 +17085,13 @@ var GCP_SECURITY_RULES = [
16432
17085
  discoSinCmek,
16433
17086
  sqlSinCmek,
16434
17087
  sqlSinSsl,
17088
+ sqlSinCopias,
17089
+ sqlSinRecuperacionPuntual,
17090
+ sqlSinAltaDisponibilidad,
17091
+ sqlSinProteccionBorrado,
17092
+ functionRuntimeRetirado,
17093
+ gcsSinVersionado,
17094
+ discoSinSnapshots,
16435
17095
  kmsSinRotacion2,
16436
17096
  secretoEnFunction,
16437
17097
  rolPrimitivo,
@@ -16737,7 +17397,7 @@ async function runIacCost(planJson, config2) {
16737
17397
  failed: true,
16738
17398
  markdown: null,
16739
17399
  estimate: null,
16740
- warning: `Cost estimate unavailable, continuing without blocking the build: ${error2.message}`
17400
+ warning: `Cost estimate unavailable, continuing without blocking the build: ${describeApiError(error2, COST_ACCESS)}`
16741
17401
  };
16742
17402
  }
16743
17403
  }
@@ -16750,13 +17410,21 @@ function decodePlan(bytes) {
16750
17410
  if (bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191) return bytes.subarray(3).toString("utf-8");
16751
17411
  return bytes.toString("utf-8");
16752
17412
  }
16753
- var fmtUsd2 = (n) => `${n < 0 ? "-" : "+"}$${Math.abs(n).toFixed(2)}/mo`;
16754
17413
  function costText(estimate) {
16755
17414
  const { coverage } = estimate;
16756
- const total2 = estimate.totalMonthlyDeltaUsd === null ? "no total (coverage too low)" : `${fmtUsd2(estimate.totalMonthlyDeltaUsd)} (list price, USD)`;
17415
+ const usd = estimate.totalMonthlyDeltaUsd;
17416
+ const display = orgCurrency(estimate);
17417
+ let total2;
17418
+ if (usd === null) total2 = "no total (coverage too low)";
17419
+ else if (display && typeof estimate.totalMonthlyDelta === "number") {
17420
+ const rate = `ECB rate${display.rateDate ? ` of ${display.rateDate}` : ""}, 1 USD = ${display.rate} ${display.code}`;
17421
+ total2 = `${fmtConverted(estimate.totalMonthlyDelta, display.code)} (approximate: list price converted from ${fmtUsd(usd)} in USD at the ${rate})`;
17422
+ } else total2 = `${fmtUsd(usd)} (list price, USD)`;
17423
+ const partial2 = partialTotalLabel(estimate);
16757
17424
  return [
16758
17425
  "Cost",
16759
17426
  ` Estimated change: ${total2}`,
17427
+ ...partial2 ? [` Total is ${partial2}: the real change can differ`] : [],
16760
17428
  ` Coverage: ${coverage.pricedResources} of ${coverage.pricedResources + coverage.unpricedResources} billable resources priced`
16761
17429
  ].join("\n");
16762
17430
  }
@@ -16816,7 +17484,7 @@ async function runCli(options, readPlan, credentials) {
16816
17484
  });
16817
17485
  report.drift = compareDrift(evaluation.verdicts, live, options.driftAccount);
16818
17486
  } catch (error2) {
16819
- warnings.push(`Drift check unavailable, continuing: ${error2.message}`);
17487
+ warnings.push(`Drift check unavailable, continuing: ${describeApiError(error2, DRIFT_ACCESS)}`);
16820
17488
  }
16821
17489
  }
16822
17490
  }
@@ -16845,7 +17513,7 @@ async function runCli(options, readPlan, credentials) {
16845
17513
  );
16846
17514
  if (evaluateBudgetGate(budgets, mode).blocks) exitCode = 1;
16847
17515
  } catch (error2) {
16848
- warnings.push(`Budget check unavailable: ${error2.message}`);
17516
+ warnings.push(`Budget check unavailable: ${describeApiError(error2, BUDGET_ACCESS)}`);
16849
17517
  gateUnavailable = true;
16850
17518
  }
16851
17519
  }
@@ -16853,7 +17521,7 @@ async function runCli(options, readPlan, credentials) {
16853
17521
  if (exitCode === 0 && gateUnavailable) exitCode = 2;
16854
17522
  if (options.format === "json") {
16855
17523
  return {
16856
- stdout: JSON.stringify({ formatVersion: "1", cost: estimate, security: report, ...options.failOnBudget ? { budgets } : {}, warnings }, null, 2),
17524
+ stdout: JSON.stringify({ formatVersion: "1", cost: estimate ? { ...estimate, totalIsPartial: isPartialTotal(estimate) } : null, security: report, ...options.failOnBudget ? { budgets } : {}, warnings }, null, 2),
16857
17525
  warnings,
16858
17526
  exitCode
16859
17527
  };
@@ -17506,7 +18174,7 @@ ${OWNERS_USAGE}`], exitCode: 2 });
17506
18174
  try {
17507
18175
  token = await fetchToken(config2, SCOPE5);
17508
18176
  } catch (error2) {
17509
- errors.push(`could not get a token with the owners:write scope: ${error2.message}`);
18177
+ errors.push(`could not get a token with the owners:write scope: ${describeApiError(error2, OWNERS_ACCESS)}`);
17510
18178
  }
17511
18179
  if (token) {
17512
18180
  for (const p of prepared) {
@@ -17518,7 +18186,7 @@ ${OWNERS_USAGE}`], exitCode: 2 });
17518
18186
  try {
17519
18187
  results.push({ request: p.request, result: await syncOwners(config2, p.request, token) });
17520
18188
  } catch (error2) {
17521
- errors.push(`${p.request.source.kind}: ${error2.message}`);
18189
+ errors.push(`${p.request.source.kind}: ${describeApiError(error2, OWNERS_ACCESS)}`);
17522
18190
  }
17523
18191
  }
17524
18192
  }
@@ -17679,7 +18347,7 @@ ${POSTURE_USAGE}`);
17679
18347
  } catch (error2) {
17680
18348
  const mensaje = error2.message;
17681
18349
  if (gate && /_http_4(00|01|03|04)$/.test(mensaje)) return fail(`could not read the posture history (${mensaje}): check the app scope (security:read) and the account id`);
17682
- return { stdout: null, warnings: [...warnings, `could not read the posture history, skipping: ${mensaje}`], exitCode: 0 };
18350
+ return { stdout: null, warnings: [...warnings, `could not read the posture history, skipping: ${describeApiError(error2, DRIFT_ACCESS)}`], exitCode: 0 };
17683
18351
  }
17684
18352
  if (history.access !== "full") {
17685
18353
  return { stdout: null, warnings: [...warnings, "the account does not have the risk and compliance add-on: no posture history to show"], exitCode: 0 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aaa-sentinel/iac-cost",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
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",