iam-policy-validator 1.0.3__py3-none-any.whl → 1.1.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.

Potentially problematic release.


This version of iam-policy-validator might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iam-policy-validator
3
- Version: 1.0.3
3
+ Version: 1.1.0
4
4
  Summary: Validate AWS IAM policies for correctness and security using AWS Service Reference API
5
5
  Project-URL: Homepage, https://github.com/boogy/iam-policy-validator
6
6
  Project-URL: Documentation, https://github.com/boogy/iam-policy-validator/tree/main/docs
@@ -40,7 +40,7 @@ Requires-Dist: types-boto3; extra == 'dev'
40
40
  Requires-Dist: types-pyyaml; extra == 'dev'
41
41
  Description-Content-Type: text/markdown
42
42
 
43
- # IAM Validator
43
+ # IAM Policy Validator
44
44
 
45
45
  A high-performance GitHub Action and Python CLI tool that validates AWS IAM policies for correctness and security by checking against the official AWS Service Reference API.
46
46
 
@@ -70,7 +70,8 @@ A high-performance GitHub Action and Python CLI tool that validates AWS IAM poli
70
70
  - **Comment Updates**: Update existing comments instead of creating duplicates
71
71
 
72
72
  ### Output Formats
73
- - **Console**: Rich terminal output with colors and tables
73
+ - **Console** (default): Clean terminal output with colors and tables
74
+ - **Enhanced**: Modern visual output with progress bars, tree structure, and rich visuals
74
75
  - **JSON**: Structured format for programmatic processing
75
76
  - **Markdown**: GitHub-flavored markdown for PR comments
76
77
  - **SARIF**: GitHub code scanning integration format
@@ -85,9 +86,13 @@ A high-performance GitHub Action and Python CLI tool that validates AWS IAM poli
85
86
 
86
87
  ## Quick Start
87
88
 
88
- ### As a GitHub Action
89
+ ### As a GitHub Action (Recommended) ⭐
89
90
 
90
- #### Option 1: Basic Validation (Custom Checks Only)
91
+ The IAM Policy Validator is available as **both** a standalone GitHub Action and a Python module. Choose the approach that best fits your needs:
92
+
93
+ #### **Option A: Standalone GitHub Action** (Recommended - Zero Setup)
94
+
95
+ Use the published action directly - it handles all setup automatically:
91
96
 
92
97
  Create `.github/workflows/iam-policy-validator.yml`:
93
98
 
@@ -108,38 +113,29 @@ jobs:
108
113
 
109
114
  steps:
110
115
  - name: Checkout code
111
- uses: actions/checkout@v4
112
-
113
- - name: Set up Python
114
- uses: actions/setup-python@v5
115
- with:
116
- python-version: '3.12'
117
-
118
- - name: Install uv
119
- uses: astral-sh/setup-uv@v3
120
-
121
- - name: Install dependencies
122
- run: uv sync
116
+ uses: actions/checkout@v5
123
117
 
124
118
  - name: Validate IAM Policies
125
- env:
126
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127
- GITHUB_REPOSITORY: ${{ github.repository }}
128
- GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
129
- run: |
130
- uv run iam-validator validate \
131
- --path ./policies/ \
132
- --github-comment \
133
- --github-review \
134
- --fail-on-warnings
119
+ uses: boogy/iam-policy-validator@v1
120
+ with:
121
+ path: policies/
122
+ post-comment: true
123
+ create-review: true
124
+ fail-on-warnings: true
135
125
  ```
136
126
 
137
- #### Option 2: Sequential Validation (Recommended) ⭐
127
+ **Benefits:**
128
+ - ✅ Zero setup - action handles Python, uv, and dependencies
129
+ - ✅ Automatic dependency caching
130
+ - ✅ Simple, declarative configuration
131
+ - ✅ Perfect for CI/CD workflows
138
132
 
139
- Run AWS Access Analyzer first, then custom checks if it passes:
133
+ #### With AWS Access Analyzer (Standalone Action)
134
+
135
+ Use AWS's official policy validation service:
140
136
 
141
137
  ```yaml
142
- name: Sequential IAM Policy Validation
138
+ name: IAM Policy Validation with Access Analyzer
143
139
 
144
140
  on:
145
141
  pull_request:
@@ -156,7 +152,7 @@ jobs:
156
152
 
157
153
  steps:
158
154
  - name: Checkout code
159
- uses: actions/checkout@v4
155
+ uses: actions/checkout@v5
160
156
 
161
157
  - name: Configure AWS Credentials
162
158
  uses: aws-actions/configure-aws-credentials@v4
@@ -164,53 +160,28 @@ jobs:
164
160
  role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
165
161
  aws-region: us-east-1
166
162
 
167
- - name: Set up Python
168
- uses: actions/setup-python@v5
163
+ - name: Validate with Access Analyzer
164
+ uses: boogy/iam-policy-validator@v1
169
165
  with:
170
- python-version: '3.12'
171
-
172
- - name: Install uv
173
- uses: astral-sh/setup-uv@v3
174
-
175
- - name: Install dependencies
176
- run: uv sync
177
-
178
- - name: Sequential Validation
179
- env:
180
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
181
- GITHUB_REPOSITORY: ${{ github.repository }}
182
- GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
183
- run: |
184
- # Posts 2 separate PR comments:
185
- # 1. Access Analyzer results (immediate)
186
- # 2. Custom validation (only if Access Analyzer passes)
187
- uv run iam-validator analyze \
188
- --path ./policies/ \
189
- --github-comment \
190
- --run-all-checks \
191
- --github-review \
192
- --fail-on-warnings
166
+ path: policies/
167
+ use-access-analyzer: true
168
+ run-all-checks: true
169
+ post-comment: true
170
+ create-review: true
171
+ fail-on-warnings: true
193
172
  ```
194
173
 
195
- **Why Sequential Validation?**
196
- - ✅ Access Analyzer validates first (fast, official AWS validation)
197
- - ✅ If errors found, stops immediately (saves time)
198
- - ✅ Only runs custom checks if Access Analyzer passes
199
- - ✅ Two separate PR comments for clear separation
200
-
201
- #### Option 3: Multiple Paths
174
+ #### **Option B: As Python Module/CLI Tool**
202
175
 
203
- Validate policies across multiple directories and files:
176
+ For advanced use cases or when you need more control:
204
177
 
205
178
  ```yaml
206
- name: Multi-Path IAM Policy Validation
179
+ name: IAM Policy Validation (CLI)
207
180
 
208
181
  on:
209
182
  pull_request:
210
183
  paths:
211
- - 'iam/**/*.json'
212
- - 's3-policies/**/*.json'
213
- - 'lambda-policies/**/*.json'
184
+ - 'policies/**/*.json'
214
185
 
215
186
  jobs:
216
187
  validate:
@@ -221,12 +192,12 @@ jobs:
221
192
 
222
193
  steps:
223
194
  - name: Checkout code
224
- uses: actions/checkout@v4
195
+ uses: actions/checkout@v5
225
196
 
226
197
  - name: Set up Python
227
198
  uses: actions/setup-python@v5
228
199
  with:
229
- python-version: '3.12'
200
+ python-version: '3.13'
230
201
 
231
202
  - name: Install uv
232
203
  uses: astral-sh/setup-uv@v3
@@ -234,24 +205,29 @@ jobs:
234
205
  - name: Install dependencies
235
206
  run: uv sync
236
207
 
237
- - name: Validate Multiple Paths
208
+ - name: Validate IAM Policies
238
209
  env:
239
210
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240
211
  GITHUB_REPOSITORY: ${{ github.repository }}
241
212
  GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
242
213
  run: |
243
214
  uv run iam-validator validate \
244
- --path ./iam/ \
245
- --path ./s3-policies/ \
246
- --path ./lambda-policies/special-policy.json \
215
+ --path ./policies/ \
247
216
  --github-comment \
248
217
  --github-review \
249
- --fail-on-warnings
218
+ --fail-on-warnings \
219
+ --log-level info
250
220
  ```
251
221
 
252
- #### Option 4: Custom Policy Checks in GitHub Actions
222
+ **Use this when you need:**
223
+ - Advanced CLI options (e.g., `--log-level`, `--custom-checks-dir`, `--stream`)
224
+ - Full control over the Python environment
225
+ - Integration with existing Python workflows
226
+ - Multiple validation commands in sequence
227
+
228
+ #### Custom Policy Checks (Standalone Action)
253
229
 
254
- Use custom policy checks to enforce specific security requirements:
230
+ Enforce specific security requirements:
255
231
 
256
232
  ```yaml
257
233
  name: IAM Policy Security Validation
@@ -262,7 +238,7 @@ on:
262
238
  - 'policies/**/*.json'
263
239
 
264
240
  jobs:
265
- validate-with-custom-checks:
241
+ validate-security:
266
242
  runs-on: ubuntu-latest
267
243
  permissions:
268
244
  contents: read
@@ -271,7 +247,7 @@ jobs:
271
247
 
272
248
  steps:
273
249
  - name: Checkout code
274
- uses: actions/checkout@v4
250
+ uses: actions/checkout@v5
275
251
 
276
252
  - name: Configure AWS Credentials
277
253
  uses: aws-actions/configure-aws-credentials@v4
@@ -281,7 +257,7 @@ jobs:
281
257
 
282
258
  # Prevent dangerous actions
283
259
  - name: Check for Dangerous Actions
284
- uses: boogy/iam-policy-auditor@v1
260
+ uses: boogy/iam-policy-validator@v1
285
261
  with:
286
262
  path: policies/
287
263
  use-access-analyzer: true
@@ -291,7 +267,7 @@ jobs:
291
267
 
292
268
  # Check S3 bucket policies for public access
293
269
  - name: Check S3 Public Access
294
- uses: boogy/iam-policy-auditor@v1
270
+ uses: boogy/iam-policy-validator@v1
295
271
  with:
296
272
  path: s3-policies/
297
273
  use-access-analyzer: true
@@ -309,7 +285,7 @@ jobs:
309
285
  path: baseline
310
286
 
311
287
  - name: Check for New Access
312
- uses: boogy/iam-policy-auditor@v1
288
+ uses: boogy/iam-policy-validator@v1
313
289
  with:
314
290
  path: policies/role-policy.json
315
291
  use-access-analyzer: true
@@ -318,46 +294,152 @@ jobs:
318
294
  fail-on-warnings: true
319
295
  ```
320
296
 
321
- See [examples/github-actions/](examples/github-actions/) for more workflow examples including resource policies, multi-region validation, and custom policy checks.
297
+ ---
298
+
299
+ ### Choosing the Right Approach
300
+
301
+ | Feature | Standalone Action | Python Module/CLI |
302
+ | --------------------- | ------------------------ | ------------------------------------------------------------------------ |
303
+ | Setup Required | None - fully automated | Manual (Python, uv, dependencies) |
304
+ | Configuration | YAML inputs | CLI arguments |
305
+ | Advanced Options | Limited to action inputs | Full CLI access (`--log-level`, `--custom-checks-dir`, `--stream`, etc.) |
306
+ | Custom Checks | Via config file only | Via config file or `--custom-checks-dir` |
307
+ | Best For | CI/CD, simple workflows | Development, advanced workflows, testing |
308
+ | Dependency Management | Automatic | Manual |
309
+
310
+ **Recommendation:** Use the **Standalone Action** for production CI/CD workflows, and the **Python Module/CLI** for development, testing, or when you need advanced features.
311
+
312
+ #### Multiple Paths (Standalone Action)
313
+
314
+ Validate policies across multiple directories:
315
+
316
+ ```yaml
317
+ - name: Validate Multiple Paths
318
+ uses: boogy/iam-policy-validator@v1
319
+ with:
320
+ path: |
321
+ iam/
322
+ s3-policies/
323
+ lambda-policies/special-policy.json
324
+ post-comment: true
325
+ fail-on-warnings: true
326
+ ```
327
+
328
+ #### Custom Configuration
329
+
330
+ Use a custom configuration file to customize validation rules:
331
+
332
+ ```yaml
333
+ name: IAM Policy Validation with Custom Config
334
+
335
+ on:
336
+ pull_request:
337
+ paths:
338
+ - 'policies/**/*.json'
339
+ - '.iam-validator.yaml'
340
+
341
+ jobs:
342
+ validate:
343
+ runs-on: ubuntu-latest
344
+ permissions:
345
+ contents: read
346
+ pull-requests: write
347
+
348
+ steps:
349
+ - name: Checkout code
350
+ uses: actions/checkout@v5
351
+
352
+ - name: Validate with Custom Config
353
+ uses: boogy/iam-policy-validator@v1
354
+ with:
355
+ path: policies/
356
+ config-file: .iam-validator.yaml
357
+ post-comment: true
358
+ create-review: true
359
+ fail-on-warnings: true
360
+ ```
361
+
362
+ **Example `.iam-validator.yaml`:**
363
+ ```yaml
364
+ settings:
365
+ fail_fast: false
366
+ enable_builtin_checks: true
367
+
368
+ # Custom check configurations
369
+ security_best_practices_check:
370
+ enabled: true
371
+ wildcard_action_check:
372
+ enabled: true
373
+ severity: high
374
+
375
+ action_condition_enforcement_check:
376
+ enabled: true
377
+ severity: critical
378
+ action_condition_requirements:
379
+ - actions:
380
+ - "iam:PassRole"
381
+ severity: critical
382
+ required_conditions:
383
+ - condition_key: "iam:PassedToService"
384
+ ```
385
+
386
+ See [default-config.yaml](default-config.yaml) for a complete configuration example.
387
+
388
+ ### GitHub Action Inputs
389
+
390
+ | Input | Description | Required | Default |
391
+ | ----------------------------- | ---------------------------------------------------------------------- | -------- | ----------------- |
392
+ | `path` | Path(s) to IAM policy file or directory (newline-separated) | Yes | - |
393
+ | `config-file` | Path to custom configuration file (iam-validator.yaml) | No | "" |
394
+ | `fail-on-warnings` | Fail validation if warnings are found | No | `false` |
395
+ | `post-comment` | Post validation results as PR comment | No | `true` |
396
+ | `create-review` | Create line-specific review comments on PR | No | `true` |
397
+ | `format` | Output format (console, enhanced, json, markdown, sarif, csv, html) | No | `console` |
398
+ | `output-file` | Path to save output file | No | "" |
399
+ | `recursive` | Recursively search directories for policy files | No | `true` |
400
+ | `use-access-analyzer` | Use AWS IAM Access Analyzer for validation | No | `false` |
401
+ | `access-analyzer-region` | AWS region for Access Analyzer | No | `us-east-1` |
402
+ | `policy-type` | Policy type (IDENTITY_POLICY, RESOURCE_POLICY, SERVICE_CONTROL_POLICY) | No | `IDENTITY_POLICY` |
403
+ | `run-all-checks` | Run custom checks after Access Analyzer | No | `false` |
404
+ | `check-access-not-granted` | Actions that should NOT be granted (space-separated) | No | "" |
405
+ | `check-access-resources` | Resources to check with check-access-not-granted | No | "" |
406
+ | `check-no-new-access` | Path to baseline policy to compare against | No | "" |
407
+ | `check-no-public-access` | Check that resource policies do not allow public access | No | `false` |
408
+ | `public-access-resource-type` | Resource type(s) for public access check | No | `AWS::S3::Bucket` |
409
+
410
+ See [examples/github-actions/](examples/github-actions/) for more workflow examples.
322
411
 
323
412
  ### As a CLI Tool
324
413
 
414
+ Install and use locally for development:
415
+
325
416
  ```bash
326
- # Clone and install
327
- git clone https://github.com/boogy/iam-policy-auditor.git
328
- cd iam-policy-auditor
329
- uv sync
417
+ # Install from PyPI
418
+ pip install iam-policy-validator
419
+
420
+ # Or install with pipx (recommended for CLI tools)
421
+ pipx install iam-policy-validator
330
422
 
331
423
  # Validate a single policy
332
- uv run iam-validator validate --path policy.json
424
+ iam-validator validate --path policy.json
333
425
 
334
426
  # Validate all policies in a directory
335
- uv run iam-validator validate --path ./policies/
427
+ iam-validator validate --path ./policies/
336
428
 
337
- # Validate multiple paths (files and directories)
338
- uv run iam-validator validate --path policy1.json --path ./policies/ --path ./more-policies/
429
+ # Validate multiple paths
430
+ iam-validator validate --path policy1.json --path ./policies/ --path ./more-policies/
339
431
 
340
432
  # Generate JSON output
341
- uv run iam-validator validate --path ./policies/ --format json --output report.json
342
-
343
- # Post validation results to a PR with line-specific comments
344
- uv run iam-validator validate --path ./policies/ --github-comment --github-review
345
-
346
- # Two-step workflow: generate report, then post to PR
347
- uv run iam-validator validate --path ./policies/ --format json --output report.json
348
- uv run iam-validator post-to-pr --report report.json
433
+ iam-validator validate --path ./policies/ --format json --output report.json
349
434
 
350
435
  # Validate with AWS IAM Access Analyzer
351
- uv run iam-validator analyze --path policy.json
436
+ iam-validator analyze --path policy.json
352
437
 
353
438
  # Analyze with specific region and profile
354
- uv run iam-validator analyze --path policy.json --region us-west-2 --profile my-profile
355
-
356
- # Post Access Analyzer results to PR
357
- uv run iam-validator analyze --path policy.json --github-comment
439
+ iam-validator analyze --path policy.json --region us-west-2 --profile my-profile
358
440
 
359
- # Sequential validation: Access Analyzer → Custom Checks (if AA passes)
360
- uv run iam-validator analyze \
441
+ # Sequential validation: Access Analyzer → Custom Checks
442
+ iam-validator analyze \
361
443
  --path policy.json \
362
444
  --github-comment \
363
445
  --run-all-checks \
@@ -374,18 +456,18 @@ Verify that policies do NOT grant specific actions (max 100 actions, 100 resourc
374
456
 
375
457
  ```bash
376
458
  # Check that policies don't grant dangerous S3 actions
377
- uv run iam-validator analyze \
459
+ iam-validator analyze \
378
460
  --path ./policies/ \
379
461
  --check-access-not-granted s3:DeleteBucket s3:DeleteObject
380
462
 
381
- # Scope to specific resources (wildcards only in resource ID portion)
382
- uv run iam-validator analyze \
463
+ # Scope to specific resources
464
+ iam-validator analyze \
383
465
  --path ./policies/ \
384
466
  --check-access-not-granted s3:PutObject \
385
467
  --check-access-resources "arn:aws:s3:::production-bucket/*"
386
468
 
387
469
  # Prevent privilege escalation
388
- uv run iam-validator analyze \
470
+ iam-validator analyze \
389
471
  --path ./policies/ \
390
472
  --check-access-not-granted \
391
473
  iam:CreateAccessKey \
@@ -397,17 +479,17 @@ uv run iam-validator analyze \
397
479
 
398
480
  #### 2. CheckNoNewAccess - Validate Policy Updates
399
481
 
400
- Ensure policy changes don't grant new permissions (both policies must be same type):
482
+ Ensure policy changes don't grant new permissions:
401
483
 
402
484
  ```bash
403
485
  # Compare updated policy against baseline
404
- uv run iam-validator analyze \
486
+ iam-validator analyze \
405
487
  --path ./new-policy.json \
406
488
  --check-no-new-access ./old-policy.json
407
489
 
408
490
  # In CI/CD - compare against main branch
409
491
  git show main:policies/policy.json > baseline-policy.json
410
- uv run iam-validator analyze \
492
+ iam-validator analyze \
411
493
  --path policies/policy.json \
412
494
  --check-no-new-access baseline-policy.json
413
495
  ```
@@ -416,39 +498,25 @@ uv run iam-validator analyze \
416
498
 
417
499
  #### 3. CheckNoPublicAccess - Prevent Public Exposure
418
500
 
419
- Validate that resource policies don't allow public access (RESOURCE_POLICY only, 29+ resource types):
501
+ Validate that resource policies don't allow public access (29+ resource types):
420
502
 
421
503
  ```bash
422
504
  # Check S3 bucket policies
423
- uv run iam-validator analyze \
505
+ iam-validator analyze \
424
506
  --path ./bucket-policy.json \
425
507
  --policy-type RESOURCE_POLICY \
426
508
  --check-no-public-access \
427
509
  --public-access-resource-type "AWS::S3::Bucket"
428
510
 
429
- # Check Lambda function policies
430
- uv run iam-validator analyze \
431
- --path ./lambda-policy.json \
432
- --policy-type RESOURCE_POLICY \
433
- --check-no-public-access \
434
- --public-access-resource-type "AWS::Lambda::Function"
435
-
436
- # Check KMS key policies
437
- uv run iam-validator analyze \
438
- --path ./kms-policy.json \
439
- --policy-type RESOURCE_POLICY \
440
- --check-no-public-access \
441
- --public-access-resource-type "AWS::KMS::Key"
442
-
443
- # Check multiple resource types at once
444
- uv run iam-validator analyze \
511
+ # Check multiple resource types
512
+ iam-validator analyze \
445
513
  --path ./resource-policies/ \
446
514
  --policy-type RESOURCE_POLICY \
447
515
  --check-no-public-access \
448
516
  --public-access-resource-type "AWS::S3::Bucket" "AWS::Lambda::Function" "AWS::SNS::Topic"
449
517
 
450
518
  # Check ALL 29 resource types
451
- uv run iam-validator analyze \
519
+ iam-validator analyze \
452
520
  --path ./resource-policies/ \
453
521
  --policy-type RESOURCE_POLICY \
454
522
  --check-no-public-access \
@@ -464,17 +532,11 @@ uv run iam-validator analyze \
464
532
  - **API**: API Gateway REST API
465
533
  - **DevOps**: CodeArtifact Domain, Backup Vault, CloudTrail
466
534
 
467
- See [docs/custom-policy-checks.md](docs/custom-policy-checks.md) for complete documentation and examples.
535
+ See [docs/custom-policy-checks.md](docs/custom-policy-checks.md) for complete documentation.
468
536
 
469
537
  ### As a Python Package
470
538
 
471
- ```bash
472
- # Install from PyPI (once published)
473
- pip install iam-policy-validator
474
-
475
- # Or install from source
476
- pip install git+https://github.com/boogy/iam-policy-auditor.git
477
- ```
539
+ Use as a library in your Python applications:
478
540
 
479
541
  ```python
480
542
  import asyncio
@@ -496,82 +558,6 @@ async def main():
496
558
  asyncio.run(main())
497
559
  ```
498
560
 
499
- ## Memory Management & Performance
500
-
501
- ### Streaming Mode (Recommended for Large Policy Sets)
502
-
503
- The validator supports two processing modes:
504
-
505
- #### 1. **Batch Mode (Default)**
506
- Loads all policies into memory at once. Best for:
507
- - Small to medium policy sets (< 100 files)
508
- - When you need the full summary upfront
509
- - Local development
510
-
511
- #### 2. **Streaming Mode** (`--stream`)
512
- Processes policies one-by-one. Best for:
513
- - Large policy sets (100+ files)
514
- - CI/CD environments (auto-enabled)
515
- - Limited memory environments
516
- - Progressive feedback (see results as they come)
517
-
518
- ```bash
519
- # Enable streaming mode explicitly
520
- uv run iam-validator validate --path ./policies/ --stream
521
-
522
- # Streaming mode with GitHub PR comments (posts per-file reviews progressively)
523
- uv run iam-validator validate \
524
- --path ./policies/ \
525
- --stream \
526
- --github-comment \
527
- --github-review
528
- ```
529
-
530
- **Streaming Benefits:**
531
- - ✅ **Lower Memory Usage**: Only one policy in memory at a time
532
- - ✅ **Progressive Feedback**: See results immediately as files are processed
533
- - ✅ **Partial Results**: Get results even if later files fail
534
- - ✅ **Better CI/CD Experience**: GitHub PR comments appear progressively
535
- - ✅ **Auto-enabled in CI**: Automatically detects CI environment
536
-
537
- **File Size Limits:**
538
- - Default max file size: 100MB per policy file
539
- - Files exceeding limit are skipped with a warning
540
- - Prevents memory exhaustion from unexpectedly large files
541
-
542
- ### GitHub Action Memory Optimization
543
-
544
- The GitHub Action automatically uses streaming mode in CI environments:
545
-
546
- ```yaml
547
- - name: Validate Large Policy Set
548
- run: |
549
- # Streaming is auto-enabled in CI
550
- uv run iam-validator validate \
551
- --path ./policies/ \
552
- --github-comment \
553
- --github-review
554
- ```
555
-
556
- ## Configuration
557
-
558
- ### GitHub Action Inputs
559
-
560
- | Input | Description | Required | Default |
561
- | ------------------ | ----------------------------------------------------------- | -------- | ------- |
562
- | `path` | Path(s) to IAM policy file or directory (newline-separated) | Yes | - |
563
- | `fail-on-warnings` | Fail validation if warnings are found | No | `false` |
564
- | `post-comment` | Post validation results as PR comment | No | `true` |
565
- | `create-review` | Create line-specific review comments on PR | No | `true` |
566
-
567
- ### Environment Variables
568
-
569
- For GitHub integration:
570
-
571
- - `GITHUB_TOKEN`: GitHub API token (automatically provided in GitHub Actions)
572
- - `GITHUB_REPOSITORY`: Repository in format `owner/repo`
573
- - `GITHUB_PR_NUMBER`: Pull request number
574
-
575
561
  ## Validation Checks
576
562
 
577
563
  ### 1. Action Validation
@@ -664,156 +650,6 @@ Run 2: Finds 3 issues → Deletes old 5 comments → Posts 3 new comments + upda
664
650
  Result: PR always shows current state, no stale comments
665
651
  ```
666
652
 
667
- ### Post PR Comments
668
-
669
- Automatically posts validation results as PR comments:
670
-
671
- ```python
672
- async with GitHubIntegration() as github:
673
- await github.post_comment(validation_report)
674
- ```
675
-
676
- ### Line-Specific Comments
677
-
678
- Add comments to specific lines in policy files:
679
-
680
- ```python
681
- comments = [
682
- {
683
- "path": "policies/policy.json",
684
- "line": 5,
685
- "body": "Invalid action detected here",
686
- }
687
- ]
688
- await github.create_review_with_comments(comments)
689
- ```
690
-
691
- ### Manage Labels
692
-
693
- Add or remove labels based on validation results:
694
-
695
- ```python
696
- # Add labels
697
- await github.add_labels(["iam-policy", "security-review"])
698
-
699
- # Remove labels
700
- await github.remove_label("needs-review")
701
-
702
- # Set labels (replaces all existing)
703
- await github.set_labels(["approved", "security-validated"])
704
- ```
705
-
706
- ### Set Commit Status
707
-
708
- Update commit status based on validation:
709
-
710
- ```python
711
- await github.set_commit_status(
712
- state="success", # or "error", "failure", "pending"
713
- context="IAM Policy Validator",
714
- description="All policies validated successfully"
715
- )
716
- ```
717
-
718
- ## CLI Usage
719
-
720
- ### Analyze Command (AWS IAM Access Analyzer)
721
-
722
- The `analyze` command uses AWS IAM Access Analyzer's ValidatePolicy API to validate IAM policies. This provides AWS's official policy validation with detailed findings about errors, security warnings, and suggestions.
723
-
724
- **New in latest version:** Post results to GitHub PRs and run sequential validation (Access Analyzer → Custom Checks).
725
-
726
- **Prerequisites**: You need AWS credentials configured. The tool will use the standard AWS credential chain (environment variables, AWS profile, IAM role, etc.).
727
-
728
- ```bash
729
- iam-validator analyze --path PATH [OPTIONS]
730
-
731
- Options:
732
- --path PATH, -p PATH Path to IAM policy file or directory (required)
733
- --format {console,json,markdown}
734
- Output format (default: console)
735
- --output OUTPUT, -o OUTPUT Output file path (only for json/markdown)
736
- --region REGION, -r REGION AWS region for Access Analyzer (default: us-east-1)
737
- --policy-type {IDENTITY_POLICY,RESOURCE_POLICY,SERVICE_CONTROL_POLICY}
738
- Type of IAM policy to validate (default: IDENTITY_POLICY)
739
- --profile PROFILE AWS profile name to use for credentials
740
- --github-comment Post Access Analyzer results as GitHub PR comment
741
- --run-all-checks Run full validation if Access Analyzer passes
742
- --github-review Add line-specific review comments (requires --run-all-checks)
743
- --no-recursive Don't recursively search directories
744
- --fail-on-warnings Fail validation if warnings are found
745
- --verbose, -v Enable verbose logging
746
- ```
747
-
748
- **Examples**:
749
-
750
- ```bash
751
- # Analyze a single identity policy
752
- iam-validator analyze --path policy.json
753
-
754
- # Analyze an S3 bucket policy (resource policy)
755
- iam-validator analyze --path bucket-policy.json --policy-type RESOURCE_POLICY
756
-
757
- # Analyze multiple paths
758
- iam-validator analyze --path ./iam/ --path ./s3-policies/ --path bucket-policy.json
759
-
760
- # Analyze with specific AWS profile and region
761
- iam-validator analyze --path policy.json --profile prod --region us-west-2
762
-
763
- # Post Access Analyzer results to PR
764
- iam-validator analyze --path policy.json --github-comment
765
-
766
- # Sequential validation: Run Access Analyzer, then custom checks if it passes
767
- iam-validator analyze \
768
- --path policy.json \
769
- --github-comment \
770
- --run-all-checks \
771
- --github-review
772
-
773
- # Generate JSON output
774
- iam-validator analyze --path ./policies/ --format json --output analyzer-report.json
775
-
776
- # Fail on any finding (including warnings and suggestions)
777
- iam-validator analyze --path policy.json --fail-on-warnings
778
- ```
779
-
780
- **Access Analyzer Finding Types**:
781
- - **ERROR**: Syntax errors or invalid policy elements that prevent the policy from working
782
- - **SECURITY_WARNING**: Security issues that should be addressed
783
- - **WARNING**: Best practice violations or potential issues
784
- - **SUGGESTION**: Recommendations for policy improvements
785
-
786
- ### Validate Command
787
-
788
- ```bash
789
- iam-validator validate --path PATH [OPTIONS]
790
-
791
- Options:
792
- --path PATH, -p PATH Path to IAM policy file or directory (required)
793
- --format {console,json,markdown}
794
- Output format (default: console)
795
- --output OUTPUT, -o OUTPUT Output file path (only for json/markdown)
796
- --no-recursive Don't recursively search directories
797
- --fail-on-warnings Fail validation if warnings are found
798
- --github-comment Post validation results as GitHub PR comment
799
- --github-review Create line-specific review comments (requires --github-comment)
800
- --verbose, -v Enable verbose logging
801
- ```
802
-
803
- ### Post-to-PR Command
804
-
805
- ```bash
806
- iam-validator post-to-pr --report REPORT [OPTIONS]
807
-
808
- Options:
809
- --report REPORT, -r REPORT Path to JSON report file (required)
810
- --create-review Create line-specific review comments (default: true)
811
- --no-review Don't create line-specific review comments
812
- --add-summary Add summary comment (default: true)
813
- --no-summary Don't add summary comment
814
- --verbose, -v Enable verbose logging
815
- ```
816
-
817
653
  ## Example Output
818
654
 
819
655
  ### Console Output
@@ -857,68 +693,6 @@ Options:
857
693
  - 💡 Suggestion: This grants full administrative access. Restrict to specific actions and resources.
858
694
  ```
859
695
 
860
- ## Development
861
-
862
- ### Project Structure
863
-
864
- ```
865
- iam-policy-auditor/
866
- ├── action.yaml # GitHub Action definition
867
- ├── pyproject.toml # Python project configuration
868
- ├── iam_validator/ # Main Python package
869
- │ ├── iam_validator/
870
- │ │ ├── __init__.py
871
- │ │ ├── models.py # Pydantic models
872
- │ │ ├── aws_fetcher.py # AWS Service Reference API client
873
- │ │ ├── github_integration.py # GitHub API client
874
- │ │ ├── cli.py # CLI interface
875
- │ │ ├── utils.py # Utility functions
876
- │ │ └── core/
877
- │ │ ├── policy_loader.py # Policy file loader
878
- │ │ ├── policy_checks.py # Validation logic
879
- │ │ └── report.py # Report generation
880
- │ └── pyproject.toml
881
- └── examples/
882
- ├── sample_policy.json # Valid example
883
- └── invalid_policy.json # Invalid example
884
- ```
885
-
886
- ### Running Tests
887
-
888
- ```bash
889
- cd iam-policy-validator
890
- uv run pytest
891
- ```
892
-
893
- ### Type Checking
894
-
895
- ```bash
896
- uv run mypy iam_validator/
897
- ```
898
-
899
- ## Architecture
900
-
901
- ### AWS Service Reference API
902
-
903
- The validator fetches real-time service information from AWS's official service reference API:
904
-
905
- ```
906
- https://servicereference.us-east-1.amazonaws.com/
907
- ```
908
-
909
- This ensures validation is always up-to-date with the latest AWS services and actions.
910
-
911
- ### Validation Flow
912
-
913
- 1. **Load Policies**: Parse JSON/YAML policy files
914
- 2. **Fetch Service Data**: Get service information from AWS API (with caching)
915
- 3. **Validate Actions**: Check each action against service definitions
916
- 4. **Validate Conditions**: Verify condition keys are valid for actions
917
- 5. **Validate Resources**: Check ARN format and structure
918
- 6. **Security Checks**: Identify security best practice violations
919
- 7. **Generate Report**: Create formatted output in desired format
920
- 8. **GitHub Integration**: Post comments/labels to PR (if enabled)
921
-
922
696
  ## 📚 Documentation
923
697
 
924
698
  **[📖 Complete Documentation →](DOCS.md)**
@@ -949,7 +723,7 @@ Contributions are welcome! We appreciate your help in making this project better
949
723
  ### How to Contribute
950
724
 
951
725
  1. **Read the [Contributing Guide](CONTRIBUTING.md)** - Comprehensive guide for contributors
952
- 2. **Check [existing issues](https://github.com/boogy/iam-policy-auditor/issues)** - Find something to work on
726
+ 2. **Check [existing issues](https://github.com/boogy/iam-policy-validator/issues)** - Find something to work on
953
727
  3. **Fork the repository** - Create your own copy
954
728
  4. **Make your changes** - Follow our code quality standards
955
729
  5. **Submit a Pull Request** - We'll review and merge
@@ -958,17 +732,17 @@ Contributions are welcome! We appreciate your help in making this project better
958
732
 
959
733
  ```bash
960
734
  # Clone your fork
961
- git clone https://github.com/YOUR-USERNAME/iam-policy-auditor.git
962
- cd iam-policy-auditor
735
+ git clone https://github.com/YOUR-USERNAME/iam-policy-validator.git
736
+ cd iam-policy-validator
963
737
 
964
738
  # Install dependencies
965
739
  uv sync --extra dev
966
740
 
967
741
  # Run tests
968
- make test
742
+ uv run pytest
969
743
 
970
- # Run quality checks
971
- make check
744
+ # Run linting
745
+ uv run ruff check .
972
746
  ```
973
747
 
974
748
  See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed instructions.
@@ -980,5 +754,5 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
980
754
  ## 🆘 Support
981
755
 
982
756
  - **Documentation**: Check the [docs/](docs/) directory
983
- - **Issues**: Report bugs or request features via [GitHub Issues](https://github.com/boogy/iam-policy-auditor/issues)
984
- - **Questions**: Ask questions in [GitHub Discussions](https://github.com/boogy/iam-policy-auditor/discussions)
757
+ - **Issues**: Report bugs or request features via [GitHub Issues](https://github.com/boogy/iam-policy-validator/issues)
758
+ - **Questions**: Ask questions in [GitHub Discussions](https://github.com/boogy/iam-policy-validator/discussions)