@aaa-sentinel/iac-cost 0.6.1 → 0.7.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 +7 -3
- package/dist/cli.js +194 -19
- package/package.json +43 -43
package/README.md
CHANGED
|
@@ -7,7 +7,11 @@ 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
|
-
> **
|
|
10
|
+
> **New in 0.7.0:** the plan check flags RDS and Aurora instances with `auto_minor_version_upgrade = false`
|
|
11
|
+
> (CIS AWS 2.3.2; RDS Custom is skipped), and `iac-cost fix` turns it back on. Security findings have a
|
|
12
|
+
> seventh category, `security_patching`.
|
|
13
|
+
|
|
14
|
+
> **Changed in 0.6.1:** `fix` says when the risk and compliance add-on is not active on the account, names the
|
|
11
15
|
> fixes whose pull or merge request was closed without merging (they are not reopened), and says
|
|
12
16
|
> "merge request" on GitLab. The fix jobs below no longer end in `|| true` or `continue-on-error`, so a
|
|
13
17
|
> setup error (exit code 2) fails the job instead of passing unseen. Rejected OAuth app credentials
|
|
@@ -56,7 +60,7 @@ console changes (see [Fixes as pull requests](#fixes-as-pull-requests)).
|
|
|
56
60
|
estimate needs a **Pro** or **Business** plan.
|
|
57
61
|
- For the optional **drift check**, a second application with `security:read` and the security
|
|
58
62
|
add-on on the account (see [Drift](#drift-plan-vs-cloud)).
|
|
59
|
-
- For **`iac-cost fix`**, an application with the `security:fix` scope, the
|
|
63
|
+
- For **`iac-cost fix`**, an application with the `security:fix` scope, the risk and compliance add-on on the
|
|
60
64
|
account, and a CI token that can push a branch and open a pull request (see
|
|
61
65
|
[Fixes as pull requests](#fixes-as-pull-requests)).
|
|
62
66
|
- On **GitLab**, a project access token of your own for the note or the merge request: the job
|
|
@@ -299,7 +303,7 @@ or an RDS instance is only matched when the region of the plan resource is known
|
|
|
299
303
|
their names are unique only within a region.
|
|
300
304
|
|
|
301
305
|
It needs a **separate** OAuth2 application with the `security:read` scope, in
|
|
302
|
-
`IAC_SECURITY_CLIENT_ID` / `IAC_SECURITY_CLIENT_SECRET`, and the
|
|
306
|
+
`IAC_SECURITY_CLIENT_ID` / `IAC_SECURITY_CLIENT_SECRET`, and the risk and compliance add-on on that account.
|
|
303
307
|
Keep `iac:estimate` and `security:read` in two applications: the first one is safe in a CI that
|
|
304
308
|
third parties can trigger, the second one reads your findings.
|
|
305
309
|
|
package/dist/cli.js
CHANGED
|
@@ -8170,6 +8170,7 @@ function rdsInstances(index) {
|
|
|
8170
8170
|
const builder = new ObservationBuilder(index, db, "rds_instance", "aws").cloudId("identifier");
|
|
8171
8171
|
builder.from("engine", index.get(db, "engine"), String, null);
|
|
8172
8172
|
builder.from("publiclyAccessible", index.get(db, "publicly_accessible"), Boolean, false);
|
|
8173
|
+
builder.from("autoMinorVersionUpgrade", index.get(db, "auto_minor_version_upgrade"), Boolean, true);
|
|
8173
8174
|
if (db.type === "aws_rds_cluster_instance") {
|
|
8174
8175
|
const cluster = index.parentOf(db, "cluster_identifier", ["aws_rds_cluster"], "cluster_identifier");
|
|
8175
8176
|
const clusterId = index.get(db, "cluster_identifier");
|
|
@@ -8657,6 +8658,7 @@ var RULE_TITLES = {
|
|
|
8657
8658
|
SEC_AWS_IAM_POLITICA_CONTRASENAS: "Weak or missing IAM password policy",
|
|
8658
8659
|
SEC_AWS_ENCRYPTION_KMS_SIN_ROTACION: "KMS key without rotation",
|
|
8659
8660
|
SEC_AWS_ENCRYPTION_RDS_SIN_CIFRAR: "Unencrypted RDS",
|
|
8661
|
+
SEC_AWS_PATCHING_RDS_SIN_ACTUALIZACION_MENOR: "RDS without automatic minor version upgrade",
|
|
8660
8662
|
SEC_AWS_LOGGING_TRAIL_PARADO: "CloudTrail stopped",
|
|
8661
8663
|
SEC_AWS_LOGGING_TRAIL_GESTION_INCOMPLETA: "CloudTrail skips some management events",
|
|
8662
8664
|
SEC_AWS_LOGGING_VPC_SIN_FLOW_LOGS: "VPC without flow logs",
|
|
@@ -9004,6 +9006,14 @@ function kmsRotation(ctx, builder) {
|
|
|
9004
9006
|
throw new FixedInCode(where.file, "enable_key_rotation");
|
|
9005
9007
|
}
|
|
9006
9008
|
}
|
|
9009
|
+
function rdsAutoMinor(ctx, builder) {
|
|
9010
|
+
const where = located(ctx, ctx.anchor);
|
|
9011
|
+
const items = body(where.text, where.block);
|
|
9012
|
+
if (setLiteral(builder, where, items, "auto_minor_version_upgrade", "true", (l) => l?.kind === "bool" && l.value) === "already") {
|
|
9013
|
+
throw new FixedInCode(where.file, "auto_minor_version_upgrade");
|
|
9014
|
+
}
|
|
9015
|
+
builder.changes.push("note: RDS may apply a pending minor version upgrade in the next maintenance window, which restarts the instance");
|
|
9016
|
+
}
|
|
9007
9017
|
function lambdaUrl(ctx, builder) {
|
|
9008
9018
|
const { index, anchor: anchor2 } = ctx;
|
|
9009
9019
|
const urls = index.ofType("aws_lambda_function_url").filter((url) => index.parentOf(url, "function_name", ["aws_lambda_function"], "function_name", lambdaName) === anchor2).filter((url) => {
|
|
@@ -9058,6 +9068,7 @@ var FIXERS = {
|
|
|
9058
9068
|
SEC_AWS_NETWORK_ADMIN_ABIERTO: { types: ["aws_security_group", "aws_default_security_group"], fix: awsAdminOpen },
|
|
9059
9069
|
SEC_AWS_EXPOSURE_S3_PUBLICO: { types: ["aws_s3_bucket"], fix: s3PublicAccess },
|
|
9060
9070
|
SEC_AWS_ENCRYPTION_KMS_SIN_ROTACION: { types: ["aws_kms_key"], fix: kmsRotation },
|
|
9071
|
+
SEC_AWS_PATCHING_RDS_SIN_ACTUALIZACION_MENOR: { types: ["aws_db_instance", "aws_rds_cluster_instance"], fix: rdsAutoMinor },
|
|
9061
9072
|
SEC_AWS_EXPOSURE_LAMBDA_PUBLICA: { types: ["aws_lambda_function"], fix: lambdaUrl },
|
|
9062
9073
|
SEC_AZURE_EXPOSURE_BLOB_PUBLICO: { types: ["azurerm_storage_account"], fix: azureBlobPublic },
|
|
9063
9074
|
SEC_AZURE_ENCRYPTION_STORAGE_TLS: { types: ["azurerm_storage_account"], fix: azureStorageTls },
|
|
@@ -9177,10 +9188,10 @@ function loadFailure(error2, accountId) {
|
|
|
9177
9188
|
return { message: `${detail} (${tag})`, setup: true };
|
|
9178
9189
|
}
|
|
9179
9190
|
if (code2 === "SECURITY_ADDON_INACTIVE") {
|
|
9180
|
-
return { message: `the
|
|
9191
|
+
return { message: `the risk and compliance add-on is not active on account ${accountId} (402 SECURITY_ADDON_INACTIVE): activate it in AAA Sentinel to get fixes; nothing to fix`, setup: false };
|
|
9181
9192
|
}
|
|
9182
9193
|
if (code2 === "PLAN_SECURITY_ADDON") {
|
|
9183
|
-
return { message: `the plan of this organization does not include the
|
|
9194
|
+
return { message: `the plan of this organization does not include the risk and compliance add-on (402 PLAN_SECURITY_ADDON): fixes need the Pro or Business plan with the add-on; nothing to fix`, setup: false };
|
|
9184
9195
|
}
|
|
9185
9196
|
return { message: `could not read the open findings, nothing to fix: ${error2.message}`, setup: false };
|
|
9186
9197
|
}
|
|
@@ -9669,7 +9680,7 @@ ${POSTURE_USAGE}`);
|
|
|
9669
9680
|
return { stdout: null, warnings: [...warnings, `could not read the posture history, skipping: ${mensaje}`], exitCode: 0 };
|
|
9670
9681
|
}
|
|
9671
9682
|
if (history.access !== "full") {
|
|
9672
|
-
return { stdout: null, warnings: [...warnings, "the account does not have the
|
|
9683
|
+
return { stdout: null, warnings: [...warnings, "the account does not have the risk and compliance add-on: no posture history to show"], exitCode: 0 };
|
|
9673
9684
|
}
|
|
9674
9685
|
const nuevos = gate ? newAtOrAbove(history.summary, gate) : 0;
|
|
9675
9686
|
const stdout = format === "json" ? JSON.stringify(history, null, 2) : renderPosture(history, format);
|
|
@@ -9932,6 +9943,23 @@ function costEvidence(input, signal, options) {
|
|
|
9932
9943
|
...options.amount ? { monthlySavingsUsd: signal.monthlySavingsUsd } : {}
|
|
9933
9944
|
};
|
|
9934
9945
|
}
|
|
9946
|
+
function withCostSignal(input, options) {
|
|
9947
|
+
const senales = new Map(costSignalsOf(input, options.costRule).map((s) => [options.signalKey(s), s]));
|
|
9948
|
+
if (senales.size === 0) return [];
|
|
9949
|
+
return input.findings.filter((f) => f.ruleId === options.rule).flatMap((f) => {
|
|
9950
|
+
const coste = senales.get(options.findingKey(f));
|
|
9951
|
+
if (!coste) return [];
|
|
9952
|
+
return [
|
|
9953
|
+
{
|
|
9954
|
+
region: f.region,
|
|
9955
|
+
resourceId: f.resourceId,
|
|
9956
|
+
resourceName: f.resourceName,
|
|
9957
|
+
findingIds: [f.id],
|
|
9958
|
+
evidence: costEvidence(input, coste, { amount: options.amount })
|
|
9959
|
+
}
|
|
9960
|
+
];
|
|
9961
|
+
});
|
|
9962
|
+
}
|
|
9935
9963
|
var indices = /* @__PURE__ */ new WeakMap();
|
|
9936
9964
|
function observationOf(input, kind, region, id) {
|
|
9937
9965
|
let indice = indices.get(input.observations);
|
|
@@ -9978,11 +10006,18 @@ function lambdaRef(resourceId, region) {
|
|
|
9978
10006
|
}
|
|
9979
10007
|
return `${region}::${resourceId}`;
|
|
9980
10008
|
}
|
|
10009
|
+
var LAMBDA_SIN_USO = {
|
|
10010
|
+
costRule: "SERVERLESS_UNUSED_LAMBDA",
|
|
10011
|
+
findingKey: (f) => lambdaRef(f.resourceId, f.region),
|
|
10012
|
+
signalKey: (s) => lambdaRef(s.resourceId, s.region),
|
|
10013
|
+
amount: false
|
|
10014
|
+
};
|
|
9981
10015
|
var AWS_SECURITY_COMBOS = [
|
|
9982
10016
|
{
|
|
9983
10017
|
// Cualquiera puede invocarla y lleva credenciales en su configuración: un fallo de la función las expone.
|
|
9984
10018
|
id: "COMBO_AWS_PUBLIC_FUNCTION_SECRETS",
|
|
9985
10019
|
provider: "aws",
|
|
10020
|
+
resourceKind: "lambda_function",
|
|
9986
10021
|
severity: "critical",
|
|
9987
10022
|
rules: ["SEC_AWS_EXPOSURE_LAMBDA_PUBLICA", "SEC_AWS_SECRETS_LAMBDA_ENV"],
|
|
9988
10023
|
detect: (input) => sameResource(input, "SEC_AWS_EXPOSURE_LAMBDA_PUBLICA", "SEC_AWS_SECRETS_LAMBDA_ENV")
|
|
@@ -9991,23 +10026,83 @@ var AWS_SECURITY_COMBOS = [
|
|
|
9991
10026
|
// Cualquiera puede invocarla y nadie la ha invocado en 30 días: superficie de ataque que no da servicio a nadie.
|
|
9992
10027
|
id: "COMBO_AWS_PUBLIC_FUNCTION_UNUSED",
|
|
9993
10028
|
provider: "aws",
|
|
10029
|
+
resourceKind: "lambda_function",
|
|
9994
10030
|
severity: "high",
|
|
9995
10031
|
rules: ["SEC_AWS_EXPOSURE_LAMBDA_PUBLICA"],
|
|
9996
10032
|
costRules: ["SERVERLESS_UNUSED_LAMBDA"],
|
|
10033
|
+
detect: (input) => withCostSignal(input, { rule: "SEC_AWS_EXPOSURE_LAMBDA_PUBLICA", ...LAMBDA_SIN_USO })
|
|
10034
|
+
},
|
|
10035
|
+
{
|
|
10036
|
+
// Guarda credenciales en su configuración y nadie la invoca: se borra y se rotan las credenciales.
|
|
10037
|
+
id: "COMBO_AWS_UNUSED_FUNCTION_SECRETS",
|
|
10038
|
+
provider: "aws",
|
|
10039
|
+
resourceKind: "lambda_function",
|
|
10040
|
+
severity: "high",
|
|
10041
|
+
rules: ["SEC_AWS_SECRETS_LAMBDA_ENV"],
|
|
10042
|
+
costRules: ["SERVERLESS_UNUSED_LAMBDA"],
|
|
9997
10043
|
detect: (input) => {
|
|
9998
|
-
const
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
if (!coste) return [];
|
|
10003
|
-
return [{ region: f.region, resourceId: f.resourceId, resourceName: f.resourceName, findingIds: [f.id], evidence: costEvidence(input, coste, { amount: false }) }];
|
|
10004
|
-
});
|
|
10044
|
+
const publicas = findingsByResource(input.findings, "SEC_AWS_EXPOSURE_LAMBDA_PUBLICA");
|
|
10045
|
+
return withCostSignal(input, { rule: "SEC_AWS_SECRETS_LAMBDA_ENV", ...LAMBDA_SIN_USO }).filter(
|
|
10046
|
+
(m) => !publicas.has(`${m.region}::${m.resourceId}`)
|
|
10047
|
+
);
|
|
10005
10048
|
}
|
|
10006
10049
|
},
|
|
10050
|
+
{
|
|
10051
|
+
// Cualquiera puede copiarlo y su volumen de origen ya no existe; se sigue pagando cada mes.
|
|
10052
|
+
id: "COMBO_AWS_PUBLIC_SNAPSHOT_ORPHAN",
|
|
10053
|
+
provider: "aws",
|
|
10054
|
+
resourceKind: "ebs_snapshot",
|
|
10055
|
+
severity: "critical",
|
|
10056
|
+
rules: ["SEC_AWS_EXPOSURE_EBS_SNAPSHOT_PUBLICO"],
|
|
10057
|
+
costRules: ["STORAGE_ORPHAN_SNAPSHOT"],
|
|
10058
|
+
detect: (input) => withCostSignal(input, {
|
|
10059
|
+
rule: "SEC_AWS_EXPOSURE_EBS_SNAPSHOT_PUBLICO",
|
|
10060
|
+
costRule: "STORAGE_ORPHAN_SNAPSHOT",
|
|
10061
|
+
// Los dos módulos usan el id del snapshot (snap-…) y la región.
|
|
10062
|
+
findingKey: (f) => `${f.region}::${f.resourceId}`,
|
|
10063
|
+
signalKey: (s) => `${s.region}::${s.resourceId}`,
|
|
10064
|
+
amount: true
|
|
10065
|
+
})
|
|
10066
|
+
},
|
|
10067
|
+
{
|
|
10068
|
+
// Endpoint público y una semana sin conexiones: se paga por una puerta abierta que nadie usa.
|
|
10069
|
+
id: "COMBO_AWS_PUBLIC_DB_IDLE",
|
|
10070
|
+
provider: "aws",
|
|
10071
|
+
resourceKind: "rds_instance",
|
|
10072
|
+
severity: "high",
|
|
10073
|
+
rules: ["SEC_AWS_EXPOSURE_RDS_PUBLICA"],
|
|
10074
|
+
costRules: ["DATABASE_ZERO_CONN_RDS"],
|
|
10075
|
+
detect: (input) => withCostSignal(input, {
|
|
10076
|
+
rule: "SEC_AWS_EXPOSURE_RDS_PUBLICA",
|
|
10077
|
+
costRule: "DATABASE_ZERO_CONN_RDS",
|
|
10078
|
+
// Los dos módulos usan el DBInstanceIdentifier, único por región.
|
|
10079
|
+
findingKey: (f) => `${f.region}::${f.resourceId}`,
|
|
10080
|
+
signalKey: (s) => `${s.region}::${s.resourceId}`,
|
|
10081
|
+
amount: true
|
|
10082
|
+
})
|
|
10083
|
+
},
|
|
10084
|
+
{
|
|
10085
|
+
// Se paga el soporte extendido para recibir parches y no se aplican solos. Medium: no afirma ninguna vulnerabilidad.
|
|
10086
|
+
id: "COMBO_AWS_RDS_EXTENDED_NO_AUTO_MINOR",
|
|
10087
|
+
provider: "aws",
|
|
10088
|
+
resourceKind: "rds_instance",
|
|
10089
|
+
severity: "medium",
|
|
10090
|
+
rules: ["SEC_AWS_PATCHING_RDS_SIN_ACTUALIZACION_MENOR"],
|
|
10091
|
+
costRules: ["DATABASE_RDS_EXTENDED_SUPPORT"],
|
|
10092
|
+
detect: (input) => withCostSignal(input, {
|
|
10093
|
+
rule: "SEC_AWS_PATCHING_RDS_SIN_ACTUALIZACION_MENOR",
|
|
10094
|
+
costRule: "DATABASE_RDS_EXTENDED_SUPPORT",
|
|
10095
|
+
findingKey: (f) => `${f.region}::${f.resourceId}`,
|
|
10096
|
+
signalKey: (s) => `${s.region}::${s.resourceId}`,
|
|
10097
|
+
amount: true
|
|
10098
|
+
// El aviso de «entra en soporte extendido en ≤60 días» lleva importe 0: aún no se paga nada.
|
|
10099
|
+
}).filter((m) => typeof m.evidence["monthlySavingsUsd"] === "number" && m.evidence["monthlySavingsUsd"] > 0)
|
|
10100
|
+
},
|
|
10007
10101
|
{
|
|
10008
10102
|
// Dos defensas que faltan a la vez: endpoint público (PubliclyAccessible) y datos sin cifrar en disco. No prueba la ruta de red completa.
|
|
10009
10103
|
id: "COMBO_AWS_PUBLIC_DB_UNENCRYPTED",
|
|
10010
10104
|
provider: "aws",
|
|
10105
|
+
resourceKind: "rds_instance",
|
|
10011
10106
|
severity: "critical",
|
|
10012
10107
|
rules: ["SEC_AWS_ENCRYPTION_RDS_SIN_CIFRAR", "SEC_AWS_EXPOSURE_RDS_PUBLICA"],
|
|
10013
10108
|
detect: (input) => sameResource(input, "SEC_AWS_ENCRYPTION_RDS_SIN_CIFRAR", "SEC_AWS_EXPOSURE_RDS_PUBLICA").map((m) => ({ ...m, evidence: { publiclyAccessible: true } }))
|
|
@@ -10016,6 +10111,7 @@ var AWS_SECURITY_COMBOS = [
|
|
|
10016
10111
|
// Entra a la consola solo con contraseña y además tiene una clave de acceso vieja y activa: dos puertas sin segundo factor.
|
|
10017
10112
|
id: "COMBO_AWS_USER_NO_MFA_OLD_KEY",
|
|
10018
10113
|
provider: "aws",
|
|
10114
|
+
resourceKind: "iam_user",
|
|
10019
10115
|
severity: "critical",
|
|
10020
10116
|
rules: ["SEC_AWS_IAM_USUARIO_SIN_MFA", "SEC_AWS_IAM_CLAVE_ANTIGUA"],
|
|
10021
10117
|
detect: (input) => {
|
|
@@ -10040,6 +10136,7 @@ var AWS_SECURITY_COMBOS = [
|
|
|
10040
10136
|
// Administrador efectivo, consola sin MFA y una clave activa que nadie usa: tres puertas a toda la cuenta y nadie mirando una de ellas.
|
|
10041
10137
|
id: "COMBO_AWS_ADMIN_NO_MFA_UNUSED_KEY",
|
|
10042
10138
|
provider: "aws",
|
|
10139
|
+
resourceKind: "iam_user",
|
|
10043
10140
|
severity: "critical",
|
|
10044
10141
|
rules: ["SEC_AWS_IAM_ADMIN_EFECTIVO", "SEC_AWS_IAM_USUARIO_SIN_MFA", "SEC_AWS_IAM_CLAVE_SIN_USO"],
|
|
10045
10142
|
detect: (input) => {
|
|
@@ -11738,6 +11835,34 @@ var ALARM_RULES = ALARM_CONTROLS.map((control) => ({
|
|
|
11738
11835
|
evaluate: (observations) => evaluateAlarmControl(control, observations)
|
|
11739
11836
|
}));
|
|
11740
11837
|
|
|
11838
|
+
// ../../services/security/src/rules/aws/patching.ts
|
|
11839
|
+
var SIN_ACTUALIZACION_MENOR_GESTIONADA = /^(custom-|docdb$|neptune$)/;
|
|
11840
|
+
function rdsSinActualizacionMenorEvaluate(observation) {
|
|
11841
|
+
const engine = observation.attributes.engine;
|
|
11842
|
+
if (typeof engine === "string" && SIN_ACTUALIZACION_MENOR_GESTIONADA.test(engine)) return { status: "ok" };
|
|
11843
|
+
const auto = observation.attributes.autoMinorVersionUpgrade;
|
|
11844
|
+
if (typeof auto !== "boolean") return { status: "unknown", check: RDS_CHECKS.instances, attribute: "autoMinorVersionUpgrade" };
|
|
11845
|
+
if (auto) return { status: "ok" };
|
|
11846
|
+
return {
|
|
11847
|
+
status: "finding",
|
|
11848
|
+
evidence: {
|
|
11849
|
+
autoMinorVersionUpgrade: false,
|
|
11850
|
+
engine: engine ?? null,
|
|
11851
|
+
engineVersion: observation.attributes.engineVersion ?? null
|
|
11852
|
+
}
|
|
11853
|
+
};
|
|
11854
|
+
}
|
|
11855
|
+
var rdsSinActualizacionMenor = {
|
|
11856
|
+
id: "SEC_AWS_PATCHING_RDS_SIN_ACTUALIZACION_MENOR",
|
|
11857
|
+
scope: "resource",
|
|
11858
|
+
category: "security_patching",
|
|
11859
|
+
severity: "medium",
|
|
11860
|
+
provider: "aws",
|
|
11861
|
+
kinds: ["rds_instance"],
|
|
11862
|
+
requires: [REGION_CHECKS.listRegions, RDS_CHECKS.instances],
|
|
11863
|
+
evaluate: rdsSinActualizacionMenorEvaluate
|
|
11864
|
+
};
|
|
11865
|
+
|
|
11741
11866
|
// ../../services/security/src/rules/aws/secrets.ts
|
|
11742
11867
|
var SOSPECHOSAS = [
|
|
11743
11868
|
"PASSWORD",
|
|
@@ -11798,6 +11923,7 @@ var AWS_SECURITY_RULES = [
|
|
|
11798
11923
|
lambdaPublica,
|
|
11799
11924
|
kmsSinRotacion,
|
|
11800
11925
|
rdsSinCifrar,
|
|
11926
|
+
rdsSinActualizacionMenor,
|
|
11801
11927
|
rootSinMfa,
|
|
11802
11928
|
usuarioSinMfa,
|
|
11803
11929
|
claveAntigua,
|
|
@@ -11822,6 +11948,7 @@ var AZURE_SECURITY_COMBOS = [
|
|
|
11822
11948
|
// Abierto a internet y con un TLS que admite versiones viejas: lo que viaja se puede leer por el camino.
|
|
11823
11949
|
id: "COMBO_AZURE_PUBLIC_SQL_WEAK_TLS",
|
|
11824
11950
|
provider: "azure",
|
|
11951
|
+
resourceKind: "sql_server",
|
|
11825
11952
|
severity: "high",
|
|
11826
11953
|
rules: ["SEC_AZURE_EXPOSURE_SQL_PUBLICO", "SEC_AZURE_ENCRYPTION_SQL_TLS"],
|
|
11827
11954
|
detect: (input) => sameResource(input, "SEC_AZURE_EXPOSURE_SQL_PUBLICO", "SEC_AZURE_ENCRYPTION_SQL_TLS")
|
|
@@ -11830,10 +11957,40 @@ var AZURE_SECURITY_COMBOS = [
|
|
|
11830
11957
|
// Permite contenedores públicos y además TLS débil o HTTP: la exposición de la cuenta se suma a la del tránsito.
|
|
11831
11958
|
id: "COMBO_AZURE_PUBLIC_STORAGE_WEAK_TLS",
|
|
11832
11959
|
provider: "azure",
|
|
11960
|
+
resourceKind: "storage_account",
|
|
11833
11961
|
severity: "critical",
|
|
11834
11962
|
rules: ["SEC_AZURE_EXPOSURE_BLOB_PUBLICO", "SEC_AZURE_ENCRYPTION_STORAGE_TLS"],
|
|
11835
11963
|
detect: (input) => sameResource(input, "SEC_AZURE_EXPOSURE_BLOB_PUBLICO", "SEC_AZURE_ENCRYPTION_STORAGE_TLS")
|
|
11836
11964
|
},
|
|
11965
|
+
{
|
|
11966
|
+
// Servidor abierto a internet con bases que llevan una semana sin conexiones: se paga por datos expuestos que nadie usa.
|
|
11967
|
+
id: "COMBO_AZURE_PUBLIC_SQL_IDLE",
|
|
11968
|
+
provider: "azure",
|
|
11969
|
+
resourceKind: "sql_server",
|
|
11970
|
+
severity: "high",
|
|
11971
|
+
rules: ["SEC_AZURE_EXPOSURE_SQL_PUBLICO"],
|
|
11972
|
+
costRules: ["AZURE_SQL_ZERO_CONN"],
|
|
11973
|
+
detect: (input) => {
|
|
11974
|
+
const sinUso = costSignalsOf(input, "AZURE_SQL_ZERO_CONN").filter((s) => s.armId);
|
|
11975
|
+
if (sinUso.length === 0) return [];
|
|
11976
|
+
return input.findings.filter((f) => f.ruleId === "SEC_AZURE_EXPOSURE_SQL_PUBLICO").flatMap((f) => {
|
|
11977
|
+
const prefijo2 = `${f.resourceId.toLowerCase()}/databases/`;
|
|
11978
|
+
const bases = sinUso.filter((s) => s.armId.toLowerCase().startsWith(prefijo2));
|
|
11979
|
+
const primera = bases[0];
|
|
11980
|
+
if (!primera) return [];
|
|
11981
|
+
const ahorro = Math.round(bases.reduce((total2, s) => total2 + s.monthlySavingsUsd, 0) * 100) / 100;
|
|
11982
|
+
return [
|
|
11983
|
+
{
|
|
11984
|
+
region: f.region,
|
|
11985
|
+
resourceId: f.resourceId,
|
|
11986
|
+
resourceName: f.resourceName,
|
|
11987
|
+
findingIds: [f.id],
|
|
11988
|
+
evidence: { ...costEvidence(input, { ...primera, monthlySavingsUsd: ahorro }, { amount: true }), idleDatabases: bases.length }
|
|
11989
|
+
}
|
|
11990
|
+
];
|
|
11991
|
+
});
|
|
11992
|
+
}
|
|
11993
|
+
},
|
|
11837
11994
|
{
|
|
11838
11995
|
// VM expuesta a internet según Defender y con un CVE crítico o alto con exploit conocido.
|
|
11839
11996
|
id: "COMBO_AZURE_PUBLIC_VULNERABLE",
|
|
@@ -12301,18 +12458,36 @@ var GCP_SECURITY_COMBOS = [
|
|
|
12301
12458
|
// Abierta a internet, sin uso en 7 días y facturando: se paga por una puerta que nadie usa.
|
|
12302
12459
|
id: "COMBO_GCP_PUBLIC_SQL_IDLE",
|
|
12303
12460
|
provider: "gcp",
|
|
12461
|
+
resourceKind: "cloud_sql_instance",
|
|
12304
12462
|
severity: "high",
|
|
12305
12463
|
rules: ["SEC_GCP_EXPOSURE_SQL_PUBLICO"],
|
|
12306
12464
|
costRules: ["GCP_SQL_ZERO_CONNECTIONS"],
|
|
12307
|
-
detect: (input) => {
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12465
|
+
detect: (input) => withCostSignal(input, {
|
|
12466
|
+
rule: "SEC_GCP_EXPOSURE_SQL_PUBLICO",
|
|
12467
|
+
costRule: "GCP_SQL_ZERO_CONNECTIONS",
|
|
12468
|
+
// Por nombre: coste y seguridad usan el nombre de la instancia, único dentro del proyecto.
|
|
12469
|
+
findingKey: (f) => f.resourceId,
|
|
12470
|
+
signalKey: (s) => s.resourceId,
|
|
12471
|
+
amount: true
|
|
12472
|
+
})
|
|
12473
|
+
},
|
|
12474
|
+
{
|
|
12475
|
+
// Guarda credenciales en su configuración y nadie la invoca: borrarla quita las credenciales del proyecto sin romper nada.
|
|
12476
|
+
id: "COMBO_GCP_UNUSED_FUNCTION_SECRETS",
|
|
12477
|
+
provider: "gcp",
|
|
12478
|
+
resourceKind: "cloud_function",
|
|
12479
|
+
severity: "high",
|
|
12480
|
+
rules: ["SEC_GCP_SECRETS_FUNCTION_ENV"],
|
|
12481
|
+
costRules: ["GCP_FUNCTION_UNUSED"],
|
|
12482
|
+
detect: (input) => withCostSignal(input, {
|
|
12483
|
+
rule: "SEC_GCP_SECRETS_FUNCTION_ENV",
|
|
12484
|
+
costRule: "GCP_FUNCTION_UNUSED",
|
|
12485
|
+
// Los dos módulos usan el nombre completo (projects/…/locations/…/functions/…), que ya lleva la región.
|
|
12486
|
+
findingKey: (f) => f.resourceId,
|
|
12487
|
+
signalKey: (s) => s.resourceId,
|
|
12488
|
+
// El módulo de coste no pone precio a una función: depende del uso.
|
|
12489
|
+
amount: false
|
|
12490
|
+
})
|
|
12316
12491
|
},
|
|
12317
12492
|
{
|
|
12318
12493
|
// Una cuenta de servicio Owner o Editor con una clave descargable: quien tenga el fichero tiene el proyecto.
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@aaa-sentinel/iac-cost",
|
|
3
|
-
"version": "0.
|
|
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
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"bin": {
|
|
8
|
-
"iac-cost": "dist/cli.js"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
|
-
"keywords": [
|
|
14
|
-
"terraform",
|
|
15
|
-
"finops",
|
|
16
|
-
"cost",
|
|
17
|
-
"iac",
|
|
18
|
-
"security",
|
|
19
|
-
"shift-left"
|
|
20
|
-
],
|
|
21
|
-
"publishConfig": {
|
|
22
|
-
"access": "public"
|
|
23
|
-
},
|
|
24
|
-
"homepage": "https://app.aaa-sentinel.com/developer/docs#terraform-ci",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://app.aaa-sentinel.com/contact"
|
|
27
|
-
},
|
|
28
|
-
"engines": {
|
|
29
|
-
"node": ">=20"
|
|
30
|
-
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "esbuild src/cli.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/cli.js",
|
|
33
|
-
"prepublishOnly": "npm --prefix ../.. run build:iac-cost",
|
|
34
|
-
"test": "vitest run"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@finops-sentinel/shared": "*",
|
|
38
|
-
"@types/node": "^22.0.0",
|
|
39
|
-
"esbuild": "^0.24.0",
|
|
40
|
-
"typescript": "^5.7.0",
|
|
41
|
-
"vitest": "^3.2.0"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@aaa-sentinel/iac-cost",
|
|
3
|
+
"version": "0.7.0",
|
|
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
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"iac-cost": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"terraform",
|
|
15
|
+
"finops",
|
|
16
|
+
"cost",
|
|
17
|
+
"iac",
|
|
18
|
+
"security",
|
|
19
|
+
"shift-left"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://app.aaa-sentinel.com/developer/docs#terraform-ci",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://app.aaa-sentinel.com/contact"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "esbuild src/cli.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/cli.js",
|
|
33
|
+
"prepublishOnly": "npm --prefix ../.. run build:iac-cost",
|
|
34
|
+
"test": "vitest run"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@finops-sentinel/shared": "*",
|
|
38
|
+
"@types/node": "^22.0.0",
|
|
39
|
+
"esbuild": "^0.24.0",
|
|
40
|
+
"typescript": "^5.7.0",
|
|
41
|
+
"vitest": "^3.2.0"
|
|
42
|
+
}
|
|
43
|
+
}
|