iam-policy-validator 1.0.1__tar.gz → 1.0.2__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.
Files changed (132) hide show
  1. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/.github/workflows/release.yml +1 -0
  2. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/PKG-INFO +1 -1
  3. iam_policy_validator-1.0.2/iam-validator.yaml +584 -0
  4. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/__version__.py +1 -1
  5. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/config_loader.py +15 -1
  6. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/pyproject.toml +1 -1
  7. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/uv.lock +1 -1
  8. iam_policy_validator-1.0.1/iam-validator.yaml +0 -585
  9. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/.github/dependabot.yml +0 -0
  10. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/.github/workflows/ci.yml +0 -0
  11. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/.gitignore +0 -0
  12. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/.python-version +0 -0
  13. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/CONTRIBUTING.md +0 -0
  14. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/DOCS.md +0 -0
  15. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/LICENSE +0 -0
  16. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/Makefile +0 -0
  17. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/README.md +0 -0
  18. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/action.yaml +0 -0
  19. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/docs/README.md +0 -0
  20. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/docs/development/PUBLISHING.md +0 -0
  21. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/README.md +0 -0
  22. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/access-analyzer/example1.json +0 -0
  23. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/access-analyzer/example2.json +0 -0
  24. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/configs/action-condition-enforcement-advanced.yaml +0 -0
  25. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/configs/config-privilege-escalation.yaml +0 -0
  26. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/configs/custom-business-rules.yaml +0 -0
  27. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/configs/custom-wildcard-config.yaml +0 -0
  28. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/configs/none_of_example.yaml +0 -0
  29. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/configs/unified-condition-enforcement.yaml +0 -0
  30. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/README.md +0 -0
  31. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/advanced_multi_condition_validator.py +0 -0
  32. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/cross_account_external_id_check.py +0 -0
  33. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/domain_restriction_check.py +0 -0
  34. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/encryption_required_check.py +0 -0
  35. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/mfa_required_check.py +0 -0
  36. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/region_restriction_check.py +0 -0
  37. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/tag_enforcement_check.py +0 -0
  38. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/custom_checks/time_based_access_check.py +0 -0
  39. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/README.md +0 -0
  40. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/access-analyzer-only.yaml +0 -0
  41. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/action-examples.md +0 -0
  42. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/basic-validation.yaml +0 -0
  43. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/custom-policy-checks.yml +0 -0
  44. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/multi-region-validation.yaml +0 -0
  45. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/resource-policy-validation.yaml +0 -0
  46. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/sequential-validation.yaml +0 -0
  47. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/github-actions/two-step-validation.yaml +0 -0
  48. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/README-privilege-escalation.md +0 -0
  49. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/api_gateway_management.json +0 -0
  50. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/athena_query_access.json +0 -0
  51. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/backup_vault_access.json +0 -0
  52. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/cloudformation_deployer.json +0 -0
  53. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/cloudwatch_monitoring.json +0 -0
  54. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/cognito_user_pool.json +0 -0
  55. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/dynamodb_table_access.json +0 -0
  56. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/ecs_task_execution.json +0 -0
  57. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/eventbridge_rules.json +0 -0
  58. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/glue_etl_jobs.json +0 -0
  59. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/insecure_policy.json +0 -0
  60. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/invalid_policy.json +0 -0
  61. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/kms_encryption_keys.json +0 -0
  62. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/lambda_developer.json +0 -0
  63. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/maximum_size_policy.json +0 -0
  64. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/policy_missing_required_tags.json +0 -0
  65. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/policy_tag_enforcement_example.json +0 -0
  66. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/policy_with_wildcard_resources.json +0 -0
  67. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/privilege_escalation_scattered.json +0 -0
  68. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/rds_database_admin.json +0 -0
  69. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/sample_policy.json +0 -0
  70. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/secrets_manager_access.json +0 -0
  71. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/sns_sqs_messaging.json +0 -0
  72. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/step_functions_workflow.json +0 -0
  73. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/test_none_of_valid.json +0 -0
  74. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/test_none_of_violations.json +0 -0
  75. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/examples/policies/test-cases/wildcard_examples.json +0 -0
  76. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/__init__.py +0 -0
  77. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/__main__.py +0 -0
  78. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/checks/__init__.py +0 -0
  79. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/checks/action_condition_enforcement.py +0 -0
  80. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/checks/action_validation.py +0 -0
  81. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/checks/condition_key_validation.py +0 -0
  82. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/checks/policy_size.py +0 -0
  83. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/checks/resource_validation.py +0 -0
  84. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/checks/security_best_practices.py +0 -0
  85. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/checks/sid_uniqueness.py +0 -0
  86. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/commands/__init__.py +0 -0
  87. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/commands/analyze.py +0 -0
  88. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/commands/base.py +0 -0
  89. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/commands/post_to_pr.py +0 -0
  90. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/commands/validate.py +0 -0
  91. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/__init__.py +0 -0
  92. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/access_analyzer.py +0 -0
  93. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/access_analyzer_report.py +0 -0
  94. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/aws_fetcher.py +0 -0
  95. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/aws_global_conditions.py +0 -0
  96. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/check_registry.py +0 -0
  97. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/cli.py +0 -0
  98. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/formatters/__init__.py +0 -0
  99. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/formatters/base.py +0 -0
  100. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/formatters/console.py +0 -0
  101. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/formatters/csv.py +0 -0
  102. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/formatters/html.py +0 -0
  103. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/formatters/json.py +0 -0
  104. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/formatters/markdown.py +0 -0
  105. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/formatters/sarif.py +0 -0
  106. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/models.py +0 -0
  107. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/policy_checks.py +0 -0
  108. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/policy_loader.py +0 -0
  109. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/pr_commenter.py +0 -0
  110. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/core/report.py +0 -0
  111. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/integrations/__init__.py +0 -0
  112. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/integrations/github_integration.py +0 -0
  113. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/iam_validator/integrations/ms_teams.py +0 -0
  114. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/README.md +0 -0
  115. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/__init__.py +0 -0
  116. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_action_condition_enforcement.py +0 -0
  117. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_action_validation_check.py +0 -0
  118. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_aws_fetcher_wildcards.py +0 -0
  119. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_aws_global_conditions.py +0 -0
  120. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_check_registry.py +0 -0
  121. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_comment_truncation.py +0 -0
  122. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_condition_key_validation_check.py +0 -0
  123. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_config_loader.py +0 -0
  124. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_custom_policy_checks.py +0 -0
  125. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_models.py +0 -0
  126. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_multipart_comments.py +0 -0
  127. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_policy_loader.py +0 -0
  128. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_policy_size_check.py +0 -0
  129. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_resource_validation_check.py +0 -0
  130. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_security_best_practices.py +0 -0
  131. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_sid_uniqueness_check.py +0 -0
  132. {iam_policy_validator-1.0.1 → iam_policy_validator-1.0.2}/tests/test_wildcard_allowlist.py +0 -0
@@ -13,6 +13,7 @@ jobs:
13
13
  build-and-release:
14
14
  name: Build and Create Release
15
15
  runs-on: ubuntu-latest
16
+ environment: production
16
17
 
17
18
  steps:
18
19
  - name: Checkout code
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iam-policy-validator
3
- Version: 1.0.1
3
+ Version: 1.0.2
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
@@ -0,0 +1,584 @@
1
+ # IAM Policy Validator Configuration
2
+ # This file defines which checks to run and their configuration
3
+
4
+ # ============================================================================
5
+ # SEVERITY LEVELS
6
+ # ============================================================================
7
+ # The validator uses two types of severity levels:
8
+ #
9
+ # 1. IAM VALIDITY SEVERITIES (for AWS IAM policy correctness):
10
+ # - error: Policy violates AWS IAM rules (invalid actions, ARNs, etc.)
11
+ # - warning: Policy may have IAM-related issues but is technically valid
12
+ # - info: Informational messages about the policy structure
13
+ #
14
+ # 2. SECURITY SEVERITIES (for security best practices):
15
+ # - critical: Critical security risk (e.g., wildcard action + resource)
16
+ # - high: High security risk (e.g., missing required conditions)
17
+ # - medium: Medium security risk (e.g., overly permissive wildcards)
18
+ # - low: Low security risk (e.g., minor best practice violations)
19
+ #
20
+ # Use 'error' for policy validity issues, and 'critical/high/medium/low' for
21
+ # security best practices. This distinction helps separate "broken policies"
22
+ # from "insecure but valid policies".
23
+ # ============================================================================
24
+
25
+ # ============================================================================
26
+ # GLOBAL SETTINGS
27
+ # ============================================================================
28
+
29
+ settings:
30
+ # Stop validation on first error
31
+ fail_fast: false
32
+
33
+ # Maximum number of concurrent policy validations
34
+ max_concurrent: 10
35
+
36
+ # Enable/disable ALL built-in checks (default: true)
37
+ # Set to false when using AWS Access Analyzer to avoid redundant validation
38
+ # Individual checks can still be disabled with enabled: false below
39
+ enable_builtin_checks: true
40
+
41
+ # Enable parallel execution of checks (default: true)
42
+ parallel_execution: true
43
+
44
+ # Cache AWS service definitions locally
45
+ cache_enabled: true
46
+ cache_directory: ".cache/aws_services"
47
+ cache_ttl_hours: 24
48
+
49
+ # Severity levels that cause validation to fail
50
+ # IAM Validity: error, warning, info
51
+ # Security: critical, high, medium, low
52
+ fail_on_severity:
53
+ - error # IAM policy validity errors
54
+ - critical # Critical security issues
55
+ # - high # Uncomment to fail on high security issues
56
+ # - warning # Uncomment to fail on IAM validity warnings
57
+
58
+ # ============================================================================
59
+ # BUILT-IN CHECKS - AWS Validation
60
+ # These validate that policies conform to AWS requirements
61
+ # Disable all with: settings.enable_builtin_checks: false (useful with Access Analyzer)
62
+ # Or disable individually with: enabled: false
63
+ # ============================================================================
64
+
65
+ # Validate Statement ID (Sid) uniqueness as per AWS IAM requirements
66
+ sid_uniqueness_check:
67
+ enabled: true
68
+ severity: error
69
+ description: "Validates that Statement IDs (Sids) are unique within the policy"
70
+
71
+ # Validate policy size against AWS limits
72
+ policy_size_check:
73
+ enabled: true
74
+ severity: error
75
+ description: "Validates that IAM policies don't exceed AWS size limits"
76
+ # Policy type determines which AWS limit to enforce
77
+ # Options: managed, inline_user, inline_group, inline_role
78
+ policy_type: "managed"
79
+ # Optional: Override default AWS size limits (in characters, excluding whitespace)
80
+ # Default limits:
81
+ # managed: 6144
82
+ # inline_user: 2048
83
+ # inline_group: 5120
84
+ # inline_role: 10240
85
+ # size_limits:
86
+ # managed: 6144
87
+ # inline_user: 2048
88
+ # inline_group: 5120
89
+ # inline_role: 10240
90
+
91
+ # Validate IAM actions against AWS service definitions
92
+ action_validation_check:
93
+ enabled: true
94
+ severity: error
95
+ description: "Validates that actions exist in AWS services"
96
+
97
+ # Wildcard action allowlist - patterns that won't trigger warnings
98
+ # By default, non-sensitive read-only wildcards (List*, Describe*) are allowed
99
+ # Note: s3:Get* is EXCLUDED as it can access sensitive data
100
+ # You can customize this list to match your organization's policies
101
+ #
102
+ # Default allowlist includes common non-sensitive read-only patterns:
103
+ # - s3:List*, s3:Describe* (NOTE: s3:Get* excluded - can read sensitive data)
104
+ # - ec2:Describe*
105
+ # - iam:Get*, iam:List*
106
+ # - rds:Describe*
107
+ # - lambda:Get*, lambda:List*
108
+ # - dynamodb:Describe*
109
+ # - cloudwatch:Describe*, cloudwatch:Get*, cloudwatch:List*
110
+ # - logs:Describe*, logs:Get*, logs:Filter*
111
+ # - kms:Describe*, kms:Get*, kms:List*
112
+ # - sns:Get*, sns:List*
113
+ # - sqs:Get*, sqs:List*
114
+ # - elasticloadbalancing:Describe*
115
+ # - autoscaling:Describe*
116
+ # - cloudformation:Describe*, cloudformation:Get*, cloudformation:List*
117
+ # - route53:Get*, route53:List*
118
+ # - apigateway:GET
119
+ #
120
+ # To override the default allowlist, uncomment and customize:
121
+ # allowed_wildcards:
122
+ # - "s3:Get*" # WARNING: Can read sensitive data from S3
123
+ # - "s3:List*"
124
+ # - "ec2:Describe*"
125
+ # - "iam:List*"
126
+ # - "cloudwatch:*" # Allow all CloudWatch actions
127
+ #
128
+ # To disable wildcard informational messages (recommended - use security_best_practices instead):
129
+ # The security_best_practices check provides better wildcard analysis with proper
130
+ # security severities (critical/high/medium). The action_validation wildcard messages
131
+ # are just informational (severity: info) since wildcards ARE valid IAM syntax.
132
+ disable_wildcard_warnings: true
133
+
134
+ # Validate condition keys for actions
135
+ condition_key_validation_check:
136
+ enabled: true
137
+ severity: error # Invalid condition keys are IAM policy errors
138
+ description: "Validates condition keys against AWS service definitions"
139
+ # Validate aws:* global condition keys against known list
140
+ validate_aws_global_keys: true
141
+
142
+ # Validate resource ARN formats
143
+ resource_validation_check:
144
+ enabled: true
145
+ severity: error
146
+ description: "Validates ARN format for resources"
147
+ # Regex pattern for ARN validation
148
+ # Pattern allows wildcards (*) in region and account fields
149
+ arn_pattern: "^arn:(aws|aws-cn|aws-us-gov|aws-eusc|aws-iso|aws-iso-b|aws-iso-e|aws-iso-f):[a-z0-9\\-]+:[a-z0-9\\-*]*:[0-9*]*:.+$"
150
+
151
+ # Security best practices checks
152
+ # Scans at BOTH statement-level AND policy-level for security anti-patterns
153
+ security_best_practices_check:
154
+ enabled: true
155
+ description: "Checks for common security anti-patterns"
156
+
157
+ # Check for wildcard actions
158
+ wildcard_action_check:
159
+ enabled: true
160
+ severity: medium # Security issue: medium severity
161
+
162
+ # Check for wildcard resources
163
+ wildcard_resource_check:
164
+ enabled: true
165
+ severity: medium # Security issue: medium severity
166
+
167
+ # Critical check for both wildcards together
168
+ full_wildcard_check:
169
+ enabled: true
170
+ severity: critical # Security issue: critical severity (was error)
171
+
172
+ # Check for service-level wildcards (e.g., "iam:*", "s3:*", "ec2:*")
173
+ # These grant ALL permissions for a service and are often too permissive
174
+ service_wildcard_check:
175
+ enabled: true
176
+ severity: high # Security issue: high severity
177
+
178
+ # Optional: Allow specific services to use wildcards
179
+ # Useful for logging or monitoring services where wildcards are acceptable
180
+ allowed_services:
181
+ - "logs" # Allow "logs:*" for CloudWatch Logs
182
+ - "cloudwatch" # Allow "cloudwatch:*" for CloudWatch metrics
183
+ # - "xray" # Uncomment to allow "xray:*" for AWS X-Ray
184
+
185
+ # Check for sensitive actions without conditions
186
+ # NOTE: For specific condition requirements (like iam:PassRole needing iam:PassedToService),
187
+ # use the action_condition_enforcement built-in check instead (configured below)
188
+ sensitive_action_check:
189
+ enabled: true
190
+ severity: medium # Security issue: medium severity
191
+
192
+ # ========================================================================
193
+ # SENSITIVE ACTIONS - Exact action matches
194
+ # ========================================================================
195
+ # Supports three formats:
196
+ #
197
+ # 1. Simple list (backward compatible - uses any_of logic):
198
+ # sensitive_actions:
199
+ # - "iam:CreateUser"
200
+ # - "s3:DeleteBucket"
201
+ #
202
+ # 2. any_of: Flag if ANY of these actions appear:
203
+ # sensitive_actions:
204
+ # any_of:
205
+ # - "iam:CreateUser"
206
+ # - "s3:DeleteBucket"
207
+ #
208
+ # 3. all_of: Flag only if ALL of these actions appear in the same statement:
209
+ # sensitive_actions:
210
+ # all_of:
211
+ # - "iam:CreateUser"
212
+ # - "iam:AttachUserPolicy"
213
+ # (Useful for detecting privilege escalation patterns)
214
+ # ========================================================================
215
+
216
+ # List of specific actions considered sensitive
217
+ sensitive_actions:
218
+ # iam:PassRole commented out - use action_condition_enforcement for specific requirements
219
+ # - "iam:PassRole"
220
+ - "iam:CreateUser"
221
+ - "iam:CreateRole"
222
+ - "iam:PutUserPolicy"
223
+ - "iam:PutRolePolicy"
224
+ - "iam:AttachUserPolicy"
225
+ - "iam:AttachRolePolicy"
226
+ - "iam:CreateAccessKey"
227
+ - "iam:DeleteUser"
228
+ - "iam:DeleteRole"
229
+ - "s3:DeleteBucket"
230
+ - "s3:PutBucketPolicy"
231
+ - "s3:DeleteBucketPolicy"
232
+ - "ec2:TerminateInstances"
233
+ - "ec2:DeleteVolume"
234
+ - "rds:DeleteDBInstance"
235
+ - "lambda:DeleteFunction"
236
+ - "eks:DeleteCluster"
237
+
238
+ # ========================================================================
239
+ # SENSITIVE ACTION PATTERNS - Regex pattern matches
240
+ # ========================================================================
241
+ # Supports three formats (same as sensitive_actions):
242
+ #
243
+ # 1. Simple list (backward compatible - uses any_of logic):
244
+ # sensitive_action_patterns:
245
+ # - "^iam:Delete.*"
246
+ # - "^s3:Delete.*"
247
+ #
248
+ # 2. any_of: Flag if actions match ANY pattern:
249
+ # sensitive_action_patterns:
250
+ # any_of:
251
+ # - "^iam:Delete.*"
252
+ # - "^s3:Delete.*"
253
+ #
254
+ # 3. all_of: Flag if actions match ALL patterns:
255
+ # sensitive_action_patterns:
256
+ # all_of:
257
+ # - "^iam:.*" # Must be IAM service
258
+ # - ".*User$" # Must end with "User"
259
+ # (Useful for finding specific action types like iam:CreateUser, iam:DeleteUser)
260
+ # ========================================================================
261
+
262
+ # Regex patterns for sensitive actions
263
+ sensitive_action_patterns:
264
+ - "^iam:Delete.*" # All IAM delete actions
265
+ # - "^iam:Put.*Policy$" # All IAM policy put actions
266
+ # - ".*:Delete.*" # Uncomment to flag all delete actions
267
+ # - "^s3:PutBucket.*" # All S3 bucket modification actions
268
+ # - "^kms:(Delete|Disable).*" # KMS delete and disable actions
269
+ # - "^rds:Delete.*" # All RDS delete actions
270
+
271
+ # ========================================================================
272
+ # EXAMPLES: Using any_of and all_of
273
+ # ========================================================================
274
+ # Example 1: Detect privilege escalation pattern (all_of)
275
+ # IMPORTANT: all_of checks work at POLICY-LEVEL, detecting actions
276
+ # scattered across MULTIPLE statements in the same policy!
277
+ #
278
+ # sensitive_actions:
279
+ # all_of:
280
+ # - "iam:CreateUser"
281
+ # - "iam:AttachUserPolicy"
282
+ #
283
+ # This will flag a policy if it has BOTH actions anywhere across
284
+ # all its statements, even if they're in separate statements:
285
+ # Statement 1: "iam:CreateUser"
286
+ # Statement 2: "iam:AttachUserPolicy"
287
+ # → DETECTED: Privilege escalation risk!
288
+ #
289
+ # Example 2: Detect any destructive S3 action (any_of with patterns)
290
+ # This checks per-statement (traditional behavior):
291
+ # sensitive_action_patterns:
292
+ # any_of:
293
+ # - "^s3:Delete.*"
294
+ # - "^s3:PutBucket.*"
295
+ #
296
+ # Example 3: Detect IAM actions on user resources (all_of patterns)
297
+ # Flag only IAM actions that specifically target users:
298
+ # sensitive_action_patterns:
299
+ # all_of:
300
+ # - "^iam:.*" # Must be IAM service
301
+ # - ".*User.*" # Must involve users
302
+ #
303
+ # ========================================================================
304
+ # ADVANCED: Multiple Groups (Detect different privilege escalation patterns)
305
+ # ========================================================================
306
+ # You can specify MULTIPLE all_of groups to detect DIFFERENT privilege
307
+ # escalation patterns across the ENTIRE POLICY:
308
+ #
309
+ # sensitive_actions:
310
+ # - all_of: # Pattern 1: User privilege escalation
311
+ # - "iam:CreateUser"
312
+ # - "iam:AttachUserPolicy"
313
+ # - all_of: # Pattern 2: Role privilege escalation
314
+ # - "iam:CreateRole"
315
+ # - "iam:AttachRolePolicy"
316
+ # - all_of: # Pattern 3: Lambda backdoor
317
+ # - "lambda:CreateFunction"
318
+ # - "iam:PassRole"
319
+ #
320
+ # Each all_of group is checked independently against ALL statements.
321
+ # If a policy grants all actions in ANY all_of group (even across
322
+ # different statements), it will be flagged.
323
+ #
324
+ # Mixed groups (combine simple actions, any_of, and all_of):
325
+ # sensitive_actions:
326
+ # - "s3:DeleteBucket" # Simple action (per-statement, any_of logic)
327
+ # - all_of: # Privilege escalation (policy-level detection)
328
+ # - "iam:CreateUser"
329
+ # - "iam:AttachUserPolicy"
330
+ # - any_of: # Any Lambda code changes (per-statement)
331
+ # - "lambda:CreateFunction"
332
+ # - "lambda:UpdateFunctionCode"
333
+ #
334
+ # Pattern groups work the same way:
335
+ # sensitive_action_patterns:
336
+ # - "^kms:Delete.*" # Simple pattern
337
+ # - all_of: ["^iam:.*", ".*User$"] # IAM user actions
338
+ # - all_of: ["^s3:.*", ".*Bucket.*"] # S3 bucket operations
339
+ # ========================================================================
340
+
341
+ # ============================================================================
342
+ # Action Condition Enforcement
343
+ # Enforce ALL types of condition requirements for actions:
344
+ # - MFA requirements
345
+ # - IP/VPC restrictions
346
+ # - Tag requirements (replaces action_tag_enforcement)
347
+ # - Time-based access
348
+ # - Encryption requirements
349
+ # - Any AWS condition key
350
+ #
351
+ # Supports all_of/any_of/none_of logic for both actions and conditions
352
+ # - all_of: ALL specified items must be present
353
+ # - any_of: At least ONE specified item must be present
354
+ # - none_of: NONE of the specified items should be present (forbidden)
355
+ # ============================================================================
356
+ action_condition_enforcement_check:
357
+ enabled: true
358
+ severity: high # Default severity: high (can be overridden per-requirement)
359
+ description: "Enforce specific IAM condition requirements (unified: MFA, IP, tags, etc.)"
360
+
361
+ # ========================================================================
362
+ # PER-REQUIREMENT SEVERITY OVERRIDES
363
+ # ========================================================================
364
+ # You can set different severity levels for different requirements:
365
+ #
366
+ # Global severity (applies to all requirements unless overridden):
367
+ # severity: high
368
+ #
369
+ # Per-requirement severity (overrides global):
370
+ # - actions:
371
+ # - "iam:PassRole"
372
+ # severity: critical # This requirement is critical
373
+ # required_conditions: [...]
374
+ #
375
+ # Per-condition severity (overrides both global and requirement):
376
+ # - actions:
377
+ # - "ec2:RunInstances"
378
+ # required_conditions:
379
+ # - condition_key: "aws:RequestTag/Owner"
380
+ # severity: high # This specific condition is high
381
+ #
382
+ # Severity precedence: condition > requirement > global
383
+ # ========================================================================
384
+
385
+ action_condition_requirements:
386
+ # iam:PassRole MUST specify which services can use the role
387
+ # This is CRITICAL because missing iam:PassedToService enables privilege escalation
388
+ - actions:
389
+ - "iam:PassRole"
390
+ severity: critical # Override: this specific requirement is critical
391
+ required_conditions:
392
+ - condition_key: "iam:PassedToService"
393
+ description: "Specify which AWS services are allowed to use the passed role to prevent privilege escalation"
394
+ # enforce specific service list
395
+ # expected_value: ["lambda.amazonaws.com", "ecs-tasks.amazonaws.com"]
396
+ example: |
397
+ "Condition": {
398
+ "StringEquals": {
399
+ "iam:PassedToService": [
400
+ "lambda.amazonaws.com",
401
+ "ecs-tasks.amazonaws.com",
402
+ "ec2.amazonaws.com",
403
+ "glue.amazonaws.com",
404
+ "lambda.amazonaws.com"
405
+ ]
406
+ }
407
+ }
408
+
409
+ # Sensitive IAM actions require MFA
410
+ - action_patterns:
411
+ - "^iam:Delete.*"
412
+ - "^iam:Put.*Policy$"
413
+ - "^iam:Attach.*Policy$"
414
+ - "^iam:Detach.*Policy$"
415
+ severity: high # High severity for IAM operations without MFA
416
+ required_conditions:
417
+ - condition_key: "aws:MultiFactorAuthPresent"
418
+ description: "Require MFA authentication for sensitive IAM operations"
419
+ expected_value: true
420
+
421
+ # S3 destructive operations require MFA
422
+ - actions:
423
+ - "s3:DeleteBucket"
424
+ - "s3:DeleteBucketPolicy"
425
+ - "s3:PutBucketPolicy"
426
+ severity: high # High severity for S3 destructive operations without MFA
427
+ required_conditions:
428
+ - condition_key: "aws:MultiFactorAuthPresent"
429
+ description: "Require MFA for S3 destructive operations"
430
+ expected_value: true
431
+
432
+ # All S3 operations must use HTTPS (optional - uncomment if needed)
433
+ # - action_patterns:
434
+ # - "^s3:.*"
435
+ # required_conditions:
436
+ # - condition_key: "aws:SecureTransport"
437
+ # description: "Require HTTPS for all S3 operations"
438
+ # expected_value: true
439
+
440
+ # EC2 instances must be in specific VPCs (optional - uncomment and customize)
441
+ # - actions:
442
+ # - "ec2:RunInstances"
443
+ # required_conditions:
444
+ # - condition_key: "ec2:Vpc"
445
+ # description: "EC2 instances must be launched in approved VPCs"
446
+ # example: |
447
+ # "Condition": {
448
+ # "StringEquals": {
449
+ # "ec2:Vpc": "arn:aws:ec2:us-east-1:123456789012:vpc/vpc-12345678"
450
+ # }
451
+ # }
452
+
453
+ # Require source IP restrictions
454
+ - action_patterns:
455
+ - "^ssm:StartSession$"
456
+ - "^ssm:Run.*$"
457
+ - "^s3:GetObject$"
458
+ - "^rds:.*$"
459
+ severity: medium # Medium severity for missing IP restrictions
460
+ required_conditions:
461
+ - condition_key: "aws:SourceIp"
462
+ description: "Restrict access to corporate IP ranges"
463
+ example: |
464
+ "Condition": {
465
+ "IpAddress": {
466
+ "aws:SourceIp": [
467
+ "10.0.0.0/8",
468
+ "172.16.0.0/12"
469
+ ]
470
+ }
471
+ }
472
+
473
+ # ============================================================================
474
+ # TAG ENFORCEMENT EXAMPLES
475
+ # Use action_condition_enforcement for tag requirements too!
476
+ # ============================================================================
477
+
478
+ # EC2 instances must have owner tag matching principal's owner tag
479
+ - actions:
480
+ - "ec2:RunInstances"
481
+ required_conditions:
482
+ all_of:
483
+ - condition_key: "aws:ResourceTag/owner"
484
+ operator: "StringEquals"
485
+ expected_value: "${aws:PrincipalTag/owner}"
486
+ description: "Resource owner must match the principal's owner tag"
487
+
488
+ - condition_key: "aws:RequestTag/env"
489
+ operator: "StringEquals"
490
+ expected_value: ["prod", "pre", "dev", "sandbox"]
491
+ description: "Must specify a valid Environment tag"
492
+
493
+ # RDS databases need required tags
494
+ - action_patterns:
495
+ - "^rds:Create.*"
496
+ - "^rds:Modify.*"
497
+ required_conditions:
498
+ all_of:
499
+ - condition_key: "aws:RequestTag/DataClassification"
500
+ description: "Must specify data classification"
501
+ - condition_key: "aws:RequestTag/BackupPolicy"
502
+ description: "Must specify backup policy"
503
+ - condition_key: "aws:RequestTag/Owner"
504
+ description: "Must specify resource owner"
505
+
506
+ # S3 bucket operations with data classification matching
507
+ # - actions:
508
+ # - "s3:CreateBucket"
509
+ # - "s3:PutObject"
510
+ # required_conditions:
511
+ # all_of:
512
+ # - condition_key: "aws:ResourceTag/DataClassification"
513
+ # operator: "StringEquals"
514
+ # expected_value: "${aws:PrincipalTag/DataClassification}"
515
+ # description: "Data classification must match principal's tag"
516
+ # - condition_key: "aws:RequestTag/Owner"
517
+ # description: "Must specify owner"
518
+ # - condition_key: "aws:RequestTag/CostCenter"
519
+ # description: "Must specify cost center"
520
+
521
+ # ============================================================================
522
+ # NONE_OF EXAMPLES - Forbidden Actions and Conditions
523
+ # ============================================================================
524
+
525
+ # Example 1: Forbidden actions - flag if these dangerous actions appear
526
+ # - actions:
527
+ # none_of:
528
+ # - "iam:*"
529
+ # - "s3:DeleteBucket"
530
+ # - "s3:DeleteBucketPolicy"
531
+ # description: "These highly sensitive actions are forbidden in this policy"
532
+
533
+ # Example 2: Ensure insecure transport is never explicitly allowed
534
+ # - actions:
535
+ # - "s3:GetObject"
536
+ # - "s3:PutObject"
537
+ # required_conditions:
538
+ # none_of:
539
+ # - condition_key: "aws:SecureTransport"
540
+ # expected_value: false
541
+ # description: "Never allow insecure transport to be explicitly permitted"
542
+
543
+ # Example 3: Prevent overly permissive IP ranges
544
+ # - action_patterns:
545
+ # - "^s3:.*"
546
+ # required_conditions:
547
+ # none_of:
548
+ # - condition_key: "aws:SourceIp"
549
+ # expected_value: "0.0.0.0/0"
550
+ # description: "Do not allow access from any IP address"
551
+
552
+ # ============================================================================
553
+ # CUSTOM CHECKS - Business Rules
554
+ # These enforce your organization's specific requirements
555
+ # Configured via custom_checks_dir and the checks section below
556
+ # ============================================================================
557
+
558
+ # Custom checks directory - auto-discover PolicyCheck subclasses
559
+ # custom_checks_dir: "./custom_checks"
560
+
561
+ # Configure custom checks loaded from custom_checks_dir
562
+ # The check_id corresponds to the check's check_id property
563
+ # Note: action_condition_enforcement and action_tag_enforcement are now built-in checks
564
+ # For examples of custom business-specific checks, see: examples/custom-business-rules.yaml
565
+
566
+ # ============================================================================
567
+ # USAGE SCENARIOS
568
+ # ============================================================================
569
+
570
+ # Scenario 1: Default - Full built-in validation
571
+ # iam-validator validate --path ./policies
572
+
573
+ # Scenario 2: With AWS Access Analyzer (disable built-in AWS validation)
574
+ # Set: enable_builtin_checks: true
575
+ # Then run:
576
+ # iam-validator analyze --path ./policies --post-findings
577
+ # iam-validator validate --path ./policies # Only custom checks run
578
+
579
+ # Scenario 3: Disable specific built-in check
580
+ # sid_uniqueness_check:
581
+ # enabled: false # Disable just this one check
582
+
583
+ # Scenario 4: Enable custom business rules
584
+ # See: examples/custom-business-rules.yaml
@@ -3,5 +3,5 @@
3
3
  This file is the single source of truth for the package version.
4
4
  """
5
5
 
6
- __version__ = "1.0.0"
6
+ __version__ = "1.0.2"
7
7
  __version_info__ = tuple(int(part) for part in __version__.split("."))
@@ -30,7 +30,21 @@ class ValidatorConfig:
30
30
  config_dict: Dictionary loaded from YAML config file
31
31
  """
32
32
  self.config_dict = config_dict or {}
33
- self.checks_config = self.config_dict.get("checks", {})
33
+
34
+ # Support both nested and flat structure
35
+ # New flat structure: each check is a top-level key ending with "_check"
36
+ # Old nested structure: all checks under "checks" key
37
+ if "checks" in self.config_dict:
38
+ # Old nested structure
39
+ self.checks_config = self.config_dict.get("checks", {})
40
+ else:
41
+ # New flat structure - extract all keys ending with "_check"
42
+ self.checks_config = {
43
+ key.replace("_check", ""): value
44
+ for key, value in self.config_dict.items()
45
+ if key.endswith("_check") and isinstance(value, dict)
46
+ }
47
+
34
48
  self.custom_checks = self.config_dict.get("custom_checks", [])
35
49
  self.custom_checks_dir = self.config_dict.get("custom_checks_dir")
36
50
  self.settings = self.config_dict.get("settings", {})
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "iam-policy-validator"
3
- version = "1.0.1"
3
+ version = "1.0.2"
4
4
  description = "Validate AWS IAM policies for correctness and security using AWS Service Reference API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -284,7 +284,7 @@ wheels = [
284
284
 
285
285
  [[package]]
286
286
  name = "iam-policy-validator"
287
- version = "1.0.1"
287
+ version = "1.0.2"
288
288
  source = { editable = "." }
289
289
  dependencies = [
290
290
  { name = "boto3" },