-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update tests for network acl entry issues (Fixes #487, Fixes #483) - Test for port values from references - Test for entries without logical nacl resource - Test for correctly evaluating metadata to ignore warning Fix up various linting errors in yaml templates Refactor nacl grouping logic * Protect against missing port range
- Loading branch information
Showing
8 changed files
with
262 additions
and
65 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
30 changes: 30 additions & 0 deletions
30
spec/cfn_nag_integration/cfn_nag_ec2_network_acl_entry_spec.rb
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,30 @@ | ||
require 'spec_helper' | ||
require 'cfn-nag/cfn_nag_config' | ||
require 'cfn-nag/cfn_nag' | ||
require 'cfn-nag/cfn_nag_logging' | ||
|
||
describe CfnNag do | ||
before(:all) do | ||
CfnNagLogging.configure_logging(debug: false) | ||
@cfn_nag = CfnNag.new(config: CfnNagConfig.new) | ||
end | ||
|
||
context 'when nacl entry rule has metadata ignore' do | ||
it 'does not warn' do | ||
template_name = 'yaml/ec2_networkaclentry/metadata_overlapping_ports.yml' | ||
|
||
expected_aggregate_results = [ | ||
{ | ||
filename: test_template_path(template_name), | ||
file_results: { | ||
failure_count: 0, | ||
violations: [] | ||
} | ||
} | ||
] | ||
|
||
actual_aggregate_results = @cfn_nag.audit_aggregate_across_files input_path: test_template_path(template_name) | ||
expect(actual_aggregate_results).to eq expected_aggregate_results | ||
end | ||
end | ||
end |
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
37 changes: 37 additions & 0 deletions
37
spec/test_templates/yaml/ec2_networkaclentry/metadata_overlapping_ports.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,37 @@ | ||
--- | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: Test | ||
Parameters: | ||
PublicNetworkAcl: | ||
Type: String | ||
Description: 'Nacl Port' | ||
Resources: | ||
InboundHTTPPublicNetworkAclEntry: | ||
Type: AWS::EC2::NetworkAclEntry | ||
Metadata: | ||
cfn_nag: | ||
rules_to_suppress: | ||
- id: W72 | ||
reason: I know what I am doing | ||
Properties: | ||
NetworkAclId: !Ref 'PublicNetworkAcl' | ||
RuleNumber: 100 | ||
Protocol: 6 | ||
RuleAction: 'allow' | ||
Egress: false | ||
CidrBlock: '0.0.0.0/0' | ||
PortRange: | ||
From: 80 | ||
To: 80 | ||
InboundHTTPPublicNetworkAclEntry2: | ||
Type: AWS::EC2::NetworkAclEntry | ||
Properties: | ||
NetworkAclId: !Ref 'PublicNetworkAcl' | ||
RuleNumber: 101 | ||
Protocol: 6 | ||
RuleAction: 'allow' | ||
Egress: false | ||
CidrBlock: '0.0.0.0/0' | ||
PortRange: | ||
From: 80 | ||
To: 80 |
47 changes: 47 additions & 0 deletions
47
spec/test_templates/yaml/ec2_networkaclentry/overlapping_ports_no_nacl.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,47 @@ | ||
--- | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: Test | ||
Parameters: | ||
NaclIdOne: | ||
Type: String | ||
Description: 'Id for first Nacl' | ||
NaclIdTwo: | ||
Type: String | ||
Description: 'Id for first Nacl' | ||
Resources: | ||
BadNaclEntry1: | ||
Type: AWS::EC2::NetworkAclEntry | ||
Properties: | ||
NetworkAclId: !Ref 'NaclIdOne' | ||
RuleNumber: 100 | ||
Protocol: 6 | ||
RuleAction: 'allow' | ||
Egress: false | ||
CidrBlock: '0.0.0.0/0' | ||
PortRange: | ||
From: 80 | ||
To: 80 | ||
BadNaclEntry2: | ||
Type: AWS::EC2::NetworkAclEntry | ||
Properties: | ||
NetworkAclId: !Ref 'NaclIdOne' | ||
RuleNumber: 101 | ||
Protocol: 6 | ||
RuleAction: 'allow' | ||
Egress: false | ||
CidrBlock: '0.0.0.0/0' | ||
PortRange: | ||
From: 80 | ||
To: 80 | ||
GoodNaclEntry1: | ||
Type: AWS::EC2::NetworkAclEntry | ||
Properties: | ||
NetworkAclId: !Ref 'NaclIdTwo' | ||
RuleNumber: 101 | ||
Protocol: 6 | ||
RuleAction: 'allow' | ||
Egress: false | ||
CidrBlock: '0.0.0.0/0' | ||
PortRange: | ||
From: 80 | ||
To: 80 |
Oops, something went wrong.