Skip to content
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

Add Resource Organization, folder and project Mute Config #10772

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ab2df03
securitycenterv2 changes
thokalavinod May 19, 2024
7b4dda8
V2 changes
thokalavinod May 22, 2024
abf1168
fix the build issues
thokalavinod May 24, 2024
4526193
Addressed the review comments
thokalavinod May 25, 2024
778ec3e
changes based on comments
thokalavinod May 28, 2024
4f649a1
changed default value
thokalavinod May 29, 2024
ad1a7fc
Changes on yaml files
thokalavinod May 29, 2024
001fec7
code changes based on PR errors
thokalavinod May 29, 2024
a85efb1
PR comments addressed
thokalavinod May 29, 2024
b9a9ff5
fixed the issues in test cases
thokalavinod May 30, 2024
78a719a
Services added
thokalavinod May 30, 2024
7607454
name changed on product file
thokalavinod May 30, 2024
90e178b
fixed a test case
thokalavinod May 31, 2024
db9de8e
Comments addressed
thokalavinod May 31, 2024
d6cfd8d
fixed the errors
thokalavinod May 31, 2024
cc229c5
name changes
thokalavinod May 31, 2024
8f8f3ff
address the issues
thokalavinod Jun 1, 2024
6af7992
yaml changes
thokalavinod Jun 3, 2024
fb3efad
yaml file errors fixed
thokalavinod Jun 3, 2024
bdae90e
lint check fixed
thokalavinod Jun 3, 2024
5bf5760
test files fixed
thokalavinod Jun 3, 2024
fd5657d
added import file
thokalavinod Jun 3, 2024
f17aa1f
transport file added
thokalavinod Jun 3, 2024
4eb984a
made changes in import files
thokalavinod Jun 3, 2024
9aa1f3f
test cases errors fixed
thokalavinod Jun 4, 2024
bbfb1d0
removed unwanted import files
thokalavinod Jun 4, 2024
4010782
lint changes
thokalavinod Jun 5, 2024
4a26a96
test files import
thokalavinod Jun 5, 2024
6a37681
Added destroy function
thokalavinod Jun 5, 2024
2c3127a
added transport import file
thokalavinod Jun 5, 2024
9573d9a
unit test errors fixed
thokalavinod Jun 5, 2024
e5542ef
removed unused imports
thokalavinod Jun 5, 2024
32c7ee9
added changes required
thokalavinod Jun 5, 2024
320b0ca
changes in examples
thokalavinod Jun 6, 2024
d90ecaf
added resource folder
thokalavinod Jun 6, 2024
dc0f536
added resource folder
thokalavinod Jun 7, 2024
d1ad972
added enum type
thokalavinod Jun 7, 2024
790fe46
changes in naming
thokalavinod Jun 7, 2024
3eae539
lint errors fixed
thokalavinod Jun 7, 2024
701cca0
fixed the test erros
thokalavinod Jun 7, 2024
842293f
comments addressed
thokalavinod Jun 10, 2024
3a56a16
errors logs fixed
thokalavinod Jun 11, 2024
0cd1e3e
addressed comment
thokalavinod Jun 11, 2024
66066df
changes in examples
thokalavinod Jun 11, 2024
454aa91
removed the error
thokalavinod Jun 11, 2024
11a5846
lint changes fixed
thokalavinod Jun 11, 2024
46428c0
lint changes fixed
thokalavinod Jun 11, 2024
5f7bb8b
resolved basic example errors
thokalavinod Jun 11, 2024
31d1346
fixed build and lint errors
thokalavinod Jun 12, 2024
f9690f3
addressed the cooment
thokalavinod Jun 12, 2024
4bee56e
Lint changes
thokalavinod Jun 12, 2024
cdfaf05
addressed the comments
thokalavinod Jun 12, 2024
1223fdd
lint check errors
thokalavinod Jun 13, 2024
6e51a34
modifications in test and example files
thokalavinod Jun 13, 2024
2ea48eb
lint check errors
thokalavinod Jun 13, 2024
af1d43e
changes in yaml files
thokalavinod Jun 14, 2024
d551817
changed the parent name
thokalavinod Jun 14, 2024
b580677
comments addressed
thokalavinod Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
106 changes: 106 additions & 0 deletions mmv1/products/securitycenterv2/FolderMuteConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright 2024 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:Api::Resource
name: 'FolderMuteConfig'
base_url: '{{parent}}/foldermuteConfigs'
self_link: '{{name}}'
create_url: '{{parent}}/foldermuteConfigs?foldermuteConfigId={{folder_mute_config_id}}'
thokalavinod marked this conversation as resolved.
Show resolved Hide resolved
update_verb: :PATCH
update_mask: true
description: |
Mute Findings is a volume management feature in Security Command Center
that lets you manually or programmatically hide irrelevant findings,
and create filters to automatically silence existing and future
findings based on criteria you specify.
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/security-command-center/docs/reference/rest/v2/folders.locations.muteConfigs'
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'scc_v2_folder_mute_config_basic'
primary_resource_id: 'default'
vars:
folder_mute_config_id: 'my-config'
test_env_vars:
org_id: :ORG_ID
# Skipping sweeper since this is a child resource
skip_sweeper: true
import_format: ['{{name}}']
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_import: templates/terraform/custom_import/scc_mute_config.go.erb
parameters:
- !ruby/object:Api::Type::String
name: foldermuteConfigId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this parameter and use name instead in the create url.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, after looking at how the v1 version of this resource is implemented, this parameter should be kept and renamed to muteConfigId. The three different resources should also be combined into one resource.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

required: true
immutable: true
url_param_only: true
description: |
Unique identifier provided by the client within the parent scope.
- !ruby/object:Api::Type::String
name: location
required: false
immutable: true
url_param_only: true
default_value: global
description: |
location Id is provided by organization. If not provided, Use global as default.
- !ruby/object:Api::Type::String
name: parent
required: true
immutable: true
url_param_only: true
description: |
Resource name of the new mute configs's parent. Its format is
"organizations/[organization_id]", "folders/[folder_id]", or
"projects/[project_id]".
properties:
- !ruby/object:Api::Type::String
name: 'name'
output: true
description: |
Name of the mute config. Its format is
organizations/{organization}/muteConfigs/{configId},
folders/{folder}/muteConfigs/{configId},
or projects/{project}/muteConfigs/{configId}
- !ruby/object:Api::Type::String
name: 'description'
description: A description of the mute config.
- !ruby/object:Api::Type::String
name: 'filter'
description: |
An expression that defines the filter to apply across create/update
events of findings. While creating a filter string, be mindful of
the scope in which the mute configuration is being created. E.g.,
If a filter contains project = X but is created under the
project = Y scope, it might not match any findings.
required: true
- !ruby/object:Api::Type::String
name: 'createTime'
description: |
The time at which the mute config was created. This field is set by
the server and will be ignored if provided on config creation.
output: true
- !ruby/object:Api::Type::String
name: 'updateTime'
description: |
Output only. The most recent time at which the mute config was
updated. This field is set by the server and will be ignored if
provided on config creation or update.
output: true
- !ruby/object:Api::Type::String
name: 'mostRecentEditor'
description: |
Email address of the user who last edited the mute config. This
field is set by the server and will be ignored if provided on
config creation or update.
output: true
103 changes: 103 additions & 0 deletions mmv1/products/securitycenterv2/OrganizationMuteConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Copyright 2024 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:Api::Resource
name: 'OrganizationMuteConfig'
base_url: '{{parent}}/organizationmuteConfigs'
self_link: '{{name}}'
create_url: '{{parent}}/organizationmuteConfigs?organizationmuteConfigId={{organization_mute_Configs_id}}'
update_verb: :PATCH
update_mask: true
description: |
Mute Findings is a volume management feature in Security Command Center
that lets you manually or programmatically hide irrelevant findings,
and create filters to automatically silence existing and future
findings based on criteria you specify.
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/security-command-center/docs/reference/rest/v2/organizations.locations.muteConfigs'
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'scc_v2_organization_mute_config_basic'
primary_resource_id: 'default'
vars:
organization_mute_config_id: 'my-config'
test_env_vars:
org_id: :ORG_ID
# Skipping sweeper since this is a child resource
skip_sweeper: true
import_format: ['{{name}}']
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_import: templates/terraform/custom_import/scc_mute_config.go.erb
parameters:
- !ruby/object:Api::Type::String
name: organizationmuteConfigId
required: true
immutable: true
url_param_only: true
description: |
Unique identifier provided by the client within the parent scope.
- !ruby/object:Api::Type::String
name: parent
required: true
immutable: true
url_param_only: true
description: |
Resource name of the new organization mute configs's parent. Its format is
"organizations/[organization_id]"
- !ruby/object:Api::Type::String
name: location
required: false
immutable: true
url_param_only: true
default_value: global
description: |
location Id is provided by organization. If not provided, Use global as default.
properties:
- !ruby/object:Api::Type::String
name: 'name'
output: true
description: |
Name of the Organization mute config. Its format is
organizations/{organization}/OrgmuteConfigs/{configId},
- !ruby/object:Api::Type::String
name: 'description'
description: A description of the Organization mute config.
- !ruby/object:Api::Type::String
name: 'filter'
description: |
An expression that defines the filter to apply across create/update
events of findings. While creating a filter string, be mindful of
the scope in which the mute configuration is being created. E.g.,
If a filter contains project = X but is created under the
project = Y scope, it might not match any findings.
required: true
- !ruby/object:Api::Type::String
name: 'createTime'
description: |
The time at which the mute config was created. This field is set by
the server and will be ignored if provided on config creation.
output: true
- !ruby/object:Api::Type::String
name: 'updateTime'
description: |
Output only. The most recent time at which the mute config was
updated. This field is set by the server and will be ignored if
provided on config creation or update.
output: true
- !ruby/object:Api::Type::String
name: 'mostRecentEditor'
description: |
Email address of the user who last edited the mute config. This
field is set by the server and will be ignored if provided on
config creation or update.
output: true
106 changes: 106 additions & 0 deletions mmv1/products/securitycenterv2/ProjectMuteConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright 2024 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:Api::Resource
name: 'projectMuteConfig'
base_url: '{{parent}}/projectmuteConfigs'
self_link: '{{name}}'
create_url: '{{parent}}/projectmuteConfigs?projectmuteConfigId={{project_mute_config_id}}'
update_verb: :PATCH
update_mask: true
description: |
Mute Findings is a volume management feature in Security Command Center
that lets you manually or programmatically hide irrelevant findings,
and create filters to automatically silence existing and future
findings based on criteria you specify.
references: !ruby/object:Api::Resource::ReferenceLinks
api: 'https://cloud.google.com/security-command-center/docs/reference/rest/v2/projects.locations.muteConfigs'
examples:
- !ruby/object:Provider::Terraform::Examples
name: 'scc_v2_project_mute_config_basic'
primary_resource_id: 'default'
vars:
project_mute_config_id: 'my-config'
test_env_vars:
org_id: :ORG_ID
# Skipping sweeper since this is a child resource
skip_sweeper: true
import_format: ['{{name}}']
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_import: templates/terraform/custom_import/scc_mute_config.go.erb
parameters:
- !ruby/object:Api::Type::String
name: projectmuteConfigId
required: true
immutable: true
url_param_only: true
description: |
Unique identifier provided by the client within the parent scope.
- !ruby/object:Api::Type::String
name: location
required: false
immutable: true
url_param_only: true
default_value: global
description: |
location Id is provided by organization. If not provided, Use global as default.
- !ruby/object:Api::Type::String
name: parent
required: true
immutable: true
url_param_only: true
description: |
Resource name of the new mute configs's parent. Its format is
"organizations/[organization_id]", "folders/[folder_id]", or
"projects/[project_id]".
properties:
- !ruby/object:Api::Type::String
name: 'name'
output: true
description: |
Name of the mute config. Its format is
organizations/{organization}/muteConfigs/{configId},
folders/{folder}/muteConfigs/{configId},
or projects/{project}/muteConfigs/{configId}
- !ruby/object:Api::Type::String
name: 'description'
description: A description of the mute config.
- !ruby/object:Api::Type::String
name: 'filter'
description: |
An expression that defines the filter to apply across create/update
events of findings. While creating a filter string, be mindful of
the scope in which the mute configuration is being created. E.g.,
If a filter contains project = X but is created under the
project = Y scope, it might not match any findings.
required: true
- !ruby/object:Api::Type::String
name: 'createTime'
description: |
The time at which the mute config was created. This field is set by
the server and will be ignored if provided on config creation.
output: true
- !ruby/object:Api::Type::String
name: 'updateTime'
description: |
Output only. The most recent time at which the mute config was
updated. This field is set by the server and will be ignored if
provided on config creation or update.
output: true
- !ruby/object:Api::Type::String
name: 'mostRecentEditor'
description: |
Email address of the user who last edited the mute config. This
field is set by the server and will be ignored if provided on
config creation or update.
output: true
23 changes: 23 additions & 0 deletions mmv1/products/securitycenterv2/product.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 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:Api::Product
name: SecurityCenterV2
display_name: Security Command Center (SCC)
legacy_name: scc
versions:
- !ruby/object:Api::Product::Version
name: ga
base_url: https://securitycenter.googleapis.com/v2/
scopes:
- https://www.googleapis.com/auth/cloud-platform
thokalavinod marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "google_pubsub_topic" "scc_v2_folder_mute_config" {
thokalavinod marked this conversation as resolved.
Show resolved Hide resolved
name = "<%= ctx[:vars]['topic_name'] %>"
}

thokalavinod marked this conversation as resolved.
Show resolved Hide resolved
resource "google_scc_v2_folder_mute_config" "<%= ctx[:primary_resource_id] %>" {
trodge marked this conversation as resolved.
Show resolved Hide resolved
mute_config_id = "<%= ctx[:vars]['mute_config_id'] %>"
folder = "<%= ctx[:test_env_vars]['folder_id'] %>"
thokalavinod marked this conversation as resolved.
Show resolved Hide resolved
description = "My custom Cloud Security Command Center Mute Configuration"
filter = "severity = \"HIGH\""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "google_pubsub_topic" "scc_v2_organization_mute_config" {
name = "<%= ctx[:vars]['topic_name'] %>"
}

resource "google_scc_v2_organization_mute_config" "<%= ctx[:primary_resource_id] %>" {
mute_config_id = "<%= ctx[:vars]['mute_config_id'] %>"
organization = "<%= ctx[:test_env_vars]['org_id'] %>"
description = "My custom Cloud Security Command Center Organization Mute Configuration"
filter = "severity = \"HIGH\""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "google_pubsub_topic" "scc_v2_project_mute_config" {
name = "<%= ctx[:vars]['topic_name'] %>"
}

thokalavinod marked this conversation as resolved.
Show resolved Hide resolved
resource "google_scc_v2_project_mute_config" "<%= ctx[:primary_resource_id] %>" {
mute_config_id = "<%= ctx[:vars]['mute_config_id'] %>"
project = "<%= ctx[:test_env_vars]['project_id'] %>"
description = "My custom Cloud Security Command Center Project Mute Configuration"
filter = "severity = \"HIGH\""
}
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,11 @@ var ServicesListBeta = mapOf(
"name" to "securityposture",
"displayName" to "Securityposture",
"path" to "./google-beta/services/securityposture"
),
"securitycenterV2" to mapOf(
"name" to "securitycenterV2",
"displayName" to "securitycenterV2",
"path" to "./google-beta/services/securitycenterV2"
),
"securityscanner" to mapOf(
"name" to "securityscanner",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,11 @@ var ServicesListGa = mapOf(
"name" to "securityposture",
"displayName" to "Securityposture",
"path" to "./google/services/securityposture"
),
"securitycenterV2" to mapOf(
"name" to "securitycenterV2",
"displayName" to "securitycenterV2",
"path" to "./google-beta/services/securitycenterV2"
),
"securityscanner" to mapOf(
"name" to "securityscanner",
Expand Down