-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add-dependabot
- Loading branch information
Showing
17 changed files
with
228 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name-template: 'v$RESOLVED_VERSION' | ||
tag-template: 'v$RESOLVED_VERSION' | ||
change-template: '- $TITLE @$AUTHOR (#$NUMBER)' | ||
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. | ||
version-resolver: | ||
major: | ||
labels: | ||
- 'major' | ||
minor: | ||
labels: | ||
- 'minor' | ||
patch: | ||
labels: | ||
- 'patch' | ||
default: patch | ||
template: | | ||
## Changes | ||
$CHANGES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Release Drafter | ||
|
||
on: | ||
push: | ||
# branches to consider in the event; optional, defaults to all | ||
branches: | ||
- master | ||
# pull_request event is required only for autolabeler | ||
pull_request: | ||
# Only following types are handled by the action, but one can default to all as well | ||
types: [opened, reopened, synchronize] | ||
# pull_request_target event is required for autolabeler to support PRs from forks | ||
pull_request_target: | ||
types: [opened, reopened, synchronize] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
update_release_draft: | ||
permissions: | ||
# write permission is required to create a github release | ||
contents: write | ||
# write permission is required for autolabeler | ||
# otherwise, read permission is required at least | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Drafts your next Release notes as Pull Requests are merged into "master" | ||
- uses: release-drafter/release-drafter@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
VERSION = (1, 15, 1) | ||
VERSION = (1, 15, 4) | ||
|
||
__version__ = ".".join(map(str, VERSION)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,49 @@ | ||
# import pytest | ||
# | ||
# from cfripper.rules.KMSKeyWildcardPrincipal import KMSKeyWildcardPrincipal | ||
# from cfripper.model.result import Result | ||
# from tests.utils import get_cfmodel_from | ||
|
||
# TODO Implement check if this is needed as GenericWildcardPrincipal rule seems to include this one | ||
# @pytest.fixture() | ||
# def abcdef(): | ||
# return get_cfmodel_from("rules/KMSKeyWildcardPrincipal/abcdef.json").resolve() | ||
# | ||
# | ||
# def test_abcdef(abcdef): | ||
# result = Result() | ||
# rule = KMSKeyWildcardPrincipal(None, result) | ||
# rule.invoke(abcdef) | ||
# | ||
# assert not result.valid | ||
# assert len(result.failed_rules) == 1 | ||
# assert len(result.failed_monitored_rules) == 0 | ||
# assert result.failed_rules[0].rule == "KMSKeyWildcardPrincipal" | ||
# assert result.failed_rules[0].reason == "KMS Key policy {} should not allow wildcard principals" | ||
import pytest | ||
|
||
from cfripper.model.result import Failure | ||
from cfripper.rules import KMSKeyWildcardPrincipalRule | ||
from tests.utils import compare_lists_of_failures, get_cfmodel_from | ||
|
||
|
||
@pytest.fixture() | ||
def kms_key_with_wildcard_policy(): | ||
return get_cfmodel_from("rules/KMSKeyWildcardPrincipalRule/kms_key_with_wildcard_resource.json").resolve() | ||
|
||
|
||
@pytest.fixture() | ||
def kms_key_without_policy(): | ||
return get_cfmodel_from("rules/KMSKeyWildcardPrincipalRule/kms_key_without_policy.yml").resolve() | ||
|
||
|
||
def test_kms_key_with_wildcard_resource_not_allowed_is_flagged(kms_key_with_wildcard_policy): | ||
rule = KMSKeyWildcardPrincipalRule(None) | ||
rule._config.stack_name = "stack3" | ||
rule.all_cf_actions = set() | ||
result = rule.invoke(kms_key_with_wildcard_policy) | ||
|
||
assert result.valid is False | ||
assert compare_lists_of_failures( | ||
result.failures, | ||
[ | ||
Failure( | ||
granularity="RESOURCE", | ||
reason="KMS Key policy myKey should not allow wildcard principals", | ||
risk_value="MEDIUM", | ||
rule="KMSKeyWildcardPrincipalRule", | ||
rule_mode="BLOCKING", | ||
actions=None, | ||
resource_ids={"myKey"}, | ||
resource_types=None, | ||
) | ||
], | ||
) | ||
|
||
|
||
def test_kms_key_without_policy_is_not_flagged(kms_key_without_policy): | ||
rule = KMSKeyWildcardPrincipalRule(None) | ||
rule._config.stack_name = "stack3" | ||
rule.all_cf_actions = set() | ||
result = rule.invoke(kms_key_without_policy) | ||
|
||
assert result.valid | ||
assert compare_lists_of_failures(result.failures, []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/test_templates/rules/CrossAccountTrustRule/kms_key_without_policy.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
|
||
Resources: | ||
MyKey: | ||
Type: "AWS::KMS::Key" | ||
Properties: | ||
EnableKeyRotation: true | ||
Enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/test_templates/rules/KMSKeyWildcardPrincipalRule/kms_key_without_policy.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
|
||
Resources: | ||
MyKey: | ||
Type: "AWS::KMS::Key" | ||
Properties: | ||
EnableKeyRotation: true | ||
Enabled: true |