Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: DoesNotApplyToEmptyFiles
input: []
expectations:
rules:
has_correct_keys: SKIP
has_likely_valid_arn: SKIP
- name: FindsRequiredKeys
input: [
{"ParameterKey": "pIgnore", "ParameterValue": "arn:aws:s3:::bucket_name/key_name"}
]
expectations:
rules:
has_correct_keys: PASS
has_likely_valid_arn: PASS
- name: FindsUnsupportedKeys
input: [
{"ParameterKey": "pIgnore", "ParameterValue": "whatever", "UsePreviousValue": "true"}
]
expectations:
rules:
has_correct_keys: FAIL
has_likely_valid_arn: SKIP
- name: FindsMalformedArn
input: [
{"ParameterKey": "pIgnore", "ParameterValue": "arn:aws:foo:bar:baz"}
]
expectations:
rules:
has_correct_keys: PASS
has_likely_valid_arn: FAIL
- name: ChecksForMissingKeys
input: [
{"ParameterKey": "pIgnore", "ParmeterValue": "arn:aws:s3:::bucket_name/key_name"}
]
expectations:
rules:
has_correct_keys: FAIL
has_likely_valid_arn: SKIP
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let all_parameters = this[*]
let arn_parameters = this[ParameterValue == /^arn:aws/]

rule has_correct_keys when %all_parameters !empty {
%all_parameters[*] {
ParameterKey exists
ParameterValue exists
<< Required keys exist >>
UsePreviousValue not exists
ResolvedValue not exists
}
}

# Check that parameters that contain an ARN value conform to
# defined ARN format:
# arn:partition:service:region:namespace:relative-id
rule has_likely_valid_arn when %arn_parameters !empty {
%arn_parameters.ParameterValue {
this == /^arn:\w+:\w+:[^:]*:[^:]*:\S+$/
<< ARN parameter appears valid >>
}
}