-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inspec resource folder #1460
Merged
Merged
Inspec resource folder #1460
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
574d407
WIP, mostly working, need fix on escaping / and handling 403 from fol…
slevenick 758d93e
Remove not found test, returns 403 for folders
slevenick 8950b41
Exclude ansible for folder
slevenick 8486226
Add override for product URL for InSpec to allow for resourcemanager …
slevenick fcf282c
Add support for privileged resources. This allows lack of a flag to s…
slevenick 5a0cad3
Exclude folder from terraform
slevenick 0c7be9a
Include folders/ in folder name, matches docs better
slevenick 4c805f3
Spacing in terraform.yaml
slevenick bc59c5c
Add comments about privileged resources
slevenick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -22,6 +22,8 @@ def self.attributes | |
%i[ | ||
manual | ||
additional_functions | ||
product_url | ||
privileged | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment for what priviledged means? The rest seem self-explanatory. |
||
] | ||
end | ||
|
||
|
@@ -31,6 +33,10 @@ def validate | |
check :manual, type: :boolean, default: false | ||
super | ||
check :additional_functions, type: String | ||
check :product_url, type: String | ||
# true if the resources requires organization level privileges | ||
# resource manager Folder is an example of a privileged resource | ||
check :privileged, type: :boolean, default: false | ||
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,30 @@ | ||
# Copyright 2017 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 | ||
manifest: !ruby/object:Provider::Inspec::Manifest | ||
summary: 'InSpec resources for verifying GCP infrastructure' | ||
description: | | ||
InSpec resources for verifying GCP infrastructure | ||
overrides: !ruby/object:Overrides::ResourceOverrides | ||
Lien: !ruby/object:Overrides::Inspec::ResourceOverride | ||
exclude: true | ||
Project: !ruby/object:Overrides::Inspec::ResourceOverride | ||
exclude: true | ||
Folder: !ruby/object:Overrides::Inspec::ResourceOverride | ||
product_url: https://cloudresourcemanager.googleapis.com/v2/ | ||
# Creating and viewing folders requires organization level privileges | ||
privileged: true | ||
files: !ruby/object:Provider::Config::Files | ||
copy: | ||
'Gemfile': 'provider/inspec/Gemfile' |
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
9 changes: 9 additions & 0 deletions
9
templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folder.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,9 @@ | ||
<% folder = grab_attributes['folder'] -%> | ||
describe.one do | ||
google_resourcemanager_folders(parent: <%= doc_generation ? "'organizations/12345'" : "\"organizations/\#{gcp_organization_id}\"" -%>).names.each do |name| | ||
describe google_resourcemanager_folder(name: name) do | ||
it { should exist } | ||
its('display_name') { should eq <%= doc_generation ? "'#{folder['display_name']}'" : "folder['display_name']" -%> } | ||
end | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
...nspec/examples/google_resourcemanager_folder/google_resourcemanager_folder_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,3 @@ | ||
folder = attribute('folder', default: <%= grab_attributes['folder'] -%>) | ||
gcp_organization_id = attribute(:gcp_organization_id, default: <%= external_attribute('gcp_organization_id') -%>, description: 'The identifier of the organization that is the parent of this folder') | ||
gcp_enable_privileged_resources = attribute(:gcp_enable_privileged_resources, default:0, description:'Flag to enable privileged resources requiring elevated privileges in GCP.') |
8 changes: 8 additions & 0 deletions
8
templates/inspec/examples/google_resourcemanager_folder/google_resourcemanager_folders.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 @@ | ||
<% folder = grab_attributes['folder'] -%> | ||
describe.one do | ||
google_resourcemanager_folders(parent: <%= doc_generation ? "'organizations/12345'" : "\"organizations/\#{gcp_organization_id}\"" -%>).display_names.each do |display_name| | ||
describe display_name do | ||
it { should eq <%= doc_generation ? "'#{folder['display_name']}'" : "folder['display_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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have a way of overriding the collection_url already?
(Might've imagined that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the collection_url, it's the base
googleapis/v1/
so that I can use a v2 API for some resources without changing the other resources (they aren't on v2)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.