iam-policy-validator 1.11.1__py3-none-any.whl → 1.12.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iam-policy-validator
3
- Version: 1.11.1
3
+ Version: 1.12.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
@@ -1,8 +1,8 @@
1
1
  iam_validator/__init__.py,sha256=xHdUASOxFHwEXfT_GSr_KrkLlnxZ-pAAr1wW1PwAGko,693
2
2
  iam_validator/__main__.py,sha256=to_nz3n_IerJpVVZZ6WSFlFR5s_06J0csfPOTfQZG8g,197
3
- iam_validator/__version__.py,sha256=VA38cDITf2Rm6FSdOiIMZHEocdI2rmYOPTSCCAIrJ-M,374
3
+ iam_validator/__version__.py,sha256=W6lxpjiojokhUhDmTpeymt8Z-W7jmcwUbVTvLyrpAko,374
4
4
  iam_validator/checks/__init__.py,sha256=OTkPnmlelu4YjMO8krjhu2wXiTV72RzopA5u1SfPQA0,1990
5
- iam_validator/checks/action_condition_enforcement.py,sha256=6LJfO7DCgf10rtPjaZ5P4fmb5hfxJUBS5w1CrOiCu5Q,52442
5
+ iam_validator/checks/action_condition_enforcement.py,sha256=oj3hsh3LwPneYAsQ6iBd61ToIJMr6aDIixKP-zkaqKI,55053
6
6
  iam_validator/checks/action_resource_matching.py,sha256=WiGJmCIJfx5yituMjZxpKmk-99N6nK20ueN02ddy9oM,19296
7
7
  iam_validator/checks/action_validation.py,sha256=QXfNamcstQIO41zNed1-bCmXYkXdV77owu8G2cZ09-A,2517
8
8
  iam_validator/checks/condition_key_validation.py,sha256=QJjG82wxvjdG2m-YuEzAjKRRiWaaPkf_LChdUTvm9g4,3919
@@ -93,8 +93,8 @@ iam_validator/utils/__init__.py,sha256=NveA2F3G1E6-ANZzFr7J6Q6u5mogvMp862iFokmYu
93
93
  iam_validator/utils/cache.py,sha256=wOQKOBeoG6QqC5f0oXcHz63Cjtu_-SsSS-0pTSwyAiM,3254
94
94
  iam_validator/utils/regex.py,sha256=xHoMECttb7qaMhts-c9b0GIxdhHNZTt-UBr7wNhWfzg,6219
95
95
  iam_validator/utils/terminal.py,sha256=FsRaRMH_JAyDgXWBCOgOEhbS89cs17HCmKYoughq5io,724
96
- iam_policy_validator-1.11.1.dist-info/METADATA,sha256=yEdzYv7iyjewXjI59L_Jy5la1Gl49V6rObTECdOGfgY,34456
97
- iam_policy_validator-1.11.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
98
- iam_policy_validator-1.11.1.dist-info/entry_points.txt,sha256=8HtWd8O7mvPiPdZR5YbzY8or_qcqLM4-pKaFdhtFT8M,62
99
- iam_policy_validator-1.11.1.dist-info/licenses/LICENSE,sha256=AMnbFTBDcK4_MITe2wiQBkj0vg-jjBBhsc43ydC7tt4,1098
100
- iam_policy_validator-1.11.1.dist-info/RECORD,,
96
+ iam_policy_validator-1.12.0.dist-info/METADATA,sha256=oRx7SWFfzvm7WejCfUXLfGDYYAe-lnIBf74cfwigqT8,34456
97
+ iam_policy_validator-1.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
98
+ iam_policy_validator-1.12.0.dist-info/entry_points.txt,sha256=8HtWd8O7mvPiPdZR5YbzY8or_qcqLM4-pKaFdhtFT8M,62
99
+ iam_policy_validator-1.12.0.dist-info/licenses/LICENSE,sha256=AMnbFTBDcK4_MITe2wiQBkj0vg-jjBBhsc43ydC7tt4,1098
100
+ iam_policy_validator-1.12.0.dist-info/RECORD,,
@@ -3,7 +3,7 @@
3
3
  This file is the single source of truth for the package version.
4
4
  """
5
5
 
6
- __version__ = "1.11.1"
6
+ __version__ = "1.12.0"
7
7
  # Parse version, handling pre-release suffixes like -rc, -alpha, -beta
8
8
  _version_base = __version__.split("-", maxsplit=1)[0] # Remove pre-release suffix if present
9
9
  __version_info__ = tuple(int(part) for part in _version_base.split("."))
@@ -125,6 +125,22 @@ Configuration in iam-validator.yaml:
125
125
  - "iam:DeleteUser"
126
126
  - "s3:DeleteBucket"
127
127
  description: "These dangerous actions should never be used"
128
+
129
+ # Per-requirement ignore_patterns: Skip specific requirements for certain files/actions
130
+ - actions:
131
+ - "iam:CreateRole"
132
+ - "iam:PutRolePolicy"
133
+ - "iam:AttachRolePolicy"
134
+ required_conditions:
135
+ - condition_key: "iam:PermissionsBoundary"
136
+ description: "Require permissions boundary for IAM operations"
137
+ ignore_patterns:
138
+ # Ignore this requirement for iam-openid modules (they enforce boundary by default)
139
+ - filepath_regex: ".*modules//?iam-openid.*"
140
+
141
+ Note: ignore_patterns can be specified at TWO levels:
142
+ 1. Check-level (applies to ALL requirements): Useful for broad exclusions
143
+ 2. Requirement-level (applies to ONE requirement): Useful for fine-grained control
128
144
  """
129
145
 
130
146
  import re
@@ -132,6 +148,7 @@ from typing import TYPE_CHECKING, Any, ClassVar
132
148
 
133
149
  from iam_validator.core.aws_service import AWSServiceFetcher
134
150
  from iam_validator.core.check_registry import CheckConfig, PolicyCheck
151
+ from iam_validator.core.ignore_patterns import IgnorePatternMatcher
135
152
  from iam_validator.core.models import Statement, ValidationIssue
136
153
  from iam_validator.utils.regex import compile_and_cache
137
154
 
@@ -181,7 +198,7 @@ class ActionConditionEnforcementCheck(PolicyCheck):
181
198
  Returns:
182
199
  List of ValidationIssue objects found by this check
183
200
  """
184
- del policy_file, kwargs # Not used in current implementation
201
+ del kwargs # Not used in current implementation
185
202
  issues = []
186
203
 
187
204
  # Get action condition requirements from config
@@ -211,16 +228,60 @@ class ActionConditionEnforcementCheck(PolicyCheck):
211
228
  if uses_logical_operators:
212
229
  # Policy-wide detection (all_of/any_of/none_of)
213
230
  policy_issues = await self._check_policy_wide(policy, requirement, fetcher, config)
231
+ # Filter by requirement-level ignore_patterns
232
+ policy_issues = self._filter_requirement_issues(
233
+ policy_issues, requirement.get("ignore_patterns", []), policy_file
234
+ )
214
235
  issues.extend(policy_issues)
215
236
  else:
216
237
  # Per-statement check (simple list)
217
238
  statement_issues = await self._check_per_statement(
218
239
  policy, requirement, fetcher, config
219
240
  )
241
+ # Filter by requirement-level ignore_patterns
242
+ statement_issues = self._filter_requirement_issues(
243
+ statement_issues, requirement.get("ignore_patterns", []), policy_file
244
+ )
220
245
  issues.extend(statement_issues)
221
246
 
222
247
  return issues
223
248
 
249
+ def _filter_requirement_issues(
250
+ self,
251
+ issues: list[ValidationIssue],
252
+ ignore_patterns: list[dict[str, Any]],
253
+ filepath: str,
254
+ ) -> list[ValidationIssue]:
255
+ """
256
+ Filter issues based on requirement-level ignore patterns.
257
+
258
+ This allows each requirement within action_condition_enforcement to have its own
259
+ ignore patterns, enabling fine-grained control over which findings to suppress.
260
+
261
+ Args:
262
+ issues: List of validation issues to filter
263
+ ignore_patterns: List of ignore pattern dictionaries for this requirement
264
+ filepath: Path to the policy file being checked
265
+
266
+ Returns:
267
+ Filtered list of issues (issues matching ignore patterns are removed)
268
+
269
+ Example:
270
+ A requirement can ignore specific files while other requirements check them:
271
+ - actions: ["iam:CreateRole"]
272
+ required_conditions: [...]
273
+ ignore_patterns:
274
+ - filepath_regex: ".*modules/iam-openid.*"
275
+ """
276
+ if not ignore_patterns:
277
+ return issues
278
+
279
+ return [
280
+ issue
281
+ for issue in issues
282
+ if not IgnorePatternMatcher.should_ignore_issue(issue, filepath, ignore_patterns)
283
+ ]
284
+
224
285
  async def _check_policy_wide(
225
286
  self,
226
287
  policy: "IAMPolicy",