@aaa-sentinel/iac-cost 0.10.1 → 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.
- package/README.md +27 -5
- package/dist/cli.js +567 -18
- 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 |
|
|
@@ -323,10 +340,15 @@ or account ids. The JSON output does not: it is the complete evidence (see `--fo
|
|
|
323
340
|
a reservation that already covers the new resource makes the real marginal cost zero.
|
|
324
341
|
- **Priced in USD, shown in your organization's currency.** USD is what the providers publish, and
|
|
325
342
|
the API always returns it (`...Usd` fields). If your AAA Sentinel organization displays amounts
|
|
326
|
-
in EUR or GBP, the comment
|
|
327
|
-
reference rate and its date spelled out — it is an estimate on top of an
|
|
328
|
-
unchanged pull request can move a little as the exchange rate does.
|
|
329
|
-
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.
|
|
330
352
|
- **Coverage leads, not the total.** When fewer than half of the billable resources can be
|
|
331
353
|
priced, the breakdown is published but the total is withheld. A total built from 2 resources
|
|
332
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
|
@@ -235,6 +235,17 @@ var REASON_TEXT = {
|
|
|
235
235
|
price_not_found: "no matching price found in the catalog"
|
|
236
236
|
};
|
|
237
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
|
+
}
|
|
238
249
|
function fmtConverted(n, currency) {
|
|
239
250
|
const amount = new Intl.NumberFormat("en-US", { style: "currency", currency }).format(Math.abs(n));
|
|
240
251
|
return `\u2248 ${n < 0 ? "-" : "+"}${amount}/mo`;
|
|
@@ -251,12 +262,13 @@ function renderComment(estimate) {
|
|
|
251
262
|
`**Coverage: ${coverage.pricedResources} of ${coverage.pricedResources + coverage.unpricedResources} billable resources priced** (${coverage.freeResources} more have no cost by design).`
|
|
252
263
|
);
|
|
253
264
|
lines2.push("");
|
|
254
|
-
const display = estimate
|
|
265
|
+
const display = orgCurrency(estimate);
|
|
255
266
|
const delta = (usd, converted) => display && typeof converted === "number" ? fmtConverted(converted, display.code) : fmtUsd(usd);
|
|
256
267
|
if (estimate.totalMonthlyDeltaUsd !== null) {
|
|
257
268
|
const total2 = delta(estimate.totalMonthlyDeltaUsd, estimate.totalMonthlyDelta);
|
|
269
|
+
const partial2 = isPartialTotal(estimate) ? ` \u2014 **${partialTotalLabel(estimate)}**: the real change can differ` : "";
|
|
258
270
|
lines2.push(
|
|
259
|
-
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}`
|
|
260
272
|
);
|
|
261
273
|
} else {
|
|
262
274
|
lines2.push(
|
|
@@ -6825,7 +6837,8 @@ async function estimateChunk(projection, token, config2) {
|
|
|
6825
6837
|
continue;
|
|
6826
6838
|
}
|
|
6827
6839
|
}
|
|
6828
|
-
|
|
6840
|
+
const code2 = await apiErrorCode(response);
|
|
6841
|
+
throw new Error(`iac_cost_estimate_http_${response.status}${code2 ? ` ${code2}` : ""}`);
|
|
6829
6842
|
}
|
|
6830
6843
|
throw new Error("iac_cost_estimate_exhausted_retries");
|
|
6831
6844
|
}
|
|
@@ -6851,6 +6864,71 @@ async function estimatePlan(projection, config2) {
|
|
|
6851
6864
|
return aggregateEstimates(estimates);
|
|
6852
6865
|
}
|
|
6853
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
|
+
|
|
6854
6932
|
// src/env-cost.ts
|
|
6855
6933
|
var ENV_COST_USAGE = `Usage: iac-cost env-cost --env <name> [--comment] [--format text|markdown|json]
|
|
6856
6934
|
|
|
@@ -7052,7 +7130,7 @@ ${ENV_COST_USAGE}`], exitCode: 2 };
|
|
|
7052
7130
|
env
|
|
7053
7131
|
);
|
|
7054
7132
|
} catch (error2) {
|
|
7055
|
-
return skip(`could not read the environment cost, continuing: ${error2
|
|
7133
|
+
return skip(`could not read the environment cost, continuing: ${describeApiError(error2, ENV_COST_ACCESS)}`);
|
|
7056
7134
|
}
|
|
7057
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)`);
|
|
7058
7136
|
const now = (io.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
@@ -13494,7 +13572,17 @@ var S3_CHECKS = {
|
|
|
13494
13572
|
publicAccessBlock: "aws:s3:GetPublicAccessBlock",
|
|
13495
13573
|
policyStatus: "aws:s3:GetBucketPolicyStatus",
|
|
13496
13574
|
acl: "aws:s3:GetBucketAcl",
|
|
13497
|
-
encryption: "aws:s3:GetBucketEncryption"
|
|
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"
|
|
13498
13586
|
};
|
|
13499
13587
|
var TRAIL_BUCKET_CHECKS = {
|
|
13500
13588
|
lifecycle: "aws:s3:GetBucketLifecycleConfiguration",
|
|
@@ -13534,6 +13622,24 @@ var rdsSinCopias = {
|
|
|
13534
13622
|
// Se juzga en la cuenta: el adaptador de planes de Terraform aún no traduce las copias.
|
|
13535
13623
|
runtimeOnly: true
|
|
13536
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
|
+
};
|
|
13537
13643
|
|
|
13538
13644
|
// ../../services/security/src/rules/aws/log-retention.ts
|
|
13539
13645
|
var LOG_RETENTION_MIN_DAYS = 365;
|
|
@@ -15184,6 +15290,202 @@ var rdsSinActualizacionMenor = {
|
|
|
15184
15290
|
evaluate: rdsSinActualizacionMenorEvaluate
|
|
15185
15291
|
};
|
|
15186
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
|
+
|
|
15187
15489
|
// ../../services/security/src/rules/aws/secrets.ts
|
|
15188
15490
|
var SOSPECHOSAS = [
|
|
15189
15491
|
"PASSWORD",
|
|
@@ -15247,6 +15549,13 @@ var AWS_SECURITY_RULES = [
|
|
|
15247
15549
|
rdsSinCopias,
|
|
15248
15550
|
trailRetencionCorta,
|
|
15249
15551
|
rdsSinActualizacionMenor,
|
|
15552
|
+
rdsSinMultiAz,
|
|
15553
|
+
rdsSinProteccionBorrado,
|
|
15554
|
+
lambdaRuntimeRetirado,
|
|
15555
|
+
dynamoSinRecuperacionPuntual,
|
|
15556
|
+
dynamoSinProteccionBorrado,
|
|
15557
|
+
s3SinVersionado,
|
|
15558
|
+
acmCertificadoCaduca,
|
|
15250
15559
|
rootSinMfa,
|
|
15251
15560
|
usuarioSinMfa,
|
|
15252
15561
|
claveAntigua,
|
|
@@ -15332,7 +15641,9 @@ var AZURE_NSG_CHECKS = {
|
|
|
15332
15641
|
var AZURE_STORAGE_CHECKS = {
|
|
15333
15642
|
list: "azure:storage:list",
|
|
15334
15643
|
// Solo de las cuentas que permiten blobs públicos: dice a quien aprueba cerrarlo qué contenedores dejan de servirse.
|
|
15335
|
-
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"
|
|
15336
15647
|
};
|
|
15337
15648
|
var AZURE_SQL_CHECKS = {
|
|
15338
15649
|
list: "azure:sql:list",
|
|
@@ -15391,6 +15702,42 @@ var vmSinCopia = {
|
|
|
15391
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.
|
|
15392
15703
|
runtimeOnly: true
|
|
15393
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
|
+
};
|
|
15394
15741
|
|
|
15395
15742
|
// ../../services/security/src/rules/azure/encryption.ts
|
|
15396
15743
|
var TLS_DEBIL = /* @__PURE__ */ new Set(["tls1_0", "tls1.0", "1.0", "tls1_1", "tls1.1", "1.1"]);
|
|
@@ -15798,6 +16145,8 @@ var AZURE_SECURITY_RULES = [
|
|
|
15798
16145
|
keyVaultSinPurga,
|
|
15799
16146
|
sqlSinTde,
|
|
15800
16147
|
vmSinCopia,
|
|
16148
|
+
sqlCopiasLocales,
|
|
16149
|
+
blobSinBorradoSuave,
|
|
15801
16150
|
rolPrivilegiado,
|
|
15802
16151
|
asignacionHuerfana,
|
|
15803
16152
|
adminSinMfa,
|
|
@@ -15893,7 +16242,9 @@ var GCP_COMPUTE_CHECKS = {
|
|
|
15893
16242
|
regions: "gcp:compute:regions",
|
|
15894
16243
|
regionFirewallPolicies: "gcp:compute:regionNetworkFirewallPolicies",
|
|
15895
16244
|
sharedVpcHost: "gcp:compute:sharedVpcHostFirewalls",
|
|
15896
|
-
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"
|
|
15897
16248
|
};
|
|
15898
16249
|
var GCP_NETWORK_MANAGEMENT_CHECKS = {
|
|
15899
16250
|
vpcFlowLogsConfigs: "gcp:networkmanagement:vpcFlowLogsConfigs"
|
|
@@ -15930,11 +16281,15 @@ var GCP_LOGGING_CHECKS = {
|
|
|
15930
16281
|
var GCP_CIEM_WINDOW_DAYS = 90;
|
|
15931
16282
|
|
|
15932
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
|
+
}
|
|
15933
16288
|
function sqlSinCopiasEvaluate(observation) {
|
|
15934
16289
|
const tipo = observation.attributes.instanceType;
|
|
15935
16290
|
if (typeof tipo === "string" && tipo !== "CLOUD_SQL_INSTANCE") return { status: "ok" };
|
|
15936
|
-
const activas = observation.attributes.backupEnabled;
|
|
15937
|
-
if (
|
|
16291
|
+
const activas = interruptor(observation.attributes.backupEnabled);
|
|
16292
|
+
if (activas === void 0) return { status: "unknown", check: GCP_SQL_CHECKS.instances, attribute: "backupEnabled" };
|
|
15938
16293
|
if (activas) return { status: "ok" };
|
|
15939
16294
|
return { status: "finding", evidence: { backupEnabled: false } };
|
|
15940
16295
|
}
|
|
@@ -16510,6 +16865,186 @@ var firewallBdAbierto = {
|
|
|
16510
16865
|
evaluate: (observation) => firewallAbierto(observation, databasePortsReached)
|
|
16511
16866
|
};
|
|
16512
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
|
+
|
|
16513
17048
|
// ../../services/security/src/rules/gcp/secrets.ts
|
|
16514
17049
|
var SOSPECHOSAS2 = ["PASSWORD", "PASSWD", "SECRET", "TOKEN", "APIKEY", "API_KEY", "PRIVATE_KEY", "CREDENTIAL"];
|
|
16515
17050
|
var REFERENCIAS2 = ["_ARN", "_NAME", "_ID", "_PATH", "_URL", "_URI", "_TABLE", "_BUCKET"];
|
|
@@ -16551,6 +17086,12 @@ var GCP_SECURITY_RULES = [
|
|
|
16551
17086
|
sqlSinCmek,
|
|
16552
17087
|
sqlSinSsl,
|
|
16553
17088
|
sqlSinCopias,
|
|
17089
|
+
sqlSinRecuperacionPuntual,
|
|
17090
|
+
sqlSinAltaDisponibilidad,
|
|
17091
|
+
sqlSinProteccionBorrado,
|
|
17092
|
+
functionRuntimeRetirado,
|
|
17093
|
+
gcsSinVersionado,
|
|
17094
|
+
discoSinSnapshots,
|
|
16554
17095
|
kmsSinRotacion2,
|
|
16555
17096
|
secretoEnFunction,
|
|
16556
17097
|
rolPrimitivo,
|
|
@@ -16856,7 +17397,7 @@ async function runIacCost(planJson, config2) {
|
|
|
16856
17397
|
failed: true,
|
|
16857
17398
|
markdown: null,
|
|
16858
17399
|
estimate: null,
|
|
16859
|
-
warning: `Cost estimate unavailable, continuing without blocking the build: ${error2
|
|
17400
|
+
warning: `Cost estimate unavailable, continuing without blocking the build: ${describeApiError(error2, COST_ACCESS)}`
|
|
16860
17401
|
};
|
|
16861
17402
|
}
|
|
16862
17403
|
}
|
|
@@ -16869,13 +17410,21 @@ function decodePlan(bytes) {
|
|
|
16869
17410
|
if (bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191) return bytes.subarray(3).toString("utf-8");
|
|
16870
17411
|
return bytes.toString("utf-8");
|
|
16871
17412
|
}
|
|
16872
|
-
var fmtUsd2 = (n) => `${n < 0 ? "-" : "+"}$${Math.abs(n).toFixed(2)}/mo`;
|
|
16873
17413
|
function costText(estimate) {
|
|
16874
17414
|
const { coverage } = estimate;
|
|
16875
|
-
const
|
|
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);
|
|
16876
17424
|
return [
|
|
16877
17425
|
"Cost",
|
|
16878
17426
|
` Estimated change: ${total2}`,
|
|
17427
|
+
...partial2 ? [` Total is ${partial2}: the real change can differ`] : [],
|
|
16879
17428
|
` Coverage: ${coverage.pricedResources} of ${coverage.pricedResources + coverage.unpricedResources} billable resources priced`
|
|
16880
17429
|
].join("\n");
|
|
16881
17430
|
}
|
|
@@ -16935,7 +17484,7 @@ async function runCli(options, readPlan, credentials) {
|
|
|
16935
17484
|
});
|
|
16936
17485
|
report.drift = compareDrift(evaluation.verdicts, live, options.driftAccount);
|
|
16937
17486
|
} catch (error2) {
|
|
16938
|
-
warnings.push(`Drift check unavailable, continuing: ${error2
|
|
17487
|
+
warnings.push(`Drift check unavailable, continuing: ${describeApiError(error2, DRIFT_ACCESS)}`);
|
|
16939
17488
|
}
|
|
16940
17489
|
}
|
|
16941
17490
|
}
|
|
@@ -16964,7 +17513,7 @@ async function runCli(options, readPlan, credentials) {
|
|
|
16964
17513
|
);
|
|
16965
17514
|
if (evaluateBudgetGate(budgets, mode).blocks) exitCode = 1;
|
|
16966
17515
|
} catch (error2) {
|
|
16967
|
-
warnings.push(`Budget check unavailable: ${error2
|
|
17516
|
+
warnings.push(`Budget check unavailable: ${describeApiError(error2, BUDGET_ACCESS)}`);
|
|
16968
17517
|
gateUnavailable = true;
|
|
16969
17518
|
}
|
|
16970
17519
|
}
|
|
@@ -16972,7 +17521,7 @@ async function runCli(options, readPlan, credentials) {
|
|
|
16972
17521
|
if (exitCode === 0 && gateUnavailable) exitCode = 2;
|
|
16973
17522
|
if (options.format === "json") {
|
|
16974
17523
|
return {
|
|
16975
|
-
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),
|
|
16976
17525
|
warnings,
|
|
16977
17526
|
exitCode
|
|
16978
17527
|
};
|
|
@@ -17625,7 +18174,7 @@ ${OWNERS_USAGE}`], exitCode: 2 });
|
|
|
17625
18174
|
try {
|
|
17626
18175
|
token = await fetchToken(config2, SCOPE5);
|
|
17627
18176
|
} catch (error2) {
|
|
17628
|
-
errors.push(`could not get a token with the owners:write scope: ${error2
|
|
18177
|
+
errors.push(`could not get a token with the owners:write scope: ${describeApiError(error2, OWNERS_ACCESS)}`);
|
|
17629
18178
|
}
|
|
17630
18179
|
if (token) {
|
|
17631
18180
|
for (const p of prepared) {
|
|
@@ -17637,7 +18186,7 @@ ${OWNERS_USAGE}`], exitCode: 2 });
|
|
|
17637
18186
|
try {
|
|
17638
18187
|
results.push({ request: p.request, result: await syncOwners(config2, p.request, token) });
|
|
17639
18188
|
} catch (error2) {
|
|
17640
|
-
errors.push(`${p.request.source.kind}: ${error2
|
|
18189
|
+
errors.push(`${p.request.source.kind}: ${describeApiError(error2, OWNERS_ACCESS)}`);
|
|
17641
18190
|
}
|
|
17642
18191
|
}
|
|
17643
18192
|
}
|
|
@@ -17798,7 +18347,7 @@ ${POSTURE_USAGE}`);
|
|
|
17798
18347
|
} catch (error2) {
|
|
17799
18348
|
const mensaje = error2.message;
|
|
17800
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`);
|
|
17801
|
-
return { stdout: null, warnings: [...warnings, `could not read the posture history, skipping: ${
|
|
18350
|
+
return { stdout: null, warnings: [...warnings, `could not read the posture history, skipping: ${describeApiError(error2, DRIFT_ACCESS)}`], exitCode: 0 };
|
|
17802
18351
|
}
|
|
17803
18352
|
if (history.access !== "full") {
|
|
17804
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.
|
|
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",
|