Skip to content
Open
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
225 changes: 214 additions & 11 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Search remediation groups filtered by host and container vulnerabilities returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.security_monitoring_api import SecurityMonitoringApi
from datadog_api_client.v2.model.remediation_group_finding_type import RemediationGroupFindingType

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["search_remediation_groups"] = True
with ApiClient(configuration) as api_client:
api_instance = SecurityMonitoringApi(api_client)
response = api_instance.search_remediation_groups(
filter_finding_type=[
RemediationGroupFindingType.HOST_AND_CONTAINER_VULNERABILITY,
],
)

print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Search remediation groups filtered by status and assignee returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.security_monitoring_api import SecurityMonitoringApi
from datadog_api_client.v2.model.remediation_group_status import RemediationGroupStatus

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["search_remediation_groups"] = True
with ApiClient(configuration) as api_client:
api_instance = SecurityMonitoringApi(api_client)
response = api_instance.search_remediation_groups(
filter_status=[
RemediationGroupStatus.TRIAGE,
RemediationGroupStatus.OPEN,
],
filter_assignee_id=[
"unassigned",
],
)

print(response)
62 changes: 58 additions & 4 deletions src/datadog_api_client/v2/api/security_monitoring_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
from datadog_api_client.v2.model.severity_override_request import SeverityOverrideRequest
from datadog_api_client.v2.model.search_remediation_groups_response import SearchRemediationGroupsResponse
from datadog_api_client.v2.model.remediation_group_finding_type import RemediationGroupFindingType
from datadog_api_client.v2.model.remediation_group_status import RemediationGroupStatus
from datadog_api_client.v2.model.remediation_group_include import RemediationGroupInclude
from datadog_api_client.v2.model.remediation_group_data import RemediationGroupData
from datadog_api_client.v2.model.list_assets_sbo_ms_response import ListAssetsSBOMsResponse
Expand Down Expand Up @@ -4889,6 +4890,21 @@ def __init__(self, api_client=None):
"attribute": "filter[query]",
"location": "query",
},
"filter_status": {
"openapi_types": ([RemediationGroupStatus],),
"attribute": "filter[status]",
"location": "query",
"collection_format": "multi",
},
"filter_assignee_id": {
"validation": {
"max_items": 50,
},
"openapi_types": ([str],),
"attribute": "filter[assignee_id]",
"location": "query",
"collection_format": "multi",
},
"sort": {
"openapi_types": (str,),
"attribute": "sort",
Expand Down Expand Up @@ -10355,6 +10371,8 @@ def search_remediation_groups(
*,
filter_finding_type: Union[List[RemediationGroupFindingType], UnsetType] = unset,
filter_query: Union[str, UnsetType] = unset,
filter_status: Union[List[RemediationGroupStatus], UnsetType] = unset,
filter_assignee_id: Union[List[str], UnsetType] = unset,
sort: Union[str, UnsetType] = unset,
page_size: Union[int, UnsetType] = unset,
page_number: Union[int, UnsetType] = unset,
Expand All @@ -10363,7 +10381,7 @@ def search_remediation_groups(
"""Search remediation groups.

Search the remediation groups of your organization. A remediation group gathers the open security findings
that one change fixes, such as updating a package in a repository.
that one change fixes, such as updating a package in a repository or upgrading an image.

Each group comes from a grouping definition, which sets the finding type it covers and the kind object the
group returns:
Expand All @@ -10377,12 +10395,16 @@ def search_remediation_groups(
* - ``sca.package_update``
- ``library_vulnerability``
- ``package_update``
* - ``cloudvm.image_update``
- ``host_and_container_vulnerability``
- ``image_update``

Groups are computed from the attributes of security findings, described in the
`security findings schema <https://docs.datadoghq.com/security/guide/findings-schema/>`_. The description of
each kind object lists the findings its grouping definition reads and the attribute each field comes from.

The search includes all open findings, regardless of when they were first detected.
The search includes all open findings, regardless of when they were first detected. A closed group with no
open findings is listed from its auto-closed findings.

This endpoint requires the ``cases_read`` permission and either the ``security_monitoring_findings_read`` or
``appsec_vm_read`` permission.
Expand All @@ -10397,10 +10419,19 @@ def search_remediation_groups(
The group's counts still include every finding in the group. The query can be at most 2048 bytes after
JSON encoding, and the parameter can appear only once.
:type filter_query: str, optional
:param filter_status: Returns only groups with this status. To match more than one status, repeat the parameter. Without it,
groups of every status are returned. A closed group with neither open nor auto-closed findings is
returned with zero counts, unless the request has ``filter[query]``.
:type filter_status: [RemediationGroupStatus], optional
:param filter_assignee_id: Returns only groups whose case is assigned to this user, given as a user UUID. ``unassigned`` returns the
groups whose case has no assignee and the groups with no case. To match more than one assignee, repeat
the parameter, with at most 50 distinct values.
:type filter_assignee_id: [str], optional
:param sort: Comma-separated list of sort fields. Prefix a field with ``-`` to sort in descending order.
``findings.by_severity`` sorts by the critical count, then high, medium, low, info, none, and unknown.
``findings.total`` sorts by the total finding count. By default, groups are sorted by critical count,
then high count, then total finding count, all in descending order.
then high count, then total finding count, all in descending order. Closed groups with no open findings
come after the other groups, the group whose case changed most recently first.
:type sort: str, optional
:param page_size: Number of groups in a page.
:type page_size: int, optional
Expand All @@ -10417,6 +10448,12 @@ def search_remediation_groups(
if filter_query is not unset:
kwargs["filter_query"] = filter_query

if filter_status is not unset:
kwargs["filter_status"] = filter_status

if filter_assignee_id is not unset:
kwargs["filter_assignee_id"] = filter_assignee_id

if sort is not unset:
kwargs["sort"] = sort

Expand All @@ -10436,6 +10473,8 @@ def search_remediation_groups_with_pagination(
*,
filter_finding_type: Union[List[RemediationGroupFindingType], UnsetType] = unset,
filter_query: Union[str, UnsetType] = unset,
filter_status: Union[List[RemediationGroupStatus], UnsetType] = unset,
filter_assignee_id: Union[List[str], UnsetType] = unset,
sort: Union[str, UnsetType] = unset,
page_size: Union[int, UnsetType] = unset,
page_number: Union[int, UnsetType] = unset,
Expand All @@ -10455,10 +10494,19 @@ def search_remediation_groups_with_pagination(
The group's counts still include every finding in the group. The query can be at most 2048 bytes after
JSON encoding, and the parameter can appear only once.
:type filter_query: str, optional
:param filter_status: Returns only groups with this status. To match more than one status, repeat the parameter. Without it,
groups of every status are returned. A closed group with neither open nor auto-closed findings is
returned with zero counts, unless the request has ``filter[query]``.
:type filter_status: [RemediationGroupStatus], optional
:param filter_assignee_id: Returns only groups whose case is assigned to this user, given as a user UUID. ``unassigned`` returns the
groups whose case has no assignee and the groups with no case. To match more than one assignee, repeat
the parameter, with at most 50 distinct values.
:type filter_assignee_id: [str], optional
:param sort: Comma-separated list of sort fields. Prefix a field with ``-`` to sort in descending order.
``findings.by_severity`` sorts by the critical count, then high, medium, low, info, none, and unknown.
``findings.total`` sorts by the total finding count. By default, groups are sorted by critical count,
then high count, then total finding count, all in descending order.
then high count, then total finding count, all in descending order. Closed groups with no open findings
come after the other groups, the group whose case changed most recently first.
:type sort: str, optional
:param page_size: Number of groups in a page.
:type page_size: int, optional
Expand All @@ -10477,6 +10525,12 @@ def search_remediation_groups_with_pagination(
if filter_query is not unset:
kwargs["filter_query"] = filter_query

if filter_status is not unset:
kwargs["filter_status"] = filter_status

if filter_assignee_id is not unset:
kwargs["filter_assignee_id"] = filter_assignee_id

if sort is not unset:
kwargs["sort"] = sort

Expand Down
41 changes: 37 additions & 4 deletions src/datadog_api_client/v2/model/remediation_group_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,40 @@

if TYPE_CHECKING:
from datadog_api_client.v2.model.remediation_group_findings import RemediationGroupFindings
from datadog_api_client.v2.model.remediation_group_image_update import RemediationGroupImageUpdate
from datadog_api_client.v2.model.remediation_group_owners import RemediationGroupOwners
from datadog_api_client.v2.model.remediation_group_package_update import RemediationGroupPackageUpdate
from datadog_api_client.v2.model.remediation_group_status import RemediationGroupStatus


class RemediationGroupAttributes(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.remediation_group_findings import RemediationGroupFindings
from datadog_api_client.v2.model.remediation_group_image_update import RemediationGroupImageUpdate
from datadog_api_client.v2.model.remediation_group_owners import RemediationGroupOwners
from datadog_api_client.v2.model.remediation_group_package_update import RemediationGroupPackageUpdate
from datadog_api_client.v2.model.remediation_group_status import RemediationGroupStatus

return {
"assignee_id": (str,),
"findings": (RemediationGroupFindings,),
"grouping_definition_id": (str,),
"image_update": (RemediationGroupImageUpdate,),
"owners": (RemediationGroupOwners,),
"package_update": (RemediationGroupPackageUpdate,),
"status": (RemediationGroupStatus,),
"title": (str,),
}

attribute_map = {
"assignee_id": "assignee_id",
"findings": "findings",
"grouping_definition_id": "grouping_definition_id",
"image_update": "image_update",
"owners": "owners",
"package_update": "package_update",
"status": "status",
"title": "title",
}

Expand All @@ -47,20 +57,33 @@ def __init__(
findings: RemediationGroupFindings,
grouping_definition_id: str,
owners: RemediationGroupOwners,
status: RemediationGroupStatus,
title: str,
assignee_id: Union[str, UnsetType] = unset,
image_update: Union[RemediationGroupImageUpdate, UnsetType] = unset,
package_update: Union[RemediationGroupPackageUpdate, UnsetType] = unset,
**kwargs,
):
"""
Attributes of a remediation group. Each group includes one kind object, depending on its grouping definition.
Attributes of a remediation group. Each group includes one kind object, ``package_update`` or ``image_update`` ,
depending on its grouping definition.

:param findings: Counts of the group's open findings. The counts include every finding in the group, including findings that
don't match ``filter[query]``.
:param assignee_id: UUID of the user assigned to the group's case. Omitted when the group has no case or no assignee.
:type assignee_id: str, optional

:param findings: The group's findings: their counts and the query that selects them. The counts are of the group's open
findings or, for a closed group with no open findings, of its auto-closed findings. The counts include every
finding in the group, including findings that don't match ``filter[query]``.
:type findings: RemediationGroupFindings

:param grouping_definition_id: Grouping definition that formed the group, such as ``sca.package_update``.
:param grouping_definition_id: Grouping definition that formed the group: ``sca.package_update`` or ``cloudvm.image_update``.
:type grouping_definition_id: str

:param image_update: A container image, base image, or package to upgrade, for a group of host and container vulnerabilities
( ``cloudvm.image_update`` ). The group gathers the open vulnerabilities of running production images that have
a fix available, and groups them by ``repository_id`` , ``grouping_location`` , ``remediation_kind`` , and ``action``.
:type image_update: RemediationGroupImageUpdate, optional

:param owners: Who should fix the group: the code owners of the group's findings, from their ``@git.codeowners`` attribute,
and their Datadog teams, from their ``team`` tag. A group with no owners has empty ``items`` and a ``total`` of 0.
:type owners: RemediationGroupOwners
Expand All @@ -70,14 +93,24 @@ def __init__(
``@git.repository_id`` , ``@vulnerability.stack.ecosystem`` , and ``@remediation.recommended.name``.
:type package_update: RemediationGroupPackageUpdate, optional

:param status: Where the group's remediation stands, from its case: ``triage`` when the group has no case, then ``open`` ,
``in_progress`` , or ``closed`` , following the status of the case. The status follows the group's findings within
an hour.
:type status: RemediationGroupStatus

:param title: Title of the group, which describes the change to make.
:type title: str
"""
if assignee_id is not unset:
kwargs["assignee_id"] = assignee_id
if image_update is not unset:
kwargs["image_update"] = image_update
if package_update is not unset:
kwargs["package_update"] = package_update
super().__init__(kwargs)

self_.findings = findings
self_.grouping_definition_id = grouping_definition_id
self_.owners = owners
self_.status = status
self_.title = title
3 changes: 2 additions & 1 deletion src/datadog_api_client/v2/model/remediation_group_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def __init__(
"""
A remediation group.

:param attributes: Attributes of a remediation group. Each group includes one kind object, depending on its grouping definition.
:param attributes: Attributes of a remediation group. Each group includes one kind object, ``package_update`` or ``image_update`` ,
depending on its grouping definition.
:type attributes: RemediationGroupAttributes

:param id: Remediation key of the group: the grouping definition ID, a colon, and the group's dimensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ class RemediationGroupFindingType(ModelSimple):
"""
Value of the findings' `@finding_type` attribute that a grouping definition covers.

:param value: If omitted defaults to "library_vulnerability". Must be one of ["library_vulnerability"].
:param value: Must be one of ["library_vulnerability", "host_and_container_vulnerability"].
:type value: str
"""

allowed_values = {
"library_vulnerability",
"host_and_container_vulnerability",
}
LIBRARY_VULNERABILITY: ClassVar["RemediationGroupFindingType"]
HOST_AND_CONTAINER_VULNERABILITY: ClassVar["RemediationGroupFindingType"]

@cached_property
def openapi_types(_):
Expand All @@ -33,3 +35,6 @@ def openapi_types(_):


RemediationGroupFindingType.LIBRARY_VULNERABILITY = RemediationGroupFindingType("library_vulnerability")
RemediationGroupFindingType.HOST_AND_CONTAINER_VULNERABILITY = RemediationGroupFindingType(
"host_and_container_vulnerability"
)
22 changes: 18 additions & 4 deletions src/datadog_api_client/v2/model/remediation_group_findings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,41 @@ def openapi_types(_):

return {
"by_severity": (RemediationGroupFindingsBySeverity,),
"query": (str,),
"total": (int,),
}

attribute_map = {
"by_severity": "by_severity",
"query": "query",
"total": "total",
}

def __init__(self_, by_severity: RemediationGroupFindingsBySeverity, total: int, **kwargs):
def __init__(self_, by_severity: RemediationGroupFindingsBySeverity, query: str, total: int, **kwargs):
"""
Counts of the group's open findings. The counts include every finding in the group, including findings that
don't match ``filter[query]``.
The group's findings: their counts and the query that selects them. The counts are of the group's open
findings or, for a closed group with no open findings, of its auto-closed findings. The counts include every
finding in the group, including findings that don't match ``filter[query]``.

:param by_severity: Number of the group's findings for each value of their ``@severity`` attribute. The response includes every
level, including levels with a count of zero.
:type by_severity: RemediationGroupFindingsBySeverity

:param total: Number of open findings in the group.
:param query: Query that selects exactly the findings that the counts cover, to use with the
`search security findings endpoint <https://docs.datadoghq.com/api/latest/security-monitoring/#search-security-findings>`_.
It contains the grouping definition's search, the ``@finding_type`` it covers, and one exact term for each
field that identifies the group, such as ``repository_id`` , ``ecosystem`` , and ``package_name`` for
``package_update``. It searches for ``@status:auto_closed`` findings when the counts are of auto-closed
findings. For ``cloudvm.image_update`` , it matches findings with no ``@git.repository_id`` when
``repository_id`` is ``unknown`` , and matches ``grouping_location`` against ``@code_location.filename`` , or
against ``@container_image.repository`` for findings with no file.
:type query: str

:param total: Number of findings in the group that the counts cover.
:type total: int
"""
super().__init__(kwargs)

self_.by_severity = by_severity
self_.query = query
self_.total = total
Loading
Loading