Skip to content

Commit ca7967f

Browse files
committed
apply ruff-format to all files
1 parent 957c40d commit ca7967f

File tree

63 files changed

+786
-1086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+786
-1086
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ repos:
1313
rev: v0.5.3
1414
hooks:
1515
- id: ruff
16-
files: ^(policy_sentry/|setup.py)
16+
files: ^(examples/|policy_sentry/|utils/|setup.py)
1717
- id: ruff-format
18-
files: ^(policy_sentry/|setup.py)
1918
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
2019
rev: v1.3.3
2120
hooks:

examples/library-usage/analysis/analyze_by_access_level.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env python
2-
from policy_sentry.analysis.analyze import analyze_by_access_level
32
import json
43

5-
if __name__ == '__main__':
4+
from policy_sentry.analysis.analyze import analyze_by_access_level
5+
6+
if __name__ == "__main__":
67
permissions_management_policy = {
78
"Version": "2012-10-17",
89
"Statement": [
@@ -19,9 +20,9 @@
1920
"ecr:ListImages",
2021
"ecr:DescribeImages",
2122
],
22-
"Resource": "*"
23+
"Resource": "*",
2324
}
24-
]
25+
],
2526
}
2627
permissions_management_actions = analyze_by_access_level(permissions_management_policy, "Permissions management")
2728
print(json.dumps(permissions_management_actions, indent=4))

examples/library-usage/analysis/expand_actions_from_policy.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#!/usr/bin/env python
22

3-
from policy_sentry.util.policy_files import get_actions_from_policy
4-
from policy_sentry.analysis.analyze import determine_actions_to_expand
53
import json
64

5+
from policy_sentry.analysis.analyze import determine_actions_to_expand
6+
from policy_sentry.util.policy_files import get_actions_from_policy
7+
78
POLICY_JSON_TO_EXPAND = {
8-
"Version": "2012-10-17",
9-
"Statement": [
10-
{
11-
"Effect": "Allow",
12-
"Action": [
13-
"cloud9:*",
14-
],
15-
"Resource": "*"
16-
}
17-
]
9+
"Version": "2012-10-17",
10+
"Statement": [
11+
{
12+
"Effect": "Allow",
13+
"Action": [
14+
"cloud9:*",
15+
],
16+
"Resource": "*",
17+
}
18+
],
1819
}
1920

2021

21-
if __name__ == '__main__':
22-
22+
if __name__ == "__main__":
2323
requested_actions = get_actions_from_policy(POLICY_JSON_TO_EXPAND)
2424
expanded_actions = determine_actions_to_expand(requested_actions)
2525
print(json.dumps(expanded_actions, indent=4))

examples/library-usage/example.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#! /usr/bin/env python
22

3-
from policy_sentry.querying.actions import get_actions_for_service, get_actions_with_access_level
3+
from policy_sentry.querying.actions import (
4+
get_actions_for_service,
5+
get_actions_with_access_level,
6+
)
47

58

6-
def example():
7-
actions = get_actions_for_service('cloud9')
9+
def example() -> None:
10+
actions = get_actions_for_service("cloud9")
811
print(actions)
9-
actions = get_actions_with_access_level('s3', 'Permissions management')
12+
actions = get_actions_with_access_level("s3", "Permissions management")
1013
print(actions)
1114

1215

13-
if __name__ == '__main__':
16+
if __name__ == "__main__":
1417
print("Executing example")
1518
example()
1619
print("Done with example")

examples/library-usage/querying/actions/get_action_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python
22

3-
from policy_sentry.querying.actions import get_action_data
43
import json
54

6-
if __name__ == '__main__':
5+
from policy_sentry.querying.actions import get_action_data
76

8-
output = get_action_data('ram', 'createresourceshare')
7+
if __name__ == "__main__":
8+
output = get_action_data("ram", "createresourceshare")
99
print(json.dumps(output, indent=4))
1010

1111
"""

examples/library-usage/querying/actions/get_actions_for_service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env python
2-
from policy_sentry.querying.actions import get_actions_for_service
32
import json
43

5-
if __name__ == '__main__':
6-
output = get_actions_for_service('cloud9')
4+
from policy_sentry.querying.actions import get_actions_for_service
5+
6+
if __name__ == "__main__":
7+
output = get_actions_for_service("cloud9")
78
print(json.dumps(output, indent=4))
89

910
"""

examples/library-usage/querying/actions/get_actions_matching_condition_key.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22

3-
from policy_sentry.querying.actions import get_actions_matching_condition_key
43
import json
54

6-
if __name__ == '__main__':
5+
from policy_sentry.querying.actions import get_actions_matching_condition_key
76

7+
if __name__ == "__main__":
88
output = get_actions_matching_condition_key("ses", "ses:FeedbackAddress")
99
print(json.dumps(output, indent=4))
1010

examples/library-usage/querying/actions/get_actions_that_support_wildcard_arns_only.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22

3-
from policy_sentry.querying.actions import get_actions_that_support_wildcard_arns_only
43
import json
54

6-
if __name__ == '__main__':
5+
from policy_sentry.querying.actions import get_actions_that_support_wildcard_arns_only
76

7+
if __name__ == "__main__":
88
output = get_actions_that_support_wildcard_arns_only("secretsmanager")
99
print(json.dumps(output, indent=4))
1010

examples/library-usage/querying/actions/get_actions_with_access_level.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python
22

3-
from policy_sentry.querying.actions import get_actions_with_access_level
43
import json
54

6-
if __name__ == '__main__':
5+
from policy_sentry.querying.actions import get_actions_with_access_level
76

8-
output = get_actions_with_access_level('s3', 'Permissions management')
7+
if __name__ == "__main__":
8+
output = get_actions_with_access_level("s3", "Permissions management")
99
print(json.dumps(output, indent=4))
1010

1111
"""

examples/library-usage/querying/actions/get_actions_with_arn_type_and_access_level.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22

3-
from policy_sentry.querying.actions import get_actions_with_arn_type_and_access_level
43
import json
54

6-
if __name__ == '__main__':
5+
from policy_sentry.querying.actions import get_actions_with_arn_type_and_access_level
76

7+
if __name__ == "__main__":
88
output = get_actions_with_arn_type_and_access_level("ram", "resource-share", "Permissions management")
99
print(json.dumps(output, indent=4))
1010

0 commit comments

Comments
 (0)