attackmap-analyzer-terraform 0.1.0__tar.gz
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.
Potentially problematic release.
This version of attackmap-analyzer-terraform might be problematic. Click here for more details.
- attackmap_analyzer_terraform-0.1.0/LICENSE +21 -0
- attackmap_analyzer_terraform-0.1.0/PKG-INFO +94 -0
- attackmap_analyzer_terraform-0.1.0/README.md +54 -0
- attackmap_analyzer_terraform-0.1.0/pyproject.toml +74 -0
- attackmap_analyzer_terraform-0.1.0/setup.cfg +4 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform/__init__.py +3 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform/analyzer.py +540 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform/contracts.py +30 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform.egg-info/PKG-INFO +94 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform.egg-info/SOURCES.txt +13 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform.egg-info/dependency_links.txt +1 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform.egg-info/entry_points.txt +2 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform.egg-info/requires.txt +9 -0
- attackmap_analyzer_terraform-0.1.0/src/attackmap_analyzer_terraform.egg-info/top_level.txt +1 -0
- attackmap_analyzer_terraform-0.1.0/tests/test_terraform_analyzer.py +514 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthew Davis and AttackMap Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: attackmap-analyzer-terraform
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Terraform / HCL infrastructure-as-code analyzer plugin for AttackMap (AWS, Azure, GCP resources; IAM wildcards; open security groups; secret resources).
|
|
5
|
+
Author: AttackMap Contributors
|
|
6
|
+
Author-email: Matthew Davis <matthewd@matthewd.xyz>
|
|
7
|
+
Maintainer-email: Matthew Davis <matthewd@matthewd.xyz>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/mlaify/attackmap-analyzer-terraform
|
|
10
|
+
Project-URL: Repository, https://github.com/mlaify/attackmap-analyzer-terraform
|
|
11
|
+
Project-URL: Issues, https://github.com/mlaify/attackmap-analyzer-terraform/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/mlaify/attackmap-analyzer-terraform/blob/main/CHANGELOG.md
|
|
13
|
+
Project-URL: AttackMap core, https://github.com/mlaify/AttackMap
|
|
14
|
+
Keywords: security,static-analysis,appsec,defensive-security,attackmap,attackmap-plugin
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Information Technology
|
|
18
|
+
Classifier: Intended Audience :: System Administrators
|
|
19
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
26
|
+
Classifier: Topic :: Security
|
|
27
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
28
|
+
Classifier: Typing :: Typed
|
|
29
|
+
Requires-Python: >=3.11
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: pydantic>=2.7.0
|
|
33
|
+
Provides-Extra: core
|
|
34
|
+
Requires-Dist: attackmap>=0.1.0; extra == "core"
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
38
|
+
Requires-Dist: attackmap>=0.1.0; extra == "dev"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# attackmap-analyzer-terraform
|
|
42
|
+
|
|
43
|
+
Terraform / HCL infrastructure-as-code analyzer for [AttackMap](https://github.com/mlaify/AttackMap).
|
|
44
|
+
|
|
45
|
+
This analyzer is shaped differently from language analyzers — Terraform doesn't have routes in the application sense. Instead, it extracts:
|
|
46
|
+
|
|
47
|
+
- **Public ingress** — security groups and firewall rules with `0.0.0.0/0`, Lambda Function URLs with no auth, API Gateway methods with `authorization = "NONE"`, S3 buckets with public ACLs or disabled public-access blocks → `entrypoint_hints`
|
|
48
|
+
- **Asset inventory** — S3 buckets, Azure storage accounts, GCS buckets, KMS keys, Cognito user pools → `service_hints`
|
|
49
|
+
- **Databases** — `aws_db_instance` and `aws_rds_cluster` (engine-aware: postgres / mysql / oracle / sqlserver / mariadb), `aws_dynamodb_table`, `aws_elasticache_*`, `aws_documentdb_*`, Azure PostgreSQL/MySQL/CosmosDB, GCP Cloud SQL → `database_hints`
|
|
50
|
+
- **Secrets** — `aws_secretsmanager_secret`, `aws_ssm_parameter` (SecureString), `azurerm_key_vault`, plus `variable` blocks marked `sensitive = true` or with secret-shaped names (`*secret*`, `*token*`, `*password*`, `*key*`) → `secret_hints`
|
|
51
|
+
- **IAM blast radius** — `aws_iam_*_policy` resources with wildcard `Action = "*"` or `Resource = "*"` → `auth_hints` with confidence 0.7
|
|
52
|
+
- **Cognito** — `aws_cognito_user_pool` → `auth_hints`
|
|
53
|
+
- **Modules** — `module "x" { source = ... }` → `service_hints` keyed `module:x`
|
|
54
|
+
- **API Gateway v2 routes** — `aws_apigatewayv2_route` with `route_key = "POST /charges"` → actual `Route` entries
|
|
55
|
+
|
|
56
|
+
All emissions populate AttackMap's Signal v2 fields (line numbers + evidence snippets) so downstream insights can cite `infra/main.tf:NN`.
|
|
57
|
+
|
|
58
|
+
## Install
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install git+https://github.com/mlaify/attackmap-analyzer-terraform.git
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The analyzer is auto-discovered by AttackMap via the `attackmap.analyzers` entry-point group.
|
|
65
|
+
|
|
66
|
+
## Usage with AttackMap
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Auto-discovered when installed:
|
|
70
|
+
attackmap analyze /path/to/terraform/repo
|
|
71
|
+
|
|
72
|
+
# Or invoke explicitly:
|
|
73
|
+
attackmap analyze /path/to/terraform/repo --module terraform
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Detection
|
|
77
|
+
|
|
78
|
+
`detect()` returns true when any `.tf`, `.tf.json`, or `.tfvars` file is present in the tree, ignoring `.terraform/`, `.git/`, `node_modules/`, and `vendor/`.
|
|
79
|
+
|
|
80
|
+
## HCL block parsing
|
|
81
|
+
|
|
82
|
+
The analyzer parses HCL block bodies via brace-depth counting (with string-literal awareness so `"{" inside strings"` doesn't throw off the counter). Nested blocks like multiple `ingress { }` blocks inside a security group are handled correctly. **Variable interpolation** (`${var.foo}`, `aws_iam_role.app.id`) is **not resolved** — string literals and direct attribute values are what get extracted.
|
|
83
|
+
|
|
84
|
+
## Coverage notes
|
|
85
|
+
|
|
86
|
+
- **AWS** is the most thoroughly covered provider. Azure and GCP have basic coverage (NSG/firewall open ingress, Storage Account / GCS bucket as service hints, PostgreSQL/MySQL/CosmosDB/CloudSQL as databases) — extend per resource type as needed.
|
|
87
|
+
- **IAM wildcard detection** matches both JSON-shaped (`"Action": "*"`) and HCL-shaped (`Action = "*"`) policy bodies. It does not currently look across separate `aws_iam_policy_document` data sources — that's roadmap.
|
|
88
|
+
- **API Gateway v1** routing is partial — only individual `aws_api_gateway_method` resources emit entrypoint hints. Path joining across `aws_api_gateway_resource` chains is not yet implemented (use API Gateway v2 / `aws_apigatewayv2_route` for full path+method extraction).
|
|
89
|
+
- **Lambda Function URLs** with `authorization_type = "NONE"` are flagged as open entrypoints. IAM-authorized URLs are emitted with the regular `lambda_url:` prefix.
|
|
90
|
+
- **Database `publicly_accessible = true`** on `aws_db_instance` produces a separate `rds_publicly_accessible:` entrypoint hint in addition to the standard database hint.
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# attackmap-analyzer-terraform
|
|
2
|
+
|
|
3
|
+
Terraform / HCL infrastructure-as-code analyzer for [AttackMap](https://github.com/mlaify/AttackMap).
|
|
4
|
+
|
|
5
|
+
This analyzer is shaped differently from language analyzers — Terraform doesn't have routes in the application sense. Instead, it extracts:
|
|
6
|
+
|
|
7
|
+
- **Public ingress** — security groups and firewall rules with `0.0.0.0/0`, Lambda Function URLs with no auth, API Gateway methods with `authorization = "NONE"`, S3 buckets with public ACLs or disabled public-access blocks → `entrypoint_hints`
|
|
8
|
+
- **Asset inventory** — S3 buckets, Azure storage accounts, GCS buckets, KMS keys, Cognito user pools → `service_hints`
|
|
9
|
+
- **Databases** — `aws_db_instance` and `aws_rds_cluster` (engine-aware: postgres / mysql / oracle / sqlserver / mariadb), `aws_dynamodb_table`, `aws_elasticache_*`, `aws_documentdb_*`, Azure PostgreSQL/MySQL/CosmosDB, GCP Cloud SQL → `database_hints`
|
|
10
|
+
- **Secrets** — `aws_secretsmanager_secret`, `aws_ssm_parameter` (SecureString), `azurerm_key_vault`, plus `variable` blocks marked `sensitive = true` or with secret-shaped names (`*secret*`, `*token*`, `*password*`, `*key*`) → `secret_hints`
|
|
11
|
+
- **IAM blast radius** — `aws_iam_*_policy` resources with wildcard `Action = "*"` or `Resource = "*"` → `auth_hints` with confidence 0.7
|
|
12
|
+
- **Cognito** — `aws_cognito_user_pool` → `auth_hints`
|
|
13
|
+
- **Modules** — `module "x" { source = ... }` → `service_hints` keyed `module:x`
|
|
14
|
+
- **API Gateway v2 routes** — `aws_apigatewayv2_route` with `route_key = "POST /charges"` → actual `Route` entries
|
|
15
|
+
|
|
16
|
+
All emissions populate AttackMap's Signal v2 fields (line numbers + evidence snippets) so downstream insights can cite `infra/main.tf:NN`.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install git+https://github.com/mlaify/attackmap-analyzer-terraform.git
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The analyzer is auto-discovered by AttackMap via the `attackmap.analyzers` entry-point group.
|
|
25
|
+
|
|
26
|
+
## Usage with AttackMap
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Auto-discovered when installed:
|
|
30
|
+
attackmap analyze /path/to/terraform/repo
|
|
31
|
+
|
|
32
|
+
# Or invoke explicitly:
|
|
33
|
+
attackmap analyze /path/to/terraform/repo --module terraform
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Detection
|
|
37
|
+
|
|
38
|
+
`detect()` returns true when any `.tf`, `.tf.json`, or `.tfvars` file is present in the tree, ignoring `.terraform/`, `.git/`, `node_modules/`, and `vendor/`.
|
|
39
|
+
|
|
40
|
+
## HCL block parsing
|
|
41
|
+
|
|
42
|
+
The analyzer parses HCL block bodies via brace-depth counting (with string-literal awareness so `"{" inside strings"` doesn't throw off the counter). Nested blocks like multiple `ingress { }` blocks inside a security group are handled correctly. **Variable interpolation** (`${var.foo}`, `aws_iam_role.app.id`) is **not resolved** — string literals and direct attribute values are what get extracted.
|
|
43
|
+
|
|
44
|
+
## Coverage notes
|
|
45
|
+
|
|
46
|
+
- **AWS** is the most thoroughly covered provider. Azure and GCP have basic coverage (NSG/firewall open ingress, Storage Account / GCS bucket as service hints, PostgreSQL/MySQL/CosmosDB/CloudSQL as databases) — extend per resource type as needed.
|
|
47
|
+
- **IAM wildcard detection** matches both JSON-shaped (`"Action": "*"`) and HCL-shaped (`Action = "*"`) policy bodies. It does not currently look across separate `aws_iam_policy_document` data sources — that's roadmap.
|
|
48
|
+
- **API Gateway v1** routing is partial — only individual `aws_api_gateway_method` resources emit entrypoint hints. Path joining across `aws_api_gateway_resource` chains is not yet implemented (use API Gateway v2 / `aws_apigatewayv2_route` for full path+method extraction).
|
|
49
|
+
- **Lambda Function URLs** with `authorization_type = "NONE"` are flagged as open entrypoints. IAM-authorized URLs are emitted with the regular `lambda_url:` prefix.
|
|
50
|
+
- **Database `publicly_accessible = true`** on `aws_db_instance` produces a separate `rds_publicly_accessible:` entrypoint hint in addition to the standard database hint.
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "attackmap-analyzer-terraform"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Terraform / HCL infrastructure-as-code analyzer plugin for AttackMap (AWS, Azure, GCP resources; IAM wildcards; open security groups; secret resources)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Matthew Davis", email = "matthewd@matthewd.xyz"},
|
|
14
|
+
{name = "AttackMap Contributors"},
|
|
15
|
+
]
|
|
16
|
+
maintainers = [
|
|
17
|
+
{name = "Matthew Davis", email = "matthewd@matthewd.xyz"},
|
|
18
|
+
]
|
|
19
|
+
keywords = [
|
|
20
|
+
"security",
|
|
21
|
+
"static-analysis",
|
|
22
|
+
"appsec",
|
|
23
|
+
"defensive-security",
|
|
24
|
+
"attackmap",
|
|
25
|
+
"attackmap-plugin",
|
|
26
|
+
]
|
|
27
|
+
classifiers = [
|
|
28
|
+
"Development Status :: 4 - Beta",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"Intended Audience :: Information Technology",
|
|
31
|
+
"Intended Audience :: System Administrators",
|
|
32
|
+
"License :: OSI Approved :: MIT License",
|
|
33
|
+
"Operating System :: OS Independent",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.11",
|
|
36
|
+
"Programming Language :: Python :: 3.12",
|
|
37
|
+
"Programming Language :: Python :: 3.13",
|
|
38
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
39
|
+
"Topic :: Security",
|
|
40
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
41
|
+
"Typing :: Typed",
|
|
42
|
+
]
|
|
43
|
+
dependencies = [
|
|
44
|
+
"pydantic>=2.7.0",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.optional-dependencies]
|
|
48
|
+
core = [
|
|
49
|
+
"attackmap>=0.1.0",
|
|
50
|
+
]
|
|
51
|
+
dev = [
|
|
52
|
+
"pytest>=8.0.0",
|
|
53
|
+
"build>=1.2.0",
|
|
54
|
+
"attackmap>=0.1.0",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[project.urls]
|
|
58
|
+
Homepage = "https://github.com/mlaify/attackmap-analyzer-terraform"
|
|
59
|
+
Repository = "https://github.com/mlaify/attackmap-analyzer-terraform"
|
|
60
|
+
Issues = "https://github.com/mlaify/attackmap-analyzer-terraform/issues"
|
|
61
|
+
Changelog = "https://github.com/mlaify/attackmap-analyzer-terraform/blob/main/CHANGELOG.md"
|
|
62
|
+
"AttackMap core" = "https://github.com/mlaify/AttackMap"
|
|
63
|
+
|
|
64
|
+
[project.entry-points."attackmap.analyzers"]
|
|
65
|
+
terraform = "attackmap_analyzer_terraform:TerraformAnalyzer"
|
|
66
|
+
|
|
67
|
+
[tool.setuptools]
|
|
68
|
+
package-dir = {"" = "src"}
|
|
69
|
+
|
|
70
|
+
[tool.setuptools.packages.find]
|
|
71
|
+
where = ["src"]
|
|
72
|
+
|
|
73
|
+
[tool.pytest.ini_options]
|
|
74
|
+
testpaths = ["tests"]
|