Skip to content

Commit c768e7a

Browse files
Google APIscopybara-github
authored andcommitted
feat: Add SimulateSecurityHealthAnalyticsCustomModule API for testing SHA custom module
PiperOrigin-RevId: 574612611
1 parent 7cdf4d0 commit c768e7a

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

google/cloud/securitycenter/v1/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ proto_library(
6666
"//google/iam/v1:policy_proto",
6767
"//google/longrunning:operations_proto",
6868
"//google/type:expr_proto",
69+
"//google/rpc:status_proto",
6970
"@com_google_protobuf//:duration_proto",
7071
"@com_google_protobuf//:empty_proto",
7172
"@com_google_protobuf//:field_mask_proto",
@@ -166,6 +167,7 @@ go_proto_library(
166167
"//google/iam/v1:iam_go_proto",
167168
"//google/longrunning:longrunning_go_proto",
168169
"//google/type:expr_go_proto",
170+
"//google/rpc:status_go_proto",
169171
],
170172
)
171173

google/cloud/securitycenter/v1/securitycenter_service.proto

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import "google/cloud/securitycenter/v1/mute_config.proto";
3030
import "google/cloud/securitycenter/v1/notification_config.proto";
3131
import "google/cloud/securitycenter/v1/organization_settings.proto";
3232
import "google/cloud/securitycenter/v1/run_asset_discovery_response.proto";
33+
import "google/cloud/securitycenter/v1/security_health_analytics_custom_config.proto";
3334
import "google/cloud/securitycenter/v1/security_health_analytics_custom_module.proto";
3435
import "google/cloud/securitycenter/v1/security_marks.proto";
3536
import "google/cloud/securitycenter/v1/source.proto";
@@ -41,6 +42,7 @@ import "google/protobuf/empty.proto";
4142
import "google/protobuf/field_mask.proto";
4243
import "google/protobuf/struct.proto";
4344
import "google/protobuf/timestamp.proto";
45+
import "google/rpc/status.proto";
4446

4547
option csharp_namespace = "Google.Cloud.SecurityCenter.V1";
4648
option go_package = "cloud.google.com/go/securitycenter/apiv1/securitycenterpb;securitycenterpb";
@@ -515,6 +517,25 @@ service SecurityCenter {
515517
option (google.api.method_signature) = "resource,permissions";
516518
}
517519

520+
// Simulates a given SecurityHealthAnalyticsCustomModule and Resource.
521+
rpc SimulateSecurityHealthAnalyticsCustomModule(
522+
SimulateSecurityHealthAnalyticsCustomModuleRequest)
523+
returns (SimulateSecurityHealthAnalyticsCustomModuleResponse) {
524+
option (google.api.http) = {
525+
post: "/v1/{parent=organizations/*/securityHealthAnalyticsSettings}/customModules:simulate"
526+
body: "*"
527+
additional_bindings {
528+
post: "/v1/{parent=folders/*/securityHealthAnalyticsSettings}/customModules:simulate"
529+
body: "*"
530+
}
531+
additional_bindings {
532+
post: "/v1/{parent=projects/*/securityHealthAnalyticsSettings}/customModules:simulate"
533+
body: "*"
534+
}
535+
};
536+
option (google.api.method_signature) = "parent,custom_config,resource";
537+
}
538+
518539
// Updates external system. This is for a given finding.
519540
rpc UpdateExternalSystem(UpdateExternalSystemRequest)
520541
returns (ExternalSystem) {
@@ -2030,6 +2051,62 @@ message RunAssetDiscoveryRequest {
20302051
];
20312052
}
20322053

2054+
// Request message to simulate a CustomConfig against a given test resource.
2055+
// Maximum size of the request is 4 MB by default.
2056+
message SimulateSecurityHealthAnalyticsCustomModuleRequest {
2057+
// Manually constructed resource. If the custom module only evaluates against
2058+
// the resource data, the iam_policy_data field can be omitted, and vice
2059+
// versa.
2060+
message SimulatedResource {
2061+
// Required. The type of the resource, e.g. `compute.googleapis.com/Disk`.
2062+
string resource_type = 1 [(google.api.field_behavior) = REQUIRED];
2063+
2064+
// Optional. A representation of the GCP resource. Should match the GCP
2065+
// resource JSON format.
2066+
google.protobuf.Struct resource_data = 2
2067+
[(google.api.field_behavior) = OPTIONAL];
2068+
2069+
// Optional. A representation of the IAM policy.
2070+
google.iam.v1.Policy iam_policy_data = 3
2071+
[(google.api.field_behavior) = OPTIONAL];
2072+
}
2073+
2074+
// Required. The relative resource name of the organization, project, or
2075+
// folder. See:
2076+
// https://cloud.google.com/apis/design/resource_names#relative_resource_name
2077+
// An example is:
2078+
// "organizations/{organization_id}".
2079+
string parent = 1 [(google.api.field_behavior) = REQUIRED];
2080+
2081+
// Required. The user specified custom configuration to test.
2082+
CustomConfig custom_config = 2 [(google.api.field_behavior) = REQUIRED];
2083+
2084+
// Required. Resource data to simulate custom module against.
2085+
SimulatedResource resource = 3 [(google.api.field_behavior) = REQUIRED];
2086+
}
2087+
2088+
// Response message for simulating a SecurityHealthAnalyticsCustomModule against
2089+
// a given resource.
2090+
message SimulateSecurityHealthAnalyticsCustomModuleResponse {
2091+
// Possible test result.
2092+
message SimulatedResult {
2093+
oneof result {
2094+
// Finding that would be published for the test case,
2095+
// if a violation is detected.
2096+
Finding finding = 1;
2097+
2098+
// Indicates that the test case does not trigger any violation.
2099+
google.protobuf.Empty no_violation = 2;
2100+
2101+
// Error encountered during the test.
2102+
google.rpc.Status error = 3;
2103+
}
2104+
}
2105+
2106+
// Result for test case in the corresponding request.
2107+
SimulatedResult result = 1;
2108+
}
2109+
20332110
// Request message for updating a ExternalSystem resource.
20342111
message UpdateExternalSystemRequest {
20352112
// Required. The external system resource to update.

0 commit comments

Comments
 (0)