@aaa-sentinel/iac-cost 0.10.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -5
- package/dist/cli.js +581 -20
- 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,80 @@ 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 (status === 403 && code2 === "APP_OWNER_NOT_MEMBER") {
|
|
6898
|
+
return `the person who created the app in ${access.idVar} is no longer a member of the organization: an administrator can reassign the app to another member in ${APPS_URL}, then run the job again.`;
|
|
6899
|
+
}
|
|
6900
|
+
if (status === 403 && code2 === "APP_OWNER_NOT_ACTIVE") {
|
|
6901
|
+
return `the access of the person who created the app in ${access.idVar} is suspended: an administrator can reactivate it or reassign the app in ${APPS_URL}, then run the job again.`;
|
|
6902
|
+
}
|
|
6903
|
+
if (status === 503 && code2 === "OWNER_CHECK_UNAVAILABLE") {
|
|
6904
|
+
return "the API could not check the person who created the app: run the job again in a few minutes.";
|
|
6905
|
+
}
|
|
6906
|
+
if (stage === "token" && status === 400 && code2 === "INVALID_SCOPE") {
|
|
6907
|
+
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.`;
|
|
6908
|
+
}
|
|
6909
|
+
if (stage === "token" && (status === 400 || status === 401)) {
|
|
6910
|
+
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.`;
|
|
6911
|
+
}
|
|
6912
|
+
if (status === 401) {
|
|
6913
|
+
return `the API rejected the access token: run the job again; if it keeps failing, check ${creds} in ${APPS_URL}.`;
|
|
6914
|
+
}
|
|
6915
|
+
if (status === 403) {
|
|
6916
|
+
if (code2 === "INSUFFICIENT_SCOPE") {
|
|
6917
|
+
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.`;
|
|
6918
|
+
}
|
|
6919
|
+
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}).`;
|
|
6920
|
+
}
|
|
6921
|
+
if (status === 402) {
|
|
6922
|
+
if (code2 === "TRIAL_EXPIRED" || code2 === "SUBSCRIPTION_EXPIRED") {
|
|
6923
|
+
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.`;
|
|
6924
|
+
}
|
|
6925
|
+
return `the organization's plan does not include this${access.planNeed ? ` (${access.planNeed})` : ""}: change the plan in ${BILLING_URL}, then run the job again.`;
|
|
6926
|
+
}
|
|
6927
|
+
if (status === 429) {
|
|
6928
|
+
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.";
|
|
6929
|
+
}
|
|
6930
|
+
if (status >= 500) {
|
|
6931
|
+
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.";
|
|
6932
|
+
}
|
|
6933
|
+
return null;
|
|
6934
|
+
}
|
|
6935
|
+
function describeApiError(error2, access) {
|
|
6936
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
6937
|
+
const hint = httpHint(error2, access);
|
|
6938
|
+
return hint ? `${message}. ${hint[0].toUpperCase()}${hint.slice(1)}` : message;
|
|
6939
|
+
}
|
|
6940
|
+
|
|
6854
6941
|
// src/env-cost.ts
|
|
6855
6942
|
var ENV_COST_USAGE = `Usage: iac-cost env-cost --env <name> [--comment] [--format text|markdown|json]
|
|
6856
6943
|
|
|
@@ -7052,7 +7139,7 @@ ${ENV_COST_USAGE}`], exitCode: 2 };
|
|
|
7052
7139
|
env
|
|
7053
7140
|
);
|
|
7054
7141
|
} catch (error2) {
|
|
7055
|
-
return skip(`could not read the environment cost, continuing: ${error2
|
|
7142
|
+
return skip(`could not read the environment cost, continuing: ${describeApiError(error2, ENV_COST_ACCESS)}`);
|
|
7056
7143
|
}
|
|
7057
7144
|
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
7145
|
const now = (io.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
@@ -13259,6 +13346,9 @@ function publicVulnerable(input, provider) {
|
|
|
13259
13346
|
}
|
|
13260
13347
|
|
|
13261
13348
|
// ../../services/security/src/rules/aws/combos.ts
|
|
13349
|
+
function rdsInstanceIdOf(resourceId) {
|
|
13350
|
+
return /^arn:aws[a-z-]*:rds:[a-z0-9-]+:\d{12}:db:([^:]+)$/.exec(resourceId)?.[1] ?? resourceId;
|
|
13351
|
+
}
|
|
13262
13352
|
function lambdaRef(resourceId, region) {
|
|
13263
13353
|
const partes = resourceId.split(":");
|
|
13264
13354
|
if (partes[0] === "arn" && partes[2] === "lambda" && partes[5] === "function" && partes[3] && partes[6]) {
|
|
@@ -13337,7 +13427,7 @@ var AWS_SECURITY_COMBOS = [
|
|
|
13337
13427
|
costRule: "DATABASE_ZERO_CONN_RDS",
|
|
13338
13428
|
// Los dos módulos usan el DBInstanceIdentifier, único por región.
|
|
13339
13429
|
findingKey: (f) => `${f.region}::${f.resourceId}`,
|
|
13340
|
-
signalKey: (s) => `${s.region}::${s.resourceId}`,
|
|
13430
|
+
signalKey: (s) => `${s.region}::${rdsInstanceIdOf(s.resourceId)}`,
|
|
13341
13431
|
amount: true
|
|
13342
13432
|
})
|
|
13343
13433
|
},
|
|
@@ -13353,7 +13443,7 @@ var AWS_SECURITY_COMBOS = [
|
|
|
13353
13443
|
rule: "SEC_AWS_PATCHING_RDS_SIN_ACTUALIZACION_MENOR",
|
|
13354
13444
|
costRule: "DATABASE_RDS_EXTENDED_SUPPORT",
|
|
13355
13445
|
findingKey: (f) => `${f.region}::${f.resourceId}`,
|
|
13356
|
-
signalKey: (s) => `${s.region}::${s.resourceId}`,
|
|
13446
|
+
signalKey: (s) => `${s.region}::${rdsInstanceIdOf(s.resourceId)}`,
|
|
13357
13447
|
amount: true
|
|
13358
13448
|
// El aviso de «entra en soporte extendido en ≤60 días» lleva importe 0: aún no se paga nada.
|
|
13359
13449
|
}).filter((m) => typeof m.evidence["monthlySavingsUsd"] === "number" && m.evidence["monthlySavingsUsd"] > 0)
|
|
@@ -13494,7 +13584,17 @@ var S3_CHECKS = {
|
|
|
13494
13584
|
publicAccessBlock: "aws:s3:GetPublicAccessBlock",
|
|
13495
13585
|
policyStatus: "aws:s3:GetBucketPolicyStatus",
|
|
13496
13586
|
acl: "aws:s3:GetBucketAcl",
|
|
13497
|
-
encryption: "aws:s3:GetBucketEncryption"
|
|
13587
|
+
encryption: "aws:s3:GetBucketEncryption",
|
|
13588
|
+
// La misma acción que lee el bucket de CloudTrail, aquí por cada bucket: id propio para que un fallo no se cruce.
|
|
13589
|
+
versioning: "aws:s3:GetBucketVersioning#bucket"
|
|
13590
|
+
};
|
|
13591
|
+
var DYNAMODB_CHECKS = {
|
|
13592
|
+
tables: "aws:dynamodb:ListTables",
|
|
13593
|
+
describeTable: "aws:dynamodb:DescribeTable",
|
|
13594
|
+
continuousBackups: "aws:dynamodb:DescribeContinuousBackups"
|
|
13595
|
+
};
|
|
13596
|
+
var ACM_CHECKS = {
|
|
13597
|
+
certificates: "aws:acm:ListCertificates"
|
|
13498
13598
|
};
|
|
13499
13599
|
var TRAIL_BUCKET_CHECKS = {
|
|
13500
13600
|
lifecycle: "aws:s3:GetBucketLifecycleConfiguration",
|
|
@@ -13534,6 +13634,24 @@ var rdsSinCopias = {
|
|
|
13534
13634
|
// Se juzga en la cuenta: el adaptador de planes de Terraform aún no traduce las copias.
|
|
13535
13635
|
runtimeOnly: true
|
|
13536
13636
|
};
|
|
13637
|
+
function dynamoSinRecuperacionPuntualEvaluate(observation) {
|
|
13638
|
+
if (observation.attributes.sampleCapped === true) return { status: "unknown", check: DYNAMODB_CHECKS.continuousBackups, attribute: "pointInTimeRecovery", reason: "sample_capped" };
|
|
13639
|
+
const pitr = observation.attributes.pointInTimeRecovery;
|
|
13640
|
+
if (typeof pitr !== "boolean") return { status: "unknown", check: DYNAMODB_CHECKS.continuousBackups, attribute: "pointInTimeRecovery" };
|
|
13641
|
+
if (pitr) return { status: "ok" };
|
|
13642
|
+
return { status: "finding", evidence: { pointInTimeRecovery: false } };
|
|
13643
|
+
}
|
|
13644
|
+
var dynamoSinRecuperacionPuntual = {
|
|
13645
|
+
id: "SEC_AWS_BACKUP_DYNAMODB_SIN_RECUPERACION_PUNTUAL",
|
|
13646
|
+
scope: "resource",
|
|
13647
|
+
category: "security_backup",
|
|
13648
|
+
severity: "medium",
|
|
13649
|
+
provider: "aws",
|
|
13650
|
+
kinds: ["dynamodb_table"],
|
|
13651
|
+
requires: [REGION_CHECKS.listRegions, DYNAMODB_CHECKS.tables, DYNAMODB_CHECKS.continuousBackups],
|
|
13652
|
+
evaluate: dynamoSinRecuperacionPuntualEvaluate,
|
|
13653
|
+
runtimeOnly: true
|
|
13654
|
+
};
|
|
13537
13655
|
|
|
13538
13656
|
// ../../services/security/src/rules/aws/log-retention.ts
|
|
13539
13657
|
var LOG_RETENTION_MIN_DAYS = 365;
|
|
@@ -15184,6 +15302,202 @@ var rdsSinActualizacionMenor = {
|
|
|
15184
15302
|
evaluate: rdsSinActualizacionMenorEvaluate
|
|
15185
15303
|
};
|
|
15186
15304
|
|
|
15305
|
+
// ../../services/security/src/rules/runtime-dates.ts
|
|
15306
|
+
var RUNTIME_NOTICE_DAYS = 60;
|
|
15307
|
+
var RUNTIME_REVIEW_DUE_MS = 183 * 864e5;
|
|
15308
|
+
function runtimeDaysLeft(table, runtime, now) {
|
|
15309
|
+
const fecha = table[runtime];
|
|
15310
|
+
return fecha === void 0 ? null : Math.ceil((Date.parse(`${fecha}T00:00:00Z`) - now) / 864e5);
|
|
15311
|
+
}
|
|
15312
|
+
function runtimeRetirement(table, runtime, now) {
|
|
15313
|
+
const dias = runtimeDaysLeft(table, runtime, now);
|
|
15314
|
+
const fecha = table[runtime];
|
|
15315
|
+
if (dias === null || fecha === void 0 || dias > RUNTIME_NOTICE_DAYS) return null;
|
|
15316
|
+
return { runtime, deprecationDate: fecha, deprecated: dias <= 0 };
|
|
15317
|
+
}
|
|
15318
|
+
|
|
15319
|
+
// ../../services/security/src/rules/aws/lambda-runtimes.ts
|
|
15320
|
+
var LAMBDA_RUNTIME_DEPRECATION = {
|
|
15321
|
+
"nodejs24.x": "2028-04-30",
|
|
15322
|
+
"nodejs22.x": "2027-05-30",
|
|
15323
|
+
"python3.14": "2029-06-30",
|
|
15324
|
+
"python3.13": "2029-06-30",
|
|
15325
|
+
"python3.12": "2028-10-31",
|
|
15326
|
+
"python3.11": "2027-06-30",
|
|
15327
|
+
java25: "2029-06-30",
|
|
15328
|
+
java21: "2029-06-30",
|
|
15329
|
+
"java17.al2023": "2029-06-30",
|
|
15330
|
+
"java11.al2023": "2029-06-30",
|
|
15331
|
+
"java8.al2023": "2029-06-30",
|
|
15332
|
+
java17: "2027-06-30",
|
|
15333
|
+
java11: "2027-06-30",
|
|
15334
|
+
"java8.al2": "2027-06-30",
|
|
15335
|
+
dotnet10: "2028-11-14",
|
|
15336
|
+
"ruby4.0": "2029-03-31",
|
|
15337
|
+
"ruby3.4": "2028-03-31",
|
|
15338
|
+
"ruby3.3": "2027-03-31",
|
|
15339
|
+
"provided.al2023": "2029-06-30",
|
|
15340
|
+
dotnet8: "2026-11-10",
|
|
15341
|
+
"python3.10": "2026-10-31",
|
|
15342
|
+
"provided.al2": "2026-07-31",
|
|
15343
|
+
"nodejs20.x": "2026-04-30",
|
|
15344
|
+
"ruby3.2": "2026-03-31",
|
|
15345
|
+
"python3.9": "2025-12-15",
|
|
15346
|
+
"nodejs18.x": "2025-09-01",
|
|
15347
|
+
dotnet6: "2024-12-20",
|
|
15348
|
+
"python3.8": "2024-10-14",
|
|
15349
|
+
"nodejs16.x": "2024-06-12",
|
|
15350
|
+
java8: "2024-01-08",
|
|
15351
|
+
"go1.x": "2024-01-08",
|
|
15352
|
+
provided: "2024-01-08",
|
|
15353
|
+
"ruby2.7": "2023-12-07",
|
|
15354
|
+
"nodejs14.x": "2023-12-04",
|
|
15355
|
+
"python3.7": "2023-12-04",
|
|
15356
|
+
"dotnetcore3.1": "2023-04-03",
|
|
15357
|
+
"nodejs12.x": "2023-03-31",
|
|
15358
|
+
"python3.6": "2022-07-18",
|
|
15359
|
+
"dotnetcore2.1": "2022-01-05",
|
|
15360
|
+
"nodejs10.x": "2021-07-30",
|
|
15361
|
+
"ruby2.5": "2021-07-30",
|
|
15362
|
+
"python2.7": "2021-07-15",
|
|
15363
|
+
"nodejs8.10": "2020-03-06",
|
|
15364
|
+
"nodejs4.3": "2020-03-05",
|
|
15365
|
+
"nodejs4.3-edge": "2020-03-05",
|
|
15366
|
+
"nodejs6.10": "2019-08-12",
|
|
15367
|
+
"dotnetcore1.0": "2019-06-27",
|
|
15368
|
+
"dotnetcore2.0": "2019-05-30",
|
|
15369
|
+
nodejs: "2016-08-30"
|
|
15370
|
+
};
|
|
15371
|
+
|
|
15372
|
+
// ../../services/security/src/rules/aws/resilience.ts
|
|
15373
|
+
function propio(observation, attribute, deCluster) {
|
|
15374
|
+
const miembro = typeof observation.attributes.clusterId === "string";
|
|
15375
|
+
const valor = observation.attributes[miembro ? deCluster : attribute];
|
|
15376
|
+
if (typeof valor === "boolean") return valor;
|
|
15377
|
+
return { status: "unknown", check: miembro ? RDS_CHECKS.clusters : RDS_CHECKS.instances, attribute: miembro ? deCluster : attribute };
|
|
15378
|
+
}
|
|
15379
|
+
function evidencia(observation, attribute) {
|
|
15380
|
+
return { [attribute]: false, engine: observation.attributes.engine ?? null, clusterId: observation.attributes.clusterId ?? null };
|
|
15381
|
+
}
|
|
15382
|
+
function rdsSinMultiAzEvaluate(observation) {
|
|
15383
|
+
if (typeof observation.attributes.readReplicaSource === "string") return { status: "ok" };
|
|
15384
|
+
const multiAz = propio(observation, "multiAz", "clusterMultiAz");
|
|
15385
|
+
if (typeof multiAz !== "boolean") return multiAz;
|
|
15386
|
+
return multiAz ? { status: "ok" } : { status: "finding", evidence: evidencia(observation, "multiAz") };
|
|
15387
|
+
}
|
|
15388
|
+
var rdsSinMultiAz = {
|
|
15389
|
+
id: "SEC_AWS_RESILIENCE_RDS_SIN_MULTI_AZ",
|
|
15390
|
+
scope: "resource",
|
|
15391
|
+
category: "security_resilience",
|
|
15392
|
+
severity: "medium",
|
|
15393
|
+
provider: "aws",
|
|
15394
|
+
kinds: ["rds_instance"],
|
|
15395
|
+
requires: [REGION_CHECKS.listRegions, RDS_CHECKS.instances, RDS_CHECKS.clusters],
|
|
15396
|
+
evaluate: rdsSinMultiAzEvaluate,
|
|
15397
|
+
// Se juzga en la cuenta: el adaptador de planes de Terraform aún no distingue las réplicas.
|
|
15398
|
+
runtimeOnly: true
|
|
15399
|
+
};
|
|
15400
|
+
function rdsSinProteccionBorradoEvaluate(observation) {
|
|
15401
|
+
const protegida = propio(observation, "deletionProtection", "clusterDeletionProtection");
|
|
15402
|
+
if (typeof protegida !== "boolean") return protegida;
|
|
15403
|
+
return protegida ? { status: "ok" } : { status: "finding", evidence: evidencia(observation, "deletionProtection") };
|
|
15404
|
+
}
|
|
15405
|
+
var rdsSinProteccionBorrado = {
|
|
15406
|
+
id: "SEC_AWS_RESILIENCE_RDS_SIN_PROTECCION_BORRADO",
|
|
15407
|
+
scope: "resource",
|
|
15408
|
+
category: "security_resilience",
|
|
15409
|
+
severity: "low",
|
|
15410
|
+
provider: "aws",
|
|
15411
|
+
kinds: ["rds_instance"],
|
|
15412
|
+
requires: [REGION_CHECKS.listRegions, RDS_CHECKS.instances, RDS_CHECKS.clusters],
|
|
15413
|
+
evaluate: rdsSinProteccionBorradoEvaluate,
|
|
15414
|
+
runtimeOnly: true
|
|
15415
|
+
};
|
|
15416
|
+
function lambdaRuntimeRetiradoEvaluate(observation) {
|
|
15417
|
+
const runtime = observation.attributes.runtime;
|
|
15418
|
+
if (runtime === null) return { status: "ok" };
|
|
15419
|
+
if (typeof runtime !== "string") return { status: "unknown", check: LAMBDA_CHECKS.functions, attribute: "runtime" };
|
|
15420
|
+
const retirada = runtimeRetirement(LAMBDA_RUNTIME_DEPRECATION, runtime, Date.now());
|
|
15421
|
+
return retirada ? { status: "finding", evidence: retirada } : { status: "ok" };
|
|
15422
|
+
}
|
|
15423
|
+
var lambdaRuntimeRetirado = {
|
|
15424
|
+
id: "SEC_AWS_RESILIENCE_LAMBDA_RUNTIME_RETIRADO",
|
|
15425
|
+
scope: "resource",
|
|
15426
|
+
category: "security_resilience",
|
|
15427
|
+
severity: "medium",
|
|
15428
|
+
provider: "aws",
|
|
15429
|
+
kinds: ["lambda_function"],
|
|
15430
|
+
requires: [REGION_CHECKS.listRegions, LAMBDA_CHECKS.functions],
|
|
15431
|
+
evaluate: lambdaRuntimeRetiradoEvaluate,
|
|
15432
|
+
// El veredicto depende de la fecha del escaneo y el adaptador de planes no trae el runtime.
|
|
15433
|
+
runtimeOnly: true
|
|
15434
|
+
};
|
|
15435
|
+
function dynamoSinProteccionBorradoEvaluate(observation) {
|
|
15436
|
+
if (observation.attributes.sampleCapped === true) return { status: "unknown", check: DYNAMODB_CHECKS.describeTable, attribute: "deletionProtection", reason: "sample_capped" };
|
|
15437
|
+
const protegida = observation.attributes.deletionProtection;
|
|
15438
|
+
if (typeof protegida !== "boolean") return { status: "unknown", check: DYNAMODB_CHECKS.describeTable, attribute: "deletionProtection" };
|
|
15439
|
+
return protegida ? { status: "ok" } : { status: "finding", evidence: { deletionProtection: false } };
|
|
15440
|
+
}
|
|
15441
|
+
var dynamoSinProteccionBorrado = {
|
|
15442
|
+
id: "SEC_AWS_RESILIENCE_DYNAMODB_SIN_PROTECCION_BORRADO",
|
|
15443
|
+
scope: "resource",
|
|
15444
|
+
category: "security_resilience",
|
|
15445
|
+
severity: "low",
|
|
15446
|
+
provider: "aws",
|
|
15447
|
+
kinds: ["dynamodb_table"],
|
|
15448
|
+
requires: [REGION_CHECKS.listRegions, DYNAMODB_CHECKS.tables, DYNAMODB_CHECKS.describeTable],
|
|
15449
|
+
evaluate: dynamoSinProteccionBorradoEvaluate,
|
|
15450
|
+
runtimeOnly: true
|
|
15451
|
+
};
|
|
15452
|
+
function s3SinVersionadoEvaluate(observation) {
|
|
15453
|
+
const estado = observation.attributes.versioning;
|
|
15454
|
+
if (estado === void 0) return { status: "unknown", check: S3_CHECKS.versioning, attribute: "versioning" };
|
|
15455
|
+
if (estado === "Enabled") return { status: "ok" };
|
|
15456
|
+
return { status: "finding", evidence: { versioning: estado ?? "never" } };
|
|
15457
|
+
}
|
|
15458
|
+
var s3SinVersionado = {
|
|
15459
|
+
id: "SEC_AWS_RESILIENCE_S3_SIN_VERSIONADO",
|
|
15460
|
+
scope: "resource",
|
|
15461
|
+
category: "security_resilience",
|
|
15462
|
+
severity: "low",
|
|
15463
|
+
provider: "aws",
|
|
15464
|
+
kinds: ["s3_bucket"],
|
|
15465
|
+
requires: [S3_CHECKS.listBuckets, S3_CHECKS.versioning],
|
|
15466
|
+
evaluate: s3SinVersionadoEvaluate,
|
|
15467
|
+
runtimeOnly: true
|
|
15468
|
+
};
|
|
15469
|
+
var CERT_NOTICE_DAYS = 30;
|
|
15470
|
+
function acmCertificadoCaducaEvaluate(observation) {
|
|
15471
|
+
const enUso = observation.attributes.inUse;
|
|
15472
|
+
if (typeof enUso !== "boolean") return { status: "unknown", check: ACM_CHECKS.certificates, attribute: "inUse" };
|
|
15473
|
+
if (!enUso) return { status: "ok" };
|
|
15474
|
+
const fin = observation.attributes.notAfter;
|
|
15475
|
+
if (typeof fin !== "string") return { status: "ok" };
|
|
15476
|
+
const dias = Math.ceil((Date.parse(fin) - Date.now()) / 864e5);
|
|
15477
|
+
if (!Number.isFinite(dias) || dias > CERT_NOTICE_DAYS) return { status: "ok" };
|
|
15478
|
+
return {
|
|
15479
|
+
status: "finding",
|
|
15480
|
+
evidence: {
|
|
15481
|
+
notAfter: fin,
|
|
15482
|
+
expired: dias <= 0,
|
|
15483
|
+
type: observation.attributes.type ?? null,
|
|
15484
|
+
renewalEligibility: observation.attributes.renewalEligibility ?? null
|
|
15485
|
+
}
|
|
15486
|
+
};
|
|
15487
|
+
}
|
|
15488
|
+
var acmCertificadoCaduca = {
|
|
15489
|
+
id: "SEC_AWS_RESILIENCE_ACM_CERTIFICADO_CADUCA",
|
|
15490
|
+
scope: "resource",
|
|
15491
|
+
category: "security_resilience",
|
|
15492
|
+
severity: "medium",
|
|
15493
|
+
provider: "aws",
|
|
15494
|
+
kinds: ["acm_certificate"],
|
|
15495
|
+
requires: [REGION_CHECKS.listRegions, ACM_CHECKS.certificates],
|
|
15496
|
+
evaluate: acmCertificadoCaducaEvaluate,
|
|
15497
|
+
// El veredicto depende de la fecha del escaneo.
|
|
15498
|
+
runtimeOnly: true
|
|
15499
|
+
};
|
|
15500
|
+
|
|
15187
15501
|
// ../../services/security/src/rules/aws/secrets.ts
|
|
15188
15502
|
var SOSPECHOSAS = [
|
|
15189
15503
|
"PASSWORD",
|
|
@@ -15247,6 +15561,13 @@ var AWS_SECURITY_RULES = [
|
|
|
15247
15561
|
rdsSinCopias,
|
|
15248
15562
|
trailRetencionCorta,
|
|
15249
15563
|
rdsSinActualizacionMenor,
|
|
15564
|
+
rdsSinMultiAz,
|
|
15565
|
+
rdsSinProteccionBorrado,
|
|
15566
|
+
lambdaRuntimeRetirado,
|
|
15567
|
+
dynamoSinRecuperacionPuntual,
|
|
15568
|
+
dynamoSinProteccionBorrado,
|
|
15569
|
+
s3SinVersionado,
|
|
15570
|
+
acmCertificadoCaduca,
|
|
15250
15571
|
rootSinMfa,
|
|
15251
15572
|
usuarioSinMfa,
|
|
15252
15573
|
claveAntigua,
|
|
@@ -15332,7 +15653,9 @@ var AZURE_NSG_CHECKS = {
|
|
|
15332
15653
|
var AZURE_STORAGE_CHECKS = {
|
|
15333
15654
|
list: "azure:storage:list",
|
|
15334
15655
|
// Solo de las cuentas que permiten blobs públicos: dice a quien aprueba cerrarlo qué contenedores dejan de servirse.
|
|
15335
|
-
containers: "azure:storage:containers"
|
|
15656
|
+
containers: "azure:storage:containers",
|
|
15657
|
+
// Propiedades del servicio de blobs de cada cuenta: borrado suave de blobs y de contenedores.
|
|
15658
|
+
blobService: "azure:storage:blobServices"
|
|
15336
15659
|
};
|
|
15337
15660
|
var AZURE_SQL_CHECKS = {
|
|
15338
15661
|
list: "azure:sql:list",
|
|
@@ -15391,6 +15714,42 @@ var vmSinCopia = {
|
|
|
15391
15714
|
// 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
15715
|
runtimeOnly: true
|
|
15393
15716
|
};
|
|
15717
|
+
function sqlCopiasLocalesEvaluate(observation) {
|
|
15718
|
+
const redundancia = observation.attributes.backupStorageRedundancy;
|
|
15719
|
+
if (typeof redundancia !== "string") return { status: "unknown", check: AZURE_SQL_CHECKS.databases, attribute: "backupStorageRedundancy" };
|
|
15720
|
+
if (redundancia.toLowerCase() !== "local") return { status: "ok" };
|
|
15721
|
+
return { status: "finding", evidence: { backupStorageRedundancy: redundancia } };
|
|
15722
|
+
}
|
|
15723
|
+
var sqlCopiasLocales = {
|
|
15724
|
+
id: "SEC_AZURE_BACKUP_SQL_COPIAS_LOCALES",
|
|
15725
|
+
scope: "resource",
|
|
15726
|
+
category: "security_backup",
|
|
15727
|
+
severity: "low",
|
|
15728
|
+
provider: "azure",
|
|
15729
|
+
kinds: ["sql_database"],
|
|
15730
|
+
requires: [AZURE_SQL_CHECKS.list, AZURE_SQL_CHECKS.databases],
|
|
15731
|
+
evaluate: sqlCopiasLocalesEvaluate,
|
|
15732
|
+
runtimeOnly: true
|
|
15733
|
+
};
|
|
15734
|
+
function blobSinBorradoSuaveEvaluate(observation) {
|
|
15735
|
+
if (observation.attributes.kind === "FileStorage") return { status: "ok" };
|
|
15736
|
+
if (observation.attributes.managedResourceGroup === true) return { status: "ok" };
|
|
15737
|
+
const suave = observation.attributes.blobSoftDelete;
|
|
15738
|
+
if (typeof suave !== "boolean") return { status: "unknown", check: AZURE_STORAGE_CHECKS.blobService, attribute: "blobSoftDelete" };
|
|
15739
|
+
if (suave) return { status: "ok" };
|
|
15740
|
+
return { status: "finding", evidence: { blobSoftDelete: false } };
|
|
15741
|
+
}
|
|
15742
|
+
var blobSinBorradoSuave = {
|
|
15743
|
+
id: "SEC_AZURE_RESILIENCE_BLOB_SIN_BORRADO_SUAVE",
|
|
15744
|
+
scope: "resource",
|
|
15745
|
+
category: "security_resilience",
|
|
15746
|
+
severity: "low",
|
|
15747
|
+
provider: "azure",
|
|
15748
|
+
kinds: ["storage_account"],
|
|
15749
|
+
requires: [AZURE_STORAGE_CHECKS.list, AZURE_STORAGE_CHECKS.blobService],
|
|
15750
|
+
evaluate: blobSinBorradoSuaveEvaluate,
|
|
15751
|
+
runtimeOnly: true
|
|
15752
|
+
};
|
|
15394
15753
|
|
|
15395
15754
|
// ../../services/security/src/rules/azure/encryption.ts
|
|
15396
15755
|
var TLS_DEBIL = /* @__PURE__ */ new Set(["tls1_0", "tls1.0", "1.0", "tls1_1", "tls1.1", "1.1"]);
|
|
@@ -15798,6 +16157,8 @@ var AZURE_SECURITY_RULES = [
|
|
|
15798
16157
|
keyVaultSinPurga,
|
|
15799
16158
|
sqlSinTde,
|
|
15800
16159
|
vmSinCopia,
|
|
16160
|
+
sqlCopiasLocales,
|
|
16161
|
+
blobSinBorradoSuave,
|
|
15801
16162
|
rolPrivilegiado,
|
|
15802
16163
|
asignacionHuerfana,
|
|
15803
16164
|
adminSinMfa,
|
|
@@ -15893,7 +16254,9 @@ var GCP_COMPUTE_CHECKS = {
|
|
|
15893
16254
|
regions: "gcp:compute:regions",
|
|
15894
16255
|
regionFirewallPolicies: "gcp:compute:regionNetworkFirewallPolicies",
|
|
15895
16256
|
sharedVpcHost: "gcp:compute:sharedVpcHostFirewalls",
|
|
15896
|
-
subnetworks: "gcp:compute:subnetworks"
|
|
16257
|
+
subnetworks: "gcp:compute:subnetworks",
|
|
16258
|
+
// Políticas de recursos del proyecto: distinguen una programación de snapshots de un grupo de consistencia.
|
|
16259
|
+
resourcePolicies: "gcp:compute:resourcePolicies"
|
|
15897
16260
|
};
|
|
15898
16261
|
var GCP_NETWORK_MANAGEMENT_CHECKS = {
|
|
15899
16262
|
vpcFlowLogsConfigs: "gcp:networkmanagement:vpcFlowLogsConfigs"
|
|
@@ -15930,11 +16293,15 @@ var GCP_LOGGING_CHECKS = {
|
|
|
15930
16293
|
var GCP_CIEM_WINDOW_DAYS = 90;
|
|
15931
16294
|
|
|
15932
16295
|
// ../../services/security/src/rules/gcp/backup.ts
|
|
16296
|
+
function interruptor(valor) {
|
|
16297
|
+
if (typeof valor === "boolean") return valor;
|
|
16298
|
+
return valor === null ? false : void 0;
|
|
16299
|
+
}
|
|
15933
16300
|
function sqlSinCopiasEvaluate(observation) {
|
|
15934
16301
|
const tipo = observation.attributes.instanceType;
|
|
15935
16302
|
if (typeof tipo === "string" && tipo !== "CLOUD_SQL_INSTANCE") return { status: "ok" };
|
|
15936
|
-
const activas = observation.attributes.backupEnabled;
|
|
15937
|
-
if (
|
|
16303
|
+
const activas = interruptor(observation.attributes.backupEnabled);
|
|
16304
|
+
if (activas === void 0) return { status: "unknown", check: GCP_SQL_CHECKS.instances, attribute: "backupEnabled" };
|
|
15938
16305
|
if (activas) return { status: "ok" };
|
|
15939
16306
|
return { status: "finding", evidence: { backupEnabled: false } };
|
|
15940
16307
|
}
|
|
@@ -16510,6 +16877,186 @@ var firewallBdAbierto = {
|
|
|
16510
16877
|
evaluate: (observation) => firewallAbierto(observation, databasePortsReached)
|
|
16511
16878
|
};
|
|
16512
16879
|
|
|
16880
|
+
// ../../services/security/src/rules/gcp/function-runtimes.ts
|
|
16881
|
+
var FUNCTION_RUNTIME_DEPRECATION = {
|
|
16882
|
+
nodejs24: "2028-04-30",
|
|
16883
|
+
nodejs22: "2027-04-30",
|
|
16884
|
+
nodejs20: "2026-04-30",
|
|
16885
|
+
nodejs18: "2025-04-30",
|
|
16886
|
+
nodejs16: "2024-01-30",
|
|
16887
|
+
nodejs14: "2024-01-30",
|
|
16888
|
+
nodejs12: "2024-01-30",
|
|
16889
|
+
nodejs10: "2024-01-30",
|
|
16890
|
+
nodejs8: "2020-06-05",
|
|
16891
|
+
nodejs6: "2019-04-17",
|
|
16892
|
+
python314: "2030-10-10",
|
|
16893
|
+
python313: "2029-10-10",
|
|
16894
|
+
python312: "2028-10-02",
|
|
16895
|
+
python311: "2027-10-24",
|
|
16896
|
+
python310: "2026-10-04",
|
|
16897
|
+
python39: "2025-10-05",
|
|
16898
|
+
python38: "2024-10-14",
|
|
16899
|
+
python37: "2024-01-30",
|
|
16900
|
+
go125: "2026-10-01",
|
|
16901
|
+
go124: "2026-09-02",
|
|
16902
|
+
go123: "2026-02-21",
|
|
16903
|
+
go122: "2026-01-28",
|
|
16904
|
+
go121: "2025-09-03",
|
|
16905
|
+
go120: "2024-05-01",
|
|
16906
|
+
go119: "2024-04-30",
|
|
16907
|
+
go118: "2024-01-30",
|
|
16908
|
+
go116: "2024-01-30",
|
|
16909
|
+
go113: "2024-01-30",
|
|
16910
|
+
go111: "2020-08-05",
|
|
16911
|
+
java11: "2024-10-31",
|
|
16912
|
+
ruby40: "2029-03-31",
|
|
16913
|
+
ruby34: "2028-03-31",
|
|
16914
|
+
ruby33: "2027-03-31",
|
|
16915
|
+
ruby32: "2026-03-31",
|
|
16916
|
+
ruby30: "2024-03-31",
|
|
16917
|
+
ruby27: "2024-01-30",
|
|
16918
|
+
ruby26: "2024-01-30",
|
|
16919
|
+
php85: "2029-12-31",
|
|
16920
|
+
php84: "2028-12-31",
|
|
16921
|
+
php83: "2027-12-31",
|
|
16922
|
+
php82: "2026-12-31",
|
|
16923
|
+
php81: "2025-12-31",
|
|
16924
|
+
php74: "2024-01-30",
|
|
16925
|
+
dotnet10: "2028-11-14",
|
|
16926
|
+
dotnet8: "2026-11-10",
|
|
16927
|
+
dotnet6: "2024-11-12",
|
|
16928
|
+
dotnet3: "2024-01-30"
|
|
16929
|
+
};
|
|
16930
|
+
|
|
16931
|
+
// ../../services/security/src/rules/gcp/resilience.ts
|
|
16932
|
+
var noEsPrincipal = (observation) => {
|
|
16933
|
+
const tipo = observation.attributes.instanceType;
|
|
16934
|
+
return typeof tipo === "string" && tipo !== "CLOUD_SQL_INSTANCE";
|
|
16935
|
+
};
|
|
16936
|
+
var sinDato = (attribute) => ({ status: "unknown", check: GCP_SQL_CHECKS.instances, attribute });
|
|
16937
|
+
function sqlSinAltaDisponibilidadEvaluate(observation) {
|
|
16938
|
+
if (noEsPrincipal(observation)) return { status: "ok" };
|
|
16939
|
+
const tipo = observation.attributes.availabilityType;
|
|
16940
|
+
if (typeof tipo !== "string") return sinDato("availabilityType");
|
|
16941
|
+
if (tipo === "REGIONAL") return { status: "ok" };
|
|
16942
|
+
return { status: "finding", evidence: { availabilityType: tipo } };
|
|
16943
|
+
}
|
|
16944
|
+
var sqlSinAltaDisponibilidad = {
|
|
16945
|
+
id: "SEC_GCP_RESILIENCE_SQL_SIN_ALTA_DISPONIBILIDAD",
|
|
16946
|
+
scope: "resource",
|
|
16947
|
+
category: "security_resilience",
|
|
16948
|
+
severity: "medium",
|
|
16949
|
+
provider: "gcp",
|
|
16950
|
+
kinds: ["cloud_sql_instance"],
|
|
16951
|
+
requires: [GCP_SQL_CHECKS.instances],
|
|
16952
|
+
evaluate: sqlSinAltaDisponibilidadEvaluate,
|
|
16953
|
+
// Se juzga en la cuenta: el adaptador de planes de Terraform aún no traduce la disponibilidad.
|
|
16954
|
+
runtimeOnly: true
|
|
16955
|
+
};
|
|
16956
|
+
function sqlSinProteccionBorradoEvaluate(observation) {
|
|
16957
|
+
if (observation.attributes.instanceType === "ON_PREMISES_INSTANCE") return { status: "ok" };
|
|
16958
|
+
const protegida = interruptor(observation.attributes.deletionProtection);
|
|
16959
|
+
if (protegida === void 0) return sinDato("deletionProtection");
|
|
16960
|
+
if (protegida) return { status: "ok" };
|
|
16961
|
+
return { status: "finding", evidence: { deletionProtection: false } };
|
|
16962
|
+
}
|
|
16963
|
+
var sqlSinProteccionBorrado = {
|
|
16964
|
+
id: "SEC_GCP_RESILIENCE_SQL_SIN_PROTECCION_BORRADO",
|
|
16965
|
+
scope: "resource",
|
|
16966
|
+
category: "security_resilience",
|
|
16967
|
+
severity: "low",
|
|
16968
|
+
provider: "gcp",
|
|
16969
|
+
kinds: ["cloud_sql_instance"],
|
|
16970
|
+
requires: [GCP_SQL_CHECKS.instances],
|
|
16971
|
+
evaluate: sqlSinProteccionBorradoEvaluate,
|
|
16972
|
+
runtimeOnly: true
|
|
16973
|
+
};
|
|
16974
|
+
function sqlSinRecuperacionPuntualEvaluate(observation) {
|
|
16975
|
+
if (noEsPrincipal(observation)) return { status: "ok" };
|
|
16976
|
+
const copias = interruptor(observation.attributes.backupEnabled);
|
|
16977
|
+
if (copias === void 0) return sinDato("backupEnabled");
|
|
16978
|
+
if (!copias) return { status: "ok" };
|
|
16979
|
+
const version2 = observation.attributes.databaseVersion;
|
|
16980
|
+
if (typeof version2 !== "string") return sinDato("databaseVersion");
|
|
16981
|
+
const attribute = version2.startsWith("MYSQL") ? "binaryLogEnabled" : "pointInTimeRecoveryEnabled";
|
|
16982
|
+
const activa = interruptor(observation.attributes[attribute]);
|
|
16983
|
+
if (activa === void 0) return sinDato(attribute);
|
|
16984
|
+
if (activa) return { status: "ok" };
|
|
16985
|
+
return { status: "finding", evidence: { [attribute]: false, databaseVersion: version2 } };
|
|
16986
|
+
}
|
|
16987
|
+
var sqlSinRecuperacionPuntual = {
|
|
16988
|
+
id: "SEC_GCP_BACKUP_SQL_SIN_RECUPERACION_PUNTUAL",
|
|
16989
|
+
scope: "resource",
|
|
16990
|
+
category: "security_backup",
|
|
16991
|
+
severity: "medium",
|
|
16992
|
+
provider: "gcp",
|
|
16993
|
+
kinds: ["cloud_sql_instance"],
|
|
16994
|
+
requires: [GCP_SQL_CHECKS.instances],
|
|
16995
|
+
evaluate: sqlSinRecuperacionPuntualEvaluate,
|
|
16996
|
+
runtimeOnly: true
|
|
16997
|
+
};
|
|
16998
|
+
function functionRuntimeRetiradoEvaluate(observation) {
|
|
16999
|
+
const runtime = observation.attributes.runtime;
|
|
17000
|
+
if (typeof runtime !== "string") return { status: "unknown", check: GCP_FUNCTIONS_CHECKS.list, attribute: "runtime" };
|
|
17001
|
+
const retirada = runtimeRetirement(FUNCTION_RUNTIME_DEPRECATION, runtime, Date.now());
|
|
17002
|
+
return retirada ? { status: "finding", evidence: retirada } : { status: "ok" };
|
|
17003
|
+
}
|
|
17004
|
+
var functionRuntimeRetirado = {
|
|
17005
|
+
id: "SEC_GCP_RESILIENCE_FUNCTION_RUNTIME_RETIRADO",
|
|
17006
|
+
scope: "resource",
|
|
17007
|
+
category: "security_resilience",
|
|
17008
|
+
severity: "medium",
|
|
17009
|
+
provider: "gcp",
|
|
17010
|
+
kinds: ["cloud_function"],
|
|
17011
|
+
requires: [GCP_FUNCTIONS_CHECKS.list],
|
|
17012
|
+
evaluate: functionRuntimeRetiradoEvaluate,
|
|
17013
|
+
// El veredicto depende de la fecha del escaneo y el adaptador de planes no trae el runtime.
|
|
17014
|
+
runtimeOnly: true
|
|
17015
|
+
};
|
|
17016
|
+
function gcsSinVersionadoEvaluate(observation) {
|
|
17017
|
+
const versionado = observation.attributes.versioning;
|
|
17018
|
+
if (versionado === void 0) return { status: "unknown", check: GCP_STORAGE_CHECKS.buckets, attribute: "versioning" };
|
|
17019
|
+
if (versionado === true) return { status: "ok" };
|
|
17020
|
+
const suave = observation.attributes.softDeleteSeconds;
|
|
17021
|
+
if (typeof suave !== "number") return { status: "unknown", check: GCP_STORAGE_CHECKS.buckets, attribute: "softDeleteSeconds" };
|
|
17022
|
+
if (suave > 0) return { status: "ok" };
|
|
17023
|
+
return { status: "finding", evidence: { versioning: versionado === false ? "disabled" : "never", softDeleteSeconds: 0 } };
|
|
17024
|
+
}
|
|
17025
|
+
var gcsSinVersionado = {
|
|
17026
|
+
id: "SEC_GCP_RESILIENCE_GCS_SIN_VERSIONADO",
|
|
17027
|
+
scope: "resource",
|
|
17028
|
+
category: "security_resilience",
|
|
17029
|
+
severity: "low",
|
|
17030
|
+
provider: "gcp",
|
|
17031
|
+
kinds: ["gcs_bucket"],
|
|
17032
|
+
requires: [GCP_STORAGE_CHECKS.buckets],
|
|
17033
|
+
evaluate: gcsSinVersionadoEvaluate,
|
|
17034
|
+
runtimeOnly: true
|
|
17035
|
+
};
|
|
17036
|
+
function discoSinSnapshotsEvaluate(observation) {
|
|
17037
|
+
const estado = observation.attributes.status;
|
|
17038
|
+
if (typeof estado === "string" && ["FAILED", "DELETING"].includes(estado)) return { status: "ok" };
|
|
17039
|
+
const programado = observation.attributes.snapshotSchedule;
|
|
17040
|
+
if (programado === true) return { status: "ok" };
|
|
17041
|
+
const arranque = typeof observation.attributes.boot === "boolean" ? observation.attributes.boot : observation.attributes.fromImage === true ? true : void 0;
|
|
17042
|
+
if (arranque === void 0) return { status: "unknown", check: GCP_COMPUTE_CHECKS.disks, attribute: "boot" };
|
|
17043
|
+
if (arranque) return { status: "ok" };
|
|
17044
|
+
if (programado !== false) return { status: "unknown", check: GCP_COMPUTE_CHECKS.resourcePolicies, attribute: "snapshotSchedule" };
|
|
17045
|
+
return { status: "finding", evidence: { snapshotSchedule: false } };
|
|
17046
|
+
}
|
|
17047
|
+
var discoSinSnapshots = {
|
|
17048
|
+
id: "SEC_GCP_BACKUP_DISCO_SIN_SNAPSHOTS",
|
|
17049
|
+
scope: "resource",
|
|
17050
|
+
category: "security_backup",
|
|
17051
|
+
severity: "low",
|
|
17052
|
+
provider: "gcp",
|
|
17053
|
+
kinds: ["persistent_disk"],
|
|
17054
|
+
// Sin la lista de instancias se decide por la imagen de origen: no se exige, para que su fallo no ciegue la categoría.
|
|
17055
|
+
requires: [GCP_COMPUTE_CHECKS.disks, GCP_COMPUTE_CHECKS.resourcePolicies],
|
|
17056
|
+
evaluate: discoSinSnapshotsEvaluate,
|
|
17057
|
+
runtimeOnly: true
|
|
17058
|
+
};
|
|
17059
|
+
|
|
16513
17060
|
// ../../services/security/src/rules/gcp/secrets.ts
|
|
16514
17061
|
var SOSPECHOSAS2 = ["PASSWORD", "PASSWD", "SECRET", "TOKEN", "APIKEY", "API_KEY", "PRIVATE_KEY", "CREDENTIAL"];
|
|
16515
17062
|
var REFERENCIAS2 = ["_ARN", "_NAME", "_ID", "_PATH", "_URL", "_URI", "_TABLE", "_BUCKET"];
|
|
@@ -16551,6 +17098,12 @@ var GCP_SECURITY_RULES = [
|
|
|
16551
17098
|
sqlSinCmek,
|
|
16552
17099
|
sqlSinSsl,
|
|
16553
17100
|
sqlSinCopias,
|
|
17101
|
+
sqlSinRecuperacionPuntual,
|
|
17102
|
+
sqlSinAltaDisponibilidad,
|
|
17103
|
+
sqlSinProteccionBorrado,
|
|
17104
|
+
functionRuntimeRetirado,
|
|
17105
|
+
gcsSinVersionado,
|
|
17106
|
+
discoSinSnapshots,
|
|
16554
17107
|
kmsSinRotacion2,
|
|
16555
17108
|
secretoEnFunction,
|
|
16556
17109
|
rolPrimitivo,
|
|
@@ -16856,7 +17409,7 @@ async function runIacCost(planJson, config2) {
|
|
|
16856
17409
|
failed: true,
|
|
16857
17410
|
markdown: null,
|
|
16858
17411
|
estimate: null,
|
|
16859
|
-
warning: `Cost estimate unavailable, continuing without blocking the build: ${error2
|
|
17412
|
+
warning: `Cost estimate unavailable, continuing without blocking the build: ${describeApiError(error2, COST_ACCESS)}`
|
|
16860
17413
|
};
|
|
16861
17414
|
}
|
|
16862
17415
|
}
|
|
@@ -16869,13 +17422,21 @@ function decodePlan(bytes) {
|
|
|
16869
17422
|
if (bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191) return bytes.subarray(3).toString("utf-8");
|
|
16870
17423
|
return bytes.toString("utf-8");
|
|
16871
17424
|
}
|
|
16872
|
-
var fmtUsd2 = (n) => `${n < 0 ? "-" : "+"}$${Math.abs(n).toFixed(2)}/mo`;
|
|
16873
17425
|
function costText(estimate) {
|
|
16874
17426
|
const { coverage } = estimate;
|
|
16875
|
-
const
|
|
17427
|
+
const usd = estimate.totalMonthlyDeltaUsd;
|
|
17428
|
+
const display = orgCurrency(estimate);
|
|
17429
|
+
let total2;
|
|
17430
|
+
if (usd === null) total2 = "no total (coverage too low)";
|
|
17431
|
+
else if (display && typeof estimate.totalMonthlyDelta === "number") {
|
|
17432
|
+
const rate = `ECB rate${display.rateDate ? ` of ${display.rateDate}` : ""}, 1 USD = ${display.rate} ${display.code}`;
|
|
17433
|
+
total2 = `${fmtConverted(estimate.totalMonthlyDelta, display.code)} (approximate: list price converted from ${fmtUsd(usd)} in USD at the ${rate})`;
|
|
17434
|
+
} else total2 = `${fmtUsd(usd)} (list price, USD)`;
|
|
17435
|
+
const partial2 = partialTotalLabel(estimate);
|
|
16876
17436
|
return [
|
|
16877
17437
|
"Cost",
|
|
16878
17438
|
` Estimated change: ${total2}`,
|
|
17439
|
+
...partial2 ? [` Total is ${partial2}: the real change can differ`] : [],
|
|
16879
17440
|
` Coverage: ${coverage.pricedResources} of ${coverage.pricedResources + coverage.unpricedResources} billable resources priced`
|
|
16880
17441
|
].join("\n");
|
|
16881
17442
|
}
|
|
@@ -16935,7 +17496,7 @@ async function runCli(options, readPlan, credentials) {
|
|
|
16935
17496
|
});
|
|
16936
17497
|
report.drift = compareDrift(evaluation.verdicts, live, options.driftAccount);
|
|
16937
17498
|
} catch (error2) {
|
|
16938
|
-
warnings.push(`Drift check unavailable, continuing: ${error2
|
|
17499
|
+
warnings.push(`Drift check unavailable, continuing: ${describeApiError(error2, DRIFT_ACCESS)}`);
|
|
16939
17500
|
}
|
|
16940
17501
|
}
|
|
16941
17502
|
}
|
|
@@ -16964,7 +17525,7 @@ async function runCli(options, readPlan, credentials) {
|
|
|
16964
17525
|
);
|
|
16965
17526
|
if (evaluateBudgetGate(budgets, mode).blocks) exitCode = 1;
|
|
16966
17527
|
} catch (error2) {
|
|
16967
|
-
warnings.push(`Budget check unavailable: ${error2
|
|
17528
|
+
warnings.push(`Budget check unavailable: ${describeApiError(error2, BUDGET_ACCESS)}`);
|
|
16968
17529
|
gateUnavailable = true;
|
|
16969
17530
|
}
|
|
16970
17531
|
}
|
|
@@ -16972,7 +17533,7 @@ async function runCli(options, readPlan, credentials) {
|
|
|
16972
17533
|
if (exitCode === 0 && gateUnavailable) exitCode = 2;
|
|
16973
17534
|
if (options.format === "json") {
|
|
16974
17535
|
return {
|
|
16975
|
-
stdout: JSON.stringify({ formatVersion: "1", cost: estimate, security: report, ...options.failOnBudget ? { budgets } : {}, warnings }, null, 2),
|
|
17536
|
+
stdout: JSON.stringify({ formatVersion: "1", cost: estimate ? { ...estimate, totalIsPartial: isPartialTotal(estimate) } : null, security: report, ...options.failOnBudget ? { budgets } : {}, warnings }, null, 2),
|
|
16976
17537
|
warnings,
|
|
16977
17538
|
exitCode
|
|
16978
17539
|
};
|
|
@@ -17625,7 +18186,7 @@ ${OWNERS_USAGE}`], exitCode: 2 });
|
|
|
17625
18186
|
try {
|
|
17626
18187
|
token = await fetchToken(config2, SCOPE5);
|
|
17627
18188
|
} catch (error2) {
|
|
17628
|
-
errors.push(`could not get a token with the owners:write scope: ${error2
|
|
18189
|
+
errors.push(`could not get a token with the owners:write scope: ${describeApiError(error2, OWNERS_ACCESS)}`);
|
|
17629
18190
|
}
|
|
17630
18191
|
if (token) {
|
|
17631
18192
|
for (const p of prepared) {
|
|
@@ -17637,7 +18198,7 @@ ${OWNERS_USAGE}`], exitCode: 2 });
|
|
|
17637
18198
|
try {
|
|
17638
18199
|
results.push({ request: p.request, result: await syncOwners(config2, p.request, token) });
|
|
17639
18200
|
} catch (error2) {
|
|
17640
|
-
errors.push(`${p.request.source.kind}: ${error2
|
|
18201
|
+
errors.push(`${p.request.source.kind}: ${describeApiError(error2, OWNERS_ACCESS)}`);
|
|
17641
18202
|
}
|
|
17642
18203
|
}
|
|
17643
18204
|
}
|
|
@@ -17798,7 +18359,7 @@ ${POSTURE_USAGE}`);
|
|
|
17798
18359
|
} catch (error2) {
|
|
17799
18360
|
const mensaje = error2.message;
|
|
17800
18361
|
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: ${
|
|
18362
|
+
return { stdout: null, warnings: [...warnings, `could not read the posture history, skipping: ${describeApiError(error2, DRIFT_ACCESS)}`], exitCode: 0 };
|
|
17802
18363
|
}
|
|
17803
18364
|
if (history.access !== "full") {
|
|
17804
18365
|
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.1",
|
|
4
4
|
"description": "Estimate the monthly cost delta of a Terraform plan, check it against the AAA Sentinel security rules, open security fixes as pull requests and report how the security posture changed, from your CI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|