Skip to content

Commit 3f5d0c9

Browse files
Google APIscopybara-github
authored andcommitted
feat: add SubmitUri endpoint
PiperOrigin-RevId: 533110799
1 parent af8fe57 commit 3f5d0c9

3 files changed

Lines changed: 236 additions & 11 deletions

File tree

google/cloud/webrisk/v1/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ proto_library(
2828
"//google/api:client_proto",
2929
"//google/api:field_behavior_proto",
3030
"//google/api:resource_proto",
31+
"//google/longrunning:operations_proto",
3132
"@com_google_protobuf//:timestamp_proto",
3233
],
3334
)
@@ -120,6 +121,7 @@ go_proto_library(
120121
protos = [":webrisk_proto"],
121122
deps = [
122123
"//google/api:annotations_go_proto",
124+
"//google/longrunning:longrunning_go_proto",
123125
],
124126
)
125127

@@ -135,6 +137,9 @@ go_gapic_library(
135137
transport = "grpc+rest",
136138
deps = [
137139
":webrisk_go_proto",
140+
"//google/longrunning:longrunning_go_proto",
141+
"@com_google_cloud_go_longrunning//:go_default_library",
142+
"@com_google_cloud_go_longrunning//autogen:go_default_library",
138143
],
139144
)
140145

@@ -222,6 +227,7 @@ php_gapic_library(
222227
name = "webrisk_php_gapic",
223228
srcs = [":webrisk_proto_with_info"],
224229
grpc_service_config = "webrisk_grpc_service_config.json",
230+
migration_mode = "PRE_MIGRATION_SURFACE_ONLY",
225231
rest_numeric_enums = True,
226232
service_yaml = "webrisk_v1.yaml",
227233
transport = "grpc+rest",

google/cloud/webrisk/v1/webrisk.proto

Lines changed: 209 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import "google/api/annotations.proto";
2020
import "google/api/client.proto";
2121
import "google/api/field_behavior.proto";
2222
import "google/api/resource.proto";
23+
import "google/longrunning/operations.proto";
2324
import "google/protobuf/timestamp.proto";
2425

2526
option csharp_namespace = "Google.Cloud.WebRisk.V1";
@@ -35,19 +36,22 @@ option ruby_package = "Google::Cloud::WebRisk::V1";
3536
// website and in client applications.
3637
service WebRiskService {
3738
option (google.api.default_host) = "webrisk.googleapis.com";
38-
option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
39+
option (google.api.oauth_scopes) =
40+
"https://www.googleapis.com/auth/cloud-platform";
3941

4042
// Gets the most recent threat list diffs. These diffs should be applied to
4143
// a local database of hashes to keep it up-to-date. If the local database is
4244
// empty or excessively out-of-date, a complete snapshot of the database will
4345
// be returned. This Method only updates a single ThreatList at a time. To
4446
// update multiple ThreatList databases, this method needs to be called once
4547
// for each list.
46-
rpc ComputeThreatListDiff(ComputeThreatListDiffRequest) returns (ComputeThreatListDiffResponse) {
48+
rpc ComputeThreatListDiff(ComputeThreatListDiffRequest)
49+
returns (ComputeThreatListDiffResponse) {
4750
option (google.api.http) = {
4851
get: "/v1/threatLists:computeDiff"
4952
};
50-
option (google.api.method_signature) = "threat_type,version_token,constraints";
53+
option (google.api.method_signature) =
54+
"threat_type,version_token,constraints";
5155
}
5256

5357
// This method is used to check whether a URI is on a given threatList.
@@ -88,6 +92,27 @@ service WebRiskService {
8892
};
8993
option (google.api.method_signature) = "parent,submission";
9094
}
95+
96+
// Submits a URI suspected of containing malicious content to be reviewed.
97+
// Returns a google.longrunning.Operation which, once the review is complete,
98+
// is updated with its result. You can use the [Pub/Sub API]
99+
// (https://cloud.google.com/pubsub) to receive notifications for the returned
100+
// Operation. If the result verifies the existence of malicious content, the
101+
// site will be added to the [Google's Social Engineering lists]
102+
// (https://support.google.com/webmasters/answer/6350487/) in order to
103+
// protect users that could get exposed to this threat in the future. Only
104+
// allowlisted projects can use this method during Early Access. Please reach
105+
// out to Sales or your customer engineer to obtain access.
106+
rpc SubmitUri(SubmitUriRequest) returns (google.longrunning.Operation) {
107+
option (google.api.http) = {
108+
post: "/v1/{parent=projects/*}/uris:submit"
109+
body: "*"
110+
};
111+
option (google.longrunning.operation_info) = {
112+
response_type: "Submission"
113+
metadata_type: "SubmitUriMetadata"
114+
};
115+
}
91116
}
92117

93118
// Describes an API diff request.
@@ -108,9 +133,9 @@ message ComputeThreatListDiffRequest {
108133
repeated CompressionType supported_compressions = 3;
109134
}
110135

111-
// Required. The threat list to update. Only a single ThreatType should be specified
112-
// per request. If you want to handle multiple ThreatTypes, you must make one
113-
// request per ThreatType.
136+
// Required. The threat list to update. Only a single ThreatType should be
137+
// specified per request. If you want to handle multiple ThreatTypes, you must
138+
// make one request per ThreatType.
114139
ThreatType threat_type = 1 [(google.api.field_behavior) = REQUIRED];
115140

116141
// The current version token of the client for the requested list (the
@@ -180,7 +205,8 @@ message SearchUrisRequest {
180205
// Required. The URI to be checked for matches.
181206
string uri = 1 [(google.api.field_behavior) = REQUIRED];
182207

183-
// Required. The ThreatLists to search in. Multiple ThreatLists may be specified.
208+
// Required. The ThreatLists to search in. Multiple ThreatLists may be
209+
// specified.
184210
repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED];
185211
}
186212

@@ -207,7 +233,8 @@ message SearchHashesRequest {
207233
// the web safe base64 variant (RFC 4648).
208234
bytes hash_prefix = 1;
209235

210-
// Required. The ThreatLists to search in. Multiple ThreatLists may be specified.
236+
// Required. The ThreatLists to search in. Multiple ThreatLists may be
237+
// specified.
211238
repeated ThreatType threat_types = 2 [(google.api.field_behavior) = REQUIRED];
212239
}
213240

@@ -342,14 +369,130 @@ message RiceDeltaEncoding {
342369

343370
// Wraps a URI that might be displaying malicious content.
344371
message Submission {
345-
// Required. The URI that is being reported for malicious content to be analyzed.
372+
// Required. The URI that is being reported for malicious content to be
373+
// analyzed.
346374
string uri = 1 [(google.api.field_behavior) = REQUIRED];
375+
376+
// Output only. ThreatTypes found to be associated with the submitted URI
377+
// after reviewing it. This might be empty if the URI was not added to any
378+
// list.
379+
repeated ThreatType threat_types = 2
380+
[(google.api.field_behavior) = OUTPUT_ONLY];
381+
}
382+
383+
// Context about the submission including the type of abuse found on the URI and
384+
// supporting details.
385+
// option (google.api.message_visibility).restriction = "TRUSTED_TESTER";
386+
message ThreatInfo {
387+
// The abuse type found on the URI.
388+
enum AbuseType {
389+
// Default.
390+
ABUSE_TYPE_UNSPECIFIED = 0;
391+
392+
// The URI contains malware.
393+
MALWARE = 1;
394+
395+
// The URI contains social engineering.
396+
SOCIAL_ENGINEERING = 2;
397+
398+
// The URI contains unwanted software.
399+
UNWANTED_SOFTWARE = 3;
400+
}
401+
402+
// Confidence that a URI is unsafe.
403+
message Confidence {
404+
// Enum representation of confidence.
405+
enum ConfidenceLevel {
406+
// Default.
407+
CONFIDENCE_LEVEL_UNSPECIFIED = 0;
408+
409+
// Less than 60% confidence that the URI is unsafe.
410+
LOW = 1;
411+
412+
// Between 60% and 80% confidence that the URI is unsafe.
413+
MEDIUM = 2;
414+
415+
// Greater than 80% confidence that the URI is unsafe.
416+
HIGH = 3;
417+
}
418+
419+
oneof value {
420+
// A decimal representation of confidence in the range of 0
421+
// to 1 where 0 indicates no confidence and 1 indicates
422+
// complete confidence.
423+
float score = 1;
424+
425+
// Enum representation of confidence.
426+
ConfidenceLevel level = 2;
427+
}
428+
}
429+
430+
// Context about why the URI is unsafe.
431+
message ThreatJustification {
432+
// Labels that explain how the URI was classified.
433+
enum JustificationLabel {
434+
// Default.
435+
JUSTIFICATION_LABEL_UNSPECIFIED = 0;
436+
437+
// The submitter manually verified that the submission is unsafe.
438+
MANUAL_VERIFICATION = 1;
439+
440+
// The submitter received the submission from an end user.
441+
USER_REPORT = 2;
442+
443+
// The submitter received the submission from an automated system.
444+
AUTOMATED_REPORT = 3;
445+
}
446+
447+
// Labels associated with this URI that explain how it was classified.
448+
repeated JustificationLabel labels = 1;
449+
450+
// Free-form context on why this URI is unsafe.
451+
repeated string comments = 2;
452+
}
453+
454+
// The type of abuse.
455+
AbuseType abuse_type = 1;
456+
457+
// Confidence that the URI is unsafe.
458+
Confidence threat_confidence = 2;
459+
460+
// Context about why the URI is unsafe.
461+
ThreatJustification threat_justification = 3;
462+
}
463+
464+
// Details about how the threat was discovered.
465+
message ThreatDiscovery {
466+
// Platform types.
467+
enum Platform {
468+
// Default.
469+
PLATFORM_UNSPECIFIED = 0;
470+
471+
// General Android platform.
472+
ANDROID = 1;
473+
474+
// General iOS platform.
475+
IOS = 2;
476+
477+
// General macOS platform.
478+
MACOS = 3;
479+
480+
// General Windows platform.
481+
WINDOWS = 4;
482+
}
483+
484+
// Platform on which the threat was discovered.
485+
Platform platform = 1;
486+
487+
// CLDR region code of the countries/regions the URI poses a threat ordered
488+
// from most impact to least impact. Example: "US" for United States.
489+
repeated string region_codes = 2;
347490
}
348491

349492
// Request to send a potentially phishy URI to WebRisk.
350493
message CreateSubmissionRequest {
351-
// Required. The name of the project that is making the submission. This string is in
352-
// the format "projects/{project_number}".
494+
// Required. The name of the project that is making the submission. This
495+
// string is in the format "projects/{project_number}".
353496
string parent = 1 [
354497
(google.api.field_behavior) = REQUIRED,
355498
(google.api.resource_reference) = {
@@ -360,3 +503,58 @@ message CreateSubmissionRequest {
360503
// Required. The submission that contains the content of the phishing report.
361504
Submission submission = 2 [(google.api.field_behavior) = REQUIRED];
362505
}
506+
507+
// Request to send a potentially malicious URI to WebRisk.
508+
message SubmitUriRequest {
509+
// Required. The name of the project that is making the submission. This
510+
// string is in the format "projects/{project_number}".
511+
string parent = 1 [
512+
(google.api.field_behavior) = REQUIRED,
513+
(google.api.resource_reference) = {
514+
type: "cloudresourcemanager.googleapis.com/Project"
515+
}
516+
];
517+
518+
// Required. The submission that contains the URI to be scanned.
519+
Submission submission = 2 [(google.api.field_behavior) = REQUIRED];
520+
521+
// Provides additional information about the submission.
522+
ThreatInfo threat_info = 3;
523+
524+
// Provides additional information about how the submission was discovered.
525+
ThreatDiscovery threat_discovery = 4;
526+
}
527+
528+
// Metadata for the Submit URI long-running operation.
529+
// option (google.api.message_visibility).restriction = "TRUSTED_TESTER";
530+
message SubmitUriMetadata {
531+
// Enum that represents the state of the long-running operation.
532+
enum State {
533+
// Default unspecified state.
534+
STATE_UNSPECIFIED = 0;
535+
536+
// The operation is currently running.
537+
RUNNING = 1;
538+
539+
// The operation finished with a success status.
540+
SUCCEEDED = 2;
541+
542+
// The operation was cancelled.
543+
CANCELLED = 3;
544+
545+
// The operation finished with a failure status.
546+
FAILED = 4;
547+
548+
// The operation was closed with no action taken.
549+
CLOSED = 5;
550+
}
551+
552+
// The state of the operation.
553+
State state = 1;
554+
555+
// Creation time of the operation.
556+
google.protobuf.Timestamp create_time = 2;
557+
558+
// Latest update time of the operation.
559+
google.protobuf.Timestamp update_time = 3;
560+
}

google/cloud/webrisk/v1/webrisk_v1.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,31 @@ title: Web Risk API
55

66
apis:
77
- name: google.cloud.webrisk.v1.WebRiskService
8+
- name: google.longrunning.Operations
9+
10+
types:
11+
- name: google.cloud.webrisk.v1.Submission
12+
- name: google.cloud.webrisk.v1.SubmitUriMetadata
13+
14+
http:
15+
rules:
16+
- selector: google.longrunning.Operations.CancelOperation
17+
post: '/v1/{name=projects/*/operations/*}:cancel'
18+
body: '*'
19+
- selector: google.longrunning.Operations.DeleteOperation
20+
delete: '/v1/{name=projects/*/operations/*}'
21+
- selector: google.longrunning.Operations.GetOperation
22+
get: '/v1/{name=projects/*/operations/*}'
23+
- selector: google.longrunning.Operations.ListOperations
24+
get: '/v1/{name=projects/*}/operations'
825

926
authentication:
1027
rules:
1128
- selector: 'google.cloud.webrisk.v1.WebRiskService.*'
1229
oauth:
1330
canonical_scopes: |-
1431
https://www.googleapis.com/auth/cloud-platform
32+
- selector: google.longrunning.Operations.GetOperation
33+
oauth:
34+
canonical_scopes: |-
35+
https://www.googleapis.com/auth/cloud-platform

0 commit comments

Comments
 (0)