@intentius/chant-lexicon-terraform 0.100.0 → 0.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/codegen/package.d.ts +1 -1
  2. package/dist/config.d.ts +2 -2
  3. package/dist/hcl/jsonencode.d.ts +106 -0
  4. package/dist/hcl/jsonencode.d.ts.map +1 -0
  5. package/dist/hcl/marker.d.ts.map +1 -1
  6. package/dist/integrity.json +11 -2
  7. package/dist/lint/audit-catalog.d.ts.map +1 -1
  8. package/dist/lint/audit-lineage.d.ts +1 -1
  9. package/dist/lint/audit-lineage.d.ts.map +1 -1
  10. package/dist/lint/post-synth/flat-attributes.d.ts +69 -0
  11. package/dist/lint/post-synth/flat-attributes.d.ts.map +1 -0
  12. package/dist/lint/post-synth/index.d.ts.map +1 -1
  13. package/dist/lint/post-synth/tf030.d.ts +51 -0
  14. package/dist/lint/post-synth/tf030.d.ts.map +1 -0
  15. package/dist/lint/post-synth/tf031.d.ts +55 -0
  16. package/dist/lint/post-synth/tf031.d.ts.map +1 -0
  17. package/dist/lint/post-synth/tf032.d.ts +71 -0
  18. package/dist/lint/post-synth/tf032.d.ts.map +1 -0
  19. package/dist/lint/post-synth/tf033.d.ts +50 -0
  20. package/dist/lint/post-synth/tf033.d.ts.map +1 -0
  21. package/dist/lint/post-synth/tf034.d.ts +25 -0
  22. package/dist/lint/post-synth/tf034.d.ts.map +1 -0
  23. package/dist/lint/post-synth/tf035.d.ts +33 -0
  24. package/dist/lint/post-synth/tf035.d.ts.map +1 -0
  25. package/dist/lint/post-synth/tf036.d.ts +33 -0
  26. package/dist/lint/post-synth/tf036.d.ts.map +1 -0
  27. package/dist/lint/post-synth/tf037.d.ts +31 -0
  28. package/dist/lint/post-synth/tf037.d.ts.map +1 -0
  29. package/dist/manifest.json +1 -1
  30. package/dist/okf/index.md +8 -0
  31. package/dist/okf/rules/TF030.md +11 -0
  32. package/dist/okf/rules/TF031.md +11 -0
  33. package/dist/okf/rules/TF032.md +11 -0
  34. package/dist/okf/rules/TF033.md +11 -0
  35. package/dist/okf/rules/TF034.md +11 -0
  36. package/dist/okf/rules/TF035.md +11 -0
  37. package/dist/okf/rules/TF036.md +11 -0
  38. package/dist/okf/rules/TF037.md +11 -0
  39. package/dist/op/activity-contracts.d.ts +18 -18
  40. package/dist/op/builders.d.ts.map +1 -1
  41. package/dist/rules/flat-attributes.ts +146 -0
  42. package/dist/rules/tf030.ts +290 -0
  43. package/dist/rules/tf031.ts +370 -0
  44. package/dist/rules/tf032.ts +226 -0
  45. package/dist/rules/tf033.ts +160 -0
  46. package/dist/rules/tf034.ts +63 -0
  47. package/dist/rules/tf035.ts +74 -0
  48. package/dist/rules/tf036.ts +119 -0
  49. package/dist/rules/tf037.ts +101 -0
  50. package/package.json +3 -3
  51. package/src/hcl/jsonencode.test.ts +226 -0
  52. package/src/hcl/jsonencode.ts +454 -0
  53. package/src/lint/audit-catalog.ts +148 -0
  54. package/src/lint/audit-lineage.ts +155 -1
  55. package/src/lint/post-synth/estate-2284.test.ts +68 -0
  56. package/src/lint/post-synth/fixtures/TF030/negative-rules.tf +45 -0
  57. package/src/lint/post-synth/fixtures/TF030/negative.tf +55 -0
  58. package/src/lint/post-synth/fixtures/TF030/not-determined-port.tf +28 -0
  59. package/src/lint/post-synth/fixtures/TF030/not-determined-standalone.tf +32 -0
  60. package/src/lint/post-synth/fixtures/TF030/not-determined-vpc-rule.tf +21 -0
  61. package/src/lint/post-synth/fixtures/TF030/not-determined.tf +39 -0
  62. package/src/lint/post-synth/fixtures/TF030/positive-ipv6.tf +44 -0
  63. package/src/lint/post-synth/fixtures/TF030/positive-mixed.tf +36 -0
  64. package/src/lint/post-synth/fixtures/TF030/positive-standalone.tf +25 -0
  65. package/src/lint/post-synth/fixtures/TF030/positive.tf +43 -0
  66. package/src/lint/post-synth/fixtures/TF031/negative.tf +89 -0
  67. package/src/lint/post-synth/fixtures/TF031/not-determined.tf +139 -0
  68. package/src/lint/post-synth/fixtures/TF031/positive-data-source.tf +57 -0
  69. package/src/lint/post-synth/fixtures/TF031/positive-heredoc.tf +149 -0
  70. package/src/lint/post-synth/fixtures/TF031/positive-jsonencode.tf +115 -0
  71. package/src/lint/post-synth/fixtures/TF032/negative-heredoc.tf +20 -0
  72. package/src/lint/post-synth/fixtures/TF032/negative-references.tf +214 -0
  73. package/src/lint/post-synth/fixtures/TF032/negative.tf +99 -0
  74. package/src/lint/post-synth/fixtures/TF032/positive-heredoc.tf +22 -0
  75. package/src/lint/post-synth/fixtures/TF032/positive-sidecar.tf +197 -0
  76. package/src/lint/post-synth/fixtures/TF032/positive.tf +54 -0
  77. package/src/lint/post-synth/fixtures/TF033/negative.tf +39 -0
  78. package/src/lint/post-synth/fixtures/TF033/not-determined-aurora.tf +25 -0
  79. package/src/lint/post-synth/fixtures/TF033/positive-absent.tf +93 -0
  80. package/src/lint/post-synth/fixtures/TF033/positive.tf +50 -0
  81. package/src/lint/post-synth/fixtures/TF034/negative.tf +24 -0
  82. package/src/lint/post-synth/fixtures/TF034/positive-absent.tf +36 -0
  83. package/src/lint/post-synth/fixtures/TF034/positive.tf +14 -0
  84. package/src/lint/post-synth/fixtures/TF035/negative-absent.tf +43 -0
  85. package/src/lint/post-synth/fixtures/TF035/negative.tf +54 -0
  86. package/src/lint/post-synth/fixtures/TF035/positive.tf +37 -0
  87. package/src/lint/post-synth/fixtures/TF036/negative.tf +61 -0
  88. package/src/lint/post-synth/fixtures/TF036/not-determined.tf +28 -0
  89. package/src/lint/post-synth/fixtures/TF036/positive.tf +38 -0
  90. package/src/lint/post-synth/fixtures/TF037/negative-exclusion.tf +63 -0
  91. package/src/lint/post-synth/fixtures/TF037/negative.tf +27 -0
  92. package/src/lint/post-synth/fixtures/TF037/not-determined.tf +27 -0
  93. package/src/lint/post-synth/fixtures/TF037/positive-absent.tf +15 -0
  94. package/src/lint/post-synth/fixtures/TF037/positive.tf +26 -0
  95. package/src/lint/post-synth/fixtures/estate-2284/clean/main.tf +132 -0
  96. package/src/lint/post-synth/fixtures/estate-2284/violating/main.tf +112 -0
  97. package/src/lint/post-synth/flat-attributes.ts +146 -0
  98. package/src/lint/post-synth/index.ts +16 -0
  99. package/src/lint/post-synth/tf030.test.ts +219 -0
  100. package/src/lint/post-synth/tf030.ts +290 -0
  101. package/src/lint/post-synth/tf031.test.ts +229 -0
  102. package/src/lint/post-synth/tf031.ts +370 -0
  103. package/src/lint/post-synth/tf032.test.ts +127 -0
  104. package/src/lint/post-synth/tf032.ts +226 -0
  105. package/src/lint/post-synth/tf033.test.ts +126 -0
  106. package/src/lint/post-synth/tf033.ts +160 -0
  107. package/src/lint/post-synth/tf034.test.ts +71 -0
  108. package/src/lint/post-synth/tf034.ts +63 -0
  109. package/src/lint/post-synth/tf035.test.ts +68 -0
  110. package/src/lint/post-synth/tf035.ts +74 -0
  111. package/src/lint/post-synth/tf036.test.ts +87 -0
  112. package/src/lint/post-synth/tf036.ts +119 -0
  113. package/src/lint/post-synth/tf037.test.ts +88 -0
  114. package/src/lint/post-synth/tf037.ts +101 -0
  115. package/src/op/activities/terraform.test.ts +2 -2
@@ -56,7 +56,7 @@
56
56
  * | `tflint-ruleset-redeploy` | tflint-ruleset-redeploy | https://github.com/RedeployAB/tflint-ruleset-redeploy | 0BSD | scanner | Community ruleset; richest source of language-level rules outside the official set. Sweep: indexed from `docs/rules/README.md`, same table shape (33 rules). |
57
57
  * | `tflint-ruleset-avm` | tflint-ruleset-avm | https://github.com/Azure/tflint-ruleset-avm | MIT | scanner | Azure Verified Modules conformance; two of its 33 rules are provider-agnostic. Sweep: indexed from the repository-root `RULES.md`, since `docs/` holds pages for only two rules (33 rules). |
58
58
  * | `tfsec` | tfsec | https://github.com/aquasecurity/tfsec | MIT | scanner | Historical: not archived but effectively frozen (no release since 2025-05); its docs site 404s above v0.61.x, so cite pinned repository paths (`github.com/aquasecurity/tfsec/blob/master/docs/checks/...`), not the docs site. Sweep: indexed from the root `rules.md` on `master`, a flat table of all 152 check ids, because `docs/checks` nests a directory per provider, service and check. |
59
- * | `trivy-checks` | trivy-checks | https://github.com/aquasecurity/trivy-checks | MIT (not the trivy scanner's own Apache-2.0; cite the checks repo's licence, not the engine's) | scanner | Where tfsec's rules live today (tfsec -> defsec -> trivy + trivy-checks). Cite rules by `long_id` (stable, human-readable); `AVD-*` ids are aliases now. Sweep: not registered in `PRIOR_ART` (no rule cites it yet) and its `long_id`s live in Rego metadata under `checks/<kind>/<provider>/<service>/`, with no flat index. |
59
+ * | `trivy-checks` | trivy-checks | https://github.com/aquasecurity/trivy-checks | MIT (not the trivy scanner's own Apache-2.0; cite the checks repo's licence, not the engine's) | scanner | Where tfsec's rules live today (tfsec -> defsec -> trivy + trivy-checks). Cite rules by `long_id` (stable, human-readable); `AVD-*` ids are aliases now. Sweep: registered in `PRIOR_ART` since TF030 (#2285) cited `aws-ec2-no-public-ingress-sgr` (TF032 also cites `aws-ecs-no-plaintext-secrets`, AWS-0036), but not swept: its `long_id`s live in Rego metadata under `checks/<kind>/<provider>/<service>/`, with no flat index. Check a cited id is live: TF031's counterpart, `aws-iam-no-policy-wildcards`, is a `deprecated: true` stub with no rule body, so TF031 does not cite it. |
60
60
  * | `terraform-sentinel-policies` | HashiCorp reference Sentinel policies | https://github.com/hashicorp/terraform-sentinel-policies | MPL-2.0 | specification | HashiCorp's own example policy set; ships zero rules baked into HCP Terraform itself, so treat a cited policy as a documented pattern (`specification`) unless a future entry runs it as a real check (`scanner`); the `kind` union allows either. Sweep: indexed by listing the five per-cloud directories, whose `.sentinel` filenames are the policy ids credits cite (73 policies); the repository publishes no index page. |
61
61
  * | `choudoufu` | choudoufu | https://github.com/INTENTIUS/choudoufu | MPL-2.0 | scanner | Its `internal/live/lint` package; experimental, AWS-only. Sweep: unsweepable, its rule ids are Go constants in `internal/live/lint/issue.go` and it publishes no rule index. |
62
62
  * | `hashicorp-style-guide` | HashiCorp Terraform style guide | https://developer.hashicorp.com/terraform/language/style | n/a | specification | Sweep: unsweepable, one prose page of recommendations with no rule ids; a credit quotes the sentence and links its fragment. |
@@ -401,4 +401,158 @@ export const terraformAuditLineage: Record<string, Lineage[]> = {
401
401
  },
402
402
  { tool: "kics", rule: "a88baa34-e2ad-44ea-ad6f-8cac87bc7c71", url: "https://docs.kics.io/latest/secrets/", relation: "overlaps" },
403
403
  ],
404
+ TF030: [
405
+ // Every credit overlaps; none is equivalent. TF030 is WAW019's port list
406
+ // (22, 3389, 3306, 5432) on 0.0.0.0/0 or ::/0, read across the three
407
+ // Terraform shapes. Checkov checks one port per id and, unlike TF030,
408
+ // reads tcp 0-0 as every port and passes any rule with `self = true`.
409
+ // tfsec flags a /0 on any port; trivy-checks only SSH and RDP; KICS a
410
+ // longer port list; the Sentinel policies only `aws_security_group_rule`
411
+ // with an exact `to_port`. Each upstream id was read from its source on
412
+ // 2026-10-02 (checkov `AbsSecurityGroupUnrestrictedIngress.py`, trivy-checks
413
+ // `no_public_ingress_sgr.rego` metadata, KICS `metadata.json`, tfsec
414
+ // `rules.md`).
415
+ { tool: "checkov", rule: "CKV_AWS_24", url: "https://www.checkov.io/5.Policy%20Index/terraform.html", relation: "overlaps" },
416
+ { tool: "checkov", rule: "CKV_AWS_25", url: "https://www.checkov.io/5.Policy%20Index/terraform.html", relation: "overlaps" },
417
+ {
418
+ tool: "tfsec",
419
+ rule: "aws-vpc-no-public-ingress-sgr",
420
+ url: "https://github.com/aquasecurity/tfsec/blob/master/docs/checks/aws/vpc/no-public-ingress-sgr/index.md",
421
+ relation: "overlaps",
422
+ },
423
+ {
424
+ tool: "trivy-checks",
425
+ rule: "aws-ec2-no-public-ingress-sgr",
426
+ url: "https://github.com/aquasecurity/trivy-checks/blob/main/checks/cloud/aws/ec2/no_public_ingress_sgr.rego",
427
+ relation: "overlaps",
428
+ },
429
+ {
430
+ tool: "kics",
431
+ rule: "381c3f2a-ef6f-4eff-99f7-b169cda3422c",
432
+ url: "https://docs.kics.io/latest/queries/terraform-queries/aws/381c3f2a-ef6f-4eff-99f7-b169cda3422c/",
433
+ relation: "overlaps",
434
+ },
435
+ {
436
+ tool: "terraform-sentinel-policies",
437
+ rule: "restrict-ingress-sg-rule-ssh",
438
+ url: "https://github.com/hashicorp/terraform-sentinel-policies/blob/main/aws/restrict-ingress-sg-rule-ssh.sentinel",
439
+ relation: "overlaps",
440
+ },
441
+ {
442
+ tool: "terraform-sentinel-policies",
443
+ rule: "restrict-ingress-sg-rule-rdp",
444
+ url: "https://github.com/hashicorp/terraform-sentinel-policies/blob/main/aws/restrict-ingress-sg-rule-rdp.sentinel",
445
+ relation: "overlaps",
446
+ },
447
+ ],
448
+ // tfsec's check also flags a service wildcard (`s3:*`), which TF031 does
449
+ // not, so "overlaps". checkov splits the condition four ways: CKV_AWS_63
450
+ // (Action "*" on the policy resources, plus aws_ssoadmin_permission_set_
451
+ // inline_policy, which TF031 does not read) and CKV_AWS_49 (the same on the
452
+ // data source, which TF031 extends with Resource "*"); CKV_AWS_355/356 ask
453
+ // cloudsplaining whether Resource "*" meets a RESTRICTABLE action, a
454
+ // narrower test than TF031's literal one. trivy-checks has no credit:
455
+ // `aws-iam-no-policy-wildcards` (AWS-0057) survives there only as a
456
+ // `deprecated: true` metadata stub with no rule body, added by
457
+ // aquasecurity/trivy-checks c292eb6737e0 ("add removed Go checks as
458
+ // deprecated"), so it checks nothing to be equivalent to (#2286).
459
+ TF031: [
460
+ {
461
+ tool: "tfsec",
462
+ rule: "aws-iam-no-policy-wildcards",
463
+ url: "https://github.com/aquasecurity/tfsec/blob/master/docs/checks/aws/iam/no-policy-wildcards/index.md",
464
+ relation: "overlaps",
465
+ },
466
+ {
467
+ tool: "checkov",
468
+ rule: "CKV_AWS_63",
469
+ url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/IAMStarActionPolicyDocument.py",
470
+ relation: "overlaps",
471
+ },
472
+ {
473
+ tool: "checkov",
474
+ rule: "CKV_AWS_49",
475
+ url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/data/aws/StarActionPolicyDocument.py",
476
+ relation: "extends",
477
+ },
478
+ {
479
+ tool: "checkov",
480
+ rule: "CKV_AWS_355",
481
+ url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/IAMStarResourcePolicyDocument.py",
482
+ relation: "overlaps",
483
+ },
484
+ {
485
+ tool: "checkov",
486
+ rule: "CKV_AWS_356",
487
+ url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/data/aws/ResourcePolicyDocument.py",
488
+ relation: "overlaps",
489
+ },
490
+ ],
491
+ // tfsec's `aws-ecs-no-plaintext-secrets` and its successor in trivy-checks
492
+ // (`long_id` aws-ecs-no-plaintext-secrets, AVD-AWS-0036) fire on the same
493
+ // condition: an environment entry whose name is sensitive or whose value a
494
+ // secret scanner flags. `overlaps`, not `equivalent`, because both evaluate
495
+ // the definition first and so also read what TF032 reports as not
496
+ // determined, and their name list differs from secret-shape.ts's. Checkov
497
+ // has no Terraform check for ECS environment values (its ECS checks cover
498
+ // privilege, read-only root, host process, task role and EFS encryption,
499
+ // `checkov/terraform/checks/resource/aws/ECS*.py`), so it gets no credit.
500
+ TF032: [
501
+ {
502
+ tool: "tfsec",
503
+ rule: "aws-ecs-no-plaintext-secrets",
504
+ url: "https://github.com/aquasecurity/tfsec/blob/master/docs/checks/aws/ecs/no-plaintext-secrets/index.md",
505
+ relation: "overlaps",
506
+ },
507
+ {
508
+ tool: "trivy-checks",
509
+ rule: "aws-ecs-no-plaintext-secrets",
510
+ url: "https://github.com/aquasecurity/trivy-checks/blob/main/checks/cloud/aws/ecs/no_plaintext_secrets.rego",
511
+ relation: "overlaps",
512
+ },
513
+ ],
514
+ // TF033-TF037 (#2288). Every tool below reports an absent attribute the
515
+ // same as an insecure one, which is right for SNS (TF034) and ECR (TF037)
516
+ // and wrong for the rest: SQS encrypts new queues by default, an unset
517
+ // EBS `encrypted` follows the Region's encryption by default, and Aurora
518
+ // encrypts new clusters whatever `storage_encrypted` says. Where chant's
519
+ // answer to absence differs the credit is "overlaps"; where it agrees and
520
+ // the condition is the same, "equivalent". The ECR credits are "overlaps"
521
+ // too: none of them knows provider v6's `IMMUTABLE_WITH_EXCLUSION`, which
522
+ // TF037 passes and they report. trivy-checks ids are the live
523
+ // Rego checks (not `deprecated` stubs) at aquasecurity/trivy-checks
524
+ // 71c05d02845c. tfsec has no TF036 credit: its frozen `rules.md`, which
525
+ // the prior-art sweep indexes, no longer lists an EBS volume check.
526
+ TF033: [
527
+ { tool: "tfsec", rule: "aws-rds-encrypt-instance-storage-data", url: "https://github.com/aquasecurity/tfsec/blob/master/docs/checks/aws/rds/encrypt-instance-storage-data/index.md", relation: "overlaps" },
528
+ { tool: "tfsec", rule: "aws-rds-encrypt-cluster-storage-data", url: "https://github.com/aquasecurity/tfsec/blob/master/docs/checks/aws/rds/encrypt-cluster-storage-data/index.md", relation: "overlaps" },
529
+ { tool: "trivy-checks", rule: "aws-rds-encrypt-instance-storage-data", url: "https://github.com/aquasecurity/trivy-checks/blob/main/checks/cloud/aws/rds/encrypt_instance_storage_data.rego", relation: "overlaps" },
530
+ { tool: "trivy-checks", rule: "aws-rds-encrypt-cluster-storage-data", url: "https://github.com/aquasecurity/trivy-checks/blob/main/checks/cloud/aws/rds/encrypt_cluster_storage_data.rego", relation: "overlaps" },
531
+ { tool: "checkov", rule: "CKV_AWS_16", url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/RDSEncryption.py", relation: "overlaps" },
532
+ { tool: "checkov", rule: "CKV_AWS_96", url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/AuroraEncryption.py", relation: "overlaps" },
533
+ { tool: "kics", rule: "08bd0760-8752-44e1-9779-7bb369b2b4e4", url: "https://docs.kics.io/latest/queries/terraform-queries/aws/08bd0760-8752-44e1-9779-7bb369b2b4e4/", relation: "overlaps" },
534
+ ],
535
+ TF034: [
536
+ { tool: "tfsec", rule: "aws-sns-enable-topic-encryption", url: "https://github.com/aquasecurity/tfsec/blob/master/docs/checks/aws/sns/enable-topic-encryption/index.md", relation: "equivalent" },
537
+ { tool: "trivy-checks", rule: "aws-sns-enable-topic-encryption", url: "https://github.com/aquasecurity/trivy-checks/blob/main/checks/cloud/aws/sns/enable_topic_encryption.rego", relation: "equivalent" },
538
+ { tool: "checkov", rule: "CKV_AWS_26", url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/SNSTopicEncryption.py", relation: "equivalent" },
539
+ { tool: "kics", rule: "28545147-2fc6-42d5-a1f9-cf226658e591", url: "https://docs.kics.io/latest/queries/terraform-queries/aws/28545147-2fc6-42d5-a1f9-cf226658e591/", relation: "equivalent" },
540
+ ],
541
+ TF035: [
542
+ { tool: "tfsec", rule: "aws-sqs-enable-queue-encryption", url: "https://github.com/aquasecurity/tfsec/blob/master/docs/checks/aws/sqs/enable-queue-encryption/index.md", relation: "overlaps" },
543
+ { tool: "trivy-checks", rule: "aws-sqs-enable-queue-encryption", url: "https://github.com/aquasecurity/trivy-checks/blob/main/checks/cloud/aws/sqs/enable_queue_encryption.rego", relation: "overlaps" },
544
+ { tool: "checkov", rule: "CKV_AWS_27", url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/SQSQueueEncryption.py", relation: "overlaps" },
545
+ { tool: "kics", rule: "6e8849c1-3aa7-40e3-9063-b85ee300f29f", url: "https://docs.kics.io/latest/queries/terraform-queries/aws/6e8849c1-3aa7-40e3-9063-b85ee300f29f/", relation: "overlaps" },
546
+ ],
547
+ TF036: [
548
+ { tool: "trivy-checks", rule: "aws-ec2-enable-volume-encryption", url: "https://github.com/aquasecurity/trivy-checks/blob/main/checks/cloud/aws/ec2/enable_volume_encryption.rego", relation: "overlaps" },
549
+ { tool: "checkov", rule: "CKV_AWS_3", url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/EBSEncryption.py", relation: "overlaps" },
550
+ { tool: "kics", rule: "cc997676-481b-4e93-aa81-d19f8c5e9b12", url: "https://docs.kics.io/latest/queries/terraform-queries/aws/cc997676-481b-4e93-aa81-d19f8c5e9b12/", relation: "overlaps" },
551
+ ],
552
+ TF037: [
553
+ { tool: "tfsec", rule: "aws-ecr-enforce-immutable-repository", url: "https://github.com/aquasecurity/tfsec/blob/master/docs/checks/aws/ecr/enforce-immutable-repository/index.md", relation: "overlaps" },
554
+ { tool: "trivy-checks", rule: "aws-ecr-enforce-immutable-repository", url: "https://github.com/aquasecurity/trivy-checks/blob/main/checks/cloud/aws/ecr/enforce_immutable_repository.rego", relation: "overlaps" },
555
+ { tool: "checkov", rule: "CKV_AWS_51", url: "https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/ECRImmutableTags.py", relation: "overlaps" },
556
+ { tool: "kics", rule: "d1846b12-20c5-4d45-8798-fc35b79268eb", url: "https://docs.kics.io/latest/queries/terraform-queries/aws/d1846b12-20c5-4d45-8798-fc35b79268eb/", relation: "overlaps" },
557
+ ],
404
558
  };
@@ -0,0 +1,68 @@
1
+ import { dirname, join } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { describe, expect, test } from "vitest";
4
+ import { auditFiles, type AuditFinding, type ChecksProvider, type EntitiesProvider } from "@intentius/chant/audit/core";
5
+ import { discoverByDetection, type DetectPlugin } from "@intentius/chant/audit/discover";
6
+ import { terraformPlugin } from "../../plugin";
7
+ import { postSynthChecks } from "./index";
8
+
9
+ /**
10
+ * Epic #2284's definition of done, run through `chant audit`'s terraform path
11
+ * (real discovery, the plugin's `auditEntities` parse, every post-synth check
12
+ * in the barrel) over the two estate roots in `fixtures/estate-2284/`. The
13
+ * violating root holds one violation per rule, TF030 to TF037; the clean root
14
+ * holds the same estate fixed, with the provider-default cases (an SQS queue
15
+ * with no encryption attribute, an EBS volume behind an enabled
16
+ * `aws_ebs_encryption_by_default`) left as real estates leave them.
17
+ */
18
+ const estate = join(dirname(fileURLToPath(import.meta.url)), "fixtures", "estate-2284");
19
+
20
+ const terraformDetectPlugin: DetectPlugin = { name: "terraform" };
21
+ const checksProvider: ChecksProvider = async (lexicon) =>
22
+ lexicon === "terraform" ? (terraformPlugin.postSynthChecks?.() ?? []) : [];
23
+ const entitiesProvider: EntitiesProvider = async (lexicon) =>
24
+ lexicon === "terraform" ? terraformPlugin.auditEntities?.bind(terraformPlugin) : undefined;
25
+
26
+ async function audit(root: "violating" | "clean"): Promise<AuditFinding[]> {
27
+ return auditFiles(discoverByDetection(join(estate, root), [terraformDetectPlugin]), { checksProvider, entitiesProvider });
28
+ }
29
+
30
+ /** The rule each violating resource is written for. */
31
+ const EXPECTED: Record<string, string> = {
32
+ TF030: "aws_security_group.bastion",
33
+ TF031: "aws_iam_policy.deployer",
34
+ TF032: "aws_ecs_task_definition.api",
35
+ TF033: "aws_db_instance.ledger",
36
+ TF034: "aws_sns_topic.alerts",
37
+ TF035: "aws_sqs_queue.settlements",
38
+ TF036: "aws_ebs_volume.scratch",
39
+ TF037: "aws_ecr_repository.api",
40
+ };
41
+
42
+ const FAMILY = /^TF03[0-7]$/;
43
+
44
+ describe("epic #2284 acceptance: chant audit over the estate roots", () => {
45
+ test("every rule TF030 to TF037 is in the barrel", () => {
46
+ const shipped = new Set(postSynthChecks.map((c) => c.id));
47
+ expect(Object.keys(EXPECTED).filter((id) => !shipped.has(id))).toEqual([]);
48
+ });
49
+
50
+ for (const [id, address] of Object.entries(EXPECTED)) {
51
+ test(`the violating root reports ${id} on ${address}`, async () => {
52
+ const findings = (await audit("violating")).filter((f) => f.checkId === id);
53
+ expect(findings.map((f) => f.entity)).toEqual([`audit-root/${address}`]);
54
+ expect(["error", "warning"]).toContain(findings[0]!.severity);
55
+ });
56
+ }
57
+
58
+ test("the violating root reports nothing TF030 to TF037 cannot prove", async () => {
59
+ const family = (await audit("violating")).filter((f) => FAMILY.test(f.checkId));
60
+ expect(family.filter((f) => f.severity === "info")).toEqual([]);
61
+ expect(family.map((f) => f.checkId).sort()).toEqual(Object.keys(EXPECTED));
62
+ });
63
+
64
+ test("the clean root, provider-default cases included, reports nothing from TF030 to TF037", async () => {
65
+ const family = (await audit("clean")).filter((f) => FAMILY.test(f.checkId));
66
+ expect(family).toEqual([]);
67
+ });
68
+ });
@@ -0,0 +1,45 @@
1
+ # Vendored for TF030 from https://github.com/aws-samples/aws-cloudwan-workshop-code
2
+ # Path: terraform/modules/compute/main.tf
3
+ # Commit: 1a331e8782b6cccdc5d0bb4ed28c45594445cc2f
4
+ # Licence: MIT-0, https://github.com/aws-samples/aws-cloudwan-workshop-code/blob/1a331e8782b6cccdc5d0bb4ed28c45594445cc2f/LICENSE
5
+ # Excerpt: lines 1-37, unmodified.
6
+ #
7
+ # TF030: silent. A group with no ingress at all (closed, not unknown), ICMP from 0.0.0.0/0 (no ports), SSH from a referenced security group rather than a CIDR, and an all-traffic egress rule.
8
+
9
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
10
+ # SPDX-License-Identifier: MIT-0
11
+
12
+ # --- modules/compute/main.tf ---
13
+
14
+ # ---------- EC2 INSTANCES ----------
15
+ # Security Group
16
+ resource "aws_security_group" "instance_sg" {
17
+ name = "${var.vpc_name}-instance-security-group-${var.project_name}"
18
+ description = "EC2 Instance Security Group"
19
+ vpc_id = var.vpc_information.vpc_attributes.id
20
+ }
21
+
22
+ resource "aws_vpc_security_group_ingress_rule" "allowing_ingress_icmp" {
23
+ security_group_id = aws_security_group.instance_sg.id
24
+
25
+ from_port = -1
26
+ to_port = -1
27
+ ip_protocol = "icmp"
28
+ cidr_ipv4 = "0.0.0.0/0"
29
+ }
30
+
31
+ resource "aws_vpc_security_group_ingress_rule" "allowing_ingress_eic" {
32
+ security_group_id = aws_security_group.instance_sg.id
33
+
34
+ from_port = 22
35
+ to_port = 22
36
+ ip_protocol = "tcp"
37
+ referenced_security_group_id = aws_security_group.eic_sg.id
38
+ }
39
+
40
+ resource "aws_vpc_security_group_egress_rule" "allowing_egress_any" {
41
+ security_group_id = aws_security_group.instance_sg.id
42
+
43
+ ip_protocol = "-1"
44
+ cidr_ipv4 = "0.0.0.0/0"
45
+ }
@@ -0,0 +1,55 @@
1
+ # Vendored for TF030 from https://github.com/aws-samples/web-hosting-architecture-examples-for-china-region-terraform
2
+ # Path: eks/security-groups.tf
3
+ # Commit: 718a45d536672e7f5f4e1fa6011e3acb27ab4f5a
4
+ # Licence: MIT-0, https://github.com/aws-samples/web-hosting-architecture-examples-for-china-region-terraform/blob/718a45d536672e7f5f4e1fa6011e3acb27ab4f5a/LICENSE
5
+ # The whole file, unmodified.
6
+ #
7
+ # TF030: silent. Every group opens 22, but only to private ranges.
8
+
9
+
10
+ resource "aws_security_group" "worker_group_mgmt_one" {
11
+ name_prefix = "worker_group_mgmt_one"
12
+ vpc_id = module.vpc.vpc_id
13
+
14
+ ingress {
15
+ from_port = 22
16
+ to_port = 22
17
+ protocol = "tcp"
18
+
19
+ cidr_blocks = [
20
+ "10.0.0.0/8",
21
+ ]
22
+ }
23
+ }
24
+
25
+ resource "aws_security_group" "worker_group_mgmt_two" {
26
+ name_prefix = "worker_group_mgmt_two"
27
+ vpc_id = module.vpc.vpc_id
28
+
29
+ ingress {
30
+ from_port = 22
31
+ to_port = 22
32
+ protocol = "tcp"
33
+
34
+ cidr_blocks = [
35
+ "192.168.0.0/16",
36
+ ]
37
+ }
38
+ }
39
+
40
+ resource "aws_security_group" "all_worker_mgmt" {
41
+ name_prefix = "all_worker_management"
42
+ vpc_id = module.vpc.vpc_id
43
+
44
+ ingress {
45
+ from_port = 22
46
+ to_port = 22
47
+ protocol = "tcp"
48
+
49
+ cidr_blocks = [
50
+ "10.0.0.0/8",
51
+ "172.16.0.0/12",
52
+ "192.168.0.0/16",
53
+ ]
54
+ }
55
+ }
@@ -0,0 +1,28 @@
1
+ # Vendored for TF030 from https://github.com/gruntwork-io/terratest
2
+ # Path: examples/terraform-ssh-example/main.tf
3
+ # Commit: 75a9f881c31f71255b474149edada4a1850bce22
4
+ # Licence: Apache-2.0, https://github.com/gruntwork-io/terratest/blob/75a9f881c31f71255b474149edada4a1850bce22/LICENSE
5
+ # Excerpt: lines 61-80, the aws_security_group.example block, unmodified.
6
+ #
7
+ # TF030: one info, Not determined: the CIDR is 0.0.0.0/0 but from_port and to_port are var.ssh_port. The open egress is not reported.
8
+
9
+ resource "aws_security_group" "example" {
10
+ name = var.instance_name
11
+
12
+ egress {
13
+ from_port = 0
14
+ to_port = 0
15
+ protocol = "-1"
16
+ cidr_blocks = ["0.0.0.0/0"]
17
+ }
18
+
19
+ ingress {
20
+ from_port = var.ssh_port
21
+ to_port = var.ssh_port
22
+ protocol = "tcp"
23
+
24
+ # To keep this example simple, we allow incoming SSH requests from any IP. In real-world usage, you should only
25
+ # allow SSH requests from trusted servers, such as a bastion host or VPN server.
26
+ cidr_blocks = ["0.0.0.0/0"]
27
+ }
28
+ }
@@ -0,0 +1,32 @@
1
+ # Vendored for TF030 from https://github.com/aws-samples/terraform-sample-workshop
2
+ # Path: module_1/one_file_tf/simple_nginx_stack/main.tf
3
+ # Commit: 0a265e356a3cf4fd0f15ba821b7bedf712a32239
4
+ # Licence: MIT-0, https://github.com/aws-samples/terraform-sample-workshop/blob/0a265e356a3cf4fd0f15ba821b7bedf712a32239/LICENSE
5
+ # Excerpt: lines 127-150, unmodified.
6
+ #
7
+ # TF030: one info, Not determined: allow_ssh_internal opens 22 to cidr_blocks = [var.cidr_vpc]. egress_allow_all (protocol "all", 0.0.0.0/0) is egress and is not reported.
8
+
9
+ resource "aws_security_group" "vpc_security_group" {
10
+ name = "aws-${var.vpc_name}-vpc-sg"
11
+ vpc_id = aws_vpc.vpc.id
12
+ }
13
+
14
+ resource "aws_security_group_rule" "allow_ssh_internal" {
15
+ type = "ingress"
16
+ from_port = 22
17
+ to_port = 22
18
+ protocol = "tcp"
19
+ cidr_blocks = [var.cidr_vpc]
20
+
21
+ security_group_id = aws_security_group.vpc_security_group.id
22
+ }
23
+
24
+ resource "aws_security_group_rule" "egress_allow_all" {
25
+ type = "egress"
26
+ from_port = 0
27
+ to_port = 65535
28
+ protocol = "all"
29
+ cidr_blocks = ["0.0.0.0/0"]
30
+
31
+ security_group_id = aws_security_group.vpc_security_group.id
32
+ }
@@ -0,0 +1,21 @@
1
+ # Vendored for TF030 from https://github.com/aws-samples/sample-parallel-computing-service
2
+ # Path: modules/vpc/main.tf
3
+ # Commit: e74e5806f8fa203b268532f9f6c64e649b35708e
4
+ # Licence: MIT-0, https://github.com/aws-samples/sample-parallel-computing-service/blob/e74e5806f8fa203b268532f9f6c64e649b35708e/LICENSE
5
+ # Excerpt: lines 81-93, unmodified. The for_each map it reads, local.pcs_public_security_group_rules.ingress (lines 37-51 of the same file), does open 22 to 0.0.0.0/0.
6
+ #
7
+ # TF030: one info, Not determined: every attribute is each.value.*, so the rule cannot see the open SSH port that the locals declare. This is what the info finding is for.
8
+
9
+ resource "aws_security_group" "pcs_public" {
10
+ name = "${var.project}-public-sg"
11
+ vpc_id = aws_vpc.pcs.id
12
+ }
13
+
14
+ resource "aws_vpc_security_group_ingress_rule" "pcs_public_allow_ingress" {
15
+ for_each = local.pcs_public_security_group_rules.ingress
16
+ security_group_id = aws_security_group.pcs_public.id
17
+ cidr_ipv4 = each.value.cidr_ipv4
18
+ from_port = each.value.from_port
19
+ ip_protocol = each.value.ip_protocol
20
+ to_port = each.value.to_port
21
+ }
@@ -0,0 +1,39 @@
1
+ # Vendored for TF030 from https://github.com/aws-samples/sample-issac-lab-on-aws
2
+ # Path: main.tf
3
+ # Commit: 50ea76d87d873c1d69bed92c450ab144894f437e
4
+ # Licence: MIT-0, https://github.com/aws-samples/sample-issac-lab-on-aws/blob/50ea76d87d873c1d69bed92c450ab144894f437e/LICENSE
5
+ # Excerpt: lines 116-146, the aws_security_group.isaac block, unmodified.
6
+ #
7
+ # TF030: one info, Not determined: port 22 is open to cidr_blocks = var.allowed_ssh_cidrs, which the parse cannot read. No error.
8
+
9
+ resource "aws_security_group" "isaac" {
10
+ name_prefix = "${var.project_name}-sg-"
11
+ description = "Isaac Lab training instance security group"
12
+ vpc_id = aws_vpc.isaac.id
13
+
14
+ # SSH
15
+ ingress {
16
+ description = "SSH"
17
+ from_port = 22
18
+ to_port = 22
19
+ protocol = "tcp"
20
+ cidr_blocks = var.allowed_ssh_cidrs
21
+ }
22
+
23
+ # All outbound
24
+ egress {
25
+ from_port = 0
26
+ to_port = 0
27
+ protocol = "-1"
28
+ cidr_blocks = ["0.0.0.0/0"]
29
+ }
30
+
31
+ tags = {
32
+ Name = "${var.project_name}-sg"
33
+ Project = var.project_name
34
+ }
35
+
36
+ lifecycle {
37
+ create_before_destroy = true
38
+ }
39
+ }
@@ -0,0 +1,44 @@
1
+ # Vendored for TF030 from https://github.com/bridgecrewio/checkov
2
+ # Path: tests/terraform/checks/resource/aws/example_SecurityGroupUnrestrictedIngress22/main.tf
3
+ # Commit: 4ef6eb50e33f60d8a204138f08883e12494ac230
4
+ # Licence: Apache-2.0, https://github.com/bridgecrewio/checkov/blob/4ef6eb50e33f60d8a204138f08883e12494ac230/LICENSE
5
+ # Checkov's own test corpus for CKV_AWS_24. Excerpt: lines 63-98, the aws_security_group.fail4 and aws_security_group.fail-ipv6 blocks, unmodified.
6
+ #
7
+ # TF030: two errors: fail4 writes ingress in attribute syntax with protocol "-1" (every port), fail-ipv6 opens 22 to ::/0.
8
+
9
+ resource "aws_security_group" "fail4" {
10
+ description = "SG with inline rules"
11
+ ingress = [
12
+ {
13
+ cidr_blocks = ["0.0.0.0/0"]
14
+ description = "Wide Open"
15
+ from_port = 0
16
+ ipv6_cidr_blocks = []
17
+ prefix_list_ids = []
18
+ security_groups = []
19
+ protocol = "-1"
20
+ self = false
21
+ to_port = 65535
22
+ }
23
+ ]
24
+ }
25
+
26
+ resource "aws_security_group" "fail-ipv6" {
27
+ name = "sg-bar"
28
+ vpc_id = aws_vpc.main.id
29
+
30
+ ingress {
31
+ from_port = 22
32
+ to_port = 22
33
+ protocol = "tcp"
34
+ ipv6_cidr_blocks = ["192.168.0.0/16", "::/0"]
35
+ description = "foo"
36
+ }
37
+
38
+ egress {
39
+ from_port = 0
40
+ to_port = 0
41
+ protocol = "-1"
42
+ cidr_blocks = ["0.0.0.0/0"]
43
+ }
44
+ }
@@ -0,0 +1,36 @@
1
+ # Vendored for TF030 from https://github.com/aws-samples/aws-database-acceleration-toolkit
2
+ # Path: modules/tffiles-jenkins/jenkins.tf
3
+ # Commit: dbb3d2df6a53ef95049e04b7bbe69aa70c607f81
4
+ # Licence: MIT-0, https://github.com/aws-samples/aws-database-acceleration-toolkit/blob/dbb3d2df6a53ef95049e04b7bbe69aa70c607f81/LICENSE
5
+ # Excerpt: lines 38-65, the aws_security_group.jenkins_port block, unmodified.
6
+ #
7
+ # TF030: one error, on the second ingress (port 22 from 0.0.0.0/0). The first ingress opens 8080, which is not on the sensitive list, and the egress is not ingress.
8
+
9
+ resource "aws_security_group" "jenkins_port" {
10
+ vpc_id = var.vpc_id
11
+ provider = aws.primary
12
+
13
+ egress {
14
+ from_port = 0
15
+ to_port = 0
16
+ protocol = -1
17
+ cidr_blocks = ["0.0.0.0/0"]
18
+ }
19
+
20
+
21
+ ingress {
22
+ from_port = 8080
23
+ to_port = 8080
24
+ protocol = "tcp"
25
+ cidr_blocks = ["0.0.0.0/0"]
26
+ }
27
+
28
+ ingress {
29
+ from_port = 22
30
+ to_port = 22
31
+ protocol = "tcp"
32
+ cidr_blocks = ["0.0.0.0/0"]
33
+ }
34
+
35
+ lifecycle { create_before_destroy = true }
36
+ }
@@ -0,0 +1,25 @@
1
+ # Vendored for TF030 from https://github.com/bridgecrewio/checkov
2
+ # Path: tests/terraform/checks/resource/aws/example_SecurityGroupUnrestrictedIngress22/main.tf
3
+ # Commit: 4ef6eb50e33f60d8a204138f08883e12494ac230
4
+ # Licence: Apache-2.0, https://github.com/bridgecrewio/checkov/blob/4ef6eb50e33f60d8a204138f08883e12494ac230/LICENSE
5
+ # Checkov's own test corpus for CKV_AWS_24. Excerpt: lines 100-116, the aws_security_group_rule.fail and aws_vpc_security_group_ingress_rule.fail blocks, unmodified.
6
+ #
7
+ # TF030: two errors, one per standalone shape: a 0.0.0.0/0 among other CIDRs on 22, and cidr_ipv4 = "0.0.0.0/0" on 22.
8
+
9
+ resource "aws_security_group_rule" "fail" {
10
+ type = "ingress"
11
+ from_port = 22
12
+ to_port = 22
13
+ protocol = "tcp"
14
+ cidr_blocks = ["192.168.0.0/16", "0.0.0.0/0"]
15
+ security_group_id = aws_security_group.bar-sg.id
16
+ }
17
+
18
+ resource "aws_vpc_security_group_ingress_rule" "fail" {
19
+ security_group_id = aws_security_group.example.id
20
+
21
+ cidr_ipv4 = "0.0.0.0/0"
22
+ from_port = 22
23
+ ip_protocol = "tcp"
24
+ to_port = 22
25
+ }
@@ -0,0 +1,43 @@
1
+ # Vendored for TF030 from https://github.com/aws-samples/terraform-ec2-image-builder-container-hardening-pipeline
2
+ # Path: sec-groups.tf
3
+ # Commit: 68c34a21e966afc11c572677c319f2cc8379ec94
4
+ # Licence: MIT-0, https://github.com/aws-samples/terraform-ec2-image-builder-container-hardening-pipeline/blob/68c34a21e966afc11c572677c319f2cc8379ec94/LICENSE
5
+ # The whole file, unmodified.
6
+ #
7
+ # TF030: one error, on the "Ephemeral" ingress: tcp 1025-65535 from 0.0.0.0/0 spans 3306, 3389 and 5432. The TLS ingress on 443 is not reported.
8
+
9
+ resource "aws_security_group" "image_builder_sg" {
10
+ depends_on = [
11
+ aws_vpc.hardening_pipeline
12
+ ]
13
+ name = "${var.image_name}-sg"
14
+ description = "Security group for EC2 Image Builder"
15
+ vpc_id = aws_vpc.hardening_pipeline.id
16
+
17
+ ingress {
18
+ description = "TLS"
19
+ from_port = 443
20
+ to_port = 443
21
+ protocol = "tcp"
22
+ cidr_blocks = ["0.0.0.0/0"]
23
+ }
24
+
25
+ ingress {
26
+ description = "Ephemeral"
27
+ from_port = 1025
28
+ to_port = 65535
29
+ protocol = "tcp"
30
+ cidr_blocks = ["0.0.0.0/0"]
31
+ }
32
+
33
+ egress {
34
+ description = "Allow all eggress"
35
+ from_port = 0
36
+ to_port = 0
37
+ protocol = "-1"
38
+ cidr_blocks = ["0.0.0.0/0"]
39
+ ipv6_cidr_blocks = ["::/0"]
40
+ }
41
+
42
+ tags = local.core_tags
43
+ }