-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Issue #, if available:** ## Description of changes: When you need to split egress and inspection traffic you also need to split the rules. By introducing the rules per type we enable this behaviour. **Checklist** <!--- Leave unchecked if your change doesn't seem to apply --> * [x] Update tests * [ ] Update docs * [x] PR title follows [conventional commit semantics](https://www.conventionalcommits.org/en/v1.0.0-beta.2/#commit-message-for-a-fix-using-an-optional-issue-number) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
- Loading branch information
Showing
7 changed files
with
103 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from aws_network_firewall.account import Account | ||
from aws_network_firewall.cidr_range import CidrRange | ||
from aws_network_firewall.cidr_ranges import CidrRanges | ||
from aws_network_firewall.destination import Destination | ||
from aws_network_firewall.rule import Rule | ||
from aws_network_firewall.source import Source | ||
|
||
|
||
def generate_rule(type: str) -> Rule: | ||
return Rule( | ||
workload="my-workload", | ||
name="my-rule", | ||
type=type, | ||
description="My description", | ||
sources=[Source(description="my source", cidr="10.0.0.0/24", region=None)], | ||
destinations=[ | ||
Destination( | ||
description="my destination", | ||
protocol="TCP", | ||
port=443, | ||
cidr=None, | ||
endpoint=None, | ||
region=None, | ||
) | ||
], | ||
) | ||
|
||
|
||
def test_no_rules() -> None: | ||
rules = [] | ||
account = Account( | ||
name="my-account", | ||
account_id="123412341234", | ||
cidr_ranges=CidrRanges( | ||
cidr_ranges=[CidrRange(region="eu-west-1", value="10.0.0.0/24")] | ||
), | ||
rules=rules, | ||
) | ||
assert len(account.rules) == 0 | ||
assert len(account.egress_rules) == 0 | ||
assert len(account.inspection_rules) == 0 | ||
|
||
|
||
def test_inspection_rules() -> None: | ||
rules = [generate_rule(Rule.INSPECTION)] | ||
account = Account( | ||
name="my-account", | ||
account_id="123412341234", | ||
cidr_ranges=CidrRanges( | ||
cidr_ranges=[CidrRange(region="eu-west-1", value="10.0.0.0/8")] | ||
), | ||
rules=rules, | ||
) | ||
assert len(account.rules) == 1 | ||
assert len(account.egress_rules) == 0 | ||
assert len(account.inspection_rules) == 1 | ||
|
||
|
||
def test_egress_rules() -> None: | ||
rules = [generate_rule(Rule.EGRESS)] | ||
account = Account( | ||
name="my-account", | ||
account_id="123412341234", | ||
cidr_ranges=CidrRanges( | ||
cidr_ranges=[CidrRange(region="eu-west-1", value="10.0.0.0/8")] | ||
), | ||
rules=rules, | ||
) | ||
assert len(account.rules) == 1 | ||
assert len(account.egress_rules) == 1 | ||
assert len(account.inspection_rules) == 0 |
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