awspec 1.16.1 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/_resource_types/wafregional_web_acl.md +29 -0
- data/doc/resource_types.md +29 -1
- data/lib/awspec/generator/doc/type/wafregional_web_acl.rb +17 -0
- data/lib/awspec/helper/finder.rb +3 -0
- data/lib/awspec/helper/finder/wafregional.rb +53 -0
- data/lib/awspec/helper/type.rb +3 -3
- data/lib/awspec/matcher/have_rule.rb +1 -0
- data/lib/awspec/stub/wafregional_web_acl.rb +62 -0
- data/lib/awspec/type/wafregional_web_acl.rb +24 -0
- data/lib/awspec/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a3421504dfb769b8367414a61de64c4ff31bf23
|
4
|
+
data.tar.gz: bf6e0a3d1e1650497b3fc023d38e74b68cad19db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c780579a44dbdfeefeac6b30f63240023afee5487d92cb3f22c2ebc27b9e742e9585c10280bf90413f333cf6f83609d72c7e8bd43d0c7da2ccec3d6aaf44c40f
|
7
|
+
data.tar.gz: 3d7a2b8b2ee72b3819ac838806ef454e1151aa88150a1d445211b9dabfd8f80b1c2583b054ff803f81a1ad8b8aca5fb0c983eb285d1b16f3442a2ea7465e80ea
|
@@ -0,0 +1,29 @@
|
|
1
|
+
### exist
|
2
|
+
|
3
|
+
```ruby
|
4
|
+
describe wafregional_web_acl('my-wafregional-web-acl') do
|
5
|
+
it { should exist }
|
6
|
+
its(:default_action) { should eq 'BLOCK' }
|
7
|
+
it { should have_rule('my-wafregional-web-acl-allowed-ips') }
|
8
|
+
it { should have_rule('my-wafregional-web-acl-allowed-ips').order(2).action('BLOCK') }
|
9
|
+
end
|
10
|
+
```
|
11
|
+
|
12
|
+
### have_rule
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
describe wafregional_web_acl('my-wafregional-web-acl') do
|
16
|
+
it { should have_rule('my-wafregional-web-acl-allowed-ips') }
|
17
|
+
it { should have_rule('my-wafregional-web-acl-allowed-ips').order(2).action('BLOCK') }
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
### its(:default_action), its(:web_acl_id), its(:name), its(:metric_name)
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
describe wafregional_web_acl('my-wafregional-web-acl') do
|
25
|
+
its(:default_action) { should eq 'BLOCK' }
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
|
data/doc/resource_types.md
CHANGED
@@ -74,6 +74,7 @@
|
|
74
74
|
| [vpn_connection](#vpn_connection)
|
75
75
|
| [vpn_gateway](#vpn_gateway)
|
76
76
|
| [waf_web_acl](#waf_web_acl)
|
77
|
+
| [wafregional_web_acl](#wafregional_web_acl)
|
77
78
|
| [account](#account)
|
78
79
|
|
79
80
|
## <a name="acm">acm</a>
|
@@ -1216,7 +1217,7 @@ describe ecs_task_definition('my-ecs-task-definition') do
|
|
1216
1217
|
end
|
1217
1218
|
```
|
1218
1219
|
|
1219
|
-
### its(:task_definition_arn), its(:family), its(:task_role_arn), its(:execution_role_arn), its(:network_mode), its(:revision), its(:volumes), its(:status), its(:requires_attributes), its(:placement_constraints), its(:compatibilities), its(:requires_compatibilities), its(:cpu), its(:memory), its(:pid_mode), its(:ipc_mode)
|
1220
|
+
### its(:task_definition_arn), its(:family), its(:task_role_arn), its(:execution_role_arn), its(:network_mode), its(:revision), its(:volumes), its(:status), its(:requires_attributes), its(:placement_constraints), its(:compatibilities), its(:requires_compatibilities), its(:cpu), its(:memory), its(:pid_mode), its(:ipc_mode), its(:proxy_configuration)
|
1220
1221
|
## <a name="efs">efs</a>
|
1221
1222
|
|
1222
1223
|
EFS resource type.
|
@@ -3583,6 +3584,33 @@ end
|
|
3583
3584
|
```
|
3584
3585
|
|
3585
3586
|
|
3587
|
+
### its(:default_action), its(:web_acl_id), its(:name), its(:metric_name), its(:web_acl_arn)
|
3588
|
+
## <a name="wafregional_web_acl">wafregional_web_acl</a>
|
3589
|
+
|
3590
|
+
WafregionalWebAcl resource type.
|
3591
|
+
|
3592
|
+
### exist
|
3593
|
+
|
3594
|
+
```ruby
|
3595
|
+
describe wafregional_web_acl('my-wafregional-web-acl') do
|
3596
|
+
it { should exist }
|
3597
|
+
its(:default_action) { should eq 'BLOCK' }
|
3598
|
+
it { should have_rule('my-wafregional-web-acl-allowed-ips') }
|
3599
|
+
it { should have_rule('my-wafregional-web-acl-allowed-ips').order(2).action('BLOCK') }
|
3600
|
+
end
|
3601
|
+
```
|
3602
|
+
|
3603
|
+
|
3604
|
+
### have_rule
|
3605
|
+
|
3606
|
+
```ruby
|
3607
|
+
describe wafregional_web_acl('my-wafregional-web-acl') do
|
3608
|
+
it { should have_rule('my-wafregional-web-acl-allowed-ips') }
|
3609
|
+
it { should have_rule('my-wafregional-web-acl-allowed-ips').order(2).action('BLOCK') }
|
3610
|
+
end
|
3611
|
+
```
|
3612
|
+
|
3613
|
+
|
3586
3614
|
### its(:default_action), its(:web_acl_id), its(:name), its(:metric_name), its(:web_acl_arn)
|
3587
3615
|
# Account and Attributes
|
3588
3616
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class WafregionalWebAcl < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'WafregionalWebAcl'
|
8
|
+
@type = Awspec::Type::WafregionalWebAcl.new('my-wafregional-web-acl')
|
9
|
+
@ret = @type.resource_via_client
|
10
|
+
@matchers = []
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = %w(default_action)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/awspec/helper/finder.rb
CHANGED
@@ -29,6 +29,7 @@ require 'awspec/helper/finder/cloudfront'
|
|
29
29
|
require 'awspec/helper/finder/elastictranscoder'
|
30
30
|
require 'awspec/helper/finder/cloudtrail'
|
31
31
|
require 'awspec/helper/finder/waf'
|
32
|
+
require 'awspec/helper/finder/wafregional'
|
32
33
|
require 'awspec/helper/finder/acm'
|
33
34
|
require 'awspec/helper/finder/cloudwatch_logs'
|
34
35
|
require 'awspec/helper/finder/dynamodb'
|
@@ -82,6 +83,7 @@ module Awspec::Helper
|
|
82
83
|
include Awspec::Helper::Finder::Elastictranscoder
|
83
84
|
include Awspec::Helper::Finder::Cloudtrail
|
84
85
|
include Awspec::Helper::Finder::Waf
|
86
|
+
include Awspec::Helper::Finder::WafRegional
|
85
87
|
include Awspec::Helper::Finder::Acm
|
86
88
|
include Awspec::Helper::Finder::AccountAttributes
|
87
89
|
include Awspec::Helper::Finder::CloudwatchLogs
|
@@ -125,6 +127,7 @@ module Awspec::Helper
|
|
125
127
|
elasticsearch_client: Aws::ElasticsearchService::Client,
|
126
128
|
cloudtrail_client: Aws::CloudTrail::Client,
|
127
129
|
waf_client: Aws::WAF::Client,
|
130
|
+
wafregional_client: Aws::WAFRegional::Client,
|
128
131
|
sts_client: Aws::STS::Client,
|
129
132
|
acm_client: Aws::ACM::Client,
|
130
133
|
cloudwatch_logs_client: Aws::CloudWatchLogs::Client,
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Awspec::Helper
|
2
|
+
module Finder
|
3
|
+
module WafRegional
|
4
|
+
def find_wafregional_web_acl(id)
|
5
|
+
finded = nil
|
6
|
+
next_marker = nil
|
7
|
+
|
8
|
+
loop do
|
9
|
+
res = wafregional_client.list_web_acls(next_marker: next_marker, limit: 100)
|
10
|
+
finded = res.web_acls.find do |acl|
|
11
|
+
acl.web_acl_id == id || acl.name == id
|
12
|
+
end
|
13
|
+
(finded.nil? && next_marker = res.next_marker) || break
|
14
|
+
end
|
15
|
+
|
16
|
+
return nil unless finded
|
17
|
+
wafregional_client.get_web_acl(web_acl_id: finded.web_acl_id).web_acl
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_wafregional_rule(id)
|
21
|
+
finded = nil
|
22
|
+
next_marker = nil
|
23
|
+
|
24
|
+
loop do
|
25
|
+
res = wafregional_client.list_rules(next_marker: next_marker, limit: 1)
|
26
|
+
finded = res.rules.find do |rule|
|
27
|
+
rule.rule_id == id || rule.name == id
|
28
|
+
end
|
29
|
+
(finded.nil? && next_marker = res.next_marker) || break
|
30
|
+
end
|
31
|
+
|
32
|
+
return nil unless finded
|
33
|
+
wafregional_client.get_rule(rule_id: finded.rule_id).rule
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_wafregional_ip_set(id)
|
37
|
+
finded = nil
|
38
|
+
next_marker = nil
|
39
|
+
|
40
|
+
loop do
|
41
|
+
res = wafregional_client.list_ip_sets(next_marker: next_marker, limit: 1)
|
42
|
+
finded = res.ip_sets.find do |set|
|
43
|
+
set.ip_set_id == id || set.name == id
|
44
|
+
end
|
45
|
+
(finded.nil? && next_marker = res.next_marker) || break
|
46
|
+
end
|
47
|
+
|
48
|
+
return nil unless finded
|
49
|
+
wafregional_client.get_ip_set(ip_set_id: finded.ip_set_id).ip_set
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/awspec/helper/type.rb
CHANGED
@@ -17,9 +17,9 @@ module Awspec
|
|
17
17
|
network_acl network_interface nlb nlb_listener nlb_target_group
|
18
18
|
rds rds_db_cluster_parameter_group rds_db_parameter_group route53_hosted_zone
|
19
19
|
route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
|
20
|
-
elastictranscoder_pipeline waf_web_acl customer_gateway vpn_gateway vpn_connection
|
21
|
-
cloudwatch_logs dynamodb_table eip sqs ssm_parameter cloudformation_stack
|
22
|
-
redshift_cluster_parameter_group codedeploy codedeploy_deployment_group
|
20
|
+
elastictranscoder_pipeline waf_web_acl wafregional_web_acl customer_gateway vpn_gateway vpn_connection
|
21
|
+
internet_gateway acm cloudwatch_logs dynamodb_table eip sqs ssm_parameter cloudformation_stack
|
22
|
+
codebuild sns_topic redshift redshift_cluster_parameter_group codedeploy codedeploy_deployment_group
|
23
23
|
)
|
24
24
|
|
25
25
|
ACCOUNT_ATTRIBUTES = %w(
|
@@ -1,6 +1,7 @@
|
|
1
1
|
RSpec::Matchers.define :have_rule do |rule_id|
|
2
2
|
match do |type|
|
3
3
|
return type.has_rule?(rule_id, @priority, @action) if type.instance_of?(Awspec::Type::WafWebAcl)
|
4
|
+
return type.has_rule?(rule_id, @priority, @action) if type.instance_of?(Awspec::Type::WafregionalWebAcl)
|
4
5
|
return type.has_rule?(rule_id, @priority, @conditions, @actions) if type.instance_of?(Awspec::Type::AlbListener)
|
5
6
|
type.has_rule?(rule_id, @priority, @conditions, @actions) if type.instance_of?(Awspec::Type::NlbListener)
|
6
7
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Aws.config[:wafregional] = {
|
2
|
+
stub_responses: {
|
3
|
+
list_web_acls: {
|
4
|
+
next_marker: nil,
|
5
|
+
web_acls: [
|
6
|
+
{
|
7
|
+
web_acl_id: '1234567-abcd-1234-efgh-5678-1234567890',
|
8
|
+
name: 'my-wafregional-web-acl'
|
9
|
+
}
|
10
|
+
]
|
11
|
+
},
|
12
|
+
get_web_acl: {
|
13
|
+
web_acl: {
|
14
|
+
web_acl_id: '1234567-abcd-1234-efgh-5678-1234567890',
|
15
|
+
name: 'my-wafregional-web-acl',
|
16
|
+
metric_name: 'mywafregionalwebacl',
|
17
|
+
default_action: {
|
18
|
+
type: 'BLOCK'
|
19
|
+
},
|
20
|
+
rules: [
|
21
|
+
{
|
22
|
+
priority: 1,
|
23
|
+
rule_id: 'aaaaaaaa-0000-5555-3333-eeeeeeeeeeee',
|
24
|
+
action: {
|
25
|
+
type: 'ALLOW'
|
26
|
+
}
|
27
|
+
},
|
28
|
+
{
|
29
|
+
priority: 2,
|
30
|
+
rule_id: 'dddddddd-1111-2222-3333-eeeeeeeeeeee',
|
31
|
+
action: {
|
32
|
+
type: 'BLOCK'
|
33
|
+
}
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}
|
37
|
+
},
|
38
|
+
list_rules: {
|
39
|
+
next_marker: nil,
|
40
|
+
rules: [
|
41
|
+
{
|
42
|
+
rule_id: 'dddddddd-1111-2222-3333-eeeeeeeeeeee',
|
43
|
+
name: 'my-wafregional-web-acl-allowed-ips'
|
44
|
+
}
|
45
|
+
]
|
46
|
+
},
|
47
|
+
get_rule: {
|
48
|
+
rule: {
|
49
|
+
rule_id: 'dddddddd-1111-2222-3333-eeeeeeeeeeee',
|
50
|
+
name: 'my-wafregional-web-acl-allowed-ips',
|
51
|
+
metric_name: 'mywafregionalwebaclallowedips',
|
52
|
+
predicates: [
|
53
|
+
{
|
54
|
+
negated: false,
|
55
|
+
type: 'IPMatch',
|
56
|
+
data_id: '22aa22bb-3333-aaaa-8888-bbbbbbbbbbbb'
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class WafregionalWebAcl < ResourceBase
|
3
|
+
def resource_via_client
|
4
|
+
@resource_via_client ||= find_wafregional_web_acl(@display_name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@id ||= resource_via_client.web_acl_id if resource_via_client
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_action
|
12
|
+
resource_via_client.default_action.type
|
13
|
+
end
|
14
|
+
|
15
|
+
def has_rule?(rule_id, priority = nil, action = nil)
|
16
|
+
resource_via_client.rules.find do |rule|
|
17
|
+
next false if !priority.nil? && rule.priority != priority
|
18
|
+
next false if !action.nil? && rule.action.type != action
|
19
|
+
next true if rule.rule_id == rule_id
|
20
|
+
find_wafregional_rule(rule_id).name == rule_id
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -296,6 +296,7 @@ files:
|
|
296
296
|
- doc/_resource_types/vpn_connection.md
|
297
297
|
- doc/_resource_types/vpn_gateway.md
|
298
298
|
- doc/_resource_types/waf_web_acl.md
|
299
|
+
- doc/_resource_types/wafregional_web_acl.md
|
299
300
|
- doc/contributing.md
|
300
301
|
- doc/resource_types.md
|
301
302
|
- exe/awspec
|
@@ -392,6 +393,7 @@ files:
|
|
392
393
|
- lib/awspec/generator/doc/type/vpn_connection.rb
|
393
394
|
- lib/awspec/generator/doc/type/vpn_gateway.rb
|
394
395
|
- lib/awspec/generator/doc/type/waf_web_acl.rb
|
396
|
+
- lib/awspec/generator/doc/type/wafregional_web_acl.rb
|
395
397
|
- lib/awspec/generator/spec/acm.rb
|
396
398
|
- lib/awspec/generator/spec/alb.rb
|
397
399
|
- lib/awspec/generator/spec/alb_listener.rb
|
@@ -482,6 +484,7 @@ files:
|
|
482
484
|
- lib/awspec/helper/finder/subnet.rb
|
483
485
|
- lib/awspec/helper/finder/vpc.rb
|
484
486
|
- lib/awspec/helper/finder/waf.rb
|
487
|
+
- lib/awspec/helper/finder/wafregional.rb
|
485
488
|
- lib/awspec/helper/type.rb
|
486
489
|
- lib/awspec/matcher.rb
|
487
490
|
- lib/awspec/matcher/be_allowed.rb
|
@@ -606,6 +609,7 @@ files:
|
|
606
609
|
- lib/awspec/stub/vpn_connection.rb
|
607
610
|
- lib/awspec/stub/vpn_gateway.rb
|
608
611
|
- lib/awspec/stub/waf_web_acl.rb
|
612
|
+
- lib/awspec/stub/wafregional_web_acl.rb
|
609
613
|
- lib/awspec/toolbox.rb
|
610
614
|
- lib/awspec/type/account.rb
|
611
615
|
- lib/awspec/type/account_attribute.rb
|
@@ -690,6 +694,7 @@ files:
|
|
690
694
|
- lib/awspec/type/vpn_connection.rb
|
691
695
|
- lib/awspec/type/vpn_gateway.rb
|
692
696
|
- lib/awspec/type/waf_web_acl.rb
|
697
|
+
- lib/awspec/type/wafregional_web_acl.rb
|
693
698
|
- lib/awspec/version.rb
|
694
699
|
homepage: https://github.com/k1LoW/awspec
|
695
700
|
licenses:
|
@@ -711,7 +716,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
711
716
|
version: '0'
|
712
717
|
requirements: []
|
713
718
|
rubyforge_project:
|
714
|
-
rubygems_version: 2.6.14
|
719
|
+
rubygems_version: 2.6.14.1
|
715
720
|
signing_key:
|
716
721
|
specification_version: 4
|
717
722
|
summary: RSpec tests for your AWS resources.
|