Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: add resource config to v1beta1 (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored Jul 24, 2020
1 parent c9e263c commit 5d99acf
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 54 deletions.
44 changes: 25 additions & 19 deletions protos/google/cloud/securitycenter/v1beta1/asset.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,13 +11,13 @@
// 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.
//

syntax = "proto3";

package google.cloud.securitycenter.v1beta1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/securitycenter/v1beta1/security_marks.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
Expand All @@ -27,25 +27,31 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/
option java_multiple_files = true;
option java_package = "com.google.cloud.securitycenter.v1beta1";

// Cloud Security Command Center's (Cloud SCC) representation of a Google Cloud
// Platform (GCP) resource.
// Security Command Center representation of a Google Cloud
// resource.
//
// The Asset is a Cloud SCC resource that captures information about a single
// GCP resource. All modifications to an Asset are only within the context of
// Cloud SCC and don't affect the referenced GCP resource.
// The Asset is a Security Command Center resource that captures information
// about a single Google Cloud resource. All modifications to an Asset are only
// within the context of Security Command Center and don't affect the referenced
// Google Cloud resource.
message Asset {
// Cloud SCC managed properties. These properties are managed by Cloud SCC and
// cannot be modified by the user.
option (google.api.resource) = {
type: "securitycenter.googleapis.com/Asset"
pattern: "organizations/{organization}/assets/{asset}"
};

// Security Command Center managed properties. These properties are managed by
// Security Command Center and cannot be modified by the user.
message SecurityCenterProperties {
// Immutable. The full resource name of the GCP resource this asset
// Immutable. The full resource name of the Google Cloud resource this asset
// represents. This field is immutable after create time. See:
// https://cloud.google.com/apis/design/resource_names#full_resource_name
string resource_name = 1 [(google.api.field_behavior) = IMMUTABLE];

// The type of the GCP resource. Examples include: APPLICATION,
// The type of the Google Cloud resource. Examples include: APPLICATION,
// PROJECT, and ORGANIZATION. This is a case insensitive field defined by
// Cloud SCC and/or the producer of the resource and is immutable
// after create time.
// Security Command Center and/or the producer of the resource and is
// immutable after create time.
string resource_type = 2;

// The full resource name of the immediate parent of the resource. See:
Expand All @@ -66,22 +72,22 @@ message Asset {
// "organizations/{organization_id}/assets/{asset_id}".
string name = 1;

// Cloud SCC managed properties. These properties are managed by
// Cloud SCC and cannot be modified by the user.
// Security Command Center managed properties. These properties are managed by
// Security Command Center and cannot be modified by the user.
SecurityCenterProperties security_center_properties = 2;

// Resource managed properties. These properties are managed and defined by
// the GCP resource and cannot be modified by the user.
// the Google Cloud resource and cannot be modified by the user.
map<string, google.protobuf.Value> resource_properties = 7;

// User specified security marks. These marks are entirely managed by the user
// and come from the SecurityMarks resource that belongs to the asset.
SecurityMarks security_marks = 8;

// The time at which the asset was created in Cloud SCC.
// The time at which the asset was created in Security Command Center.
google.protobuf.Timestamp create_time = 9;

// The time at which the asset was last updated, added, or deleted in Cloud
// SCC.
// The time at which the asset was last updated, added, or deleted in Security
// Command Center.
google.protobuf.Timestamp update_time = 10;
}
29 changes: 14 additions & 15 deletions protos/google/cloud/securitycenter/v1beta1/finding.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,6 @@
// 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.
//

syntax = "proto3";

Expand All @@ -28,12 +27,12 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/
option java_multiple_files = true;
option java_package = "com.google.cloud.securitycenter.v1beta1";

// Cloud Security Command Center (Cloud SCC) finding.
// Security Command Center finding.
//
// A finding is a record of assessment data (security, risk, health or privacy)
// ingested into Cloud SCC for presentation, notification, analysis,
// policy testing, and enforcement. For example, an XSS vulnerability in an
// App Engine application is a finding.
// ingested into Security Command Center for presentation, notification,
// analysis, policy testing, and enforcement. For example, an XSS vulnerability
// in an App Engine application is a finding.
message Finding {
option (google.api.resource) = {
type: "securitycenter.googleapis.com/Finding"
Expand Down Expand Up @@ -66,12 +65,12 @@ message Finding {
// "organizations/{organization_id}/sources/{source_id}"
string parent = 2 [(google.api.field_behavior) = IMMUTABLE];

// For findings on Google Cloud Platform (GCP) resources, the full resource
// name of the GCP resource this finding is for. See:
// For findings on Google Cloud resources, the full resource
// name of the Google Cloud resource this finding is for. See:
// https://cloud.google.com/apis/design/resource_names#full_resource_name
// When the finding is for a non-GCP resource, the resourceName can be a
// customer or partner defined string.
// This field is immutable after creation time.
// When the finding is for a non-Google Cloud resource, the resourceName can
// be a customer or partner defined string. This field is immutable after
// creation time.
string resource_name = 3;

// The state of the finding.
Expand All @@ -82,9 +81,9 @@ message Finding {
// Example: "XSS_FLASH_INJECTION"
string category = 5;

// The URI that, if available, points to a web page outside of Cloud SCC
// where additional information about the finding can be found. This field is
// guaranteed to be either empty or a well formed URL.
// The URI that, if available, points to a web page outside of Security
// Command Center where additional information about the finding can be found.
// This field is guaranteed to be either empty or a well formed URL.
string external_uri = 6;

// Source specific properties. These properties are managed by the source
Expand All @@ -103,6 +102,6 @@ message Finding {
// the firewall became open. The accuracy is determined by the detector.
google.protobuf.Timestamp event_time = 9;

// The time at which the finding was created in Cloud SCC.
// The time at which the finding was created in Security Command Center.
google.protobuf.Timestamp create_time = 10;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,6 @@
// 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.
//

syntax = "proto3";

Expand All @@ -24,8 +23,8 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/
option java_multiple_files = true;
option java_package = "com.google.cloud.securitycenter.v1beta1";

// User specified settings that are attached to the Cloud Security Command
// Center (Cloud SCC) organization.
// User specified settings that are attached to the Security Command
// Center organization.
message OrganizationSettings {
option (google.api.resource) = {
type: "securitycenter.googleapis.com/OrganizationSettings"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,6 @@
// 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.
//

syntax = "proto3";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,6 @@
// 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.
//

syntax = "proto3";

Expand All @@ -24,9 +23,9 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/
option java_multiple_files = true;
option java_package = "com.google.cloud.securitycenter.v1beta1";

// User specified security marks that are attached to the parent Cloud Security
// Command Center (Cloud SCC) resource. Security marks are scoped within a Cloud
// SCC organization -- they can be modified and viewed by all users who have
// User specified security marks that are attached to the parent Security
// Command Center resource. Security marks are scoped within a Security Command
// Center organization -- they can be modified and viewed by all users who have
// proper permissions on the organization.
message SecurityMarks {
option (google.api.resource) = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,6 @@
// 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.
//

syntax = "proto3";

Expand Down
7 changes: 3 additions & 4 deletions protos/google/cloud/securitycenter/v1beta1/source.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 Google LLC.
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,7 +11,6 @@
// 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.
//

syntax = "proto3";

Expand All @@ -24,7 +23,7 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/
option java_multiple_files = true;
option java_package = "com.google.cloud.securitycenter.v1beta1";

// Cloud Security Command Center's (Cloud SCC) finding source. A finding source
// Security Command Center finding source. A finding source
// is an entity or a mechanism that can produce a finding. A source is like a
// container of findings that come from the same scanner, logger, monitor, etc.
message Source {
Expand All @@ -48,7 +47,7 @@ message Source {

// The description of the source (max of 1024 characters).
// Example:
// "Cloud Security Scanner is a web security scanner for common
// "Web Security Scanner is a web security scanner for common
// vulnerabilities in App Engine applications. It can automatically
// scan and detect four common vulnerabilities, including cross-site-scripting
// (XSS), Flash injection, mixed content (HTTP in HTTPS), and
Expand Down
4 changes: 4 additions & 0 deletions protos/protos.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions src/v1beta1/security_center_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ export class SecurityCenterClient {
// identifiers to uniquely identify resources within the API.
// Create useful helper objects for these.
this.pathTemplates = {
assetPathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/assets/{asset}'
),
findingPathTemplate: new this._gaxModule.PathTemplate(
'organizations/{organization}/sources/{source}/findings/{finding}'
),
Expand Down Expand Up @@ -3385,6 +3388,42 @@ export class SecurityCenterClient {
// -- Path templates --
// --------------------

/**
* Return a fully-qualified asset resource name string.
*
* @param {string} organization
* @param {string} asset
* @returns {string} Resource name string.
*/
assetPath(organization: string, asset: string) {
return this.pathTemplates.assetPathTemplate.render({
organization: organization,
asset: asset,
});
}

/**
* Parse the organization from Asset resource.
*
* @param {string} assetName
* A fully-qualified path representing Asset resource.
* @returns {string} A string representing the organization.
*/
matchOrganizationFromAssetName(assetName: string) {
return this.pathTemplates.assetPathTemplate.match(assetName).organization;
}

/**
* Parse the asset from Asset resource.
*
* @param {string} assetName
* A fully-qualified path representing Asset resource.
* @returns {string} A string representing the asset.
*/
matchAssetFromAssetName(assetName: string) {
return this.pathTemplates.assetPathTemplate.match(assetName).asset;
}

/**
* Return a fully-qualified finding resource name string.
*
Expand Down
6 changes: 3 additions & 3 deletions synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/nodejs-security-center.git",
"sha": "9707f8b09b87b29561cfc7368f4b202595459045"
"sha": "c9e263cb969a1ef75f8e0b7a36d1a3041e2cb9f1"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "240e65bd142ae3914cb250491bf0589331736731",
"internalRef": "320995419"
"sha": "e26e1839a45445d13cd45b1be3b1523defb72fee",
"internalRef": "322867095"
}
},
{
Expand Down
Loading

0 comments on commit 5d99acf

Please sign in to comment.