-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
150 additions
and
8 deletions.
There are no files selected for viewing
Submodule ansible
updated
from d18229 to 344b0d
Submodule inspec
updated
33 files
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,47 @@ | ||
# Copyright 2020 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- !ruby/object:Provider::Inspec::Config | ||
overrides: !ruby/object:Overrides::ResourceOverrides | ||
KeyRing: !ruby/object:Overrides::Inspec::ResourceOverride | ||
privileged: true | ||
additional_functions: third_party/inspec/custom_functions/kms_key_ring.erb | ||
plural_custom_logic: third_party/inspec/custom_functions/kms_key_ring_name.erb | ||
properties: | ||
name: !ruby/object:Overrides::Inspec::PropertyOverride | ||
# This is added back via custom methods | ||
exclude: true | ||
keyRingUrl: !ruby/object:Overrides::Inspec::PropertyOverride | ||
# Allows us to use the `name` field as the full URL | ||
exclude: false | ||
api_name: name | ||
iam_policy: !ruby/object:Api::Resource::IamPolicy | ||
base_url: 'projects/{{project}}/locations/{{location}}/keyRings/{{key_ring_name}}' | ||
exclude: false | ||
method_name_separator: ':' | ||
CryptoKey: !ruby/object:Overrides::Inspec::ResourceOverride | ||
base_url: 'projects/{{project}}/locations/{{location}}/keyRings/{{key_ring_name}}/cryptoKeys' | ||
self_link: 'projects/{{project}}/locations/{{location}}/keyRings/{{key_ring_name}}/cryptoKeys/{{name}}' | ||
privileged: true | ||
additional_functions: third_party/inspec/custom_functions/kms_crypto_key.erb | ||
properties: | ||
name: !ruby/object:Overrides::Inspec::PropertyOverride | ||
name: cryptoKeyName | ||
api_name: name | ||
name_from_self_link: true | ||
iam_policy: !ruby/object:Api::Resource::IamPolicy | ||
base_url: 'projects/{{project}}/locations/{{location}}/keyRings/{{key_ring_name}}/cryptoKeys/{{crypto_key_name}}' | ||
exclude: false | ||
method_name_separator: ':' | ||
SecretCiphertext: !ruby/object:Overrides::Inspec::ResourceOverride | ||
exclude: 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
16 changes: 16 additions & 0 deletions
16
templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key.erb
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,16 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> | ||
<% gcp_kms_key_ring_policy_name = "#{external_attribute('gcp_kms_key_ring_policy_name', doc_generation)}" -%> | ||
<% gcp_kms_crypto_key_name_policy = "#{external_attribute('gcp_kms_crypto_key_name_policy', doc_generation)}" -%> | ||
describe google_kms_crypto_key(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, key_ring_name: <%= gcp_kms_key_ring_policy_name -%>, name: <%= gcp_kms_crypto_key_name_policy -%>) do | ||
it { should exist } | ||
its('crypto_key_name') { should cmp <%= gcp_kms_crypto_key_name_policy -%> } | ||
its('primary_state') { should eq "ENABLED" } | ||
its('purpose') { should eq "ENCRYPT_DECRYPT" } | ||
its('next_rotation_time') { should be > Time.now - 100000 } | ||
its('create_time') { should be > Time.now - 365*60*60*24*10 } | ||
end | ||
|
||
describe google_kms_crypto_key(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, key_ring_name: <%= gcp_kms_key_ring_policy_name -%>, name: "nonexistent") do | ||
it { should_not exist } | ||
end |
5 changes: 5 additions & 0 deletions
5
templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_key_attributes.erb
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,5 @@ | ||
gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') | ||
gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'GCP location') | ||
gcp_kms_key_ring_policy_name = attribute(:gcp_kms_key_ring_policy_name, default: '<%= external_attribute('gcp_kms_key_ring_policy_name') -%>', description: 'Key ring name') | ||
gcp_kms_crypto_key_name_policy = attribute(:gcp_kms_crypto_key_name_policy, default: '<%= external_attribute('gcp_kms_crypto_key_name_policy') -%>', description: 'Key name') | ||
gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute('gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') |
8 changes: 8 additions & 0 deletions
8
templates/inspec/examples/google_kms_crypto_key/google_kms_crypto_keys.erb
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,8 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> | ||
<% gcp_kms_key_ring_policy_name = "#{external_attribute('gcp_kms_key_ring_policy_name', doc_generation)}" -%> | ||
<% gcp_kms_crypto_key_name_policy = "#{external_attribute('gcp_kms_crypto_key_name_policy', doc_generation)}" -%> | ||
describe google_kms_crypto_keys(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, key_ring_name: <%= gcp_kms_key_ring_policy_name -%>) do | ||
its('count') { should be >= 1 } | ||
its('crypto_key_names') { should include <%= gcp_kms_crypto_key_name_policy -%> } | ||
end |
13 changes: 13 additions & 0 deletions
13
templates/inspec/examples/google_kms_key_ring/google_kms_key_ring.erb
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,13 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> | ||
<% gcp_kms_key_ring_policy_name = "#{external_attribute('gcp_kms_key_ring_policy_name', doc_generation)}" -%> | ||
describe google_kms_key_ring(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, name: <%= gcp_kms_key_ring_policy_name -%>) do | ||
it { should exist } | ||
its('create_time') { should be > Time.now - 365*60*60*24*10 } | ||
its('key_ring_name'){ should eq <%= gcp_kms_key_ring_policy_name -%> } | ||
its('key_ring_url'){ should match <%= gcp_kms_key_ring_policy_name -%> } | ||
end | ||
|
||
describe google_kms_key_ring(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>, name: "nonexistent") do | ||
it { should_not exist } | ||
end |
4 changes: 4 additions & 0 deletions
4
templates/inspec/examples/google_kms_key_ring/google_kms_key_ring_attributes.erb
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,4 @@ | ||
gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') | ||
gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'GCP location') | ||
gcp_kms_key_ring_policy_name = attribute(:gcp_kms_key_ring_policy_name, default: '<%= external_attribute('gcp_kms_key_ring_policy_name') -%>', description: 'Key ring name') | ||
gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default: '<%= external_attribute('gcp_enable_privileged_resources') -%>', description: 'If we are running tests with escalated permissions(required for this test)') |
14 changes: 14 additions & 0 deletions
14
templates/inspec/examples/google_kms_key_ring/google_kms_key_rings.erb
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,14 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> | ||
<% gcp_kms_key_ring_policy_name = "#{external_attribute('gcp_kms_key_ring_policy_name', doc_generation)}" -%> | ||
describe google_kms_key_rings(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>) do | ||
its('key_ring_names'){ should include <%= gcp_kms_key_ring_policy_name -%> } | ||
end | ||
|
||
describe.one do | ||
google_kms_key_rings(project: <%= gcp_project_id -%>, location: <%= gcp_location -%>).key_ring_urls do |url| | ||
describe url do | ||
it { should match <%= gcp_kms_key_ring_policy_name -%> } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def primary_state | ||
@fetched['primary']['state'] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def key_ring_name | ||
name_from_self_link(@key_ring_url) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hash_with_symbols[:key_ring_name] = name_from_self_link(hash['name']) |