Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit a233f7a

Browse files
feat: Added vulnerability field to Finding (#235)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 401787368 Source-Link: googleapis/googleapis@a7a3440 Source-Link: https://github.com/googleapis/googleapis-gen/commit/169ba7febf00ee030446a0534ac77ad57f0bf83a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTY5YmE3ZmViZjAwZWUwMzA0NDZhMDUzNGFjNzdhZDU3ZjBiZjgzYSJ9 feat: Added type field to the resource which is surfaced in NotificationMessage
1 parent e5df93b commit a233f7a

9 files changed

Lines changed: 232 additions & 0 deletions

File tree

google/cloud/securitycenter/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
UpdateSourceRequest,
116116
)
117117
from google.cloud.securitycenter_v1.types.source import Source
118+
from google.cloud.securitycenter_v1.types.vulnerability import Cve
119+
from google.cloud.securitycenter_v1.types.vulnerability import Cvssv3
120+
from google.cloud.securitycenter_v1.types.vulnerability import Reference
121+
from google.cloud.securitycenter_v1.types.vulnerability import Vulnerability
118122

119123
__all__ = (
120124
"SecurityCenterClient",
@@ -157,4 +161,8 @@
157161
"UpdateSecurityMarksRequest",
158162
"UpdateSourceRequest",
159163
"Source",
164+
"Cve",
165+
"Cvssv3",
166+
"Reference",
167+
"Vulnerability",
160168
)

google/cloud/securitycenter_v1/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,19 @@
5555
from .types.securitycenter_service import UpdateSecurityMarksRequest
5656
from .types.securitycenter_service import UpdateSourceRequest
5757
from .types.source import Source
58+
from .types.vulnerability import Cve
59+
from .types.vulnerability import Cvssv3
60+
from .types.vulnerability import Reference
61+
from .types.vulnerability import Vulnerability
5862

5963
__all__ = (
6064
"SecurityCenterAsyncClient",
6165
"Asset",
6266
"CreateFindingRequest",
6367
"CreateNotificationConfigRequest",
6468
"CreateSourceRequest",
69+
"Cve",
70+
"Cvssv3",
6571
"DeleteNotificationConfigRequest",
6672
"Finding",
6773
"Folder",
@@ -85,6 +91,7 @@
8591
"NotificationConfig",
8692
"NotificationMessage",
8793
"OrganizationSettings",
94+
"Reference",
8895
"Resource",
8996
"RunAssetDiscoveryRequest",
9097
"RunAssetDiscoveryResponse",
@@ -97,4 +104,5 @@
97104
"UpdateOrganizationSettingsRequest",
98105
"UpdateSecurityMarksRequest",
99106
"UpdateSourceRequest",
107+
"Vulnerability",
100108
)

google/cloud/securitycenter_v1/services/security_center/async_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from google.cloud.securitycenter_v1.types import securitycenter_service
4747
from google.cloud.securitycenter_v1.types import source
4848
from google.cloud.securitycenter_v1.types import source as gcs_source
49+
from google.cloud.securitycenter_v1.types import vulnerability
4950
from google.iam.v1 import iam_policy_pb2 # type: ignore
5051
from google.iam.v1 import policy_pb2 # type: ignore
5152
from google.protobuf import empty_pb2 # type: ignore

google/cloud/securitycenter_v1/services/security_center/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from google.cloud.securitycenter_v1.types import securitycenter_service
5151
from google.cloud.securitycenter_v1.types import source
5252
from google.cloud.securitycenter_v1.types import source as gcs_source
53+
from google.cloud.securitycenter_v1.types import vulnerability
5354
from google.iam.v1 import iam_policy_pb2 # type: ignore
5455
from google.iam.v1 import policy_pb2 # type: ignore
5556
from google.protobuf import empty_pb2 # type: ignore

google/cloud/securitycenter_v1/types/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
UpdateSourceRequest,
5454
)
5555
from .source import Source
56+
from .vulnerability import (
57+
Cve,
58+
Cvssv3,
59+
Reference,
60+
Vulnerability,
61+
)
5662

5763
__all__ = (
5864
"Asset",
@@ -93,4 +99,8 @@
9399
"UpdateSecurityMarksRequest",
94100
"UpdateSourceRequest",
95101
"Source",
102+
"Cve",
103+
"Cvssv3",
104+
"Reference",
105+
"Vulnerability",
96106
)

google/cloud/securitycenter_v1/types/finding.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from google.cloud.securitycenter_v1.types import indicator as gcs_indicator
1919
from google.cloud.securitycenter_v1.types import security_marks as gcs_security_marks
20+
from google.cloud.securitycenter_v1.types import vulnerability as gcs_vulnerability
2021
from google.protobuf import struct_pb2 # type: ignore
2122
from google.protobuf import timestamp_pb2 # type: ignore
2223

@@ -109,6 +110,11 @@ class Finding(proto.Message):
109110
observed on a network or in an operating system that, with
110111
high confidence, indicates a computer intrusion. Reference:
111112
https://en.wikipedia.org/wiki/Indicator_of_compromise
113+
vulnerability (google.cloud.securitycenter_v1.types.Vulnerability):
114+
Represents vulnerability specific fields like
115+
cve, cvss scores etc. CVE stands for Common
116+
Vulnerabilities and Exposures
117+
(https://cve.mitre.org/about/)
112118
"""
113119

114120
class State(proto.Enum):
@@ -153,6 +159,9 @@ class FindingClass(proto.Enum):
153159
canonical_name = proto.Field(proto.STRING, number=14,)
154160
finding_class = proto.Field(proto.ENUM, number=17, enum=FindingClass,)
155161
indicator = proto.Field(proto.MESSAGE, number=18, message=gcs_indicator.Indicator,)
162+
vulnerability = proto.Field(
163+
proto.MESSAGE, number=20, message=gcs_vulnerability.Vulnerability,
164+
)
156165

157166

158167
__all__ = tuple(sorted(__protobuf__.manifest))

google/cloud/securitycenter_v1/types/resource.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class Resource(proto.Message):
4040
The full resource name of resource's parent.
4141
parent_display_name (str):
4242
The human readable name of resource's parent.
43+
type_ (str):
44+
The full resource type of the resource.
4345
folders (Sequence[google.cloud.securitycenter_v1.types.Folder]):
4446
Output only. Contains a Folder message for
4547
each folder in the assets ancestry. The first
@@ -53,6 +55,7 @@ class Resource(proto.Message):
5355
project_display_name = proto.Field(proto.STRING, number=3,)
5456
parent = proto.Field(proto.STRING, number=4,)
5557
parent_display_name = proto.Field(proto.STRING, number=5,)
58+
type_ = proto.Field(proto.STRING, number=6,)
5659
folders = proto.RepeatedField(proto.MESSAGE, number=7, message=folder.Folder,)
5760

5861

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
import proto # type: ignore
17+
18+
19+
__protobuf__ = proto.module(
20+
package="google.cloud.securitycenter.v1",
21+
manifest={"Vulnerability", "Cve", "Reference", "Cvssv3",},
22+
)
23+
24+
25+
class Vulnerability(proto.Message):
26+
r"""Refers to common vulnerability fields e.g. cve, cvss, cwe
27+
etc.
28+
29+
Attributes:
30+
cve (google.cloud.securitycenter_v1.types.Cve):
31+
CVE stands for Common Vulnerabilities and
32+
Exposures (https://cve.mitre.org/about/)
33+
"""
34+
35+
cve = proto.Field(proto.MESSAGE, number=1, message="Cve",)
36+
37+
38+
class Cve(proto.Message):
39+
r"""CVE stands for Common Vulnerabilities and Exposures.
40+
More information: https://cve.mitre.org
41+
42+
Attributes:
43+
id (str):
44+
The unique identifier for the vulnerability.
45+
e.g. CVE-2021-34527
46+
references (Sequence[google.cloud.securitycenter_v1.types.Reference]):
47+
Additional information about the CVE.
48+
e.g. https://cve.mitre.org/cgi-
49+
bin/cvename.cgi?name=CVE-2021-34527
50+
cvssv3 (google.cloud.securitycenter_v1.types.Cvssv3):
51+
Describe Common Vulnerability Scoring System
52+
specified at
53+
https://www.first.org/cvss/v3.1/specification-
54+
document
55+
"""
56+
57+
id = proto.Field(proto.STRING, number=1,)
58+
references = proto.RepeatedField(proto.MESSAGE, number=2, message="Reference",)
59+
cvssv3 = proto.Field(proto.MESSAGE, number=3, message="Cvssv3",)
60+
61+
62+
class Reference(proto.Message):
63+
r"""Additional Links
64+
65+
Attributes:
66+
source (str):
67+
Source of the reference e.g. NVD
68+
uri (str):
69+
Uri for the mentioned source e.g.
70+
https://cve.mitre.org/cgi-
71+
bin/cvename.cgi?name=CVE-2021-34527.
72+
"""
73+
74+
source = proto.Field(proto.STRING, number=1,)
75+
uri = proto.Field(proto.STRING, number=2,)
76+
77+
78+
class Cvssv3(proto.Message):
79+
r"""Common Vulnerability Scoring System version 3.
80+
81+
Attributes:
82+
base_score (float):
83+
The base score is a function of the base
84+
metric scores.
85+
attack_vector (google.cloud.securitycenter_v1.types.Cvssv3.AttackVector):
86+
Base Metrics
87+
Represents the intrinsic characteristics of a
88+
vulnerability that are constant over time and
89+
across user environments. This metric reflects
90+
the context by which vulnerability exploitation
91+
is possible.
92+
attack_complexity (google.cloud.securitycenter_v1.types.Cvssv3.AttackComplexity):
93+
This metric describes the conditions beyond
94+
the attacker's control that must exist in order
95+
to exploit the vulnerability.
96+
privileges_required (google.cloud.securitycenter_v1.types.Cvssv3.PrivilegesRequired):
97+
This metric describes the level of privileges
98+
an attacker must possess before successfully
99+
exploiting the vulnerability.
100+
user_interaction (google.cloud.securitycenter_v1.types.Cvssv3.UserInteraction):
101+
This metric captures the requirement for a
102+
human user, other than the attacker, to
103+
participate in the successful compromise of the
104+
vulnerable component.
105+
scope (google.cloud.securitycenter_v1.types.Cvssv3.Scope):
106+
The Scope metric captures whether a
107+
vulnerability in one vulnerable component
108+
impacts resources in components beyond its
109+
security scope.
110+
confidentiality_impact (google.cloud.securitycenter_v1.types.Cvssv3.Impact):
111+
This metric measures the impact to the
112+
confidentiality of the information resources
113+
managed by a software component due to a
114+
successfully exploited vulnerability.
115+
integrity_impact (google.cloud.securitycenter_v1.types.Cvssv3.Impact):
116+
This metric measures the impact to integrity
117+
of a successfully exploited vulnerability.
118+
availability_impact (google.cloud.securitycenter_v1.types.Cvssv3.Impact):
119+
This metric measures the impact to the
120+
availability of the impacted component resulting
121+
from a successfully exploited vulnerability.
122+
"""
123+
124+
class AttackVector(proto.Enum):
125+
r"""This metric reflects the context by which vulnerability
126+
exploitation is possible.
127+
"""
128+
ATTACK_VECTOR_UNSPECIFIED = 0
129+
ATTACK_VECTOR_NETWORK = 1
130+
ATTACK_VECTOR_ADJACENT = 2
131+
ATTACK_VECTOR_LOCAL = 3
132+
ATTACK_VECTOR_PHYSICAL = 4
133+
134+
class AttackComplexity(proto.Enum):
135+
r"""This metric describes the conditions beyond the attacker's
136+
control that must exist in order to exploit the vulnerability.
137+
"""
138+
ATTACK_COMPLEXITY_UNSPECIFIED = 0
139+
ATTACK_COMPLEXITY_LOW = 1
140+
ATTACK_COMPLEXITY_HIGH = 2
141+
142+
class PrivilegesRequired(proto.Enum):
143+
r"""This metric describes the level of privileges an attacker
144+
must possess before successfully exploiting the vulnerability.
145+
"""
146+
PRIVILEGES_REQUIRED_UNSPECIFIED = 0
147+
PRIVILEGES_REQUIRED_NONE = 1
148+
PRIVILEGES_REQUIRED_LOW = 2
149+
PRIVILEGES_REQUIRED_HIGH = 3
150+
151+
class UserInteraction(proto.Enum):
152+
r"""This metric captures the requirement for a human user, other
153+
than the attacker, to participate in the successful compromise
154+
of the vulnerable component.
155+
"""
156+
USER_INTERACTION_UNSPECIFIED = 0
157+
USER_INTERACTION_NONE = 1
158+
USER_INTERACTION_REQUIRED = 2
159+
160+
class Scope(proto.Enum):
161+
r"""The Scope metric captures whether a vulnerability in one
162+
vulnerable component impacts resources in components beyond its
163+
security scope.
164+
"""
165+
SCOPE_UNSPECIFIED = 0
166+
SCOPE_UNCHANGED = 1
167+
SCOPE_CHANGED = 2
168+
169+
class Impact(proto.Enum):
170+
r"""The Impact metrics capture the effects of a successfully
171+
exploited vulnerability on the component that suffers the worst
172+
outcome that is most directly and predictably associated with
173+
the attack.
174+
"""
175+
IMPACT_UNSPECIFIED = 0
176+
IMPACT_HIGH = 1
177+
IMPACT_LOW = 2
178+
IMPACT_NONE = 3
179+
180+
base_score = proto.Field(proto.DOUBLE, number=1,)
181+
attack_vector = proto.Field(proto.ENUM, number=5, enum=AttackVector,)
182+
attack_complexity = proto.Field(proto.ENUM, number=6, enum=AttackComplexity,)
183+
privileges_required = proto.Field(proto.ENUM, number=7, enum=PrivilegesRequired,)
184+
user_interaction = proto.Field(proto.ENUM, number=8, enum=UserInteraction,)
185+
scope = proto.Field(proto.ENUM, number=9, enum=Scope,)
186+
confidentiality_impact = proto.Field(proto.ENUM, number=10, enum=Impact,)
187+
integrity_impact = proto.Field(proto.ENUM, number=11, enum=Impact,)
188+
availability_impact = proto.Field(proto.ENUM, number=12, enum=Impact,)
189+
190+
191+
__all__ = tuple(sorted(__protobuf__.manifest))

tests/unit/gapic/securitycenter_v1/test_security_center.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
from google.cloud.securitycenter_v1.types import securitycenter_service
6262
from google.cloud.securitycenter_v1.types import source
6363
from google.cloud.securitycenter_v1.types import source as gcs_source
64+
from google.cloud.securitycenter_v1.types import vulnerability
6465
from google.iam.v1 import iam_policy_pb2 # type: ignore
6566
from google.iam.v1 import options_pb2 # type: ignore
6667
from google.iam.v1 import policy_pb2 # type: ignore

0 commit comments

Comments
 (0)