iam-policy-validator 1.10.2__py3-none-any.whl → 1.11.0__py3-none-any.whl
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.
- iam_policy_validator-1.11.0.dist-info/METADATA +782 -0
- {iam_policy_validator-1.10.2.dist-info → iam_policy_validator-1.11.0.dist-info}/RECORD +26 -22
- iam_validator/__version__.py +1 -1
- iam_validator/checks/action_condition_enforcement.py +27 -14
- iam_validator/checks/sensitive_action.py +123 -11
- iam_validator/checks/utils/policy_level_checks.py +47 -10
- iam_validator/checks/wildcard_resource.py +29 -7
- iam_validator/commands/__init__.py +6 -0
- iam_validator/commands/completion.py +420 -0
- iam_validator/commands/query.py +485 -0
- iam_validator/commands/validate.py +21 -26
- iam_validator/core/config/category_suggestions.py +77 -0
- iam_validator/core/config/condition_requirements.py +105 -54
- iam_validator/core/config/defaults.py +110 -6
- iam_validator/core/config/wildcards.py +3 -0
- iam_validator/core/diff_parser.py +321 -0
- iam_validator/core/formatters/enhanced.py +34 -27
- iam_validator/core/models.py +2 -0
- iam_validator/core/pr_commenter.py +179 -51
- iam_validator/core/report.py +19 -17
- iam_validator/integrations/github_integration.py +250 -1
- iam_validator/sdk/__init__.py +33 -0
- iam_validator/sdk/query_utils.py +454 -0
- iam_policy_validator-1.10.2.dist-info/METADATA +0 -549
- {iam_policy_validator-1.10.2.dist-info → iam_policy_validator-1.11.0.dist-info}/WHEEL +0 -0
- {iam_policy_validator-1.10.2.dist-info → iam_policy_validator-1.11.0.dist-info}/entry_points.txt +0 -0
- {iam_policy_validator-1.10.2.dist-info → iam_policy_validator-1.11.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,549 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: iam-policy-validator
|
|
3
|
-
Version: 1.10.2
|
|
4
|
-
Summary: Validate AWS IAM policies for correctness and security using AWS Service Reference API
|
|
5
|
-
Project-URL: Homepage, https://github.com/boogy/iam-policy-validator
|
|
6
|
-
Project-URL: Documentation, https://github.com/boogy/iam-policy-validator/tree/main/docs
|
|
7
|
-
Project-URL: Repository, https://github.com/boogy/iam-policy-validator
|
|
8
|
-
Project-URL: Issues, https://github.com/boogy/iam-policy-validator/issues
|
|
9
|
-
Project-URL: Changelog, https://github.com/boogy/iam-policy-validator/blob/main/docs/CHANGELOG.md
|
|
10
|
-
Author-email: boogy <0xboogy@gmail.com>
|
|
11
|
-
License: MIT
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Keywords: aws,github-action,iam,policy,security,validation
|
|
14
|
-
Classifier: Development Status :: 4 - Beta
|
|
15
|
-
Classifier: Intended Audience :: Developers
|
|
16
|
-
Classifier: Intended Audience :: System Administrators
|
|
17
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
-
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
-
Classifier: Topic :: Security
|
|
23
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
-
Classifier: Topic :: System :: Systems Administration
|
|
25
|
-
Requires-Python: >=3.10
|
|
26
|
-
Requires-Dist: boto3>=1.28.0
|
|
27
|
-
Requires-Dist: botocore>=1.40.55
|
|
28
|
-
Requires-Dist: httpx[http2]>=0.27.0
|
|
29
|
-
Requires-Dist: pydantic>=2.0.0
|
|
30
|
-
Requires-Dist: pyyaml>=6.0
|
|
31
|
-
Requires-Dist: rich>=13.0.0
|
|
32
|
-
Provides-Extra: dev
|
|
33
|
-
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
34
|
-
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
35
|
-
Requires-Dist: pytest-benchmark>=4.0.0; extra == 'dev'
|
|
36
|
-
Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
|
|
37
|
-
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
38
|
-
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
39
|
-
Requires-Dist: types-boto3; extra == 'dev'
|
|
40
|
-
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
41
|
-
Description-Content-Type: text/markdown
|
|
42
|
-
|
|
43
|
-
# IAM Policy Validator
|
|
44
|
-
|
|
45
|
-
> **⚡ Catch IAM policy security issues and errors before they reach production** - A comprehensive validation tool for AWS IAM policies with built-in security checks and optional AWS Access Analyzer integration.
|
|
46
|
-
|
|
47
|
-
[](https://github.com/marketplace/actions/iam-policy-validator)
|
|
48
|
-
[](https://www.python.org/downloads/)
|
|
49
|
-
[](LICENSE)
|
|
50
|
-
[](https://scorecard.dev/viewer/?uri=github.com/boogy/iam-policy-validator)
|
|
51
|
-
|
|
52
|
-
## 🚀 Why IAM Policy Validator?
|
|
53
|
-
|
|
54
|
-
**IAM policy errors are costly and dangerous.** A single misconfigured policy can:
|
|
55
|
-
- ❌ Grant unintended admin access (privilege escalation)
|
|
56
|
-
- ❌ Expose sensitive data to the public
|
|
57
|
-
- ❌ Break production deployments with invalid syntax
|
|
58
|
-
- ❌ Create security vulnerabilities that persist for months
|
|
59
|
-
|
|
60
|
-
**This tool prevents these issues** by:
|
|
61
|
-
- ✅ **Dual validation** - built-in checks + optional AWS Access Analyzer
|
|
62
|
-
- ✅ **Catches real threats** - Privilege escalation, wildcards, missing conditions
|
|
63
|
-
- ✅ **PR integration** - Automated validation in GitHub Actions
|
|
64
|
-
- ✅ **Saves security team time** - Catches common issues before manual review
|
|
65
|
-
- ✅ **Developer-friendly** - Clear errors with fix suggestions
|
|
66
|
-
- ✅ **Zero setup** - Works as a GitHub Action out of the box
|
|
67
|
-
|
|
68
|
-
## ✨ What Makes It Special
|
|
69
|
-
|
|
70
|
-
### 🔍 Two Validation Layers
|
|
71
|
-
|
|
72
|
-
**1. Built-in Checks (No AWS Credentials Required)**
|
|
73
|
-
- **Security & Compliance Checks** - Works offline, no AWS account needed
|
|
74
|
-
- **Privilege Escalation Detection** - Detects dangerous IAM actions and configurable combination patterns
|
|
75
|
-
- **Wildcard Analysis** - Catches overly permissive wildcards (`*`, `s3:*`)
|
|
76
|
-
- **Sensitive Action Enforcement** - 490 actions requiring conditions (MFA, IP, tags)
|
|
77
|
-
- **AWS Requirements Validation** - Actions, conditions, ARN formats, policy size
|
|
78
|
-
|
|
79
|
-
**2. AWS Access Analyzer (Optional)**
|
|
80
|
-
- **Official AWS Validation** - Syntax, semantics, and security checks
|
|
81
|
-
- **Public Access Detection** - Checks 29+ resource types (S3, Lambda, SNS, etc.)
|
|
82
|
-
- **Policy Comparison** - Detect new permissions vs baseline
|
|
83
|
-
- **Cross-account Analysis** - Validates external access
|
|
84
|
-
|
|
85
|
-
### 🎯 Developer Experience
|
|
86
|
-
- **Auto-detects IAM policies** - Scans mixed JSON/YAML repos automatically
|
|
87
|
-
- **PR comments & reviews** - Line-specific feedback in GitHub
|
|
88
|
-
- **7 output formats** - Console, JSON, Markdown, SARIF, CSV, HTML, Enhanced
|
|
89
|
-
- **Extensible** - Add custom checks via Python plugins
|
|
90
|
-
|
|
91
|
-
**📖 See [full feature documentation](docs/README.md) for details**
|
|
92
|
-
|
|
93
|
-
## 📈 What It Catches
|
|
94
|
-
|
|
95
|
-
### Example 1: Privilege Escalation (Built-in Check)
|
|
96
|
-
```json
|
|
97
|
-
{
|
|
98
|
-
"Statement": [
|
|
99
|
-
{"Effect": "Allow", "Action": "iam:CreateUser", "Resource": "*"},
|
|
100
|
-
{"Effect": "Allow", "Action": "iam:AttachUserPolicy", "Resource": "*"}
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**Detected:**
|
|
106
|
-
```
|
|
107
|
-
🚨 CRITICAL: Privilege escalation risk detected!
|
|
108
|
-
Actions ['iam:CreateUser', 'iam:AttachUserPolicy'] enable:
|
|
109
|
-
1. Create new IAM user
|
|
110
|
-
2. Attach AdministratorAccess to that user
|
|
111
|
-
3. Gain full AWS account access
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Example 2: Overly Permissive Wildcards (Built-in Check)
|
|
115
|
-
```json
|
|
116
|
-
{
|
|
117
|
-
"Effect": "Allow",
|
|
118
|
-
"Action": "s3:*",
|
|
119
|
-
"Resource": "*"
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**Detected:**
|
|
124
|
-
```
|
|
125
|
-
❌ HIGH: Service wildcard 's3:*' detected
|
|
126
|
-
❌ MEDIUM: Wildcard resource '*' - applies to all S3 buckets
|
|
127
|
-
❌ CRITICAL: Full wildcard (Action + Resource) grants excessive access
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Example 3: Missing Required Conditions (Built-in Check)
|
|
131
|
-
```json
|
|
132
|
-
{
|
|
133
|
-
"Effect": "Allow",
|
|
134
|
-
"Action": "iam:PassRole",
|
|
135
|
-
"Resource": "*"
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
**Detected:**
|
|
140
|
-
```
|
|
141
|
-
❌ HIGH: iam:PassRole missing required condition
|
|
142
|
-
💡 Add condition: iam:PassedToService to restrict role passing
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Example 4: Public Access (Access Analyzer - Optional)
|
|
146
|
-
```json
|
|
147
|
-
{
|
|
148
|
-
"Principal": "*",
|
|
149
|
-
"Action": "s3:GetObject",
|
|
150
|
-
"Resource": "arn:aws:s3:::private-bucket/*"
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**Detected:**
|
|
155
|
-
```
|
|
156
|
-
🛑 CRITICAL: Resource policy allows public internet access
|
|
157
|
-
Principal "*" grants world-readable access to S3 bucket
|
|
158
|
-
💡 Use specific AWS principals or add aws:SourceIp conditions
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## Quick Start
|
|
162
|
-
|
|
163
|
-
### GitHub Action (Recommended)
|
|
164
|
-
|
|
165
|
-
Create `.github/workflows/iam-validator.yml`:
|
|
166
|
-
|
|
167
|
-
```yaml
|
|
168
|
-
name: IAM Policy Validation
|
|
169
|
-
|
|
170
|
-
on:
|
|
171
|
-
pull_request:
|
|
172
|
-
paths: ['policies/**/*.json']
|
|
173
|
-
|
|
174
|
-
jobs:
|
|
175
|
-
validate:
|
|
176
|
-
runs-on: ubuntu-latest
|
|
177
|
-
permissions:
|
|
178
|
-
contents: read
|
|
179
|
-
pull-requests: write
|
|
180
|
-
steps:
|
|
181
|
-
- uses: actions/checkout@v5
|
|
182
|
-
- uses: boogy/iam-policy-validator@v1
|
|
183
|
-
with:
|
|
184
|
-
path: policies/
|
|
185
|
-
fail-on-warnings: true
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
**With AWS Access Analyzer (optional):**
|
|
189
|
-
```yaml
|
|
190
|
-
- uses: aws-actions/configure-aws-credentials@v4
|
|
191
|
-
with:
|
|
192
|
-
role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
|
|
193
|
-
aws-region: us-east-1
|
|
194
|
-
- uses: boogy/iam-policy-validator@v1
|
|
195
|
-
with:
|
|
196
|
-
path: policies/
|
|
197
|
-
use-access-analyzer: true
|
|
198
|
-
run-all-checks: true # Run both Access Analyzer + built-in checks
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
**📖 For all GitHub Action inputs and advanced workflows, see [GitHub Actions Guide](docs/github-actions-workflows.md)**
|
|
202
|
-
|
|
203
|
-
### CLI Tool
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
# Install
|
|
207
|
-
pip install iam-policy-validator
|
|
208
|
-
|
|
209
|
-
# Validate (built-in checks only - no AWS credentials needed)
|
|
210
|
-
iam-validator validate --path ./policies/
|
|
211
|
-
|
|
212
|
-
# Validate with AWS Access Analyzer (requires AWS credentials)
|
|
213
|
-
iam-validator analyze --path ./policies/
|
|
214
|
-
|
|
215
|
-
# With both Access Analyzer + built-in checks
|
|
216
|
-
iam-validator analyze --path ./policies/ --run-all-checks
|
|
217
|
-
|
|
218
|
-
# Different policy types
|
|
219
|
-
iam-validator validate --path ./policies/ --policy-type RESOURCE_POLICY
|
|
220
|
-
|
|
221
|
-
# Output formats
|
|
222
|
-
iam-validator validate --path ./policies/ --format json --output report.json
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
**📖 See [CLI documentation](docs/README.md) for all commands and options**
|
|
226
|
-
|
|
227
|
-
### Python Library
|
|
228
|
-
|
|
229
|
-
```python
|
|
230
|
-
from iam_validator.core.policy_loader import PolicyLoader
|
|
231
|
-
from iam_validator.core.policy_checks import validate_policies
|
|
232
|
-
|
|
233
|
-
# Load and validate
|
|
234
|
-
loader = PolicyLoader()
|
|
235
|
-
policies = loader.load_from_path("./policies")
|
|
236
|
-
results = await validate_policies(policies)
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
**📖 See [Python Library Guide](docs/python-library-usage.md) for complete examples**
|
|
240
|
-
|
|
241
|
-
## Built-in Validation Checks
|
|
242
|
-
|
|
243
|
-
**All checks are fully configurable** - Enable/disable checks, adjust severity levels, add custom requirements, and define ignore patterns through the configuration file.
|
|
244
|
-
|
|
245
|
-
### Core Checks (18 always-on + 1 opt-in)
|
|
246
|
-
|
|
247
|
-
The validator includes **19 built-in checks** organized into three categories:
|
|
248
|
-
|
|
249
|
-
### AWS Correctness Checks (12)
|
|
250
|
-
Validates policies against AWS IAM requirements:
|
|
251
|
-
- **Policy structure** - Validates fundamental IAM policy grammar (Version, Effect, required fields, conflicts)
|
|
252
|
-
- **Action validation** - Verify actions exist in AWS services
|
|
253
|
-
- **Condition key validation** - Check condition keys are valid for actions
|
|
254
|
-
- **Condition type matching** - Ensure condition values match expected types
|
|
255
|
-
- **Resource ARN validation** - Validate ARN formats and patterns
|
|
256
|
-
- **Principal validation** - Check principal formats (resource policies)
|
|
257
|
-
- **Policy size limits** - Enforce AWS size constraints
|
|
258
|
-
- **SID uniqueness** - Ensure statement IDs are unique
|
|
259
|
-
- **Set operator validation** - Validate ForAllValues/ForAnyValue usage
|
|
260
|
-
- **MFA condition patterns** - Detect common MFA anti-patterns
|
|
261
|
-
- **Policy type validation** - Enforce policy type requirements (RCP, SCP, etc.)
|
|
262
|
-
- **Action-resource matching** - Detect impossible action-resource combinations
|
|
263
|
-
|
|
264
|
-
### Security Best Practices (6)
|
|
265
|
-
Identifies security risks and overly permissive permissions:
|
|
266
|
-
- **Wildcard action** (`Action: "*"`)
|
|
267
|
-
- **Wildcard resource** (`Resource: "*"`)
|
|
268
|
-
- **Full wildcard** (CRITICAL: both `Action: "*"` and `Resource: "*"`)
|
|
269
|
-
- **Service wildcards** (`s3:*`, `iam:*`, etc.)
|
|
270
|
-
- **Sensitive actions** - ~490 actions across 4 risk categories requiring conditions
|
|
271
|
-
- **Action condition enforcement** - Enforce required conditions (MFA, IP, SourceArn, etc.)
|
|
272
|
-
|
|
273
|
-
### Trust Policy Validation (1 - Opt-in, Disabled by Default)
|
|
274
|
-
Specialized validation for role assumption policies:
|
|
275
|
-
- **Trust policy validation** - Validates action-principal coupling for assume role actions
|
|
276
|
-
- Ensures correct principal types (`AssumeRoleWithSAML` → Federated, etc.)
|
|
277
|
-
- Validates SAML/OIDC provider ARN formats
|
|
278
|
-
- Enforces required conditions (`SAML:aud`, OIDC audience, etc.)
|
|
279
|
-
- Use with `--policy-type TRUST_POLICY` flag
|
|
280
|
-
- See [Trust Policy Examples](examples/trust-policies/README.md)
|
|
281
|
-
|
|
282
|
-
### Configuration & Customization
|
|
283
|
-
|
|
284
|
-
All checks can be customized via a yaml configuration file ex: `.iam-validator.yaml`:
|
|
285
|
-
|
|
286
|
-
```yaml
|
|
287
|
-
settings:
|
|
288
|
-
enable_builtin_checks: true
|
|
289
|
-
fail_on_severity: high
|
|
290
|
-
|
|
291
|
-
# Customize individual checks
|
|
292
|
-
wildcard_action:
|
|
293
|
-
enabled: true
|
|
294
|
-
severity: critical
|
|
295
|
-
|
|
296
|
-
# Detect privilege escalation patterns
|
|
297
|
-
sensitive_action:
|
|
298
|
-
enabled: true
|
|
299
|
-
severity: critical
|
|
300
|
-
sensitive_actions:
|
|
301
|
-
# all_of: Detects when ALL actions exist across the entire policy
|
|
302
|
-
# (checks multiple statements - finds scattered dangerous combinations)
|
|
303
|
-
- all_of:
|
|
304
|
-
- "iam:CreateUser"
|
|
305
|
-
- "iam:AttachUserPolicy"
|
|
306
|
-
|
|
307
|
-
# any_of: Detects when ANY action exists in a single statement
|
|
308
|
-
# (per-statement check - flags individual dangerous actions)
|
|
309
|
-
- any_of:
|
|
310
|
-
- "iam:PutUserPolicy"
|
|
311
|
-
- "iam:PutGroupPolicy"
|
|
312
|
-
- "iam:PutRolePolicy"
|
|
313
|
-
|
|
314
|
-
# Lambda backdoor: Needs both actions somewhere in policy
|
|
315
|
-
- all_of:
|
|
316
|
-
- "lambda:CreateFunction"
|
|
317
|
-
- "iam:PassRole"
|
|
318
|
-
|
|
319
|
-
# Regex patterns work with all_of (policy-wide check)
|
|
320
|
-
- all_of:
|
|
321
|
-
- "iam:Create.*" # Any IAM Create action
|
|
322
|
-
- "iam:Attach.*" # Any IAM Attach action
|
|
323
|
-
|
|
324
|
-
# Enforce required conditions for sensitive actions
|
|
325
|
-
action_condition_enforcement:
|
|
326
|
-
enabled: true
|
|
327
|
-
action_condition_requirements:
|
|
328
|
-
- actions: ["iam:PassRole"]
|
|
329
|
-
severity: critical
|
|
330
|
-
required_conditions:
|
|
331
|
-
- condition_key: "iam:PassedToService"
|
|
332
|
-
|
|
333
|
-
# Ignore specific patterns
|
|
334
|
-
ignore_patterns:
|
|
335
|
-
- filepath: "terraform/modules/admin/*.json"
|
|
336
|
-
- action: "s3:*"
|
|
337
|
-
filepath: "policies/s3-admin-policy.json"
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
**📖 Complete documentation:**
|
|
341
|
-
- [Check Reference Guide](docs/check-reference.md) - All 19 checks with examples
|
|
342
|
-
- [Configuration Guide](docs/configuration.md) - Full configuration options
|
|
343
|
-
- [Condition Requirements](docs/condition-requirements.md) - Action-specific requirements
|
|
344
|
-
- [Privilege Escalation Detection](docs/privilege-escalation.md) - How privilege escalation works
|
|
345
|
-
- [Trust Policy Validation](examples/trust-policies/README.md) - Trust policy examples and validation
|
|
346
|
-
|
|
347
|
-
## Output Formats & GitHub Integration
|
|
348
|
-
|
|
349
|
-
### Output Formats
|
|
350
|
-
- **Console** - Clean terminal output with colors
|
|
351
|
-
- **Enhanced** - Visual output with progress bars
|
|
352
|
-
- **JSON** - Structured data for automation
|
|
353
|
-
- **Markdown** - GitHub PR comments
|
|
354
|
-
- **SARIF** - GitHub Code Scanning integration
|
|
355
|
-
- **CSV** - Spreadsheet analysis
|
|
356
|
-
- **HTML** - Interactive reports
|
|
357
|
-
|
|
358
|
-
### GitHub PR Integration
|
|
359
|
-
|
|
360
|
-
**Three comment modes (use any combination):**
|
|
361
|
-
- `--github-comment` - Summary in PR conversation
|
|
362
|
-
- `--github-review` - Line-specific review comments on files
|
|
363
|
-
- `--github-summary` - Overview in GitHub Actions summary tab
|
|
364
|
-
|
|
365
|
-
**Smart comment management:**
|
|
366
|
-
- Automatically cleans up old comments from previous runs
|
|
367
|
-
- Updates summaries instead of duplicating
|
|
368
|
-
- No stale comments left behind
|
|
369
|
-
|
|
370
|
-
**📖 See [GitHub Integration Guide](docs/github-actions-workflows.md) for detailed examples**
|
|
371
|
-
|
|
372
|
-
## Cache Management & Offline Mode
|
|
373
|
-
|
|
374
|
-
### Offline Validation (No AWS API Calls)
|
|
375
|
-
|
|
376
|
-
Validate policies without AWS API access using pre-downloaded service definitions. Useful for:
|
|
377
|
-
- **Air-gapped environments** - No internet access required
|
|
378
|
-
- **Rate limiting avoidance** - No AWS API throttling (429 errors)
|
|
379
|
-
- **CI/CD performance** - Faster validation with local files
|
|
380
|
-
- **Development** - Work offline without AWS credentials
|
|
381
|
-
|
|
382
|
-
**Download AWS service definitions once:**
|
|
383
|
-
```bash
|
|
384
|
-
# Download all AWS service definitions to local directory
|
|
385
|
-
iam-validator download-services --output-dir ./aws-services
|
|
386
|
-
|
|
387
|
-
# Directory structure:
|
|
388
|
-
# aws-services/
|
|
389
|
-
# ├── _services.json # List of all services
|
|
390
|
-
# ├── s3.json # S3 service definition
|
|
391
|
-
# ├── iam.json # IAM service definition
|
|
392
|
-
# └── ... (250+ services)
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
**Use offline mode:**
|
|
396
|
-
```bash
|
|
397
|
-
# CLI: Use --aws-services-dir flag
|
|
398
|
-
iam-validator validate --path policies/ --aws-services-dir ./aws-services
|
|
399
|
-
|
|
400
|
-
# Config file: Set aws_services_dir
|
|
401
|
-
# .iam-validator.yaml
|
|
402
|
-
settings:
|
|
403
|
-
aws_services_dir: ./aws-services
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
**Python library:**
|
|
407
|
-
```python
|
|
408
|
-
from iam_validator.core.policy_checks import validate_policies
|
|
409
|
-
from iam_validator.core.policy_loader import PolicyLoader
|
|
410
|
-
|
|
411
|
-
loader = PolicyLoader()
|
|
412
|
-
policies = loader.load_from_path("./policies")
|
|
413
|
-
|
|
414
|
-
# Pass aws_services_dir to enable offline mode
|
|
415
|
-
results = await validate_policies(
|
|
416
|
-
policies,
|
|
417
|
-
aws_services_dir="./aws-services"
|
|
418
|
-
)
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
### Cache Directory Control
|
|
422
|
-
|
|
423
|
-
Control where AWS service definitions are cached (for library users):
|
|
424
|
-
|
|
425
|
-
```python
|
|
426
|
-
from iam_validator.core.aws_service import AWSServiceFetcher
|
|
427
|
-
|
|
428
|
-
async with AWSServiceFetcher() as fetcher:
|
|
429
|
-
# Get current cache location
|
|
430
|
-
cache_path = fetcher.get_cache_directory()
|
|
431
|
-
print(f"Cache at: {cache_path}")
|
|
432
|
-
# macOS: ~/Library/Caches/iam-validator/aws_services
|
|
433
|
-
# Linux: ~/.cache/iam-validator/aws_services
|
|
434
|
-
# Windows: %LOCALAPPDATA%/iam-validator/cache/aws_services
|
|
435
|
-
|
|
436
|
-
# Change cache directory at runtime
|
|
437
|
-
fetcher.set_cache_directory("/tmp/custom-cache")
|
|
438
|
-
|
|
439
|
-
# All future cache operations use the new directory
|
|
440
|
-
await fetcher.fetch_services()
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
### Cache Management CLI
|
|
444
|
-
|
|
445
|
-
Manage the cache directly:
|
|
446
|
-
|
|
447
|
-
```bash
|
|
448
|
-
# Show cache information and statistics
|
|
449
|
-
iam-validator cache info
|
|
450
|
-
|
|
451
|
-
# List all cached services
|
|
452
|
-
iam-validator cache list
|
|
453
|
-
iam-validator cache list --format columns
|
|
454
|
-
|
|
455
|
-
# Show cache directory location
|
|
456
|
-
iam-validator cache location
|
|
457
|
-
|
|
458
|
-
# Clear cache
|
|
459
|
-
iam-validator cache clear
|
|
460
|
-
|
|
461
|
-
# Refresh cache (clear + re-download common services)
|
|
462
|
-
iam-validator cache refresh
|
|
463
|
-
|
|
464
|
-
# Pre-fetch common services (without clearing)
|
|
465
|
-
iam-validator cache prefetch
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
**Cache configuration:**
|
|
469
|
-
```yaml
|
|
470
|
-
# .iam-validator.yaml
|
|
471
|
-
settings:
|
|
472
|
-
cache_enabled: true # Enable/disable caching
|
|
473
|
-
cache_ttl_hours: 168 # Cache lifetime (7 days default)
|
|
474
|
-
cache_directory: /custom/path # Custom cache location
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
## AWS Access Analyzer (Optional)
|
|
478
|
-
|
|
479
|
-
In addition to the 19 built-in checks, optionally enable AWS Access Analyzer for additional validation capabilities that require AWS credentials:
|
|
480
|
-
|
|
481
|
-
### Access Analyzer Capabilities
|
|
482
|
-
|
|
483
|
-
**Custom Policy Checks:**
|
|
484
|
-
- `check-access-not-granted` - Verify policies DON'T grant specific actions (max 100 actions)
|
|
485
|
-
- `check-no-new-access` - Compare against baseline to detect permission creep
|
|
486
|
-
- `check-no-public-access` - Validate 29+ resource types for public exposure
|
|
487
|
-
|
|
488
|
-
**Example:**
|
|
489
|
-
```bash
|
|
490
|
-
# Prevent dangerous actions
|
|
491
|
-
iam-validator analyze --path policies/ \
|
|
492
|
-
--check-access-not-granted "s3:DeleteBucket iam:AttachUserPolicy"
|
|
493
|
-
|
|
494
|
-
# Compare against baseline
|
|
495
|
-
iam-validator analyze --path new-policy.json \
|
|
496
|
-
--check-no-new-access baseline-policy.json
|
|
497
|
-
|
|
498
|
-
# Check for public access
|
|
499
|
-
iam-validator analyze --path bucket-policy.json \
|
|
500
|
-
--policy-type RESOURCE_POLICY \
|
|
501
|
-
--check-no-public-access \
|
|
502
|
-
--public-access-resource-type "AWS::S3::Bucket"
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
**Supported Policy Types:**
|
|
506
|
-
- `IDENTITY_POLICY` (default) - User/role policies
|
|
507
|
-
- `RESOURCE_POLICY` - S3, SNS, KMS resource policies
|
|
508
|
-
- `SERVICE_CONTROL_POLICY` - AWS Organizations SCPs
|
|
509
|
-
- `RESOURCE_CONTROL_POLICY` - AWS Organizations RCPs (2024)
|
|
510
|
-
|
|
511
|
-
**📖 See [Access Analyzer documentation](docs/custom-checks.md) for complete details**
|
|
512
|
-
|
|
513
|
-
## 📚 Documentation
|
|
514
|
-
|
|
515
|
-
**Guides:**
|
|
516
|
-
- [Check Reference](docs/check-reference.md) - All 19 checks with examples
|
|
517
|
-
- [Configuration Guide](docs/configuration.md) - Customize checks and behavior
|
|
518
|
-
- [GitHub Actions Guide](docs/github-actions-workflows.md) - CI/CD integration
|
|
519
|
-
- [Python Library Guide](docs/python-library-usage.md) - Use as Python package
|
|
520
|
-
- [Trust Policy Guide](examples/trust-policies/README.md) - Trust policy validation
|
|
521
|
-
- [Contributing Guide](CONTRIBUTING.md) - How to contribute
|
|
522
|
-
|
|
523
|
-
**Examples:**
|
|
524
|
-
- [Configuration Examples](examples/configs/) - 9+ config file templates
|
|
525
|
-
- [Workflow Examples](examples/github-actions/) - GitHub Actions workflows
|
|
526
|
-
- [Custom Checks](examples/custom_checks/) - Add your own validation rules
|
|
527
|
-
- [Trust Policies](examples/trust-policies/) - Trust policy examples
|
|
528
|
-
|
|
529
|
-
## 🤝 Contributing
|
|
530
|
-
|
|
531
|
-
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
532
|
-
|
|
533
|
-
**Quick start:**
|
|
534
|
-
```bash
|
|
535
|
-
git clone https://github.com/YOUR-USERNAME/iam-policy-validator.git
|
|
536
|
-
cd iam-policy-validator
|
|
537
|
-
uv sync --extra dev
|
|
538
|
-
uv run pytest
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
## 📄 License
|
|
542
|
-
|
|
543
|
-
MIT License - see [LICENSE](LICENSE) file for details.
|
|
544
|
-
|
|
545
|
-
**Third-party code:** ARN pattern matching in [iam_validator/sdk/arn_matching.py](iam_validator/sdk/arn_matching.py) is derived from [Parliament](https://github.com/duo-labs/parliament) (BSD 3-Clause License).
|
|
546
|
-
|
|
547
|
-
## 🆘 Support
|
|
548
|
-
|
|
549
|
-
- **Issues**: [GitHub Issues](https://github.com/boogy/iam-policy-validator/issues)
|
|
File without changes
|
{iam_policy_validator-1.10.2.dist-info → iam_policy_validator-1.11.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{iam_policy_validator-1.10.2.dist-info → iam_policy_validator-1.11.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|