iam-policy-validator 1.15.4__py3-none-any.whl → 1.15.6__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.
@@ -197,8 +197,8 @@ async def validator(
197
197
  ... results = await v.validate_directory("./policies")
198
198
  ... v.generate_report(results, format="console")
199
199
  """
200
- fetcher = AWSServiceFetcher()
201
- yield ValidationContext(fetcher, config_path)
200
+ async with AWSServiceFetcher() as fetcher:
201
+ yield ValidationContext(fetcher, config_path)
202
202
 
203
203
 
204
204
  @asynccontextmanager
@@ -219,5 +219,5 @@ async def validator_from_config(config_path: str) -> AsyncIterator[ValidationCon
219
219
  ... results = await v.validate_directory("./policies")
220
220
  ... v.generate_report(results)
221
221
  """
222
- fetcher = AWSServiceFetcher()
223
- yield ValidationContext(fetcher, config_path=config_path)
222
+ async with AWSServiceFetcher() as fetcher:
223
+ yield ValidationContext(fetcher, config_path=config_path)
@@ -7,7 +7,6 @@ validation tasks without requiring deep knowledge of the internal API.
7
7
 
8
8
  from pathlib import Path
9
9
 
10
- from iam_validator.core.config.config_loader import ValidatorConfig
11
10
  from iam_validator.core.models import PolicyValidationResult, ValidationIssue
12
11
  from iam_validator.core.policy_checks import validate_policies
13
12
  from iam_validator.core.policy_loader import PolicyLoader
@@ -16,7 +15,6 @@ from iam_validator.core.policy_loader import PolicyLoader
16
15
  async def validate_file(
17
16
  file_path: str | Path,
18
17
  config_path: str | None = None,
19
- config: ValidatorConfig | None = None,
20
18
  ) -> PolicyValidationResult:
21
19
  """
22
20
  Validate a single IAM policy file.
@@ -24,7 +22,6 @@ async def validate_file(
24
22
  Args:
25
23
  file_path: Path to the policy file (JSON or YAML)
26
24
  config_path: Optional path to configuration file
27
- config: Optional ValidatorConfig object (overrides config_path)
28
25
 
29
26
  Returns:
30
27
  PolicyValidationResult for the policy
@@ -62,7 +59,6 @@ async def validate_file(
62
59
  async def validate_directory(
63
60
  dir_path: str | Path,
64
61
  config_path: str | None = None,
65
- config: ValidatorConfig | None = None,
66
62
  recursive: bool = True,
67
63
  ) -> list[PolicyValidationResult]:
68
64
  """
@@ -71,7 +67,6 @@ async def validate_directory(
71
67
  Args:
72
68
  dir_path: Path to directory containing policy files
73
69
  config_path: Optional path to configuration file
74
- config: Optional ValidatorConfig object (overrides config_path)
75
70
  recursive: Whether to search subdirectories (default: True)
76
71
 
77
72
  Returns:
@@ -83,7 +78,7 @@ async def validate_directory(
83
78
  >>> print(f"{valid_count}/{len(results)} policies are valid")
84
79
  """
85
80
  loader = PolicyLoader()
86
- policies = loader.load_from_path(str(dir_path))
81
+ policies = loader.load_from_path(str(dir_path), recursive=recursive)
87
82
 
88
83
  if not policies:
89
84
  raise ValueError(f"No IAM policies found in {dir_path}")
@@ -98,7 +93,6 @@ async def validate_json(
98
93
  policy_json: dict,
99
94
  policy_name: str = "inline-policy",
100
95
  config_path: str | None = None,
101
- config: ValidatorConfig | None = None,
102
96
  ) -> PolicyValidationResult:
103
97
  """
104
98
  Validate an IAM policy from a Python dictionary.
@@ -107,7 +101,6 @@ async def validate_json(
107
101
  policy_json: IAM policy as a Python dict
108
102
  policy_name: Name to identify this policy in results
109
103
  config_path: Optional path to configuration file
110
- config: Optional ValidatorConfig object (overrides config_path)
111
104
 
112
105
  Returns:
113
106
  PolicyValidationResult for the policy
@@ -148,7 +141,6 @@ async def validate_json(
148
141
  async def quick_validate(
149
142
  policy: str | Path | dict,
150
143
  config_path: str | None = None,
151
- config: ValidatorConfig | None = None,
152
144
  ) -> bool:
153
145
  """
154
146
  Quick validation returning just True/False.
@@ -158,7 +150,6 @@ async def quick_validate(
158
150
  Args:
159
151
  policy: File path, directory path, or policy dict
160
152
  config_path: Optional path to configuration file
161
- config: Optional ValidatorConfig object (overrides config_path)
162
153
 
163
154
  Returns:
164
155
  True if all policies are valid, False otherwise
@@ -194,7 +185,6 @@ async def get_issues(
194
185
  policy: str | Path | dict,
195
186
  min_severity: str = "medium",
196
187
  config_path: str | None = None,
197
- config: ValidatorConfig | None = None,
198
188
  ) -> list[ValidationIssue]:
199
189
  """
200
190
  Get just the issues from validation, filtered by severity.
@@ -203,7 +193,6 @@ async def get_issues(
203
193
  policy: File path, directory path, or policy dict
204
194
  min_severity: Minimum severity to include (critical, high, medium, low, info)
205
195
  config_path: Optional path to configuration file
206
- config: Optional ValidatorConfig object (overrides config_path)
207
196
 
208
197
  Returns:
209
198
  List of ValidationIssues meeting the severity threshold
@@ -252,7 +241,6 @@ async def get_issues(
252
241
  async def count_issues_by_severity(
253
242
  policy: str | Path | dict,
254
243
  config_path: str | None = None,
255
- config: ValidatorConfig | None = None,
256
244
  ) -> dict[str, int]:
257
245
  """
258
246
  Count issues grouped by severity level.
@@ -260,7 +248,6 @@ async def count_issues_by_severity(
260
248
  Args:
261
249
  policy: File path, directory path, or policy dict
262
250
  config_path: Optional path to configuration file
263
- config: Optional ValidatorConfig object (overrides config_path)
264
251
 
265
252
  Returns:
266
253
  Dictionary mapping severity levels to counts