File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import typer
22from devolv .iam .validator .core import validate_policy_file
33
4- app = typer .Typer (help = "IAM Validator CLI " )
4+ file_app = typer .Typer (help = "Commands to validate IAM policy files. " )
55
6- @app .command ("file" )
6+ @file_app .command ("file" )
77def validate_file (path : str ):
88 """
99 Validate an AWS IAM policy file (JSON or YAML).
1010 """
11- findings = validate_policy_file (path )
11+ try :
12+ findings = validate_policy_file (path )
13+ except FileNotFoundError :
14+ typer .secho (f"❌ File not found: { path } " , fg = typer .colors .RED )
15+ raise typer .Exit (code = 1 )
16+ except ValueError as e :
17+ typer .secho (f"❌ Error: { e } " , fg = typer .colors .RED )
18+ raise typer .Exit (code = 1 )
19+ except Exception as e :
20+ typer .secho (f"❌ Unexpected error: { e } " , fg = typer .colors .RED )
21+ raise typer .Exit (code = 1 )
22+
1223 if not findings :
1324 typer .secho ("✅ Policy is valid and passed all checks." , fg = typer .colors .GREEN )
1425 else :
26+ typer .secho ("⚠️ Issues found in the policy:" , fg = typer .colors .YELLOW )
1527 for finding in findings :
16- typer .secho (f"❌ { finding ['level' ].upper ()} : { finding ['message' ]} " , fg = typer .colors .RED )
17- raise typer .Exit (code = 1 )
28+ typer .secho (f" - { finding ['level' ].upper ()} : { finding ['message' ]} " , fg = typer .colors .RED )
29+ raise typer .Exit (code = 2 )
30+
You can’t perform that action at this time.
0 commit comments