diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index fd30acae59e1..cee9ad50485e 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -28134,6 +28134,249 @@ components: type: string x-enum-varnames: - CUSTOMER_ORG_DISABLE + CycloneDXBom: + description: A CycloneDX 1.5 Bill of Materials (BOM) document containing vulnerability data. + properties: + bomFormat: + description: The BOM format identifier. Must be `CycloneDX`. + example: CycloneDX + type: string + components: + description: The list of scanned software components. Cannot be empty. + items: + $ref: "#/components/schemas/CycloneDXComponent" + type: array + metadata: + $ref: "#/components/schemas/CycloneDXMetadata" + specVersion: + description: The CycloneDX specification version. Must be `1.5`. + example: "1.5" + type: string + version: + description: The version number of the BOM document. + example: 1 + format: int64 + type: integer + vulnerabilities: + description: The list of detected vulnerabilities. Cannot be empty. + items: + $ref: "#/components/schemas/CycloneDXVulnerability" + type: array + required: + - bomFormat + - specVersion + - metadata + - components + - vulnerabilities + type: object + CycloneDXComponent: + description: A software component identified during scanning. + properties: + bom-ref: + description: A unique reference identifier used to link vulnerabilities to this component. + example: a3390fca-c315-41ae-ae05-af5e7859cdee + type: string + name: + description: The name of the component. + example: lodash + type: string + purl: + description: The Package URL (PURL) of the component. Required when `type` is `library`. + 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 scanned component. + enum: + - library + - application + - operating-system + example: library + type: string + x-enum-varnames: + - LIBRARY + - APPLICATION + - OPERATING_SYSTEM + CycloneDXMetadata: + description: Metadata about the BOM, including the scanned asset and the scanner tool. + properties: + component: + $ref: "#/components/schemas/CycloneDXMetadataComponent" + tools: + $ref: "#/components/schemas/CycloneDXMetadataTools" + required: + - component + - tools + type: object + CycloneDXMetadataComponent: + description: The asset that was scanned (for example, a host or container image). + properties: + bom-ref: + description: >- + A unique reference identifier for this metadata component. If set, must match a `bom-ref` in `components`. + example: host-ref-abc123 + type: string + name: + description: The name or identifier of the scanned asset (for example, an instance ID or hostname). + example: i-12345 + type: string + type: + description: The type of the scanned asset. + example: operating-system + type: string + required: + - name + type: object + CycloneDXMetadataTools: + description: Information about the scanner tool that produced this BOM. + properties: + components: + description: The scanner tool components. Must contain exactly one element. + items: + $ref: "#/components/schemas/CycloneDXToolComponent" + type: array + required: + - components + type: object + CycloneDXToolComponent: + description: A scanner tool component. + properties: + name: + description: The name of the scanner tool. + example: my-scanner + type: string + type: + description: The type of the tool component. + example: application + type: string + required: + - name + type: object + CycloneDXVulnerability: + description: A security vulnerability affecting one or more components. + properties: + advisories: + description: External advisory references for the vulnerability. + items: + $ref: "#/components/schemas/CycloneDXVulnerabilityAdvisory" + type: array + affects: + description: >- + The components affected by this vulnerability. Must be non-empty. Each `ref` must match a `bom-ref` in `components`. + items: + $ref: "#/components/schemas/CycloneDXVulnerabilityAffects" + type: array + analysis: + $ref: "#/components/schemas/CycloneDXVulnerabilityAnalysis" + cwes: + description: CWE identifiers associated with the vulnerability. + example: [123, 345] + items: + format: int64 + type: integer + type: array + description: + description: A short 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 vulnerability identifier (for example, a CVE ID). + example: CVE-2021-1234 + type: string + ratings: + description: The severity ratings for the vulnerability. Must contain exactly one element. + items: + $ref: "#/components/schemas/CycloneDXVulnerabilityRating" + type: array + references: + description: External reference identifiers for the vulnerability. + items: + $ref: "#/components/schemas/CycloneDXVulnerabilityReference" + type: array + required: + - id + - ratings + - affects + type: object + CycloneDXVulnerabilityAdvisory: + description: An external advisory reference for a vulnerability. + properties: + url: + description: The URL of the advisory. + example: "https://example.com/advisory/CVE-2021-1234" + type: string + type: object + CycloneDXVulnerabilityAffects: + description: A reference to a component affected by a vulnerability. + properties: + ref: + description: The `bom-ref` of the affected component. + example: a3390fca-c315-41ae-ae05-af5e7859cdee + type: string + required: + - ref + type: object + CycloneDXVulnerabilityAnalysis: + description: |- + The exploitability analysis for the vulnerability. When `state` is set to `resolved` + or `resolved_with_pedigree`, the vulnerability is closed in Datadog. + Other state values are accepted but have no effect on the vulnerability status. + properties: + state: + description: The vulnerability analysis state. + example: resolved + type: string + type: object + CycloneDXVulnerabilityRating: + description: A severity rating for a vulnerability. + 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 + CycloneDXVulnerabilityReference: + description: An external reference identifier for a vulnerability. + properties: + id: + description: The identifier of the external reference (for example, a GHSA ID). + example: GHSA-35m5-8cvj-8783 + type: string + source: + $ref: "#/components/schemas/CycloneDXVulnerabilityReferenceSource" + type: object + CycloneDXVulnerabilityReferenceSource: + description: The source of an external vulnerability reference. + properties: + url: + description: The URL of the reference source. + example: "https://example.com" + type: string + 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. example: @@ -174464,6 +174707,91 @@ paths: x-sunset: "2027-01-01" x-unstable: |- **Note**: This endpoint is deprecated. See the [List Security Findings endpoint](https://docs.datadoghq.com/api/latest/security-monitoring/#list-security-findings). + post: + description: |- + Import security vulnerabilities from an external scanner in CycloneDX 1.5 format. + + The payload is validated against the CycloneDX 1.5 JSON schema and the following + additional constraints: + + - `metadata`, `metadata.component`, and `metadata.component.name` are required. + - `metadata.tools.components` must contain exactly one element with a `name` field. + - `components` cannot be empty. Each component requires `bom-ref`, `type`, `name`, and `version`. + - When `type` is `library`, `purl` is required and must be a valid PURL. + - When `type` is `operating-system`, `name` must be one of the supported OS values: + `alma`, `alpine`, `amazon`, `azurelinux`, `bottlerocket`, `cbl-mariner`, `chainguard`, + `centos`, `debian`, `fedora`, `opensuse`, `opensuse-leap`, `opensuse-tumbleweed`, + `oracle`, `photon`, `redhat`, `rocky`, `slem`, `sles`, `ubuntu`, `wolfi`, `windows`, `macos`. + - `vulnerabilities` cannot be empty. Each vulnerability requires `id`, exactly one `ratings` entry, + and at least one `affects` entry. + - Each `affects[].ref` must match a `bom-ref` value in `components`. + operationId: ImportSecurityVulnerabilities + requestBody: + content: + application/json: + examples: + default: + 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: + name: i-12345 + type: operating-system + tools: + components: + - name: my-scanner + type: application + specVersion: "1.5" + version: 1 + vulnerabilities: + - affects: + - ref: a3390fca-c315-41ae-ae05-af5e7859cdee + description: "Sample vulnerability detected in the application." + 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" + schema: + $ref: "#/components/schemas/CycloneDXBom" + required: true + responses: + "200": + description: Vulnerabilities accepted successfully. + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + "500": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_findings_write + summary: Import security vulnerabilities + tags: + - Security Monitoring + x-codegen-request-body-name: body + "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/ImportSecurityVulnerabilities.rb b/examples/v2/security-monitoring/ImportSecurityVulnerabilities.rb new file mode 100644 index 000000000000..86ab98f6a915 --- /dev/null +++ b/examples/v2/security-monitoring/ImportSecurityVulnerabilities.rb @@ -0,0 +1,77 @@ +# Import security vulnerabilities returns "Vulnerabilities accepted successfully." 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::CycloneDXMetadataComponent.new({ + bom_ref: "host-ref-abc123", + name: "i-12345", + type: "operating-system", + }), + tools: DatadogAPIClient::V2::CycloneDXMetadataTools.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::CycloneDXVulnerabilityAdvisory.new({ + url: "https://example.com/advisory/CVE-2021-1234", + }), + ], + affects: [ + DatadogAPIClient::V2::CycloneDXVulnerabilityAffects.new({ + ref: "a3390fca-c315-41ae-ae05-af5e7859cdee", + }), + ], + analysis: DatadogAPIClient::V2::CycloneDXVulnerabilityAnalysis.new({ + state: "resolved", + }), + cwes: [ + 123, + 345, + ], + description: "Sample vulnerability detected in the application.", + detail: "Details about the vulnerability.", + id: "CVE-2021-1234", + ratings: [ + DatadogAPIClient::V2::CycloneDXVulnerabilityRating.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::CycloneDXVulnerabilityReference.new({ + id: "GHSA-35m5-8cvj-8783", + source: DatadogAPIClient::V2::CycloneDXVulnerabilityReferenceSource.new({ + url: "https://example.com", + }), + }), + ], + }), + ], +}) +p api_instance.import_security_vulnerabilities(body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 126df7bea216..2d8697481d3a 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2238,6 +2238,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 0c14124aaecc..3ec8e88ce325 100644 --- a/features/v2/security_monitoring.feature +++ b/features/v2/security_monitoring.feature @@ -2308,6 +2308,22 @@ Feature: Security Monitoring When the request is sent Then the response status is 400 Bad Request + @generated @skip @team:DataDog/k9-cloud-vm + Scenario: Import security 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": "host-ref-abc123", "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"}], "analysis": {"state": "resolved"}, "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/k9-cloud-vm + Scenario: Import security vulnerabilities returns "Vulnerabilities accepted successfully." 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": "host-ref-abc123", "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"}], "analysis": {"state": "resolved"}, "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 Vulnerabilities accepted successfully. + @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 c07e3792ac55..486933f758d5 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -7294,6 +7294,12 @@ "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 8ce53bbd79d1..c7367d367d50 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -385,6 +385,7 @@ def initialize "v2.get_static_analysis_node_types": false, "v2.get_static_analysis_ruleset": false, "v2.get_static_analysis_tree_sitter_wasm": false, + "v2.import_security_vulnerabilities": false, "v2.list_findings": false, "v2.list_historical_jobs": false, "v2.list_indicators_of_compromise": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 5be0a02cbd93..51c3a4814b0a 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -2691,6 +2691,20 @@ def overrides "v2.custom_ruleset_request_data_attributes" => "CustomRulesetRequestDataAttributes", "v2.custom_ruleset_response" => "CustomRulesetResponse", "v2.cvss" => "CVSS", + "v2.cyclone_dx_bom" => "CycloneDXBom", + "v2.cyclone_dx_component" => "CycloneDXComponent", + "v2.cyclone_dx_component_type" => "CycloneDXComponentType", + "v2.cyclone_dx_metadata" => "CycloneDXMetadata", + "v2.cyclone_dx_metadata_component" => "CycloneDXMetadataComponent", + "v2.cyclone_dx_metadata_tools" => "CycloneDXMetadataTools", + "v2.cyclone_dx_tool_component" => "CycloneDXToolComponent", + "v2.cyclone_dx_vulnerability" => "CycloneDXVulnerability", + "v2.cyclone_dx_vulnerability_advisory" => "CycloneDXVulnerabilityAdvisory", + "v2.cyclone_dx_vulnerability_affects" => "CycloneDXVulnerabilityAffects", + "v2.cyclone_dx_vulnerability_analysis" => "CycloneDXVulnerabilityAnalysis", + "v2.cyclone_dx_vulnerability_rating" => "CycloneDXVulnerabilityRating", + "v2.cyclone_dx_vulnerability_reference" => "CycloneDXVulnerabilityReference", + "v2.cyclone_dx_vulnerability_reference_source" => "CycloneDXVulnerabilityReferenceSource", "v2.dashboard_list_add_items_request" => "DashboardListAddItemsRequest", "v2.dashboard_list_add_items_response" => "DashboardListAddItemsResponse", "v2.dashboard_list_delete_items_request" => "DashboardListDeleteItemsRequest", 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 a0d5f1b64780..ee29d62cdb0a 100644 --- a/lib/datadog_api_client/v2/api/security_monitoring_api.rb +++ b/lib/datadog_api_client/v2/api/security_monitoring_api.rb @@ -6991,6 +6991,94 @@ def get_vulnerability_notification_rules_with_http_info(opts = {}) return data, status_code, headers end + # Import security 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 security vulnerabilities. + # + # Import security vulnerabilities from an external scanner in CycloneDX 1.5 format. + # + # The payload is validated against the CycloneDX 1.5 JSON schema and the following + # additional constraints: + # + # - `metadata`, `metadata.component`, and `metadata.component.name` are required. + # - `metadata.tools.components` must contain exactly one element with a `name` field. + # - `components` cannot be empty. Each component requires `bom-ref`, `type`, `name`, and `version`. + # - When `type` is `library`, `purl` is required and must be a valid PURL. + # - When `type` is `operating-system`, `name` must be one of the supported OS values: + # `alma`, `alpine`, `amazon`, `azurelinux`, `bottlerocket`, `cbl-mariner`, `chainguard`, + # `centos`, `debian`, `fedora`, `opensuse`, `opensuse-leap`, `opensuse-tumbleweed`, + # `oracle`, `photon`, `redhat`, `rocky`, `slem`, `sles`, `ubuntu`, `wolfi`, `windows`, `macos`. + # - `vulnerabilities` cannot be empty. Each vulnerability requires `id`, exactly one `ratings` entry, + # and at least one `affects` entry. + # - Each `affects[].ref` must match a `bom-ref` value in `components`. + # + # @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, :AuthZ] + + 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 + # List assets SBOMs. # # @see #list_assets_sbo_ms_with_http_info diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_bom.rb b/lib/datadog_api_client/v2/models/cyclone_dx_bom.rb new file mode 100644 index 000000000000..0c5459129589 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_bom.rb @@ -0,0 +1,221 @@ +=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 CycloneDX 1.5 Bill of Materials (BOM) document containing vulnerability data. + class CycloneDXBom + include BaseGenericModel + + # The BOM format identifier. Must be `CycloneDX`. + attr_reader :bom_format + + # The list of scanned software components. Cannot be empty. + attr_reader :components + + # Metadata about the BOM, including the scanned asset and the scanner tool. + attr_reader :metadata + + # The CycloneDX specification version. Must be `1.5`. + attr_reader :spec_version + + # The version number of the BOM document. + attr_accessor :version + + # The list of detected vulnerabilities. Cannot be empty. + 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 @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 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/cyclone_dx_component.rb b/lib/datadog_api_client/v2/models/cyclone_dx_component.rb new file mode 100644 index 000000000000..fe778727672e --- /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 software component identified during scanning. + class CycloneDXComponent + include BaseGenericModel + + # A unique reference identifier used to link vulnerabilities to this component. + attr_reader :bom_ref + + # The name of the component. + attr_reader :name + + # The Package URL (PURL) of the component. Required when `type` is `library`. + attr_accessor :purl + + # The type of the scanned component. + 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..b51bdd0d1314 --- /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 scanned component. + 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..6af66c6c039c --- /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 about the BOM, including the scanned asset and the scanner tool. + class CycloneDXMetadata + include BaseGenericModel + + # The asset that was scanned (for example, a host or container image). + attr_reader :component + + # Information about the scanner tool that produced this 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' => :'CycloneDXMetadataComponent', + :'tools' => :'CycloneDXMetadataTools' + } + 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_metadata_component.rb b/lib/datadog_api_client/v2/models/cyclone_dx_metadata_component.rb new file mode 100644 index 000000000000..ccf93a657ea6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_metadata_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 that was scanned (for example, a host or container image). + class CycloneDXMetadataComponent + include BaseGenericModel + + # A unique reference identifier for this metadata component. If set, must match a `bom-ref` in `components`. + attr_accessor :bom_ref + + # The name or identifier of the scanned asset (for example, an instance ID or hostname). + attr_reader :name + + # The type of the scanned asset. + 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::CycloneDXMetadataComponent` 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_metadata_tools.rb b/lib/datadog_api_client/v2/models/cyclone_dx_metadata_tools.rb new file mode 100644 index 000000000000..34a534c49685 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_metadata_tools.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 + # Information about the scanner tool that produced this BOM. + class CycloneDXMetadataTools + include BaseGenericModel + + # The scanner tool components. Must contain exactly one element. + 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::CycloneDXMetadataTools` 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? + 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 + @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_tool_component.rb b/lib/datadog_api_client/v2/models/cyclone_dx_tool_component.rb new file mode 100644 index 000000000000..ba2053d95575 --- /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 + # A scanner tool component. + class CycloneDXToolComponent + include BaseGenericModel + + # The name of the scanner tool. + attr_reader :name + + # The type of the tool component. + 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_vulnerability.rb b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability.rb new file mode 100644 index 000000000000..2c862517cfca --- /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 security vulnerability affecting one or more components. + class CycloneDXVulnerability + include BaseGenericModel + + # External advisory references for the vulnerability. + attr_accessor :advisories + + # The components affected by this vulnerability. Must be non-empty. Each `ref` must match a `bom-ref` in `components`. + attr_reader :affects + + # The exploitability analysis for the vulnerability. When `state` is set to `resolved` + # or `resolved_with_pedigree`, the vulnerability is closed in Datadog. + # Other state values are accepted but have no effect on the vulnerability status. + attr_accessor :analysis + + # CWE identifiers associated with the vulnerability. + attr_accessor :cwes + + # A short description of the vulnerability. + attr_accessor :description + + # Detailed information about the vulnerability. + attr_accessor :detail + + # The vulnerability identifier (for example, a CVE ID). + attr_reader :id + + # The severity ratings for the vulnerability. Must contain exactly one element. + attr_reader :ratings + + # External reference identifiers 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', + :'analysis' => :'analysis', + :'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', + :'analysis' => :'CycloneDXVulnerabilityAnalysis', + :'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?(:'analysis') + self.analysis = attributes[:'analysis'] + 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 @id.nil? + return false if @ratings.nil? + 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 + @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 + @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 && + analysis == o.analysis && + 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, analysis, cwes, description, detail, id, ratings, references, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_advisory.rb b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_advisory.rb new file mode 100644 index 000000000000..373506f70dc9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_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 + # An external advisory reference for a vulnerability. + class CycloneDXVulnerabilityAdvisory + include BaseGenericModel + + # The URL of 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::CycloneDXVulnerabilityAdvisory` 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_vulnerability_affects.rb b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_affects.rb new file mode 100644 index 000000000000..aa386809d996 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_affects.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 + # A reference to a component affected by a vulnerability. + class CycloneDXVulnerabilityAffects + include BaseGenericModel + + # The `bom-ref` of the affected component. + 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::CycloneDXVulnerabilityAffects` 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_vulnerability_analysis.rb b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_analysis.rb new file mode 100644 index 000000000000..ee6e722859e5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_analysis.rb @@ -0,0 +1,107 @@ +=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 exploitability analysis for the vulnerability. When `state` is set to `resolved` + # or `resolved_with_pedigree`, the vulnerability is closed in Datadog. + # Other state values are accepted but have no effect on the vulnerability status. + class CycloneDXVulnerabilityAnalysis + include BaseGenericModel + + # The vulnerability analysis state. + attr_accessor :state + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'state' => :'state' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'state' => :'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::CycloneDXVulnerabilityAnalysis` 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?(:'state') + self.state = attributes[:'state'] + 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 && + state == o.state && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [state, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_rating.rb b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_rating.rb new file mode 100644 index 000000000000..301122a15fb6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_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 + # A severity rating for a vulnerability. + class CycloneDXVulnerabilityRating + 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::CycloneDXVulnerabilityRating` 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_vulnerability_reference.rb b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_reference.rb new file mode 100644 index 000000000000..745fce8f47c0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_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 + # An external reference identifier for a vulnerability. + class CycloneDXVulnerabilityReference + include BaseGenericModel + + # The identifier of the external reference (for example, a GHSA ID). + attr_accessor :id + + # The source of an external vulnerability 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' => :'CycloneDXVulnerabilityReferenceSource' + } + 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::CycloneDXVulnerabilityReference` 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_vulnerability_reference_source.rb b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_reference_source.rb new file mode 100644 index 000000000000..7d91fdfcd653 --- /dev/null +++ b/lib/datadog_api_client/v2/models/cyclone_dx_vulnerability_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 + # The source of an external vulnerability reference. + class CycloneDXVulnerabilityReferenceSource + include BaseGenericModel + + # The URL of the reference 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::CycloneDXVulnerabilityReferenceSource` 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