You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INVALID - No resources match for s3:GetObject which requires a resource format of arn:*:s3:::*/* for the resource object* - {'filepath': None}
20
+
cat > test.json << EOF
21
+
{
22
+
"Version": "2012-10-17",
23
+
"Statement": {
24
+
"Effect": "Allow",
25
+
"Action":["s3:GetObject"],
26
+
"Resource": ["arn:aws:s3:::bucket1"]
27
+
}
28
+
}
29
+
EOF
30
+
31
+
parliament --file test.json
32
+
```
33
+
34
+
This will output:
35
+
```
36
+
MEDIUM - No resources match for the given action - - [{'action': 's3:GetObject', 'required_format': 'arn:*:s3:::*/*'}] - {'actions': ['s3:GetObject'], 'filepath': 'test.json'}
37
+
```
38
+
39
+
This example is showing that the action s3:GetObject requires a resource matching an object path (ie. it must have a "/" in it).
40
+
41
+
## Custom config file
42
+
You may decide you want to change the severity of a finding, the text associated with it, or that you want to ignore certain types of findings. To support this, you can provide an override config file. First, create a test.json file:
43
+
44
+
```
45
+
{
46
+
"Version": "2012-10-17",
47
+
"Id": "123",
48
+
"Statement": [
49
+
{
50
+
"Effect": "Allow",
51
+
"Action": "s3:abc",
52
+
"Resource": "*"
53
+
},
54
+
{
55
+
"Effect": "Allow",
56
+
"Action": ["s3:*", "ec2:*"],
57
+
"Resource": "arn:aws:s3:::test/*"
58
+
}
59
+
]
60
+
}
61
+
```
62
+
63
+
This will have two findings:
64
+
- LOW - Unknown action - - Unknown action s3:abc
65
+
- MEDIUM - No resources match for the given action
66
+
67
+
The second finding will be very long, because every s3 and ec2 action are expanded and most are incorrect for the S3 object path resource that is provided.
68
+
69
+
Now create a file `config_override.yaml` with the following contents:
70
+
22
71
```
72
+
UNKNOWN_ACTION:
73
+
severity: MEDIUM
74
+
ignore_locations:
75
+
filepath:
76
+
- testa.json
77
+
- .py
23
78
24
-
This example is showing that a resource specifying an S3 bucket (not an object path) was given in a policy with s3:GetObject, which requires an object path.
79
+
RESOURCE_MISMATCH:
80
+
ignore_locations:
81
+
actions: "s3:*"
82
+
```
83
+
84
+
Now run: `parliament --file test.json --config config_override.yaml`
85
+
You will have only one output: `MEDIUM - Unknown action - - Unknown action s3:abc`
86
+
87
+
Notice that the severity of that finding has been changed from a `LOW` to a `MEDIUM`. Also, note that the other finding is gone, because the previous `RESOURCE_MISMATCH` finding contained an `actions` element of `["s3:*", "ec2:*"]`. The ignore logic looks for any of the values you provide in the element within `location`. This means that we are doing `if "s3:*" in str(["s3:*", "ec2:*"])`
88
+
89
+
Now rename `test.json` to `testa.json` and rerun the command. You will no longer have any output, because we are filtering based on the filepath for `UNKNOWN_ACTION` and filtering for any filepaths that contain `testa.json` or `.py`.
90
+
91
+
You can also check the exit status with `echo $?` and see the exit status is 0 when there are no findings. The exit status is set to the number of findings (ex. 10 findings results in an exit status of 10).
92
+
93
+
94
+
95
+
96
+
## Using parliament as a library
97
+
Parliament was meant to be used a library in other projects. A basic example follows.
0 commit comments