Skip to content
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
143 changes: 137 additions & 6 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7039,6 +7039,8 @@ components:
description: The programming language of the source code.
example: python
type: string
options:
$ref: "#/components/schemas/AnalysisRequestOptions"
rules:
description: The list of static analysis rules to apply during analysis.
items:
Expand All @@ -7060,6 +7062,20 @@ components:
type: string
x-enum-varnames:
- ANALYSIS_REQUEST
AnalysisRequestOptions:
description: |-
Analyzer options sent by browser-based clients. Accepted but ignored: the API always runs
the analysis with tree-sitter enabled and rule output logged.
properties:
log_output:
description: Whether to capture the output logged by rules during execution. Ignored by this operation.
example: true
type: boolean
use_tree_sitter:
description: Whether to use tree-sitter to parse the source code. Ignored by this operation.
example: true
type: boolean
type: object
AnalysisRequestRule:
additionalProperties: {}
description: |-
Expand Down Expand Up @@ -29880,9 +29896,7 @@ components:
example: foobarbaz
type: string
last_revision:
$ref: "#/components/schemas/CustomRuleRevisionEmbedded"
description: Most recent revision of the rule, or null when the rule has no revisions.
nullable: true
$ref: "#/components/schemas/CustomRuleNullableRevisionEmbedded"
name:
description: Rule name
example: my-rule
Expand All @@ -29907,6 +29921,125 @@ components:
type: string
x-enum-varnames:
- CUSTOM_RULE
CustomRuleNullableRevisionEmbedded:
description: The most recent revision of the rule, or null when the rule has no revisions.
nullable: true
properties:
arguments:
description: Rule arguments
items:
$ref: "#/components/schemas/Argument"
nullable: true
type: array
category:
$ref: "#/components/schemas/CustomRuleRevisionAttributesCategory"
checksum:
description: Code checksum
example: 8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99
type: string
code:
description: Rule code
example: Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==
type: string
created_at:
description: Creation timestamp
example: "2026-01-09T13:00:57.473141Z"
format: date-time
type: string
created_by:
description: Creator identifier
example: foobarbaz
type: string
creation_message:
description: Revision creation message
example: Initial revision
type: string
cve:
description: Associated CVE. Omitted when the revision has no associated CVE.
example: CVE-2024-1234
type: string
cwe:
description: Associated CWE. Omitted when the revision has no associated CWE.
example: CWE-79
type: string
description:
description: Full description
example: bG9uZyBkZXNjcmlwdGlvbg==
type: string
documentation_url:
description: Documentation URL. Omitted when the revision has no documentation URL.
example: https://docs.example.com/rules/my-rule
type: string
id:
description: Revision identifier
example: revision-123
type: string
is_published:
description: Whether the revision is published
example: false
type: boolean
is_testing:
description: Whether this is a testing revision
example: false
type: boolean
language:
$ref: "#/components/schemas/Language"
severity:
$ref: "#/components/schemas/CustomRuleRevisionAttributesSeverity"
short_description:
description: Short description
example: c2hvcnQgZGVzY3JpcHRpb24=
type: string
should_use_ai_fix:
description: Whether to use AI for fixes
example: false
type: boolean
tags:
description: Rule tags
example:
- security
- custom
items:
description: A tag attached to the rule.
type: string
nullable: true
type: array
tests:
description: Rule tests
items:
$ref: "#/components/schemas/CustomRuleRevisionTest"
nullable: true
type: array
tree_sitter_query:
description: Tree-sitter query
example: Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==
type: string
version_id:
description: Monotonically increasing version number of the revision.
example: 1
format: int64
type: integer
required:
- id
- version_id
- creation_message
- short_description
- description
- code
- checksum
- language
- tree_sitter_query
- created_at
- created_by
- severity
- category
- arguments
- tests
- tags
- is_published
- should_use_ai_fix
- is_testing
type: object
CustomRuleRequest:
description: Request body for creating or updating a custom rule.
properties:
Expand Down Expand Up @@ -30673,9 +30806,7 @@ components:
example: my-rule
type: string
last_revision:
$ref: "#/components/schemas/CustomRuleRevisionEmbedded"
description: Most recent revision of the rule, or null when the rule has no revisions.
nullable: true
$ref: "#/components/schemas/CustomRuleNullableRevisionEmbedded"
name:
description: Rule name
example: my-rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from datadog_api_client.v2.model.analysis_request_data import AnalysisRequestData
from datadog_api_client.v2.model.analysis_request_data_attributes import AnalysisRequestDataAttributes
from datadog_api_client.v2.model.analysis_request_data_type import AnalysisRequestDataType
from datadog_api_client.v2.model.analysis_request_options import AnalysisRequestOptions
from datadog_api_client.v2.model.analysis_request_rule import AnalysisRequestRule
from datadog_api_client.v2.model.analysis_request_rule_argument import AnalysisRequestRuleArgument
from datadog_api_client.v2.model.analysis_request_rule_test import AnalysisRequestRuleTest
Expand All @@ -20,6 +21,10 @@
file_encoding="utf-8",
filename="test.py",
language="python",
options=AnalysisRequestOptions(
log_output=True,
use_tree_sitter=True,
),
rules=[
AnalysisRequestRule(
arguments=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import List, TYPE_CHECKING
from typing import List, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.analysis_request_options import AnalysisRequestOptions
from datadog_api_client.v2.model.analysis_request_rule import AnalysisRequestRule


class AnalysisRequestDataAttributes(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.analysis_request_options import AnalysisRequestOptions
from datadog_api_client.v2.model.analysis_request_rule import AnalysisRequestRule

return {
"code": (str,),
"file_encoding": (str,),
"filename": (str,),
"language": (str,),
"options": (AnalysisRequestOptions,),
"rules": ([AnalysisRequestRule],),
}

Expand All @@ -33,11 +38,19 @@ def openapi_types(_):
"file_encoding": "file_encoding",
"filename": "filename",
"language": "language",
"options": "options",
"rules": "rules",
}

def __init__(
self_, code: str, file_encoding: str, filename: str, language: str, rules: List[AnalysisRequestRule], **kwargs
self_,
code: str,
file_encoding: str,
filename: str,
language: str,
rules: List[AnalysisRequestRule],
options: Union[AnalysisRequestOptions, UnsetType] = unset,
**kwargs,
):
"""
The attributes of the analysis request, containing the source code and rules to apply.
Expand All @@ -54,9 +67,15 @@ def __init__(
:param language: The programming language of the source code.
:type language: str

:param options: Analyzer options sent by browser-based clients. Accepted but ignored: the API always runs
the analysis with tree-sitter enabled and rule output logged.
:type options: AnalysisRequestOptions, optional

:param rules: The list of static analysis rules to apply during analysis.
:type rules: [AnalysisRequestRule]
"""
if options is not unset:
kwargs["options"] = options
super().__init__(kwargs)

self_.code = code
Expand Down
46 changes: 46 additions & 0 deletions src/datadog_api_client/v2/model/analysis_request_options.py
Original file line number Diff line number Diff line change
@@ -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 Union

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


class AnalysisRequestOptions(ModelNormal):
@cached_property
def openapi_types(_):
return {
"log_output": (bool,),
"use_tree_sitter": (bool,),
}

attribute_map = {
"log_output": "log_output",
"use_tree_sitter": "use_tree_sitter",
}

def __init__(
self_, log_output: Union[bool, UnsetType] = unset, use_tree_sitter: Union[bool, UnsetType] = unset, **kwargs
):
"""
Analyzer options sent by browser-based clients. Accepted but ignored: the API always runs
the analysis with tree-sitter enabled and rule output logged.

:param log_output: Whether to capture the output logged by rules during execution. Ignored by this operation.
:type log_output: bool, optional

:param use_tree_sitter: Whether to use tree-sitter to parse the source code. Ignored by this operation.
:type use_tree_sitter: bool, optional
"""
if log_output is not unset:
kwargs["log_output"] = log_output
if use_tree_sitter is not unset:
kwargs["use_tree_sitter"] = use_tree_sitter
super().__init__(kwargs)
12 changes: 8 additions & 4 deletions src/datadog_api_client/v2/model/custom_rule_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@


if TYPE_CHECKING:
from datadog_api_client.v2.model.custom_rule_nullable_revision_embedded import CustomRuleNullableRevisionEmbedded
from datadog_api_client.v2.model.custom_rule_revision_embedded import CustomRuleRevisionEmbedded


class CustomRuleAttributes(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.custom_rule_nullable_revision_embedded import (
CustomRuleNullableRevisionEmbedded,
)
from datadog_api_client.v2.model.custom_rule_revision_embedded import CustomRuleRevisionEmbedded

return {
"created_at": (datetime,),
"created_by": (str,),
"last_revision": (CustomRuleRevisionEmbedded,),
"last_revision": (CustomRuleNullableRevisionEmbedded,),
"name": (str,),
"revisions": ([CustomRuleRevisionEmbedded], none_type),
}
Expand All @@ -42,7 +46,7 @@ def __init__(
self_,
created_at: datetime,
created_by: str,
last_revision: CustomRuleRevisionEmbedded,
last_revision: Union[CustomRuleNullableRevisionEmbedded, none_type],
name: str,
revisions: Union[List[CustomRuleRevisionEmbedded], none_type],
**kwargs,
Expand All @@ -56,8 +60,8 @@ def __init__(
:param created_by: Creator identifier
:type created_by: str

:param last_revision: A revision of a custom static analysis rule as embedded in a rule or ruleset response.
:type last_revision: CustomRuleRevisionEmbedded
:param last_revision: The most recent revision of the rule, or null when the rule has no revisions.
:type last_revision: CustomRuleNullableRevisionEmbedded, none_type

:param name: Rule name
:type name: str
Expand Down
Loading
Loading