diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e1ccda720e..c354fca49e 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1314,6 +1314,67 @@ components: required: true schema: type: string + RuleBasedViewFramework: + description: Compliance framework handle to filter rules and findings by. + in: query + name: framework + required: false + schema: + default: "" + example: hipaa + type: string + RuleBasedViewIncludeRulesWithoutFindings: + description: When `true`, includes rules in the response that have no associated findings. + in: query + name: include_rules_without_findings + required: false + schema: + default: false + example: false + type: boolean + RuleBasedViewIsCustom: + description: Set to `true` when the requested `framework` is a custom framework. + in: query + name: is_custom + required: false + schema: + example: false + type: boolean + RuleBasedViewQuery: + description: Additional event-platform filters applied to the underlying findings query. For example, `scored:true project_id:datadog-prod-us5`. + in: query + name: query + required: false + schema: + default: "" + example: scored:true + type: string + RuleBasedViewQueryFindingsWithoutFrameworkVersion: + description: When `true`, returns findings without a `framework_version` tag. Used for findings from custom frameworks or those created before framework versioning was introduced. + in: query + name: query_findings_without_framework_version + required: false + schema: + default: false + example: false + type: boolean + RuleBasedViewTo: + description: Timestamp of the query end, in milliseconds since the Unix epoch. + in: query + name: to + required: true + schema: + example: 1739982278000 + format: int64 + type: integer + RuleBasedViewVersion: + description: Version of the compliance framework to filter rules and findings by. + in: query + name: version + required: false + schema: + example: "1" + type: string RuleId: description: The ID of the rule. in: path @@ -60636,6 +60697,194 @@ components: example: Deployments automated via Deployment Trains type: string type: object + RuleBasedViewAttributes: + description: Attributes of the rule-based view. + properties: + count: + description: Total number of rules in the view. + example: 1 + format: int64 + type: integer + rules: + $ref: "#/components/schemas/RuleBasedViewRules" + required: + - count + - rules + type: object + RuleBasedViewComplianceFramework: + description: Compliance framework mapping for a rule. + properties: + control: + description: Identifier of the control inside the requirement. + example: 164.308-a-4-i + type: string + framework: + description: Handle of the compliance framework. + example: hipaa + type: string + is_default: + description: Whether the framework is a Datadog default framework. `true` indicates a Datadog framework and `false` indicates a custom framework. + example: true + type: boolean + message: + description: Optional message describing the framework mapping for the rule. + example: "" + type: string + requirement: + description: Name of the requirement that contains the control. + example: Information-Access-Management + type: string + version: + description: Version of the compliance framework. + example: "1" + type: string + type: object + RuleBasedViewComplianceFrameworks: + description: List of compliance framework mappings associated with the rule. + items: + $ref: "#/components/schemas/RuleBasedViewComplianceFramework" + type: array + RuleBasedViewData: + description: Data envelope for the rule-based view response. + properties: + attributes: + $ref: "#/components/schemas/RuleBasedViewAttributes" + id: + description: Unique identifier of the rule-based view document. + example: JSONAPI_USELESS_ID + type: string + type: + $ref: "#/components/schemas/RuleBasedViewType" + required: + - attributes + - id + - type + type: object + RuleBasedViewResourceAttributes: + description: List of resource attribute names exposed by the rule. + example: + - instance_id + items: + description: Name of a resource attribute exposed by the rule. + example: instance_id + type: string + type: array + RuleBasedViewResponse: + description: Response containing an aggregated view of compliance rules with their finding statistics. + properties: + data: + $ref: "#/components/schemas/RuleBasedViewData" + required: + - data + type: object + RuleBasedViewRule: + description: A compliance rule along with its evaluation statistics and framework mappings. + properties: + compliance_frameworks: + $ref: "#/components/schemas/RuleBasedViewComplianceFrameworks" + enabled: + description: Whether the rule is enabled. + example: true + type: boolean + id: + description: Unique identifier of the rule. + example: qjx-udx-xo8 + type: string + name: + description: Human-readable name of the rule. + example: IAM roles should not allow untrusted GitHub Actions to assume them + type: string + resourceAttributes: + $ref: "#/components/schemas/RuleBasedViewResourceAttributes" + resourceCategory: + description: Resource category targeted by the rule. + example: identity + type: string + resourceType: + description: Resource type targeted by the rule. + example: aws_iam_role + type: string + stats: + $ref: "#/components/schemas/RuleBasedViewRuleStats" + status: + description: Severity associated with the rule (for example, `info`, `low`, `medium`, `high`, or `critical`). + example: critical + type: string + tags: + $ref: "#/components/schemas/RuleBasedViewRuleTags" + type: + $ref: "#/components/schemas/RuleBasedViewRuleCategory" + required: + - compliance_frameworks + - enabled + - id + - name + - resourceAttributes + - resourceCategory + - resourceType + - stats + - status + - tags + - type + type: object + RuleBasedViewRuleCategory: + description: The category of the security rule. + enum: + - cloud_configuration + - infrastructure_configuration + - api_security + example: cloud_configuration + type: string + x-enum-varnames: + - CLOUD_CONFIGURATION + - INFRASTRUCTURE_CONFIGURATION + - API_SECURITY + RuleBasedViewRuleStats: + description: Counts of findings for the rule, grouped by their evaluation status. + properties: + fail: + description: Number of findings that failed evaluation. + example: 0 + format: int64 + type: integer + muted: + description: Number of findings that have been muted. + example: 0 + format: int64 + type: integer + pass: + description: Number of findings that passed evaluation. + example: 3 + format: int64 + type: integer + required: + - fail + - pass + - muted + type: object + RuleBasedViewRuleTags: + description: List of tags attached to the rule. + example: + - security:compliance + items: + description: A tag attached to the rule. + example: security:compliance + type: string + type: array + RuleBasedViewRules: + description: List of rules in the rule-based view. + items: + $ref: "#/components/schemas/RuleBasedViewRule" + type: array + RuleBasedViewType: + default: rule_based_view + description: The type of the resource. The value should always be `rule_based_view`. + enum: + - rule_based_view + example: rule_based_view + type: string + x-enum-varnames: + - RULE_BASED_VIEW RuleId: description: The unique ID for a scorecard rule. example: q8MQxk8TCqrHnWkx @@ -95228,6 +95477,89 @@ paths: x-unstable: |- **Note**: This endpoint is in preview and may be subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/compliance_findings/rule_based_view: + get: + description: |- + Get an aggregated view of compliance rules with their pass, fail, and muted finding counts. + Supports filtering by compliance framework, framework version, and additional query filters. + operationId: GetRuleBasedView + parameters: + - $ref: "#/components/parameters/RuleBasedViewTo" + - $ref: "#/components/parameters/RuleBasedViewFramework" + - $ref: "#/components/parameters/RuleBasedViewVersion" + - $ref: "#/components/parameters/RuleBasedViewQueryFindingsWithoutFrameworkVersion" + - $ref: "#/components/parameters/RuleBasedViewIncludeRulesWithoutFindings" + - $ref: "#/components/parameters/RuleBasedViewIsCustom" + - $ref: "#/components/parameters/RuleBasedViewQuery" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + count: 1 + rules: + - compliance_frameworks: + - control: 164.308-a-4-i + framework: hipaa + is_default: true + message: "" + requirement: Information-Access-Management + version: "1" + enabled: true + id: qjx-udx-xo8 + name: IAM roles should not allow untrusted GitHub Actions to assume them + resourceAttributes: [] + resourceCategory: identity + resourceType: aws_iam_role + stats: + fail: 0 + muted: 0 + pass: 3 + status: critical + tags: + - security:compliance + - cloud_provider:aws + - framework:hipaa + type: cloud_configuration + id: JSONAPI_USELESS_ID + type: rule_based_view + schema: + $ref: "#/components/schemas/RuleBasedViewResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + "503": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Service Unavailable + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_findings_read + summary: Get the rule-based view of compliance findings + tags: ["Compliance"] + "x-permission": + operator: OR + permissions: + - security_monitoring_findings_read + x-unstable: |- + **Note**: This endpoint is in Preview and subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/container_images: get: description: |- @@ -147630,6 +147962,12 @@ tags: - description: |- Retrieve and analyze code coverage data from Code Coverage. See the [Code Coverage page](https://docs.datadoghq.com/code_coverage/) for more information. name: Code Coverage + - description: |- + Datadog Cloud Security Misconfigurations provides aggregated views of + compliance rules and findings across your cloud resources, helping you assess + posture against industry frameworks (such as HIPAA, SOC 2, ISO 27001) and custom + frameworks. Learn more at https://docs.datadoghq.com/security/cloud_security_management/misconfigurations/#maintain-compliance-with-industry-frameworks-and-benchmarks. + name: "Compliance" - description: |- Manage your Datadog Confluent Cloud integration accounts and account resources directly through the Datadog API. See the [Confluent Cloud page](https://docs.datadoghq.com/integrations/confluent_cloud/) for more information. name: Confluent Cloud diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index 93c6d5cc38..30408e92c7 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -172,6 +172,13 @@ datadog\_api\_client.v2.api.code\_coverage\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.compliance\_api module +-------------------------------------------------- + +.. automodule:: datadog_api_client.v2.api.compliance_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.confluent\_cloud\_api module -------------------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 844143f1c7..2d2220ae49 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -26499,6 +26499,62 @@ datadog\_api\_client.v2.model.rule\_attributes\_request module :members: :show-inheritance: +datadog\_api\_client.v2.model.rule\_based\_view\_attributes module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.rule_based_view_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.rule\_based\_view\_compliance\_framework module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.rule_based_view_compliance_framework + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.rule\_based\_view\_data module +------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.rule_based_view_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.rule\_based\_view\_response module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.rule_based_view_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.rule\_based\_view\_rule module +------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.rule_based_view_rule + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.rule\_based\_view\_rule\_category module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.rule_based_view_rule_category + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.rule\_based\_view\_rule\_stats module +------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.rule_based_view_rule_stats + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.rule\_based\_view\_type module +------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.rule_based_view_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.rule\_outcome\_relationships module ----------------------------------------------------------------- diff --git a/examples/v2/compliance/GetRuleBasedView.py b/examples/v2/compliance/GetRuleBasedView.py new file mode 100644 index 0000000000..a265179b7a --- /dev/null +++ b/examples/v2/compliance/GetRuleBasedView.py @@ -0,0 +1,16 @@ +""" +Get the rule-based view of compliance findings returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.compliance_api import ComplianceApi + +configuration = Configuration() +configuration.unstable_operations["get_rule_based_view"] = True +with ApiClient(configuration) as api_client: + api_instance = ComplianceApi(api_client) + response = api_instance.get_rule_based_view( + to=1739982278000, + ) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 7c21ae2cee..a52b51f05e 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -351,6 +351,7 @@ def __init__( "v2.search_security_monitoring_histsignals": False, "v2.get_code_coverage_branch_summary": False, "v2.get_code_coverage_commit_summary": False, + "v2.get_rule_based_view": False, "v2.get_cost_anomaly": False, "v2.list_cost_anomalies": False, "v2.create_dashboard_secure_embed": False, diff --git a/src/datadog_api_client/v2/api/compliance_api.py b/src/datadog_api_client/v2/api/compliance_api.py new file mode 100644 index 0000000000..5887e3d59d --- /dev/null +++ b/src/datadog_api_client/v2/api/compliance_api.py @@ -0,0 +1,136 @@ +# 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 Any, Dict, Union + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.model_utils import ( + UnsetType, + unset, +) +from datadog_api_client.v2.model.rule_based_view_response import RuleBasedViewResponse + + +class ComplianceApi: + """ + Datadog Cloud Security Misconfigurations provides aggregated views of + compliance rules and findings across your cloud resources, helping you assess + posture against industry frameworks (such as HIPAA, SOC 2, ISO 27001) and custom + frameworks. Learn more at https://docs.datadoghq.com/security/cloud_security_management/misconfigurations/#maintain-compliance-with-industry-frameworks-and-benchmarks. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._get_rule_based_view_endpoint = _Endpoint( + settings={ + "response_type": (RuleBasedViewResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/compliance_findings/rule_based_view", + "operation_id": "get_rule_based_view", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "to": { + "required": True, + "openapi_types": (int,), + "attribute": "to", + "location": "query", + }, + "framework": { + "openapi_types": (str,), + "attribute": "framework", + "location": "query", + }, + "version": { + "openapi_types": (str,), + "attribute": "version", + "location": "query", + }, + "query_findings_without_framework_version": { + "openapi_types": (bool,), + "attribute": "query_findings_without_framework_version", + "location": "query", + }, + "include_rules_without_findings": { + "openapi_types": (bool,), + "attribute": "include_rules_without_findings", + "location": "query", + }, + "is_custom": { + "openapi_types": (bool,), + "attribute": "is_custom", + "location": "query", + }, + "query": { + "openapi_types": (str,), + "attribute": "query", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + def get_rule_based_view( + self, + to: int, + *, + framework: Union[str, UnsetType] = unset, + version: Union[str, UnsetType] = unset, + query_findings_without_framework_version: Union[bool, UnsetType] = unset, + include_rules_without_findings: Union[bool, UnsetType] = unset, + is_custom: Union[bool, UnsetType] = unset, + query: Union[str, UnsetType] = unset, + ) -> RuleBasedViewResponse: + """Get the rule-based view of compliance findings. + + Get an aggregated view of compliance rules with their pass, fail, and muted finding counts. + Supports filtering by compliance framework, framework version, and additional query filters. + + :param to: Timestamp of the query end, in milliseconds since the Unix epoch. + :type to: int + :param framework: Compliance framework handle to filter rules and findings by. + :type framework: str, optional + :param version: Version of the compliance framework to filter rules and findings by. + :type version: str, optional + :param query_findings_without_framework_version: When ``true`` , returns findings without a ``framework_version`` tag. Used for findings from custom frameworks or those created before framework versioning was introduced. + :type query_findings_without_framework_version: bool, optional + :param include_rules_without_findings: When ``true`` , includes rules in the response that have no associated findings. + :type include_rules_without_findings: bool, optional + :param is_custom: Set to ``true`` when the requested ``framework`` is a custom framework. + :type is_custom: bool, optional + :param query: Additional event-platform filters applied to the underlying findings query. For example, ``scored:true project_id:datadog-prod-us5``. + :type query: str, optional + :rtype: RuleBasedViewResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["to"] = to + + if framework is not unset: + kwargs["framework"] = framework + + if version is not unset: + kwargs["version"] = version + + if query_findings_without_framework_version is not unset: + kwargs["query_findings_without_framework_version"] = query_findings_without_framework_version + + if include_rules_without_findings is not unset: + kwargs["include_rules_without_findings"] = include_rules_without_findings + + if is_custom is not unset: + kwargs["is_custom"] = is_custom + + if query is not unset: + kwargs["query"] = query + + return self._get_rule_based_view_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index a7ece1406f..472aa45fc7 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -25,6 +25,7 @@ from datadog_api_client.v2.api.cloud_network_monitoring_api import CloudNetworkMonitoringApi from datadog_api_client.v2.api.cloudflare_integration_api import CloudflareIntegrationApi from datadog_api_client.v2.api.code_coverage_api import CodeCoverageApi +from datadog_api_client.v2.api.compliance_api import ComplianceApi from datadog_api_client.v2.api.confluent_cloud_api import ConfluentCloudApi from datadog_api_client.v2.api.container_images_api import ContainerImagesApi from datadog_api_client.v2.api.containers_api import ContainersApi @@ -137,6 +138,7 @@ "CloudNetworkMonitoringApi", "CloudflareIntegrationApi", "CodeCoverageApi", + "ComplianceApi", "ConfluentCloudApi", "ContainerImagesApi", "ContainersApi", diff --git a/src/datadog_api_client/v2/model/rule_based_view_attributes.py b/src/datadog_api_client/v2/model/rule_based_view_attributes.py new file mode 100644 index 0000000000..500a4df4bd --- /dev/null +++ b/src/datadog_api_client/v2/model/rule_based_view_attributes.py @@ -0,0 +1,46 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.rule_based_view_rule import RuleBasedViewRule + + +class RuleBasedViewAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.rule_based_view_rule import RuleBasedViewRule + + return { + "count": (int,), + "rules": ([RuleBasedViewRule],), + } + + attribute_map = { + "count": "count", + "rules": "rules", + } + + def __init__(self_, count: int, rules: List[RuleBasedViewRule], **kwargs): + """ + Attributes of the rule-based view. + + :param count: Total number of rules in the view. + :type count: int + + :param rules: List of rules in the rule-based view. + :type rules: [RuleBasedViewRule] + """ + super().__init__(kwargs) + + self_.count = count + self_.rules = rules diff --git a/src/datadog_api_client/v2/model/rule_based_view_compliance_framework.py b/src/datadog_api_client/v2/model/rule_based_view_compliance_framework.py new file mode 100644 index 0000000000..a8e12f7efb --- /dev/null +++ b/src/datadog_api_client/v2/model/rule_based_view_compliance_framework.py @@ -0,0 +1,80 @@ +# 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 Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class RuleBasedViewComplianceFramework(ModelNormal): + @cached_property + def openapi_types(_): + return { + "control": (str,), + "framework": (str,), + "is_default": (bool,), + "message": (str,), + "requirement": (str,), + "version": (str,), + } + + attribute_map = { + "control": "control", + "framework": "framework", + "is_default": "is_default", + "message": "message", + "requirement": "requirement", + "version": "version", + } + + def __init__( + self_, + control: Union[str, UnsetType] = unset, + framework: Union[str, UnsetType] = unset, + is_default: Union[bool, UnsetType] = unset, + message: Union[str, UnsetType] = unset, + requirement: Union[str, UnsetType] = unset, + version: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Compliance framework mapping for a rule. + + :param control: Identifier of the control inside the requirement. + :type control: str, optional + + :param framework: Handle of the compliance framework. + :type framework: str, optional + + :param is_default: Whether the framework is a Datadog default framework. ``true`` indicates a Datadog framework and ``false`` indicates a custom framework. + :type is_default: bool, optional + + :param message: Optional message describing the framework mapping for the rule. + :type message: str, optional + + :param requirement: Name of the requirement that contains the control. + :type requirement: str, optional + + :param version: Version of the compliance framework. + :type version: str, optional + """ + if control is not unset: + kwargs["control"] = control + if framework is not unset: + kwargs["framework"] = framework + if is_default is not unset: + kwargs["is_default"] = is_default + if message is not unset: + kwargs["message"] = message + if requirement is not unset: + kwargs["requirement"] = requirement + if version is not unset: + kwargs["version"] = version + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/rule_based_view_data.py b/src/datadog_api_client/v2/model/rule_based_view_data.py new file mode 100644 index 0000000000..88134c7686 --- /dev/null +++ b/src/datadog_api_client/v2/model/rule_based_view_data.py @@ -0,0 +1,54 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.rule_based_view_attributes import RuleBasedViewAttributes + from datadog_api_client.v2.model.rule_based_view_type import RuleBasedViewType + + +class RuleBasedViewData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.rule_based_view_attributes import RuleBasedViewAttributes + from datadog_api_client.v2.model.rule_based_view_type import RuleBasedViewType + + return { + "attributes": (RuleBasedViewAttributes,), + "id": (str,), + "type": (RuleBasedViewType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: RuleBasedViewAttributes, id: str, type: RuleBasedViewType, **kwargs): + """ + Data envelope for the rule-based view response. + + :param attributes: Attributes of the rule-based view. + :type attributes: RuleBasedViewAttributes + + :param id: Unique identifier of the rule-based view document. + :type id: str + + :param type: The type of the resource. The value should always be ``rule_based_view``. + :type type: RuleBasedViewType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/rule_based_view_response.py b/src/datadog_api_client/v2/model/rule_based_view_response.py new file mode 100644 index 0000000000..97415afe46 --- /dev/null +++ b/src/datadog_api_client/v2/model/rule_based_view_response.py @@ -0,0 +1,40 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.rule_based_view_data import RuleBasedViewData + + +class RuleBasedViewResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.rule_based_view_data import RuleBasedViewData + + return { + "data": (RuleBasedViewData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: RuleBasedViewData, **kwargs): + """ + Response containing an aggregated view of compliance rules with their finding statistics. + + :param data: Data envelope for the rule-based view response. + :type data: RuleBasedViewData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/rule_based_view_rule.py b/src/datadog_api_client/v2/model/rule_based_view_rule.py new file mode 100644 index 0000000000..8db55cf0f4 --- /dev/null +++ b/src/datadog_api_client/v2/model/rule_based_view_rule.py @@ -0,0 +1,118 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.rule_based_view_compliance_framework import RuleBasedViewComplianceFramework + from datadog_api_client.v2.model.rule_based_view_rule_stats import RuleBasedViewRuleStats + from datadog_api_client.v2.model.rule_based_view_rule_category import RuleBasedViewRuleCategory + + +class RuleBasedViewRule(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.rule_based_view_compliance_framework import RuleBasedViewComplianceFramework + from datadog_api_client.v2.model.rule_based_view_rule_stats import RuleBasedViewRuleStats + from datadog_api_client.v2.model.rule_based_view_rule_category import RuleBasedViewRuleCategory + + return { + "compliance_frameworks": ([RuleBasedViewComplianceFramework],), + "enabled": (bool,), + "id": (str,), + "name": (str,), + "resource_attributes": ([str],), + "resource_category": (str,), + "resource_type": (str,), + "stats": (RuleBasedViewRuleStats,), + "status": (str,), + "tags": ([str],), + "type": (RuleBasedViewRuleCategory,), + } + + attribute_map = { + "compliance_frameworks": "compliance_frameworks", + "enabled": "enabled", + "id": "id", + "name": "name", + "resource_attributes": "resourceAttributes", + "resource_category": "resourceCategory", + "resource_type": "resourceType", + "stats": "stats", + "status": "status", + "tags": "tags", + "type": "type", + } + + def __init__( + self_, + compliance_frameworks: List[RuleBasedViewComplianceFramework], + enabled: bool, + id: str, + name: str, + resource_attributes: List[str], + resource_category: str, + resource_type: str, + stats: RuleBasedViewRuleStats, + status: str, + tags: List[str], + type: RuleBasedViewRuleCategory, + **kwargs, + ): + """ + A compliance rule along with its evaluation statistics and framework mappings. + + :param compliance_frameworks: List of compliance framework mappings associated with the rule. + :type compliance_frameworks: [RuleBasedViewComplianceFramework] + + :param enabled: Whether the rule is enabled. + :type enabled: bool + + :param id: Unique identifier of the rule. + :type id: str + + :param name: Human-readable name of the rule. + :type name: str + + :param resource_attributes: List of resource attribute names exposed by the rule. + :type resource_attributes: [str] + + :param resource_category: Resource category targeted by the rule. + :type resource_category: str + + :param resource_type: Resource type targeted by the rule. + :type resource_type: str + + :param stats: Counts of findings for the rule, grouped by their evaluation status. + :type stats: RuleBasedViewRuleStats + + :param status: Severity associated with the rule (for example, ``info`` , ``low`` , ``medium`` , ``high`` , or ``critical`` ). + :type status: str + + :param tags: List of tags attached to the rule. + :type tags: [str] + + :param type: The category of the security rule. + :type type: RuleBasedViewRuleCategory + """ + super().__init__(kwargs) + + self_.compliance_frameworks = compliance_frameworks + self_.enabled = enabled + self_.id = id + self_.name = name + self_.resource_attributes = resource_attributes + self_.resource_category = resource_category + self_.resource_type = resource_type + self_.stats = stats + self_.status = status + self_.tags = tags + self_.type = type diff --git a/src/datadog_api_client/v2/model/rule_based_view_rule_category.py b/src/datadog_api_client/v2/model/rule_based_view_rule_category.py new file mode 100644 index 0000000000..a2f64418f6 --- /dev/null +++ b/src/datadog_api_client/v2/model/rule_based_view_rule_category.py @@ -0,0 +1,41 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class RuleBasedViewRuleCategory(ModelSimple): + """ + The category of the security rule. + + :param value: Must be one of ["cloud_configuration", "infrastructure_configuration", "api_security"]. + :type value: str + """ + + allowed_values = { + "cloud_configuration", + "infrastructure_configuration", + "api_security", + } + CLOUD_CONFIGURATION: ClassVar["RuleBasedViewRuleCategory"] + INFRASTRUCTURE_CONFIGURATION: ClassVar["RuleBasedViewRuleCategory"] + API_SECURITY: ClassVar["RuleBasedViewRuleCategory"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +RuleBasedViewRuleCategory.CLOUD_CONFIGURATION = RuleBasedViewRuleCategory("cloud_configuration") +RuleBasedViewRuleCategory.INFRASTRUCTURE_CONFIGURATION = RuleBasedViewRuleCategory("infrastructure_configuration") +RuleBasedViewRuleCategory.API_SECURITY = RuleBasedViewRuleCategory("api_security") diff --git a/src/datadog_api_client/v2/model/rule_based_view_rule_stats.py b/src/datadog_api_client/v2/model/rule_based_view_rule_stats.py new file mode 100644 index 0000000000..58444990be --- /dev/null +++ b/src/datadog_api_client/v2/model/rule_based_view_rule_stats.py @@ -0,0 +1,45 @@ +# 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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class RuleBasedViewRuleStats(ModelNormal): + @cached_property + def openapi_types(_): + return { + "fail": (int,), + "muted": (int,), + "_pass": (int,), + } + + attribute_map = { + "fail": "fail", + "muted": "muted", + "_pass": "pass", + } + + def __init__(self_, fail: int, muted: int, _pass: int, **kwargs): + """ + Counts of findings for the rule, grouped by their evaluation status. + + :param fail: Number of findings that failed evaluation. + :type fail: int + + :param muted: Number of findings that have been muted. + :type muted: int + + :param _pass: Number of findings that passed evaluation. + :type _pass: int + """ + super().__init__(kwargs) + + self_.fail = fail + self_.muted = muted + self_._pass = _pass diff --git a/src/datadog_api_client/v2/model/rule_based_view_type.py b/src/datadog_api_client/v2/model/rule_based_view_type.py new file mode 100644 index 0000000000..e163c1c320 --- /dev/null +++ b/src/datadog_api_client/v2/model/rule_based_view_type.py @@ -0,0 +1,35 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class RuleBasedViewType(ModelSimple): + """ + The type of the resource. The value should always be `rule_based_view`. + + :param value: If omitted defaults to "rule_based_view". Must be one of ["rule_based_view"]. + :type value: str + """ + + allowed_values = { + "rule_based_view", + } + RULE_BASED_VIEW: ClassVar["RuleBasedViewType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +RuleBasedViewType.RULE_BASED_VIEW = RuleBasedViewType("rule_based_view") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 66bf1b1919..3fd033e84e 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -5431,6 +5431,14 @@ from datadog_api_client.v2.model.routing_rule_type import RoutingRuleType from datadog_api_client.v2.model.rule_attributes import RuleAttributes from datadog_api_client.v2.model.rule_attributes_request import RuleAttributesRequest +from datadog_api_client.v2.model.rule_based_view_attributes import RuleBasedViewAttributes +from datadog_api_client.v2.model.rule_based_view_compliance_framework import RuleBasedViewComplianceFramework +from datadog_api_client.v2.model.rule_based_view_data import RuleBasedViewData +from datadog_api_client.v2.model.rule_based_view_response import RuleBasedViewResponse +from datadog_api_client.v2.model.rule_based_view_rule import RuleBasedViewRule +from datadog_api_client.v2.model.rule_based_view_rule_category import RuleBasedViewRuleCategory +from datadog_api_client.v2.model.rule_based_view_rule_stats import RuleBasedViewRuleStats +from datadog_api_client.v2.model.rule_based_view_type import RuleBasedViewType from datadog_api_client.v2.model.rule_outcome_relationships import RuleOutcomeRelationships from datadog_api_client.v2.model.rule_severity import RuleSeverity from datadog_api_client.v2.model.rule_type import RuleType @@ -11426,6 +11434,14 @@ "RoutingRuleType", "RuleAttributes", "RuleAttributesRequest", + "RuleBasedViewAttributes", + "RuleBasedViewComplianceFramework", + "RuleBasedViewData", + "RuleBasedViewResponse", + "RuleBasedViewRule", + "RuleBasedViewRuleCategory", + "RuleBasedViewRuleStats", + "RuleBasedViewType", "RuleOutcomeRelationships", "RuleSeverity", "RuleType", diff --git a/tests/v2/features/compliance.feature b/tests/v2/features/compliance.feature new file mode 100644 index 0000000000..e59eba055b --- /dev/null +++ b/tests/v2/features/compliance.feature @@ -0,0 +1,27 @@ +@endpoint(compliance) @endpoint(compliance-v2) +Feature: Compliance + Datadog Cloud Security Misconfigurations provides aggregated views of + compliance rules and findings across your cloud resources, helping you + assess posture against industry frameworks (such as HIPAA, SOC 2, ISO + 27001) and custom frameworks. Learn more at https://docs.datadoghq.com/sec + urity/cloud_security_management/misconfigurations/#maintain-compliance- + with-industry-frameworks-and-benchmarks. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "Compliance" API + And operation "GetRuleBasedView" enabled + And new "GetRuleBasedView" request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get the rule-based view of compliance findings returns "Bad Request" response + Given request contains "to" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get the rule-based view of compliance findings returns "OK" response + Given request contains "to" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 40d310f9a5..35b117222c 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1253,6 +1253,12 @@ "type": "safe" } }, + "GetRuleBasedView": { + "tag": "Compliance", + "undo": { + "type": "safe" + } + }, "ListContainerImages": { "tag": "Container Images", "undo": {