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
709 changes: 636 additions & 73 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ const params: v2.SecurityMonitoringApiCreateStaticAnalysisServerAnalysisRequest
language: "python",
rules: [
{
arguments: [{}],
category: "BEST_PRACTICES",
checksum: "abc123def456",
code: "ZnVuY3Rpb24gdmlzaXQobm9kZSkge30=",
entityChecked: undefined,
id: "python-best-practices/no-exit",
language: "python",
name: "no-exit",
regex: undefined,
severity: "WARNING",
tests: [{}],
treeSitterQuery: "KGNhbGwgbmFtZTogKGF0dHJpYnV0ZSkpQHZhbA==",
type: "TREE_SITTER_QUERY",
},
Expand Down
50 changes: 39 additions & 11 deletions examples/v2/static-analysis/CreateCustomRuleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,53 @@ const params: v2.StaticAnalysisApiCreateCustomRulesetRequest = {
body: {
data: {
attributes: {
description: "bG9uZyBkZXNjcmlwdGlvbg==",
name: "my-ruleset",
rules: [
{
createdAt: new Date(2026, 1, 9, 13, 0, 57, 473141),
createdBy: "foobarbaz",
id: "my-rule",
lastRevision: {
attributes: {
arguments: [
{
description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
name: "YXJndW1lbnRfbmFtZQ==",
},
],
category: "SECURITY",
code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
creationMessage: "Initial revision",
cve: "CVE-2024-1234",
cwe: "CWE-79",
description: "bG9uZyBkZXNjcmlwdGlvbg==",
documentationUrl: "https://docs.example.com/rules/my-rule",
isPublished: false,
isTesting: false,
language: "PYTHON",
severity: "ERROR",
shortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
shouldUseAiFix: false,
tags: ["security", "custom"],
tests: [
{
annotationCount: 1,
code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
filename: "test.yaml",
},
],
treeSitterQuery:
"Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
},
name: "my-rule",
revisions: [
{
arguments: [
{
description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
name: "YXJndW1lbnRfbmFtZQ==",
},
],
category: "SECURITY",
checksum:
"8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
createdAt: new Date(2026, 1, 9, 13, 0, 57, 473141),
createdBy: "foobarbaz",
creationMessage: "Initial revision",
cve: "CVE-2024-1234",
cwe: "CWE-79",
Expand All @@ -52,13 +81,12 @@ const params: v2.StaticAnalysisApiCreateCustomRulesetRequest = {
treeSitterQuery:
"Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
},
id: "revision-123",
type: "custom_rule_revision",
},
name: "my-rule",
],
},
],
shortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
},
id: "my-ruleset",
type: "custom_ruleset",
},
},
Expand Down
50 changes: 39 additions & 11 deletions examples/v2/static-analysis/UpdateCustomRuleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,53 @@ const params: v2.StaticAnalysisApiUpdateCustomRulesetRequest = {
body: {
data: {
attributes: {
description: "bG9uZyBkZXNjcmlwdGlvbg==",
name: "my-ruleset",
rules: [
{
createdAt: new Date(2026, 1, 9, 13, 0, 57, 473141),
createdBy: "foobarbaz",
id: "my-rule",
lastRevision: {
attributes: {
arguments: [
{
description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
name: "YXJndW1lbnRfbmFtZQ==",
},
],
category: "SECURITY",
code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
creationMessage: "Initial revision",
cve: "CVE-2024-1234",
cwe: "CWE-79",
description: "bG9uZyBkZXNjcmlwdGlvbg==",
documentationUrl: "https://docs.example.com/rules/my-rule",
isPublished: false,
isTesting: false,
language: "PYTHON",
severity: "ERROR",
shortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
shouldUseAiFix: false,
tags: ["security", "custom"],
tests: [
{
annotationCount: 1,
code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
filename: "test.yaml",
},
],
treeSitterQuery:
"Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
},
name: "my-rule",
revisions: [
{
arguments: [
{
description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
name: "YXJndW1lbnRfbmFtZQ==",
},
],
category: "SECURITY",
checksum:
"8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
createdAt: new Date(2026, 1, 9, 13, 0, 57, 473141),
createdBy: "foobarbaz",
creationMessage: "Initial revision",
cve: "CVE-2024-1234",
cwe: "CWE-79",
Expand All @@ -52,13 +81,12 @@ const params: v2.StaticAnalysisApiUpdateCustomRulesetRequest = {
treeSitterQuery:
"Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
},
id: "revision-123",
type: "custom_rule_revision",
},
name: "my-rule",
],
},
],
shortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
},
id: "my-ruleset",
type: "custom_ruleset",
},
},
Expand Down
4 changes: 2 additions & 2 deletions features/v2/security_monitoring.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ Feature: Security Monitoring
Scenario: Analyze code returns "Bad Request" response
Given operation "CreateStaticAnalysisServerAnalysis" enabled
And new "CreateStaticAnalysisServerAnalysis" request
And body with value {"data": {"attributes": {"code": "aW1wb3J0IHN5cw==", "file_encoding": "utf-8", "filename": "test.py", "language": "python", "rules": [{"category": "BEST_PRACTICES", "checksum": "abc123def456", "code": "ZnVuY3Rpb24gdmlzaXQobm9kZSkge30=", "entity_checked": null, "id": "python-best-practices/no-exit", "language": "python", "regex": null, "severity": "WARNING", "tree_sitter_query": "KGNhbGwgbmFtZTogKGF0dHJpYnV0ZSkpQHZhbA==", "type": "TREE_SITTER_QUERY"}]}, "type": "analysis_request"}}
And body with value {"data": {"attributes": {"code": "aW1wb3J0IHN5cw==", "file_encoding": "utf-8", "filename": "test.py", "language": "python", "rules": [{"arguments": [{}], "category": "BEST_PRACTICES", "checksum": "abc123def456", "code": "ZnVuY3Rpb24gdmlzaXQobm9kZSkge30=", "entity_checked": null, "id": "python-best-practices/no-exit", "language": "python", "name": "no-exit", "regex": null, "severity": "WARNING", "tests": [{}], "tree_sitter_query": "KGNhbGwgbmFtZTogKGF0dHJpYnV0ZSkpQHZhbA==", "type": "TREE_SITTER_QUERY"}]}, "type": "analysis_request"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/k9-vm-ast
Scenario: Analyze code returns "OK" response
Given operation "CreateStaticAnalysisServerAnalysis" enabled
And new "CreateStaticAnalysisServerAnalysis" request
And body with value {"data": {"attributes": {"code": "aW1wb3J0IHN5cw==", "file_encoding": "utf-8", "filename": "test.py", "language": "python", "rules": [{"category": "BEST_PRACTICES", "checksum": "abc123def456", "code": "ZnVuY3Rpb24gdmlzaXQobm9kZSkge30=", "entity_checked": null, "id": "python-best-practices/no-exit", "language": "python", "regex": null, "severity": "WARNING", "tree_sitter_query": "KGNhbGwgbmFtZTogKGF0dHJpYnV0ZSkpQHZhbA==", "type": "TREE_SITTER_QUERY"}]}, "type": "analysis_request"}}
And body with value {"data": {"attributes": {"code": "aW1wb3J0IHN5cw==", "file_encoding": "utf-8", "filename": "test.py", "language": "python", "rules": [{"arguments": [{}], "category": "BEST_PRACTICES", "checksum": "abc123def456", "code": "ZnVuY3Rpb24gdmlzaXQobm9kZSkge30=", "entity_checked": null, "id": "python-best-practices/no-exit", "language": "python", "name": "no-exit", "regex": null, "severity": "WARNING", "tests": [{}], "tree_sitter_query": "KGNhbGwgbmFtZTogKGF0dHJpYnV0ZSkpQHZhbA==", "type": "TREE_SITTER_QUERY"}]}, "type": "analysis_request"}}
When the request is sent
Then the response status is 200 OK

Expand Down
Loading
Loading