Skip to content

Commit 9584ef7

Browse files
committed
updating package version
1 parent d1de3bd commit 9584ef7

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

devolv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.2.26"
1+
__version__ = "0.2.27"
22

devolv/drift/cli.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import boto3
55
import typer
66
from github import Github
7+
from datetime import datetime
78

89
from devolv.drift.aws_fetcher import (
910
get_aws_policy_document,
@@ -46,13 +47,16 @@ def detect_drift(local_doc, aws_doc) -> bool:
4647

4748
if missing_in_local:
4849
typer.echo("❌ Drift detected: Local is missing permissions present in AWS.")
49-
for stmt in missing_in_local:
50-
typer.echo(stmt)
50+
# No need to print each JSON line — rich diff will handle details
5151
return True
5252

5353
typer.echo("✅ No removal drift detected (local may have extra permissions; that's fine).")
5454
return False
5555

56+
57+
typer.echo("✅ No removal drift detected (local may have extra permissions; that's fine).")
58+
return False
59+
5660
@app.command()
5761
def drift(
5862
policy_name: str = typer.Option(..., "--policy-name", help="Name of the IAM policy"),
@@ -137,9 +141,13 @@ def _update_local_and_create_pr(doc, policy_file, repo_full_name, policy_name, i
137141
with open(policy_file, "w") as f:
138142
f.write(new_content)
139143

144+
timestamp = datetime.utcnow().strftime("%Y%m%d-%H%M%S")
140145
branch = (
141-
f"{description.replace(' ', '-').replace('+', 'plus').replace('/', '-')}-policy-{policy_name}"
142-
.strip("-")
146+
f"drift-sync-{policy_name}-{timestamp}"
147+
.replace(' ', '-')
148+
.replace('+', 'plus')
149+
.replace('/', '-')
150+
.strip('-')
143151
.lower()
144152
)
145153

devolv/drift/report.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import difflib
33
from rich.console import Console
44
from rich.text import Text
5-
5+
import typer
66
def clean_policy(policy):
77
"""
88
Remove empty statements ({} entries) from the policy's 'Statement' list.
@@ -13,21 +13,21 @@ def clean_policy(policy):
1313
policy["Statement"] = [s for s in statements if s]
1414
return policy
1515

16-
def detect_drift(local_doc: dict, aws_doc: dict) -> bool:
17-
"""
18-
Detect if the local policy would remove permissions from the AWS policy.
19-
Returns True if drift is detected, False otherwise.
20-
"""
21-
local_doc = clean_policy(local_doc)
22-
aws_doc = clean_policy(aws_doc)
16+
def detect_drift(local_doc, aws_doc) -> bool:
17+
"""Detect removal drift: AWS has permissions missing from local (danger)."""
18+
local_statements = {json.dumps(s, sort_keys=True) for s in local_doc.get("Statement", [])}
19+
aws_statements = {json.dumps(s, sort_keys=True) for s in aws_doc.get("Statement", [])}
20+
21+
missing_in_local = aws_statements - local_statements
2322

24-
local_statements = local_doc.get("Statement", [])
25-
aws_statements = aws_doc.get("Statement", [])
23+
if missing_in_local:
24+
typer.echo("❌ Drift detected: Local is missing permissions present in AWS.")
25+
# No need to print each JSON line — rich diff will handle details
26+
return True
2627

27-
# Check if any AWS statement is missing in local (i.e., local would remove something)
28-
missing_in_local = [stmt for stmt in aws_statements if stmt not in local_statements]
28+
typer.echo("✅ No removal drift detected (local may have extra permissions; that's fine).")
29+
return False
2930

30-
return bool(missing_in_local)
3131

3232
def generate_diff_lines(local_doc: dict, aws_doc: dict):
3333
"""

0 commit comments

Comments
 (0)