Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add included_keyword_configuration field to SDS rule #1824

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-01-05 15:09:31.771541",
"spec_repo_commit": "9cbf6566"
"regenerated": "2024-01-05 16:07:37.284367",
"spec_repo_commit": "bafcada7"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-01-05 15:09:31.789729",
"spec_repo_commit": "9cbf6566"
"regenerated": "2024-01-05 16:07:37.299570",
"spec_repo_commit": "bafcada7"
}
}
}
40 changes: 40 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16878,6 +16878,44 @@ components:
meta:
$ref: '#/components/schemas/SensitiveDataScannerMetaVersionOnly'
type: object
SensitiveDataScannerIncludedKeywordConfiguration:
description: 'Object defining a set of keywords and a number of characters that
help reduce noise.

You can provide a list of keywords you would like to check within a defined
proximity of the matching pattern.

If any of the keywords are found within the proximity check, the match is
kept.

If none are found, the match is discarded.'
properties:
character_count:
description: 'The number of characters behind a match detected by Sensitive
Data Scanner to look for the keywords defined.

`character_count` should be greater than the maximum length of a keyword
defined for a rule.'
example: 30
format: int64
maximum: 50
minimum: 1
type: integer
keywords:
description: 'Keyword list that will be checked during scanning in order
to validate a match.

The number of keywords in the list must be less than or equal to 20.'
example:
- credit card
- cc
items:
type: string
type: array
required:
- keywords
- character_count
type: object
SensitiveDataScannerMeta:
description: Meta response containing information about the API.
properties:
Expand Down Expand Up @@ -16971,6 +17009,8 @@ components:
items:
type: string
type: array
included_keyword_configuration:
$ref: '#/components/schemas/SensitiveDataScannerIncludedKeywordConfiguration'
is_enabled:
description: Whether or not the rule is enabled.
type: boolean
Expand Down
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7554,6 +7554,13 @@ sensitive\_data\_scanner\_group\_update\_response
:members:
:show-inheritance:

sensitive\_data\_scanner\_included\_keyword\_configuration
----------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.sensitive_data_scanner_included_keyword_configuration
:members:
:show-inheritance:

sensitive\_data\_scanner\_meta
------------------------------

Expand Down
9 changes: 9 additions & 0 deletions examples/v2/sensitive-data-scanner/CreateScanningRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from datadog_api_client.v2.model.sensitive_data_scanner_group import SensitiveDataScannerGroup
from datadog_api_client.v2.model.sensitive_data_scanner_group_data import SensitiveDataScannerGroupData
from datadog_api_client.v2.model.sensitive_data_scanner_group_type import SensitiveDataScannerGroupType
from datadog_api_client.v2.model.sensitive_data_scanner_included_keyword_configuration import (
SensitiveDataScannerIncludedKeywordConfiguration,
)
from datadog_api_client.v2.model.sensitive_data_scanner_meta_version_only import SensitiveDataScannerMetaVersionOnly
from datadog_api_client.v2.model.sensitive_data_scanner_rule_attributes import SensitiveDataScannerRuleAttributes
from datadog_api_client.v2.model.sensitive_data_scanner_rule_create import SensitiveDataScannerRuleCreate
Expand Down Expand Up @@ -43,6 +46,12 @@
],
is_enabled=True,
priority=1,
included_keyword_configuration=SensitiveDataScannerIncludedKeywordConfiguration(
keywords=[
"credit card",
],
character_count=35,
),
),
relationships=SensitiveDataScannerRuleRelationships(
group=SensitiveDataScannerGroupData(
Expand Down
23 changes: 9 additions & 14 deletions examples/v2/sensitive-data-scanner/UpdateScanningRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.sensitive_data_scanner_api import SensitiveDataScannerApi
from datadog_api_client.v2.model.sensitive_data_scanner_group import SensitiveDataScannerGroup
from datadog_api_client.v2.model.sensitive_data_scanner_group_data import SensitiveDataScannerGroupData
from datadog_api_client.v2.model.sensitive_data_scanner_group_type import SensitiveDataScannerGroupType
from datadog_api_client.v2.model.sensitive_data_scanner_included_keyword_configuration import (
SensitiveDataScannerIncludedKeywordConfiguration,
)
from datadog_api_client.v2.model.sensitive_data_scanner_meta_version_only import SensitiveDataScannerMetaVersionOnly
from datadog_api_client.v2.model.sensitive_data_scanner_rule_attributes import SensitiveDataScannerRuleAttributes
from datadog_api_client.v2.model.sensitive_data_scanner_rule_relationships import SensitiveDataScannerRuleRelationships
from datadog_api_client.v2.model.sensitive_data_scanner_rule_type import SensitiveDataScannerRuleType
from datadog_api_client.v2.model.sensitive_data_scanner_rule_update import SensitiveDataScannerRuleUpdate
from datadog_api_client.v2.model.sensitive_data_scanner_rule_update_request import SensitiveDataScannerRuleUpdateRequest
Expand All @@ -22,9 +21,6 @@
# the "scanning_group" has a "scanning_rule"
RULE_DATA_ID = environ["RULE_DATA_ID"]

# there is a valid "scanning_group" in the system
GROUP_DATA_ID = environ["GROUP_DATA_ID"]

body = SensitiveDataScannerRuleUpdateRequest(
meta=SensitiveDataScannerMetaVersionOnly(),
data=SensitiveDataScannerRuleUpdate(
Expand All @@ -41,13 +37,12 @@
],
is_enabled=True,
priority=5,
),
relationships=SensitiveDataScannerRuleRelationships(
group=SensitiveDataScannerGroupData(
data=SensitiveDataScannerGroup(
type=SensitiveDataScannerGroupType.SENSITIVE_DATA_SCANNER_GROUP,
id=GROUP_DATA_ID,
),
included_keyword_configuration=SensitiveDataScannerIncludedKeywordConfiguration(
keywords=[
"credit card",
"cc",
],
character_count=35,
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import List

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


class SensitiveDataScannerIncludedKeywordConfiguration(ModelNormal):
validations = {
"character_count": {
"inclusive_maximum": 50,
"inclusive_minimum": 1,
},
}

@cached_property
def openapi_types(_):
return {
"character_count": (int,),
"keywords": ([str],),
}

attribute_map = {
"character_count": "character_count",
"keywords": "keywords",
}

def __init__(self_, character_count: int, keywords: List[str], **kwargs):
"""
Object defining a set of keywords and a number of characters that help reduce noise.
You can provide a list of keywords you would like to check within a defined proximity of the matching pattern.
If any of the keywords are found within the proximity check, the match is kept.
If none are found, the match is discarded.

:param character_count: The number of characters behind a match detected by Sensitive Data Scanner to look for the keywords defined.
``character_count`` should be greater than the maximum length of a keyword defined for a rule.
:type character_count: int

:param keywords: Keyword list that will be checked during scanning in order to validate a match.
The number of keywords in the list must be less than or equal to 20.
:type keywords: [str]
"""
super().__init__(kwargs)

self_.character_count = character_count
self_.keywords = keywords
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@


if TYPE_CHECKING:
from datadog_api_client.v2.model.sensitive_data_scanner_included_keyword_configuration import (
SensitiveDataScannerIncludedKeywordConfiguration,
)
from datadog_api_client.v2.model.sensitive_data_scanner_text_replacement import SensitiveDataScannerTextReplacement


Expand All @@ -27,13 +30,17 @@ class SensitiveDataScannerRuleAttributes(ModelNormal):

@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.sensitive_data_scanner_included_keyword_configuration import (
SensitiveDataScannerIncludedKeywordConfiguration,
)
from datadog_api_client.v2.model.sensitive_data_scanner_text_replacement import (
SensitiveDataScannerTextReplacement,
)

return {
"description": (str,),
"excluded_namespaces": ([str],),
"included_keyword_configuration": (SensitiveDataScannerIncludedKeywordConfiguration,),
"is_enabled": (bool,),
"name": (str,),
"namespaces": ([str],),
Expand All @@ -46,6 +53,7 @@ def openapi_types(_):
attribute_map = {
"description": "description",
"excluded_namespaces": "excluded_namespaces",
"included_keyword_configuration": "included_keyword_configuration",
"is_enabled": "is_enabled",
"name": "name",
"namespaces": "namespaces",
Expand All @@ -59,6 +67,7 @@ def __init__(
self_,
description: Union[str, UnsetType] = unset,
excluded_namespaces: Union[List[str], UnsetType] = unset,
included_keyword_configuration: Union[SensitiveDataScannerIncludedKeywordConfiguration, UnsetType] = unset,
is_enabled: Union[bool, UnsetType] = unset,
name: Union[str, UnsetType] = unset,
namespaces: Union[List[str], UnsetType] = unset,
Expand All @@ -77,6 +86,12 @@ def __init__(
:param excluded_namespaces: Attributes excluded from the scan. If namespaces is provided, it has to be a sub-path of the namespaces array.
:type excluded_namespaces: [str], optional

:param included_keyword_configuration: Object defining a set of keywords and a number of characters that help reduce noise.
You can provide a list of keywords you would like to check within a defined proximity of the matching pattern.
If any of the keywords are found within the proximity check, the match is kept.
If none are found, the match is discarded.
:type included_keyword_configuration: SensitiveDataScannerIncludedKeywordConfiguration, optional

:param is_enabled: Whether or not the rule is enabled.
:type is_enabled: bool, optional

Expand All @@ -103,6 +118,8 @@ def __init__(
kwargs["description"] = description
if excluded_namespaces is not unset:
kwargs["excluded_namespaces"] = excluded_namespaces
if included_keyword_configuration is not unset:
kwargs["included_keyword_configuration"] = included_keyword_configuration
if is_enabled is not unset:
kwargs["is_enabled"] = is_enabled
if name is not unset:
Expand Down
4 changes: 4 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,9 @@
from datadog_api_client.v2.model.sensitive_data_scanner_group_update_response import (
SensitiveDataScannerGroupUpdateResponse,
)
from datadog_api_client.v2.model.sensitive_data_scanner_included_keyword_configuration import (
SensitiveDataScannerIncludedKeywordConfiguration,
)
from datadog_api_client.v2.model.sensitive_data_scanner_meta import SensitiveDataScannerMeta
from datadog_api_client.v2.model.sensitive_data_scanner_meta_version_only import SensitiveDataScannerMetaVersionOnly
from datadog_api_client.v2.model.sensitive_data_scanner_product import SensitiveDataScannerProduct
Expand Down Expand Up @@ -2649,6 +2652,7 @@
"SensitiveDataScannerGroupUpdate",
"SensitiveDataScannerGroupUpdateRequest",
"SensitiveDataScannerGroupUpdateResponse",
"SensitiveDataScannerIncludedKeywordConfiguration",
"SensitiveDataScannerMeta",
"SensitiveDataScannerMetaVersionOnly",
"SensitiveDataScannerProduct",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-12-13T09:06:38.820Z
2024-01-04T13:51:03.802Z
Loading
Loading