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

Commit 4af011d

Browse files
feat: add finding_class and indicator fields in Finding (#201)
finding_class field is added in order to help our customer to quickly identify and categorize the different findings (threat, vulnerability, misconfiguration, ...). And indicator field is generated to indicate the domain and IP addresses that is causing the threat. PiperOrigin-RevId: 386975549 Source-Link: googleapis/googleapis@5bf36f2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b9ab677eb147fbf3eb3b1d501f90b9d3f8078872
1 parent a00be7c commit 4af011d

8 files changed

Lines changed: 83 additions & 0 deletions

File tree

google/cloud/securitycenter/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from google.cloud.securitycenter_v1.types.asset import Asset
2525
from google.cloud.securitycenter_v1.types.finding import Finding
2626
from google.cloud.securitycenter_v1.types.folder import Folder
27+
from google.cloud.securitycenter_v1.types.indicator import Indicator
2728
from google.cloud.securitycenter_v1.types.notification_config import NotificationConfig
2829
from google.cloud.securitycenter_v1.types.notification_message import (
2930
NotificationMessage,
@@ -121,6 +122,7 @@
121122
"Asset",
122123
"Finding",
123124
"Folder",
125+
"Indicator",
124126
"NotificationConfig",
125127
"NotificationMessage",
126128
"OrganizationSettings",

google/cloud/securitycenter_v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .types.asset import Asset
2121
from .types.finding import Finding
2222
from .types.folder import Folder
23+
from .types.indicator import Indicator
2324
from .types.notification_config import NotificationConfig
2425
from .types.notification_message import NotificationMessage
2526
from .types.organization_settings import OrganizationSettings
@@ -72,6 +73,7 @@
7273
"GroupFindingsRequest",
7374
"GroupFindingsResponse",
7475
"GroupResult",
76+
"Indicator",
7577
"ListAssetsRequest",
7678
"ListAssetsResponse",
7779
"ListFindingsRequest",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from google.cloud.securitycenter_v1.services.security_center import pagers
3232
from google.cloud.securitycenter_v1.types import finding
3333
from google.cloud.securitycenter_v1.types import finding as gcs_finding
34+
from google.cloud.securitycenter_v1.types import indicator
3435
from google.cloud.securitycenter_v1.types import notification_config
3536
from google.cloud.securitycenter_v1.types import (
3637
notification_config as gcs_notification_config,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from google.cloud.securitycenter_v1.services.security_center import pagers
3636
from google.cloud.securitycenter_v1.types import finding
3737
from google.cloud.securitycenter_v1.types import finding as gcs_finding
38+
from google.cloud.securitycenter_v1.types import indicator
3839
from google.cloud.securitycenter_v1.types import notification_config
3940
from google.cloud.securitycenter_v1.types import (
4041
notification_config as gcs_notification_config,

google/cloud/securitycenter_v1/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .asset import Asset
1717
from .finding import Finding
1818
from .folder import Folder
19+
from .indicator import Indicator
1920
from .notification_config import NotificationConfig
2021
from .notification_message import NotificationMessage
2122
from .organization_settings import OrganizationSettings
@@ -57,6 +58,7 @@
5758
"Asset",
5859
"Finding",
5960
"Folder",
61+
"Indicator",
6062
"NotificationConfig",
6163
"NotificationMessage",
6264
"OrganizationSettings",

google/cloud/securitycenter_v1/types/finding.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616
import proto # type: ignore
1717

18+
from google.cloud.securitycenter_v1.types import indicator as gcs_indicator
1819
from google.cloud.securitycenter_v1.types import security_marks as gcs_security_marks
1920
from google.protobuf import struct_pb2 # type: ignore
2021
from google.protobuf import timestamp_pb2 # type: ignore
@@ -100,6 +101,14 @@ class Finding(proto.Message):
100101
"projects/{project_number}/sources/{source_id}/findings/{finding_id}",
101102
depending on the closest CRM ancestor of the resource
102103
associated with the finding.
104+
finding_class (google.cloud.securitycenter_v1.types.Finding.FindingClass):
105+
The class of the finding.
106+
indicator (google.cloud.securitycenter_v1.types.Indicator):
107+
Represents what's commonly known as an Indicator of
108+
compromise (IoC) in computer forensics. This is an artifact
109+
observed on a network or in an operating system that, with
110+
high confidence, indicates a computer intrusion. Reference:
111+
https://en.wikipedia.org/wiki/Indicator_of_compromise
103112
"""
104113

105114
class State(proto.Enum):
@@ -116,6 +125,14 @@ class Severity(proto.Enum):
116125
MEDIUM = 3
117126
LOW = 4
118127

128+
class FindingClass(proto.Enum):
129+
r"""Represents what kind of Finding it is."""
130+
FINDING_CLASS_UNSPECIFIED = 0
131+
THREAT = 1
132+
VULNERABILITY = 2
133+
MISCONFIGURATION = 3
134+
OBSERVATION = 4
135+
119136
name = proto.Field(proto.STRING, number=1,)
120137
parent = proto.Field(proto.STRING, number=2,)
121138
resource_name = proto.Field(proto.STRING, number=3,)
@@ -134,6 +151,8 @@ class Severity(proto.Enum):
134151
)
135152
severity = proto.Field(proto.ENUM, number=12, enum=Severity,)
136153
canonical_name = proto.Field(proto.STRING, number=14,)
154+
finding_class = proto.Field(proto.ENUM, number=17, enum=FindingClass,)
155+
indicator = proto.Field(proto.MESSAGE, number=18, message=gcs_indicator.Indicator,)
137156

138157

139158
__all__ = tuple(sorted(__protobuf__.manifest))
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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", manifest={"Indicator",},
21+
)
22+
23+
24+
class Indicator(proto.Message):
25+
r"""Represents what's commonly known as an Indicator of compromise (IoC)
26+
in computer forensics. This is an artifact observed on a network or
27+
in an operating system that, with high confidence, indicates a
28+
computer intrusion. Reference:
29+
https://en.wikipedia.org/wiki/Indicator_of_compromise
30+
31+
Attributes:
32+
ip_addresses (Sequence[str]):
33+
List of ip addresses associated to the
34+
Finding.
35+
domains (Sequence[str]):
36+
List of domains associated to the Finding.
37+
"""
38+
39+
ip_addresses = proto.RepeatedField(proto.STRING, number=1,)
40+
domains = proto.RepeatedField(proto.STRING, number=2,)
41+
42+
43+
__all__ = tuple(sorted(__protobuf__.manifest))

tests/unit/gapic/securitycenter_v1/test_security_center.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
)
4646
from google.cloud.securitycenter_v1.types import finding
4747
from google.cloud.securitycenter_v1.types import finding as gcs_finding
48+
from google.cloud.securitycenter_v1.types import indicator
4849
from google.cloud.securitycenter_v1.types import notification_config
4950
from google.cloud.securitycenter_v1.types import (
5051
notification_config as gcs_notification_config,
@@ -771,6 +772,7 @@ def test_create_finding(
771772
external_uri="external_uri_value",
772773
severity=gcs_finding.Finding.Severity.CRITICAL,
773774
canonical_name="canonical_name_value",
775+
finding_class=gcs_finding.Finding.FindingClass.THREAT,
774776
)
775777
response = client.create_finding(request)
776778

@@ -789,6 +791,7 @@ def test_create_finding(
789791
assert response.external_uri == "external_uri_value"
790792
assert response.severity == gcs_finding.Finding.Severity.CRITICAL
791793
assert response.canonical_name == "canonical_name_value"
794+
assert response.finding_class == gcs_finding.Finding.FindingClass.THREAT
792795

793796

794797
def test_create_finding_from_dict():
@@ -836,6 +839,7 @@ async def test_create_finding_async(
836839
external_uri="external_uri_value",
837840
severity=gcs_finding.Finding.Severity.CRITICAL,
838841
canonical_name="canonical_name_value",
842+
finding_class=gcs_finding.Finding.FindingClass.THREAT,
839843
)
840844
)
841845
response = await client.create_finding(request)
@@ -855,6 +859,7 @@ async def test_create_finding_async(
855859
assert response.external_uri == "external_uri_value"
856860
assert response.severity == gcs_finding.Finding.Severity.CRITICAL
857861
assert response.canonical_name == "canonical_name_value"
862+
assert response.finding_class == gcs_finding.Finding.FindingClass.THREAT
858863

859864

860865
@pytest.mark.asyncio
@@ -4667,6 +4672,7 @@ def test_set_finding_state(
46674672
external_uri="external_uri_value",
46684673
severity=finding.Finding.Severity.CRITICAL,
46694674
canonical_name="canonical_name_value",
4675+
finding_class=finding.Finding.FindingClass.THREAT,
46704676
)
46714677
response = client.set_finding_state(request)
46724678

@@ -4685,6 +4691,7 @@ def test_set_finding_state(
46854691
assert response.external_uri == "external_uri_value"
46864692
assert response.severity == finding.Finding.Severity.CRITICAL
46874693
assert response.canonical_name == "canonical_name_value"
4694+
assert response.finding_class == finding.Finding.FindingClass.THREAT
46884695

46894696

46904697
def test_set_finding_state_from_dict():
@@ -4736,6 +4743,7 @@ async def test_set_finding_state_async(
47364743
external_uri="external_uri_value",
47374744
severity=finding.Finding.Severity.CRITICAL,
47384745
canonical_name="canonical_name_value",
4746+
finding_class=finding.Finding.FindingClass.THREAT,
47394747
)
47404748
)
47414749
response = await client.set_finding_state(request)
@@ -4755,6 +4763,7 @@ async def test_set_finding_state_async(
47554763
assert response.external_uri == "external_uri_value"
47564764
assert response.severity == finding.Finding.Severity.CRITICAL
47574765
assert response.canonical_name == "canonical_name_value"
4766+
assert response.finding_class == finding.Finding.FindingClass.THREAT
47584767

47594768

47604769
@pytest.mark.asyncio
@@ -5395,6 +5404,7 @@ def test_update_finding(
53955404
external_uri="external_uri_value",
53965405
severity=gcs_finding.Finding.Severity.CRITICAL,
53975406
canonical_name="canonical_name_value",
5407+
finding_class=gcs_finding.Finding.FindingClass.THREAT,
53985408
)
53995409
response = client.update_finding(request)
54005410

@@ -5413,6 +5423,7 @@ def test_update_finding(
54135423
assert response.external_uri == "external_uri_value"
54145424
assert response.severity == gcs_finding.Finding.Severity.CRITICAL
54155425
assert response.canonical_name == "canonical_name_value"
5426+
assert response.finding_class == gcs_finding.Finding.FindingClass.THREAT
54165427

54175428

54185429
def test_update_finding_from_dict():
@@ -5460,6 +5471,7 @@ async def test_update_finding_async(
54605471
external_uri="external_uri_value",
54615472
severity=gcs_finding.Finding.Severity.CRITICAL,
54625473
canonical_name="canonical_name_value",
5474+
finding_class=gcs_finding.Finding.FindingClass.THREAT,
54635475
)
54645476
)
54655477
response = await client.update_finding(request)
@@ -5479,6 +5491,7 @@ async def test_update_finding_async(
54795491
assert response.external_uri == "external_uri_value"
54805492
assert response.severity == gcs_finding.Finding.Severity.CRITICAL
54815493
assert response.canonical_name == "canonical_name_value"
5494+
assert response.finding_class == gcs_finding.Finding.FindingClass.THREAT
54825495

54835496

54845497
@pytest.mark.asyncio

0 commit comments

Comments
 (0)