diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 07cf64fab0e1..2053789b98de 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -17581,6 +17581,244 @@ components: required: - data type: object + CycloneDXAdvisory: + description: Advisory reference for a vulnerability. + properties: + url: + description: URL to the advisory. + example: https://example.com/advisory/CVE-2021-1234 + type: string + type: object + CycloneDXAffect: + description: Reference to a component affected by a vulnerability. + properties: + ref: + description: Reference to a component's bom-ref. + example: a3390fca-c315-41ae-ae05-af5e7859cdee + type: string + required: + - ref + type: object + CycloneDXAssetComponent: + description: The asset component represents the system or host being scanned. + properties: + bom-ref: + description: Optional reference to a component in the components list. + example: asset-ref-123 + type: string + name: + description: The name of the asset. + example: i-12345 + type: string + type: + description: The type of the asset component. + example: operating-system + type: string + required: + - name + type: object + CycloneDXBOM: + description: CycloneDX 1.5 Bill of Materials (BOM) for importing vulnerabilities. + properties: + bomFormat: + description: The format of the BOM. Must be "CycloneDX". + example: CycloneDX + type: string + components: + description: List of components (libraries, applications, or operating systems) + that are affected by vulnerabilities. + items: + $ref: '#/components/schemas/CycloneDXComponent' + type: array + metadata: + $ref: '#/components/schemas/CycloneDXMetadata' + specVersion: + description: The version of the CycloneDX specification. Must be "1.5". + example: '1.5' + type: string + version: + description: The version of the BOM. + example: 1 + format: int64 + type: integer + vulnerabilities: + description: List of vulnerabilities to be imported. + items: + $ref: '#/components/schemas/CycloneDXVulnerability' + type: array + required: + - bomFormat + - specVersion + - version + - metadata + - vulnerabilities + - components + type: object + CycloneDXComponent: + description: A component (library, application, or operating system) in the + BOM. + properties: + bom-ref: + description: Unique reference identifier for this component. + example: a3390fca-c315-41ae-ae05-af5e7859cdee + type: string + name: + description: The name of the component. + example: lodash + type: string + purl: + description: Package URL for the component. Required for library components. + example: pkg:npm/lodash@4.17.21 + type: string + type: + $ref: '#/components/schemas/CycloneDXComponentType' + version: + description: The version of the component. + example: 4.17.21 + type: string + required: + - bom-ref + - type + - name + - version + type: object + CycloneDXComponentType: + description: The type of the component. Supported types are library, application, + and operating-system. + enum: + - library + - application + - operating-system + example: library + type: string + x-enum-varnames: + - LIBRARY + - APPLICATION + - OPERATING_SYSTEM + CycloneDXMetadata: + description: Metadata for the CycloneDX BOM. + properties: + component: + $ref: '#/components/schemas/CycloneDXAssetComponent' + tools: + $ref: '#/components/schemas/CycloneDXTools' + required: + - component + - tools + type: object + CycloneDXRating: + description: Vulnerability rating information. + properties: + score: + description: The CVSS score. + example: 9.0 + format: double + type: number + severity: + description: The severity level. + example: high + type: string + vector: + description: The CVSS vector string. + example: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N + type: string + type: object + CycloneDXReference: + description: External reference for a vulnerability. + properties: + id: + description: Identifier of the reference. + example: GHSA-35m5-8cvj-8783 + type: string + source: + $ref: '#/components/schemas/CycloneDXReferenceSource' + type: object + CycloneDXReferenceSource: + description: Source information for a reference. + properties: + url: + description: URL to the source. + example: https://example.com + type: string + type: object + CycloneDXToolComponent: + description: Tool component that detected the vulnerabilities. + properties: + name: + description: The name of the tool. + example: my-scanner + type: string + type: + description: The type of the tool. + example: application + type: string + required: + - name + type: object + CycloneDXTools: + description: Tools used to generate the BOM. + properties: + components: + description: List of tool components. Only one tool is supported. + items: + $ref: '#/components/schemas/CycloneDXToolComponent' + maxItems: 1 + minItems: 1 + type: array + required: + - components + type: object + CycloneDXVulnerability: + description: A vulnerability in the CycloneDX BOM. + properties: + advisories: + description: List of advisory references. + items: + $ref: '#/components/schemas/CycloneDXAdvisory' + type: array + affects: + description: List of component references affected by this vulnerability. + items: + $ref: '#/components/schemas/CycloneDXAffect' + minItems: 1 + type: array + cwes: + description: List of CWE (Common Weakness Enumeration) identifiers. + example: + - 123 + - 345 + items: + type: integer + type: array + description: + description: Description of the vulnerability. + example: Sample vulnerability detected in the application. + type: string + detail: + description: Detailed information about the vulnerability. + example: Details about the vulnerability + type: string + id: + description: The unique identifier of the vulnerability (e.g., CVE ID). + example: CVE-2021-1234 + type: string + ratings: + description: List of vulnerability ratings. Must contain exactly one rating. + items: + $ref: '#/components/schemas/CycloneDXRating' + maxItems: 1 + minItems: 1 + type: array + references: + description: List of external references for the vulnerability. + items: + $ref: '#/components/schemas/CycloneDXReference' + type: array + required: + - id + - ratings + - affects + type: object DORACustomTags: description: A list of user-defined tags. The tags must follow the `key:value` pattern. Up to 100 may be added per event. @@ -53101,6 +53339,16 @@ components: meta: $ref: '#/components/schemas/SecurityFilterMeta' type: object + SecurityFindingType: + description: The type of security finding. + enum: + - vulnerability + - configuration_finding + example: vulnerability + type: string + x-enum-varnames: + - VULNERABILITY + - CONFIGURATION_FINDING SecurityFindingsAttributes: description: The JSON object containing all attributes of the security finding. properties: @@ -64143,6 +64391,18 @@ components: type: $ref: '#/components/schemas/ThreatHuntingJobDataType' type: object + ThreatIntelIndicatorType: + description: The type of threat indicator. + enum: + - ip_address + - domain + - sha256 + example: ip_address + type: string + x-enum-varnames: + - IP_ADDRESS + - DOMAIN + - SHA256 TimeAggregation: description: 'Time aggregation period (in seconds) is used to aggregate the results of the notification rule evaluation. @@ -93298,6 +93558,68 @@ paths: permissions: - security_monitoring_findings_read - appsec_vm_read + post: + description: 'Allows external integrations to send security findings to Datadog. + This endpoint accepts finding data in a custom format and returns an empty + response on success. + + + **Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + operationId: CreateSecurityFinding + parameters: + - description: The vendor providing the security finding. Must be lowercase. + example: vendor-name + in: header + name: vendor + required: true + schema: + type: string + - description: The type of security finding. + in: header + name: finding_type + required: true + schema: + $ref: '#/components/schemas/SecurityFindingType' + requestBody: + content: + application/json: + schema: + additionalProperties: {} + description: Security finding data in a custom format. + type: object + required: true + responses: + '200': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create security finding + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_findings_write + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/security/findings/cases: delete: description: 'Detach security findings from their case. @@ -94050,6 +94372,92 @@ paths: operator: OR permissions: - security_monitoring_notification_profiles_write + /api/v2/security/threat-intel-feed: + post: + description: 'Import threat intelligence feeds with support for IP addresses, + domains, and SHA256 hashes. This endpoint requires specific headers to identify + the vendor and indicator type. + + + **Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + operationId: ImportThreatIntel + parameters: + - description: The vendor providing the threat intelligence feed. + example: vendor-name + in: header + name: ti_vendor + required: true + schema: + type: string + - description: The type of threat indicator. Valid values are ip_address, domain, + or sha256. + in: header + name: ti_indicator + required: true + schema: + $ref: '#/components/schemas/ThreatIntelIndicatorType' + - description: Optional integration account identifier. + in: header + name: ti_integration_account + required: false + schema: + type: string + requestBody: + content: + application/json: + schema: + description: Threat intelligence feed data. + type: object + application/octet-stream: + schema: + description: Threat intelligence feed data in binary format. + format: binary + type: string + required: true + responses: + '200': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Internal Server Error + '503': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Service Unavailable + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Import threat intelligence feed + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - reference_tables_write + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/security/vulnerabilities: get: description: "Get a list of vulnerabilities.\n\n### Pagination\n\nPagination @@ -94463,6 +94871,58 @@ paths: x-unstable: '**Note**: This endpoint is a private preview. If you are interested in accessing this API, [fill out this form](https://forms.gle/kMYC1sDr6WDUBDsx9).' + post: + description: 'Import vulnerabilities in CycloneDX 1.5 format. This endpoint + validates the payload against the CycloneDX 1.5 schema and additional mandatory + field requirements. + + + **Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + operationId: ImportSecurityVulnerabilities + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CycloneDXBOM' + required: true + responses: + '200': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Import vulnerabilities + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_findings_write + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/security/vulnerabilities/notification_rules: get: description: Returns the list of notification rules for security vulnerabilities. diff --git a/examples/v2/security-monitoring/CreateSecurityFinding.rb b/examples/v2/security-monitoring/CreateSecurityFinding.rb new file mode 100644 index 000000000000..2e4c32f2b598 --- /dev/null +++ b/examples/v2/security-monitoring/CreateSecurityFinding.rb @@ -0,0 +1,8 @@ +# Create security finding returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.create_security_finding".to_sym] = true +end +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new +p api_instance.create_security_finding("vendor", SecurityFindingType::VULNERABILITY) diff --git a/examples/v2/security-monitoring/ImportSecurityVulnerabilities.rb b/examples/v2/security-monitoring/ImportSecurityVulnerabilities.rb new file mode 100644 index 000000000000..ce9d143f2692 --- /dev/null +++ b/examples/v2/security-monitoring/ImportSecurityVulnerabilities.rb @@ -0,0 +1,74 @@ +# Import vulnerabilities returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.import_security_vulnerabilities".to_sym] = true +end +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new + +body = DatadogAPIClient::V2::CycloneDXBOM.new({ + bom_format: "CycloneDX", + components: [ + DatadogAPIClient::V2::CycloneDXComponent.new({ + bom_ref: "a3390fca-c315-41ae-ae05-af5e7859cdee", + name: "lodash", + purl: "pkg:npm/lodash@4.17.21", + type: DatadogAPIClient::V2::CycloneDXComponentType::LIBRARY, + version: "4.17.21", + }), + ], + metadata: DatadogAPIClient::V2::CycloneDXMetadata.new({ + component: DatadogAPIClient::V2::CycloneDXAssetComponent.new({ + bom_ref: "asset-ref-123", + name: "i-12345", + type: "operating-system", + }), + tools: DatadogAPIClient::V2::CycloneDXTools.new({ + components: [ + DatadogAPIClient::V2::CycloneDXToolComponent.new({ + name: "my-scanner", + type: "application", + }), + ], + }), + }), + spec_version: "1.5", + version: 1, + vulnerabilities: [ + DatadogAPIClient::V2::CycloneDXVulnerability.new({ + advisories: [ + DatadogAPIClient::V2::CycloneDXAdvisory.new({ + url: "https://example.com/advisory/CVE-2021-1234", + }), + ], + affects: [ + DatadogAPIClient::V2::CycloneDXAffect.new({ + ref: "a3390fca-c315-41ae-ae05-af5e7859cdee", + }), + ], + cwes: [ + 123, + 345, + ], + description: "Sample vulnerability detected in the application.", + detail: "Details about the vulnerability", + id: "CVE-2021-1234", + ratings: [ + DatadogAPIClient::V2::CycloneDXRating.new({ + score: 9.0, + severity: "high", + vector: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N", + }), + ], + references: [ + DatadogAPIClient::V2::CycloneDXReference.new({ + id: "GHSA-35m5-8cvj-8783", + source: DatadogAPIClient::V2::CycloneDXReferenceSource.new({ + url: "https://example.com", + }), + }), + ], + }), + ], +}) +p api_instance.import_security_vulnerabilities(body) diff --git a/examples/v2/security-monitoring/ImportThreatIntel.rb b/examples/v2/security-monitoring/ImportThreatIntel.rb new file mode 100644 index 000000000000..5487fbd3b02c --- /dev/null +++ b/examples/v2/security-monitoring/ImportThreatIntel.rb @@ -0,0 +1,8 @@ +# Import threat intelligence feed returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.import_threat_intel".to_sym] = true +end +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new +p api_instance.import_threat_intel("ti_vendor", ThreatIntelIndicatorType::IP_ADDRESS) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index d2fea4f627d3..38b57d4a43eb 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -1439,6 +1439,11 @@ "page_limit" => "Integer", "sort" => "SecurityFindingsSort", }, + "v2.CreateSecurityFinding" => { + "vendor" => "String", + "finding_type" => "SecurityFindingType", + "body" => "Hash", + }, "v2.DetachCase" => { "body" => "DetachCaseRequest", }, @@ -1495,6 +1500,12 @@ "id" => "String", "body" => "PatchNotificationRuleParameters", }, + "v2.ImportThreatIntel" => { + "ti_vendor" => "String", + "ti_indicator" => "ThreatIntelIndicatorType", + "ti_integration_account" => "String", + "body" => "Object", + }, "v2.ListVulnerabilities" => { "page_token" => "String", "page_number" => "Integer", @@ -1540,6 +1551,9 @@ "filter_asset_operating_system_name" => "String", "filter_asset_operating_system_version" => "String", }, + "v2.ImportSecurityVulnerabilities" => { + "body" => "CycloneDXBOM", + }, "v2.CreateVulnerabilityNotificationRule" => { "body" => "CreateNotificationRuleParameters", }, diff --git a/features/v2/security_monitoring.feature b/features/v2/security_monitoring.feature index 5695a7ea4a50..3ad8d5c96367 100644 --- a/features/v2/security_monitoring.feature +++ b/features/v2/security_monitoring.feature @@ -708,6 +708,24 @@ Feature: Security Monitoring When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/asm-vm + Scenario: Create security finding returns "Bad Request" response + Given operation "CreateSecurityFinding" enabled + And new "CreateSecurityFinding" request + And request contains "vendor" parameter from "REPLACE.ME" + And request contains "finding_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-vm + Scenario: Create security finding returns "OK" response + Given operation "CreateSecurityFinding" enabled + And new "CreateSecurityFinding" request + And request contains "vendor" parameter from "REPLACE.ME" + And request contains "finding_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Deactivate content pack returns "Accepted" response Given operation "DeactivateContentPack" enabled @@ -1397,6 +1415,40 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 The list of notification rules. + @generated @skip @team:DataDog/asm-vm + Scenario: Import threat intelligence feed returns "Bad Request" response + Given operation "ImportThreatIntel" enabled + And new "ImportThreatIntel" request + And request contains "ti_vendor" parameter from "REPLACE.ME" + And request contains "ti_indicator" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-vm + Scenario: Import threat intelligence feed returns "OK" response + Given operation "ImportThreatIntel" enabled + And new "ImportThreatIntel" request + And request contains "ti_vendor" parameter from "REPLACE.ME" + And request contains "ti_indicator" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-vm + Scenario: Import vulnerabilities returns "Bad Request" response + Given operation "ImportSecurityVulnerabilities" enabled + And new "ImportSecurityVulnerabilities" request + And body with value {"bomFormat": "CycloneDX", "components": [{"bom-ref": "a3390fca-c315-41ae-ae05-af5e7859cdee", "name": "lodash", "purl": "pkg:npm/lodash@4.17.21", "type": "library", "version": "4.17.21"}], "metadata": {"component": {"bom-ref": "asset-ref-123", "name": "i-12345", "type": "operating-system"}, "tools": {"components": [{"name": "my-scanner", "type": "application"}]}}, "specVersion": "1.5", "version": 1, "vulnerabilities": [{"advisories": [{"url": "https://example.com/advisory/CVE-2021-1234"}], "affects": [{"ref": "a3390fca-c315-41ae-ae05-af5e7859cdee"}], "cwes": [123, 345], "description": "Sample vulnerability detected in the application.", "detail": "Details about the vulnerability", "id": "CVE-2021-1234", "ratings": [{"score": 9.0, "severity": "high", "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N"}], "references": [{"id": "GHSA-35m5-8cvj-8783", "source": {"url": "https://example.com"}}]}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-vm + Scenario: Import vulnerabilities returns "OK" response + Given operation "ImportSecurityVulnerabilities" enabled + And new "ImportSecurityVulnerabilities" request + And body with value {"bomFormat": "CycloneDX", "components": [{"bom-ref": "a3390fca-c315-41ae-ae05-af5e7859cdee", "name": "lodash", "purl": "pkg:npm/lodash@4.17.21", "type": "library", "version": "4.17.21"}], "metadata": {"component": {"bom-ref": "asset-ref-123", "name": "i-12345", "type": "operating-system"}, "tools": {"components": [{"name": "my-scanner", "type": "application"}]}}, "specVersion": "1.5", "version": 1, "vulnerabilities": [{"advisories": [{"url": "https://example.com/advisory/CVE-2021-1234"}], "affects": [{"ref": "a3390fca-c315-41ae-ae05-af5e7859cdee"}], "cwes": [123, 345], "description": "Sample vulnerability detected in the application.", "detail": "Details about the vulnerability", "id": "CVE-2021-1234", "ratings": [{"score": 9.0, "severity": "high", "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N"}], "references": [{"id": "GHSA-35m5-8cvj-8783", "source": {"url": "https://example.com"}}]}]} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-vm Scenario: List assets SBOMs returns "Bad request: The server cannot process the request due to invalid syntax in the request." response Given new "ListAssetsSBOMs" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 75d0d7f71ed7..110c6b94f87b 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -4304,6 +4304,12 @@ "type": "safe" } }, + "CreateSecurityFinding": { + "tag": "Security Monitoring", + "undo": { + "type": "unsafe" + } + }, "DetachCase": { "tag": "Security Monitoring", "undo": { @@ -4409,12 +4415,24 @@ "type": "idempotent" } }, + "ImportThreatIntel": { + "tag": "Security Monitoring", + "undo": { + "type": "unsafe" + } + }, "ListVulnerabilities": { "tag": "Security Monitoring", "undo": { "type": "safe" } }, + "ImportSecurityVulnerabilities": { + "tag": "Security Monitoring", + "undo": { + "type": "unsafe" + } + }, "GetVulnerabilityNotificationRules": { "tag": "Security Monitoring", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 7124bbe895fb..93689f8b7cc4 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -218,6 +218,7 @@ def initialize "v2.activate_content_pack": false, "v2.cancel_threat_hunting_job": false, "v2.convert_job_result_to_signal": false, + "v2.create_security_finding": false, "v2.deactivate_content_pack": false, "v2.delete_threat_hunting_job": false, "v2.get_content_packs_states": false, @@ -227,6 +228,8 @@ def initialize "v2.get_security_monitoring_histsignal": false, "v2.get_security_monitoring_histsignals_by_job_id": false, "v2.get_threat_hunting_job": false, + "v2.import_security_vulnerabilities": false, + "v2.import_threat_intel": false, "v2.list_findings": false, "v2.list_multiple_rulesets": false, "v2.list_scanned_assets_metadata": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 4a0ac91fa81b..3b445e35350d 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1995,6 +1995,19 @@ def overrides "v2.custom_ruleset_request_data_attributes" => "CustomRulesetRequestDataAttributes", "v2.custom_ruleset_response" => "CustomRulesetResponse", "v2.cvss" => "CVSS", + "v2.cyclone_dx_advisory" => "CycloneDXAdvisory", + "v2.cyclone_dx_affect" => "CycloneDXAffect", + "v2.cyclone_dx_asset_component" => "CycloneDXAssetComponent", + "v2.cyclone_dxbom" => "CycloneDXBOM", + "v2.cyclone_dx_component" => "CycloneDXComponent", + "v2.cyclone_dx_component_type" => "CycloneDXComponentType", + "v2.cyclone_dx_metadata" => "CycloneDXMetadata", + "v2.cyclone_dx_rating" => "CycloneDXRating", + "v2.cyclone_dx_reference" => "CycloneDXReference", + "v2.cyclone_dx_reference_source" => "CycloneDXReferenceSource", + "v2.cyclone_dx_tool_component" => "CycloneDXToolComponent", + "v2.cyclone_dx_tools" => "CycloneDXTools", + "v2.cyclone_dx_vulnerability" => "CycloneDXVulnerability", "v2.dashboard_list_add_items_request" => "DashboardListAddItemsRequest", "v2.dashboard_list_add_items_response" => "DashboardListAddItemsResponse", "v2.dashboard_list_delete_items_request" => "DashboardListDeleteItemsRequest", @@ -4320,6 +4333,7 @@ def overrides "v2.security_findings_search_request_page" => "SecurityFindingsSearchRequestPage", "v2.security_findings_sort" => "SecurityFindingsSort", "v2.security_findings_status" => "SecurityFindingsStatus", + "v2.security_finding_type" => "SecurityFindingType", "v2.security_monitoring_content_pack_activation" => "SecurityMonitoringContentPackActivation", "v2.security_monitoring_content_pack_integration_status" => "SecurityMonitoringContentPackIntegrationStatus", "v2.security_monitoring_content_pack_state_attributes" => "SecurityMonitoringContentPackStateAttributes", @@ -4997,6 +5011,7 @@ def overrides "v2.threat_hunting_job_response" => "ThreatHuntingJobResponse", "v2.threat_hunting_job_response_attributes" => "ThreatHuntingJobResponseAttributes", "v2.threat_hunting_job_response_data" => "ThreatHuntingJobResponseData", + "v2.threat_intel_indicator_type" => "ThreatIntelIndicatorType", "v2.timeline_cell" => "TimelineCell", "v2.timeline_cell_author" => "TimelineCellAuthor", "v2.timeline_cell_author_user" => "TimelineCellAuthorUser", diff --git a/lib/datadog_api_client/v2/api/security_monitoring_api.rb b/lib/datadog_api_client/v2/api/security_monitoring_api.rb index 1b324c3877a8..636ef80153a6 100644 --- a/lib/datadog_api_client/v2/api/security_monitoring_api.rb +++ b/lib/datadog_api_client/v2/api/security_monitoring_api.rb @@ -867,6 +867,99 @@ def create_security_filter_with_http_info(body, opts = {}) return data, status_code, headers end + # Create security finding. + # + # @see #create_security_finding_with_http_info + def create_security_finding(vendor, finding_type, body, opts = {}) + create_security_finding_with_http_info(vendor, finding_type, body, opts) + nil + end + + # Create security finding. + # + # Allows external integrations to send security findings to Datadog. This endpoint accepts finding data in a custom format and returns an empty response on success. + # + # **Note**: This endpoint is in preview and is subject to change. + # If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + # + # @param vendor [String] The vendor providing the security finding. Must be lowercase. + # @param finding_type [SecurityFindingType] The type of security finding. + # @param body [Hash] + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def create_security_finding_with_http_info(vendor, finding_type, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.create_security_finding".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_security_finding") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_security_finding")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SecurityMonitoringAPI.create_security_finding ...' + end + # verify the required parameter 'vendor' is set + if @api_client.config.client_side_validation && vendor.nil? + fail ArgumentError, "Missing the required parameter 'vendor' when calling SecurityMonitoringAPI.create_security_finding" + end + # verify the required parameter 'finding_type' is set + if @api_client.config.client_side_validation && finding_type.nil? + fail ArgumentError, "Missing the required parameter 'finding_type' when calling SecurityMonitoringAPI.create_security_finding" + end + # verify enum value + allowable_values = ['vulnerability', 'configuration_finding'] + if @api_client.config.client_side_validation && !allowable_values.include?(finding_type) + fail ArgumentError, "invalid value for \"finding_type\", must be one of #{allowable_values}" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling SecurityMonitoringAPI.create_security_finding" + end + # resource path + local_var_path = '/api/v2/security/findings' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + header_params['vendor'] = vendor + header_params['finding_type'] = finding_type + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_security_finding, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SecurityMonitoringAPI#create_security_finding\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Create a critical asset. # # @see #create_security_monitoring_critical_asset_with_http_info @@ -3670,6 +3763,177 @@ def get_vulnerability_notification_rules_with_http_info(opts = {}) return data, status_code, headers end + # Import vulnerabilities. + # + # @see #import_security_vulnerabilities_with_http_info + def import_security_vulnerabilities(body, opts = {}) + import_security_vulnerabilities_with_http_info(body, opts) + nil + end + + # Import vulnerabilities. + # + # Import vulnerabilities in CycloneDX 1.5 format. This endpoint validates the payload against the CycloneDX 1.5 schema and additional mandatory field requirements. + # + # **Note**: This endpoint is in preview and is subject to change. + # If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + # + # @param body [CycloneDXBOM] + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def import_security_vulnerabilities_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.import_security_vulnerabilities".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.import_security_vulnerabilities") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.import_security_vulnerabilities")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SecurityMonitoringAPI.import_security_vulnerabilities ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling SecurityMonitoringAPI.import_security_vulnerabilities" + end + # resource path + local_var_path = '/api/v2/security/vulnerabilities' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :import_security_vulnerabilities, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SecurityMonitoringAPI#import_security_vulnerabilities\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Import threat intelligence feed. + # + # @see #import_threat_intel_with_http_info + def import_threat_intel(ti_vendor, ti_indicator, body, opts = {}) + import_threat_intel_with_http_info(ti_vendor, ti_indicator, body, opts) + nil + end + + # Import threat intelligence feed. + # + # Import threat intelligence feeds with support for IP addresses, domains, and SHA256 hashes. This endpoint requires specific headers to identify the vendor and indicator type. + # + # **Note**: This endpoint is in preview and is subject to change. + # If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + # + # @param ti_vendor [String] The vendor providing the threat intelligence feed. + # @param ti_indicator [ThreatIntelIndicatorType] The type of threat indicator. Valid values are ip_address, domain, or sha256. + # @param body [Object] + # @param opts [Hash] the optional parameters + # @option opts [String] :ti_integration_account Optional integration account identifier. + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def import_threat_intel_with_http_info(ti_vendor, ti_indicator, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.import_threat_intel".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.import_threat_intel") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.import_threat_intel")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SecurityMonitoringAPI.import_threat_intel ...' + end + # verify the required parameter 'ti_vendor' is set + if @api_client.config.client_side_validation && ti_vendor.nil? + fail ArgumentError, "Missing the required parameter 'ti_vendor' when calling SecurityMonitoringAPI.import_threat_intel" + end + # verify the required parameter 'ti_indicator' is set + if @api_client.config.client_side_validation && ti_indicator.nil? + fail ArgumentError, "Missing the required parameter 'ti_indicator' when calling SecurityMonitoringAPI.import_threat_intel" + end + # verify enum value + allowable_values = ['ip_address', 'domain', 'sha256'] + if @api_client.config.client_side_validation && !allowable_values.include?(ti_indicator) + fail ArgumentError, "invalid value for \"ti_indicator\", must be one of #{allowable_values}" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling SecurityMonitoringAPI.import_threat_intel" + end + # resource path + local_var_path = '/api/v2/security/threat-intel-feed' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/octet-stream']) + header_params['ti_vendor'] = ti_vendor + header_params['ti_indicator'] = ti_indicator + header_params['ti_integration_account'] = opts[:'ti_integration_account'] if !opts[:'ti_integration_account'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :import_threat_intel, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SecurityMonitoringAPI#import_threat_intel\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List assets SBOMs. # # @see #list_assets_sbo_ms_with_http_info diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_advisory.rb b/lib/datadog_api_client/v2/models/cyclone_dx_advisory.rb new file mode 100644 index 000000000000..7ec4f698a185 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_advisory.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Advisory reference for a vulnerability. + class CycloneDXAdvisory + include BaseGenericModel + + # URL to the advisory. + attr_accessor :url + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'url' => :'url' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'url' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXAdvisory` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + url == o.url && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [url, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_affect.rb b/lib/datadog_api_client/v2/models/cyclone_dx_affect.rb new file mode 100644 index 000000000000..8ccd0eeeee77 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_affect.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Reference to a component affected by a vulnerability. + class CycloneDXAffect + include BaseGenericModel + + # Reference to a component's bom-ref. + attr_reader :ref + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'ref' => :'ref' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'ref' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXAffect` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'ref') + self.ref = attributes[:'ref'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @ref.nil? + true + end + + # Custom attribute writer method with validation + # @param ref [Object] Object to be assigned + # @!visibility private + def ref=(ref) + if ref.nil? + fail ArgumentError, 'invalid value for "ref", ref cannot be nil.' + end + @ref = ref + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + ref == o.ref && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [ref, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_asset_component.rb b/lib/datadog_api_client/v2/models/cyclone_dx_asset_component.rb new file mode 100644 index 000000000000..1c8c735421ec --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_asset_component.rb @@ -0,0 +1,143 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The asset component represents the system or host being scanned. + class CycloneDXAssetComponent + include BaseGenericModel + + # Optional reference to a component in the components list. + attr_accessor :bom_ref + + # The name of the asset. + attr_reader :name + + # The type of the asset component. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'bom_ref' => :'bom-ref', + :'name' => :'name', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'bom_ref' => :'String', + :'name' => :'String', + :'type' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXAssetComponent` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'bom_ref') + self.bom_ref = attributes[:'bom_ref'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @name.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + bom_ref == o.bom_ref && + name == o.name && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [bom_ref, name, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_component.rb b/lib/datadog_api_client/v2/models/cyclone_dx_component.rb new file mode 100644 index 000000000000..42488ffdb295 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_component.rb @@ -0,0 +1,196 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A component (library, application, or operating system) in the BOM. + class CycloneDXComponent + include BaseGenericModel + + # Unique reference identifier for this component. + attr_reader :bom_ref + + # The name of the component. + attr_reader :name + + # Package URL for the component. Required for library components. + attr_accessor :purl + + # The type of the component. Supported types are library, application, and operating-system. + attr_reader :type + + # The version of the component. + attr_reader :version + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'bom_ref' => :'bom-ref', + :'name' => :'name', + :'purl' => :'purl', + :'type' => :'type', + :'version' => :'version' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'bom_ref' => :'String', + :'name' => :'String', + :'purl' => :'String', + :'type' => :'CycloneDXComponentType', + :'version' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXComponent` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'bom_ref') + self.bom_ref = attributes[:'bom_ref'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'purl') + self.purl = attributes[:'purl'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @bom_ref.nil? + return false if @name.nil? + return false if @type.nil? + return false if @version.nil? + true + end + + # Custom attribute writer method with validation + # @param bom_ref [Object] Object to be assigned + # @!visibility private + def bom_ref=(bom_ref) + if bom_ref.nil? + fail ArgumentError, 'invalid value for "bom_ref", bom_ref cannot be nil.' + end + @bom_ref = bom_ref + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Custom attribute writer method with validation + # @param version [Object] Object to be assigned + # @!visibility private + def version=(version) + if version.nil? + fail ArgumentError, 'invalid value for "version", version cannot be nil.' + end + @version = version + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + bom_ref == o.bom_ref && + name == o.name && + purl == o.purl && + type == o.type && + version == o.version && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [bom_ref, name, purl, type, version, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_component_type.rb b/lib/datadog_api_client/v2/models/cyclone_dx_component_type.rb new file mode 100644 index 000000000000..ea2923d545cd --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_component_type.rb @@ -0,0 +1,28 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of the component. Supported types are library, application, and operating-system. + class CycloneDXComponentType + include BaseEnumModel + + LIBRARY = "library".freeze + APPLICATION = "application".freeze + OPERATING_SYSTEM = "operating-system".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_metadata.rb b/lib/datadog_api_client/v2/models/cyclone_dx_metadata.rb new file mode 100644 index 000000000000..d5d96df4b729 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_metadata.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Metadata for the CycloneDX BOM. + class CycloneDXMetadata + include BaseGenericModel + + # The asset component represents the system or host being scanned. + attr_reader :component + + # Tools used to generate the BOM. + attr_reader :tools + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'component' => :'component', + :'tools' => :'tools' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'component' => :'CycloneDXAssetComponent', + :'tools' => :'CycloneDXTools' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXMetadata` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'component') + self.component = attributes[:'component'] + end + + if attributes.key?(:'tools') + self.tools = attributes[:'tools'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @component.nil? + return false if @tools.nil? + true + end + + # Custom attribute writer method with validation + # @param component [Object] Object to be assigned + # @!visibility private + def component=(component) + if component.nil? + fail ArgumentError, 'invalid value for "component", component cannot be nil.' + end + @component = component + end + + # Custom attribute writer method with validation + # @param tools [Object] Object to be assigned + # @!visibility private + def tools=(tools) + if tools.nil? + fail ArgumentError, 'invalid value for "tools", tools cannot be nil.' + end + @tools = tools + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + component == o.component && + tools == o.tools && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [component, tools, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_rating.rb b/lib/datadog_api_client/v2/models/cyclone_dx_rating.rb new file mode 100644 index 000000000000..d6d580800895 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_rating.rb @@ -0,0 +1,125 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Vulnerability rating information. + class CycloneDXRating + include BaseGenericModel + + # The CVSS score. + attr_accessor :score + + # The severity level. + attr_accessor :severity + + # The CVSS vector string. + attr_accessor :vector + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'score' => :'score', + :'severity' => :'severity', + :'vector' => :'vector' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'score' => :'Float', + :'severity' => :'String', + :'vector' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXRating` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'score') + self.score = attributes[:'score'] + end + + if attributes.key?(:'severity') + self.severity = attributes[:'severity'] + end + + if attributes.key?(:'vector') + self.vector = attributes[:'vector'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + score == o.score && + severity == o.severity && + vector == o.vector && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [score, severity, vector, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_reference.rb b/lib/datadog_api_client/v2/models/cyclone_dx_reference.rb new file mode 100644 index 000000000000..9e16552449f4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_reference.rb @@ -0,0 +1,115 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # External reference for a vulnerability. + class CycloneDXReference + include BaseGenericModel + + # Identifier of the reference. + attr_accessor :id + + # Source information for a reference. + attr_accessor :source + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id', + :'source' => :'source' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'String', + :'source' => :'CycloneDXReferenceSource' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXReference` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source == o.source && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [id, source, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_reference_source.rb b/lib/datadog_api_client/v2/models/cyclone_dx_reference_source.rb new file mode 100644 index 000000000000..dd4419863bef --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_reference_source.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Source information for a reference. + class CycloneDXReferenceSource + include BaseGenericModel + + # URL to the source. + attr_accessor :url + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'url' => :'url' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'url' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXReferenceSource` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + url == o.url && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [url, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_tool_component.rb b/lib/datadog_api_client/v2/models/cyclone_dx_tool_component.rb new file mode 100644 index 000000000000..57aea2f25650 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_tool_component.rb @@ -0,0 +1,133 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Tool component that detected the vulnerabilities. + class CycloneDXToolComponent + include BaseGenericModel + + # The name of the tool. + attr_reader :name + + # The type of the tool. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'type' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXToolComponent` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @name.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_tools.rb b/lib/datadog_api_client/v2/models/cyclone_dx_tools.rb new file mode 100644 index 000000000000..9a6bc31efce2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_tools.rb @@ -0,0 +1,133 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Tools used to generate the BOM. + class CycloneDXTools + include BaseGenericModel + + # List of tool components. Only one tool is supported. + attr_reader :components + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'components' => :'components' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'components' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXTools` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'components') + if (value = attributes[:'components']).is_a?(Array) + self.components = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @components.nil? + return false if @components.length > 1 + return false if @components.length < 1 + true + end + + # Custom attribute writer method with validation + # @param components [Object] Object to be assigned + # @!visibility private + def components=(components) + if components.nil? + fail ArgumentError, 'invalid value for "components", components cannot be nil.' + end + if components.length > 1 + fail ArgumentError, 'invalid value for "components", number of items must be less than or equal to 1.' + end + if components.length < 1 + fail ArgumentError, 'invalid value for "components", number of items must be greater than or equal to 1.' + end + @components = components + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + components == o.components && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [components, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability.rb b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability.rb new file mode 100644 index 000000000000..095ada035270 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability.rb @@ -0,0 +1,237 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A vulnerability in the CycloneDX BOM. + class CycloneDXVulnerability + include BaseGenericModel + + # List of advisory references. + attr_accessor :advisories + + # List of component references affected by this vulnerability. + attr_reader :affects + + # List of CWE (Common Weakness Enumeration) identifiers. + attr_accessor :cwes + + # Description of the vulnerability. + attr_accessor :description + + # Detailed information about the vulnerability. + attr_accessor :detail + + # The unique identifier of the vulnerability (e.g., CVE ID). + attr_reader :id + + # List of vulnerability ratings. Must contain exactly one rating. + attr_reader :ratings + + # List of external references for the vulnerability. + attr_accessor :references + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'advisories' => :'advisories', + :'affects' => :'affects', + :'cwes' => :'cwes', + :'description' => :'description', + :'detail' => :'detail', + :'id' => :'id', + :'ratings' => :'ratings', + :'references' => :'references' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'advisories' => :'Array', + :'affects' => :'Array', + :'cwes' => :'Array', + :'description' => :'String', + :'detail' => :'String', + :'id' => :'String', + :'ratings' => :'Array', + :'references' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXVulnerability` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'advisories') + if (value = attributes[:'advisories']).is_a?(Array) + self.advisories = value + end + end + + if attributes.key?(:'affects') + if (value = attributes[:'affects']).is_a?(Array) + self.affects = value + end + end + + if attributes.key?(:'cwes') + if (value = attributes[:'cwes']).is_a?(Array) + self.cwes = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'detail') + self.detail = attributes[:'detail'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'ratings') + if (value = attributes[:'ratings']).is_a?(Array) + self.ratings = value + end + end + + if attributes.key?(:'references') + if (value = attributes[:'references']).is_a?(Array) + self.references = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @affects.nil? + return false if @affects.length < 1 + return false if @id.nil? + return false if @ratings.nil? + return false if @ratings.length > 1 + return false if @ratings.length < 1 + true + end + + # Custom attribute writer method with validation + # @param affects [Object] Object to be assigned + # @!visibility private + def affects=(affects) + if affects.nil? + fail ArgumentError, 'invalid value for "affects", affects cannot be nil.' + end + if affects.length < 1 + fail ArgumentError, 'invalid value for "affects", number of items must be greater than or equal to 1.' + end + @affects = affects + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param ratings [Object] Object to be assigned + # @!visibility private + def ratings=(ratings) + if ratings.nil? + fail ArgumentError, 'invalid value for "ratings", ratings cannot be nil.' + end + if ratings.length > 1 + fail ArgumentError, 'invalid value for "ratings", number of items must be less than or equal to 1.' + end + if ratings.length < 1 + fail ArgumentError, 'invalid value for "ratings", number of items must be greater than or equal to 1.' + end + @ratings = ratings + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + advisories == o.advisories && + affects == o.affects && + cwes == o.cwes && + description == o.description && + detail == o.detail && + id == o.id && + ratings == o.ratings && + references == o.references && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [advisories, affects, cwes, description, detail, id, ratings, references, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dxbom.rb b/lib/datadog_api_client/v2/models/cyclone_dxbom.rb new file mode 100644 index 000000000000..3ad262904c5d --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dxbom.rb @@ -0,0 +1,232 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # CycloneDX 1.5 Bill of Materials (BOM) for importing vulnerabilities. + class CycloneDXBOM + include BaseGenericModel + + # The format of the BOM. Must be "CycloneDX". + attr_reader :bom_format + + # List of components (libraries, applications, or operating systems) that are affected by vulnerabilities. + attr_reader :components + + # Metadata for the CycloneDX BOM. + attr_reader :metadata + + # The version of the CycloneDX specification. Must be "1.5". + attr_reader :spec_version + + # The version of the BOM. + attr_reader :version + + # List of vulnerabilities to be imported. + attr_reader :vulnerabilities + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'bom_format' => :'bomFormat', + :'components' => :'components', + :'metadata' => :'metadata', + :'spec_version' => :'specVersion', + :'version' => :'version', + :'vulnerabilities' => :'vulnerabilities' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'bom_format' => :'String', + :'components' => :'Array', + :'metadata' => :'CycloneDXMetadata', + :'spec_version' => :'String', + :'version' => :'Integer', + :'vulnerabilities' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CycloneDXBOM` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'bom_format') + self.bom_format = attributes[:'bom_format'] + end + + if attributes.key?(:'components') + if (value = attributes[:'components']).is_a?(Array) + self.components = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'spec_version') + self.spec_version = attributes[:'spec_version'] + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + + if attributes.key?(:'vulnerabilities') + if (value = attributes[:'vulnerabilities']).is_a?(Array) + self.vulnerabilities = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @bom_format.nil? + return false if @components.nil? + return false if @metadata.nil? + return false if @spec_version.nil? + return false if @version.nil? + return false if @vulnerabilities.nil? + true + end + + # Custom attribute writer method with validation + # @param bom_format [Object] Object to be assigned + # @!visibility private + def bom_format=(bom_format) + if bom_format.nil? + fail ArgumentError, 'invalid value for "bom_format", bom_format cannot be nil.' + end + @bom_format = bom_format + end + + # Custom attribute writer method with validation + # @param components [Object] Object to be assigned + # @!visibility private + def components=(components) + if components.nil? + fail ArgumentError, 'invalid value for "components", components cannot be nil.' + end + @components = components + end + + # Custom attribute writer method with validation + # @param metadata [Object] Object to be assigned + # @!visibility private + def metadata=(metadata) + if metadata.nil? + fail ArgumentError, 'invalid value for "metadata", metadata cannot be nil.' + end + @metadata = metadata + end + + # Custom attribute writer method with validation + # @param spec_version [Object] Object to be assigned + # @!visibility private + def spec_version=(spec_version) + if spec_version.nil? + fail ArgumentError, 'invalid value for "spec_version", spec_version cannot be nil.' + end + @spec_version = spec_version + end + + # Custom attribute writer method with validation + # @param version [Object] Object to be assigned + # @!visibility private + def version=(version) + if version.nil? + fail ArgumentError, 'invalid value for "version", version cannot be nil.' + end + @version = version + end + + # Custom attribute writer method with validation + # @param vulnerabilities [Object] Object to be assigned + # @!visibility private + def vulnerabilities=(vulnerabilities) + if vulnerabilities.nil? + fail ArgumentError, 'invalid value for "vulnerabilities", vulnerabilities cannot be nil.' + end + @vulnerabilities = vulnerabilities + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + bom_format == o.bom_format && + components == o.components && + metadata == o.metadata && + spec_version == o.spec_version && + version == o.version && + vulnerabilities == o.vulnerabilities && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [bom_format, components, metadata, spec_version, version, vulnerabilities, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/security_finding_type.rb b/lib/datadog_api_client/v2/models/security_finding_type.rb new file mode 100644 index 000000000000..6561a5c367ca --- /dev/null +++ b/lib/datadog_api_client/v2/models/security_finding_type.rb @@ -0,0 +1,27 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of security finding. + class SecurityFindingType + include BaseEnumModel + + VULNERABILITY = "vulnerability".freeze + CONFIGURATION_FINDING = "configuration_finding".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/threat_intel_indicator_type.rb b/lib/datadog_api_client/v2/models/threat_intel_indicator_type.rb new file mode 100644 index 000000000000..a401188ef7cd --- /dev/null +++ b/lib/datadog_api_client/v2/models/threat_intel_indicator_type.rb @@ -0,0 +1,28 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of threat indicator. + class ThreatIntelIndicatorType + include BaseEnumModel + + IP_ADDRESS = "ip_address".freeze + DOMAIN = "domain".freeze + SHA256 = "sha256".freeze + end +end