From 032ff1190bd0c3d2bdb14d919315e2d04eb7b172 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 26 Dec 2024 10:28:00 +0000 Subject: [PATCH] Regenerate client from commit a510256c of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 1307 +++++++++++++++++ api/datadog/configuration.go | 2 + api/datadogV2/api_security_monitoring.go | 866 +++++++++++ api/datadogV2/doc.go | 2 + api/datadogV2/model_advisory.go | 168 +++ api/datadogV2/model_asset.go | 178 +++ api/datadogV2/model_asset_attributes.go | 321 ++++ ...model_asset_attributes_operating_system.go | 136 ++ api/datadogV2/model_asset_attributes_risks.go | 241 +++ .../model_asset_attributes_version.go | 137 ++ api/datadogV2/model_asset_entity_type.go | 64 + api/datadogV2/model_asset_type.go | 72 + api/datadogV2/model_code_location.go | 171 +++ api/datadogV2/model_cvss.go | 175 +++ api/datadogV2/model_dependency_location.go | 229 +++ api/datadogV2/model_epss.go | 143 ++ api/datadogV2/model_library.go | 136 ++ api/datadogV2/model_links.go | 235 +++ .../model_list_vulnerabilities_response.go | 183 +++ .../model_list_vulnerable_assets_response.go | 183 +++ api/datadogV2/model_metadata.go | 165 +++ api/datadogV2/model_remediation.go | 325 ++++ api/datadogV2/model_vulnerabilities_type.go | 64 + api/datadogV2/model_vulnerability.go | 213 +++ .../model_vulnerability_attributes.go | 764 ++++++++++ .../model_vulnerability_attributes_cvss.go | 145 ++ ...ability_attributes_dependency_locations.go | 186 +++ .../model_vulnerability_ecosystem.go | 84 ++ .../model_vulnerability_relationships.go | 110 ++ ...del_vulnerability_relationships_affects.go | 110 ++ ...ulnerability_relationships_affects_data.go | 143 ++ api/datadogV2/model_vulnerability_risks.go | 241 +++ api/datadogV2/model_vulnerability_severity.go | 74 + api/datadogV2/model_vulnerability_status.go | 72 + api/datadogV2/model_vulnerability_tool.go | 68 + api/datadogV2/model_vulnerability_type.go | 146 ++ .../ListVulnerabilities.go | 30 + .../ListVulnerableAssets.go | 30 + ...d_with_the_provided_token._response.freeze | 1 + ...ted_with_the_provided_token._response.yaml | 19 + ...vulnerabilities_returns_OK_response.freeze | 1 + ...t_vulnerabilities_returns_OK_response.yaml | 19 + ...d_with_the_provided_token._response.freeze | 1 + ...ted_with_the_provided_token._response.yaml | 19 + ...lnerable_assets_returns_OK_response.freeze | 1 + ...vulnerable_assets_returns_OK_response.yaml | 19 + .../features/v2/security_monitoring.feature | 52 + tests/scenarios/features/v2/undo.json | 12 + 49 files changed, 8067 insertions(+), 4 deletions(-) create mode 100644 api/datadogV2/model_advisory.go create mode 100644 api/datadogV2/model_asset.go create mode 100644 api/datadogV2/model_asset_attributes.go create mode 100644 api/datadogV2/model_asset_attributes_operating_system.go create mode 100644 api/datadogV2/model_asset_attributes_risks.go create mode 100644 api/datadogV2/model_asset_attributes_version.go create mode 100644 api/datadogV2/model_asset_entity_type.go create mode 100644 api/datadogV2/model_asset_type.go create mode 100644 api/datadogV2/model_code_location.go create mode 100644 api/datadogV2/model_cvss.go create mode 100644 api/datadogV2/model_dependency_location.go create mode 100644 api/datadogV2/model_epss.go create mode 100644 api/datadogV2/model_library.go create mode 100644 api/datadogV2/model_links.go create mode 100644 api/datadogV2/model_list_vulnerabilities_response.go create mode 100644 api/datadogV2/model_list_vulnerable_assets_response.go create mode 100644 api/datadogV2/model_metadata.go create mode 100644 api/datadogV2/model_remediation.go create mode 100644 api/datadogV2/model_vulnerabilities_type.go create mode 100644 api/datadogV2/model_vulnerability.go create mode 100644 api/datadogV2/model_vulnerability_attributes.go create mode 100644 api/datadogV2/model_vulnerability_attributes_cvss.go create mode 100644 api/datadogV2/model_vulnerability_attributes_dependency_locations.go create mode 100644 api/datadogV2/model_vulnerability_ecosystem.go create mode 100644 api/datadogV2/model_vulnerability_relationships.go create mode 100644 api/datadogV2/model_vulnerability_relationships_affects.go create mode 100644 api/datadogV2/model_vulnerability_relationships_affects_data.go create mode 100644 api/datadogV2/model_vulnerability_risks.go create mode 100644 api/datadogV2/model_vulnerability_severity.go create mode 100644 api/datadogV2/model_vulnerability_status.go create mode 100644 api/datadogV2/model_vulnerability_tool.go create mode 100644 api/datadogV2/model_vulnerability_type.go create mode 100644 examples/v2/security-monitoring/ListVulnerabilities.go create mode 100644 examples/v2/security-monitoring/ListVulnerableAssets.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_OK_response.yaml diff --git a/.apigentools-info b/.apigentools-info index 0ac30ddc4c4..7ca2aafd434 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-12-19 07:26:27.191303", - "spec_repo_commit": "5dd2cbe4" + "regenerated": "2024-12-26 10:26:44.419873", + "spec_repo_commit": "a510256c" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-12-19 07:26:27.207255", - "spec_repo_commit": "5dd2cbe4" + "regenerated": "2024-12-26 10:26:44.434978", + "spec_repo_commit": "a510256c" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 3480f9db3a7..3e1d95e9a26 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1601,6 +1601,25 @@ components: type: string x-enum-varnames: - BILLING_DIMENSIONS + Advisory: + description: Advisory. + properties: + base_severity: + description: Advisory base severity. + example: Critical + type: string + id: + description: Advisory id. + example: GHSA-4wrc-f8pq-fpqp + type: string + severity: + description: Advisory Datadog severity. + example: Medium + type: string + required: + - id + - base_severity + type: object ApiID: description: API identifier. example: 90646597-5fdb-4a17-a240-647003f8c028 @@ -1907,6 +1926,131 @@ components: - CREATED_AT_DESC - UPDATED_AT_DESC - USER_NAME_DESC + Asset: + description: A single vulnerable asset + properties: + attributes: + $ref: '#/components/schemas/AssetAttributes' + id: + description: The unique ID for this asset. + example: Repository|github.com/DataDog/datadog-agent.git + type: string + type: + $ref: '#/components/schemas/AssetEntityType' + required: + - id + - type + - attributes + type: object + AssetAttributes: + description: The JSON:API attributes of the asset. + properties: + arch: + description: Asset architecture. + example: arm64 + type: string + environments: + description: List of environments where the asset is deployed. + example: + - staging + items: + example: staging + type: string + type: array + name: + description: Asset name. + example: github.com/DataDog/datadog-agent.git + type: string + operating_system: + $ref: '#/components/schemas/AssetAttributesOperatingSystem' + risks: + $ref: '#/components/schemas/AssetAttributesRisks' + type: + $ref: '#/components/schemas/AssetType' + version: + $ref: '#/components/schemas/AssetAttributesVersion' + required: + - name + - type + - risks + - environments + type: object + AssetAttributesOperatingSystem: + description: Asset operating system. + properties: + description: + description: Operating system version. + example: '24.04' + type: string + name: + description: Operating system name. + example: ubuntu + type: string + required: + - name + type: object + AssetAttributesRisks: + description: Asset risks. + properties: + has_access_to_sensitive_data: + description: Whether the asset has access to sensitive data or not. + example: false + type: boolean + has_privileged_access: + description: Whether the asset has privileged access or not. + example: false + type: boolean + in_production: + description: Whether the asset is in production or not. + example: false + type: boolean + is_publicly_accessible: + description: Whether the asset is publicly accessible or not. + example: false + type: boolean + under_attack: + description: Whether the asset is under attack or not. + example: false + type: boolean + required: + - in_production + type: object + AssetAttributesVersion: + description: Asset version. + properties: + first: + description: Asset first version. + example: _latest + type: string + last: + description: Asset last version. + example: _latest + type: string + type: object + AssetEntityType: + description: The JSON:API type. + enum: + - assets + example: assets + type: string + x-enum-varnames: + - ASSETS + AssetType: + description: The asset type + enum: + - Repository + - Service + - Host + - HostImage + - Image + example: Repository + type: string + x-enum-varnames: + - REPOSITORY + - SERVICE + - HOST + - HOSTIMAGE + - IMAGE AuditLogsEvent: description: Object description of an Audit Logs event after it is processed and stored by Datadog. @@ -4508,6 +4652,25 @@ components: type: string x-enum-varnames: - DATADOG_AGENT + CVSS: + description: Vulnerability severity. + properties: + score: + description: Vulnerability severity score. + example: 4.5 + format: double + type: number + severity: + $ref: '#/components/schemas/VulnerabilitySeverity' + vector: + description: Vulnerability CVSS vector. + example: CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H + type: string + required: + - score + - severity + - vector + type: object CalculatedField: description: Calculated field. properties: @@ -5669,6 +5832,24 @@ components: $ref: '#/components/schemas/CloudflareAccountResponseData' type: array type: object + CodeLocation: + description: Code vulnerability location. + properties: + file_path: + description: Vulnerability location file path. + example: src/Class.java:100 + type: string + location: + description: Vulnerability extracted location. + example: com.example.Class:100 + type: string + method: + description: Vulnerability location method. + example: FooBar + type: string + required: + - location + type: object Component: description: The definition of `Component` object. properties: @@ -8676,6 +8857,40 @@ components: type: string x-enum-varnames: - APPDEFINITIONS + DependencyLocation: + description: Static library vulnerability location. + properties: + column_end: + description: Location column end. + example: 140 + format: int64 + type: integer + column_start: + description: Location column start. + example: 5 + format: int64 + type: integer + file_name: + description: Location file name. + example: src/go.mod + type: string + line_end: + description: Location line end. + example: 10 + format: int64 + type: integer + line_start: + description: Location line start. + example: 1 + format: int64 + type: integer + required: + - file_name + - line_start + - line_end + - column_start + - column_end + type: object DeployAppResponse: description: The definition of `DeployAppResponse` object. properties: @@ -9709,6 +9924,20 @@ components: - type - attributes type: object + EPSS: + description: Vulnerability EPSS severity. + properties: + score: + description: Vulnerability EPSS severity score. + example: 0.2 + format: double + type: number + severity: + $ref: '#/components/schemas/VulnerabilitySeverity' + required: + - score + - severity + type: object EntityAttributes: description: Entity attributes. properties: @@ -15021,6 +15250,48 @@ components: type: string x-enum-varnames: - LEAKED_KEYS + Library: + description: Vulnerability library. + properties: + name: + description: Vulnerability library name. + example: linux-aws-5.15 + type: string + version: + description: Vulnerability library version. + example: 5.15.0 + type: string + required: + - name + type: object + Links: + description: The JSON:API links related to pagination. + properties: + first: + description: First page link. + example: https://api.datadoghq.com/api/v2/security/vulnerabilities?page%5Bnumber%5D=1&page%5Btoken%5D=b82cef018aab81ed1d4bb4xb35xxfc065da7efa685fbcecdbd338f3015e3afabbbfa3a911b4984_721ee28a-zecb-4e45-9960-c42065b574f4 + type: string + last: + description: Last page link. + example: https://api.datadoghq.com/api/v2/security/vulnerabilities?page%5Bnumber%5D=15&page%5Btoken%5D=b82cef018aab81ed1d4bb4xb35xxfc065da7efa685fbcecdbd338f3015e3afabbbfa3a911b4984_721ee28a-zecb-4e45-9960-c42065b574f4 + type: string + next: + description: Next page link. + example: https://api.datadoghq.com/api/v2/security/vulnerabilities?page%5Bnumber%5D=16&page%5Btoken%5D=b82cef018aab81ed1d4bb4xb35xxfc065da7efa685fbcecdbd338f3015e3afabbbfa3a911b4984_721ee28a-zecb-4e45-9960-c42065b574f4 + type: string + previous: + description: Previous page link. + example: https://api.datadoghq.com/api/v2/security/vulnerabilities?page%5Bnumber%5D=14&page%5Btoken%5D=b82cef018aab81ed1d4bb4xb35xxfc065da7efa685fbcecdbd338f3015e3afabbbfa3a911b4984_721ee28a-zecb-4e45-9960-c42065b574f4 + type: string + self: + description: Request link. + example: https://api.datadoghq.com/api/v2/security/vulnerabilities?filter%5Btool%5D=Infra + type: string + required: + - self + - first + - last + type: object ListAPIsResponse: description: Response for `ListAPIs`. properties: @@ -15417,6 +15688,36 @@ components: - _NAME - USER_COUNT - _USER_COUNT + ListVulnerabilitiesResponse: + description: The expected response schema when listing vulnerabilities. + properties: + data: + description: List of vulnerabilities. + items: + $ref: '#/components/schemas/Vulnerability' + type: array + links: + $ref: '#/components/schemas/Links' + meta: + $ref: '#/components/schemas/Metadata' + required: + - data + type: object + ListVulnerableAssetsResponse: + description: The expected response schema when listing vulnerable assets. + properties: + data: + description: List of vulnerable assets. + items: + $ref: '#/components/schemas/Asset' + type: array + links: + $ref: '#/components/schemas/Links' + meta: + $ref: '#/components/schemas/Metadata' + required: + - data + type: object Log: description: Object description of a log after being processed and stored by Datadog. @@ -16579,6 +16880,28 @@ components: - ms_channel_name - redirect_url type: object + Metadata: + description: The metadata related to this request. + properties: + count: + description: Number of entities included in the response. + example: 150 + format: int64 + type: integer + token: + description: The token that identifies the request. + example: b82cef018aab81ed1d4bb4xb35xxfc065da7efa685fbcecdbd338f3015e3afabbbfa3a911b4984_721ee28a-zecb-4e45-9960-c42065b574f4 + type: string + total: + description: Total number of entities across all pages. + example: 152431 + format: int64 + type: integer + required: + - count + - total + - token + type: object Metric: description: Object for a single metric tag configuration. example: @@ -21264,6 +21587,56 @@ components: required: - data type: object + Remediation: + description: Vulnerability remediation. + properties: + auto_solvable: + description: Whether the vulnerability can be resolved when recompiling + the package or not. + example: false + type: boolean + avoided_advisories: + description: Avoided advisories. + items: + $ref: '#/components/schemas/Advisory' + type: array + fixed_advisories: + description: Remediation fixed advisories. + items: + $ref: '#/components/schemas/Advisory' + type: array + library_name: + description: Library name remediating the vulnerability. + example: stdlib + type: string + library_version: + description: Library version remediating the vulnerability. + example: Upgrade to a version >= 1.20.0 + type: string + new_advisories: + description: New advisories. + items: + $ref: '#/components/schemas/Advisory' + type: array + remaining_advisories: + description: Remaining advisories. + items: + $ref: '#/components/schemas/Advisory' + type: array + type: + description: Remediation type. + example: text + type: string + required: + - type + - library_name + - library_version + - auto_solvable + - fixed_advisories + - remaining_advisories + - new_advisories + - avoided_advisories + type: object ReorderRetentionFiltersRequest: description: A list of retention filters to reorder. properties: @@ -29036,6 +29409,378 @@ components: type: string x-enum-varnames: - USERS + VulnerabilitiesType: + description: The JSON:API type. + enum: + - vulnerabilities + example: vulnerabilities + type: string + x-enum-varnames: + - VULNERABILITIES + Vulnerability: + description: A single vulnerability + properties: + attributes: + $ref: '#/components/schemas/VulnerabilityAttributes' + id: + description: The unique ID for this vulnerability. + example: 3ecdfea798f2ce8f6e964805a344945f + type: string + relationships: + $ref: '#/components/schemas/VulnerabilityRelationships' + type: + $ref: '#/components/schemas/VulnerabilitiesType' + required: + - id + - type + - attributes + - relationships + type: object + VulnerabilityAttributes: + description: The JSON:API attributes of the vulnerability. + properties: + advisory_id: + description: Vulnerability advisory ID. + example: TRIVY-CVE-2023-0615 + type: string + code_location: + $ref: '#/components/schemas/CodeLocation' + cve_list: + description: Vulnerability CVE list. + example: + - CVE-2023-0615 + items: + example: CVE-2023-0615 + type: string + type: array + cvss: + $ref: '#/components/schemas/VulnerabilityAttributesCvss' + dependency_locations: + $ref: '#/components/schemas/VulnerabilityAttributesDependencyLocations' + description: + description: Vulnerability description. + example: LDAP Injection is a security vulnerability that occurs when untrusted + user input is improperly handled and directly incorporated into LDAP queries + without appropriate sanitization or validation. This vulnerability enables + attackers to manipulate LDAP queries and potentially gain unauthorized + access, modify data, or extract sensitive information from the directory + server. By exploiting the LDAP injection vulnerability, attackers can + execute malicious commands, bypass authentication mechanisms, and perform + unauthorized actions within the directory service. + type: string + ecosystem: + $ref: '#/components/schemas/VulnerabilityEcosystem' + exposure_time: + description: Vulnerability exposure time in seconds. + example: 5618604 + format: int64 + type: integer + first_detection: + description: First detection of the vulnerability in [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) + format + example: 2024-09-19 21:23:08+00:00 + type: string + fix_available: + description: Whether the vulnerability has a remediation or not. + example: false + type: boolean + language: + description: Vulnerability language. + example: ubuntu + type: string + last_detection: + description: Last detection of the vulnerability in [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) + format + example: 2024-09-01 21:23:08+00:00 + type: string + library: + $ref: '#/components/schemas/Library' + remediations: + description: List of remediations. + items: + $ref: '#/components/schemas/Remediation' + type: array + repo_digests: + description: Vulnerability `repo_digest` list (when the vulnerability is + related to `Image` asset). + items: + example: sha256:0ae7da091191787229d321e3638e39c319a97d6e20f927d465b519d699215bf7 + type: string + type: array + risks: + $ref: '#/components/schemas/VulnerabilityRisks' + status: + $ref: '#/components/schemas/VulnerabilityStatus' + title: + description: Vulnerability title. + example: LDAP Injection + type: string + tool: + $ref: '#/components/schemas/VulnerabilityTool' + type: + $ref: '#/components/schemas/VulnerabilityType' + required: + - type + - cvss + - status + - tool + - title + - description + - cve_list + - risks + - language + - first_detection + - last_detection + - exposure_time + - remediations + - fix_available + type: object + VulnerabilityAttributesCvss: + description: Vulnerability severities. + properties: + base: + $ref: '#/components/schemas/CVSS' + datadog: + $ref: '#/components/schemas/CVSS' + required: + - base + - datadog + type: object + VulnerabilityAttributesDependencyLocations: + description: Static library vulnerability location. + properties: + block: + $ref: '#/components/schemas/DependencyLocation' + name: + $ref: '#/components/schemas/DependencyLocation' + version: + $ref: '#/components/schemas/DependencyLocation' + required: + - block + type: object + VulnerabilityEcosystem: + description: The related vulnerability asset ecosystem. + enum: + - PyPI + - Maven + - NuGet + - Npm + - RubyGems + - Go + - Packagist + - Ddeb + - Rpm + - Apk + - Windows + type: string + x-enum-varnames: + - PYPI + - MAVEN + - NUGET + - NPM + - RUBY_GEMS + - GO + - PACKAGIST + - D_DEB + - RPM + - APK + - WINDOWS + VulnerabilityRelationships: + description: Related entities object. + properties: + affects: + $ref: '#/components/schemas/VulnerabilityRelationshipsAffects' + required: + - affects + type: object + VulnerabilityRelationshipsAffects: + description: Relationship type. + properties: + data: + $ref: '#/components/schemas/VulnerabilityRelationshipsAffectsData' + required: + - data + type: object + VulnerabilityRelationshipsAffectsData: + description: Asset affected by this vulnerability. + properties: + id: + description: The unique ID for this related asset. + example: Repository|github.com/DataDog/datadog-agent.git + type: string + type: + $ref: '#/components/schemas/AssetEntityType' + required: + - id + - type + type: object + VulnerabilityRisks: + description: Vulnerability risks. + properties: + epss: + $ref: '#/components/schemas/EPSS' + exploit_available: + description: Vulnerability public exploit availability. + example: false + type: boolean + exploit_sources: + description: Vulnerability exploit sources. + example: + - NIST + items: + example: NIST + type: string + type: array + exploitation_probability: + description: Vulnerability exploitation probability. + example: false + type: boolean + poc_exploit_available: + description: Vulnerability POC exploit availability. + example: false + type: boolean + required: + - exploitation_probability + - poc_exploit_available + - exploit_available + - exploit_sources + type: object + VulnerabilitySeverity: + description: The vulnerability severity. + enum: + - Unknown + - None + - Low + - Medium + - High + - Critical + example: Medium + type: string + x-enum-varnames: + - UNKNOWN + - NONE + - LOW + - MEDIUM + - HIGH + - CRITICAL + VulnerabilityStatus: + description: The vulnerability status. + enum: + - Open + - Muted + - Remediated + - InProgress + - AutoClosed + example: Open + type: string + x-enum-varnames: + - OPEN + - MUTED + - REMEDIATED + - INPROGRESS + - AUTOCLOSED + VulnerabilityTool: + description: The vulnerability tool. + enum: + - IAST + - SCA + - Infra + example: SCA + type: string + x-enum-varnames: + - IAST + - SCA + - INFRA + VulnerabilityType: + description: The vulnerability type. + enum: + - AdminConsoleActive + - CodeInjection + - CommandInjection + - ComponentWithKnownVulnerability + - DangerousWorkflows + - DefaultAppDeployed + - DefaultHtmlEscapeInvalid + - DirectoryListingLeak + - EmailHtmlInjection + - EndOfLife + - HardcodedPassword + - HardcodedSecret + - HeaderInjection + - HstsHeaderMissing + - InsecureAuthProtocol + - InsecureCookie + - InsecureJspLayout + - LdapInjection + - MaliciousPackage + - MandatoryRemediation + - NoHttpOnlyCookie + - NoSameSiteCookie + - NoSqlMongoDbInjection + - PathTraversal + - ReflectionInjection + - RiskyLicense + - SessionRewriting + - SessionTimeout + - SqlInjection + - Ssrf + - StackTraceLeak + - TrustBoundaryViolation + - Unmaintained + - UntrustedDeserialization + - UnvalidatedRedirect + - VerbTampering + - WeakCipher + - WeakHash + - WeakRandomness + - XContentTypeHeaderMissing + - XPathInjection + - Xss + example: WeakCipher + type: string + x-enum-varnames: + - ADMIN_CONSOLE_ACTIVE + - CODE_INJECTION + - COMMAND_INJECTION + - COMPONENT_WITH_KNOWN_VULNERABILITY + - DANGEROUS_WORKFLOWS + - DEFAULT_APP_DEPLOYED + - DEFAULT_HTML_ESCAPE_INVALID + - DIRECTORY_LISTING_LEAK + - EMAIL_HTML_INJECTION + - END_OF_LIFE + - HARDCODED_PASSWORD + - HARDCODED_SECRET + - HEADER_INJECTION + - HSTS_HEADER_MISSING + - INSECURE_AUTH_PROTOCOL + - INSECURE_COOKIE + - INSECURE_JSP_LAYOUT + - LDAP_INJECTION + - MALICIOUS_PACKAGE + - MANDATORY_REMEDIATION + - NO_HTTP_ONLY_COOKIE + - NO_SAME_SITE_COOKIE + - NO_SQL_MONGO_DB_INJECTION + - PATH_TRAVERSAL + - REFLECTION_INJECTION + - RISKY_LICENSE + - SESSION_REWRITING + - SESSION_TIMEOUT + - SQL_INJECTION + - SSRF + - STACK_TRACE_LEAK + - TRUST_BOUNDARY_VIOLATION + - UNMAINTAINED + - UNTRUSTED_DESERIALIZATION + - UNVALIDATED_REDIRECT + - VERB_TAMPERING + - WEAK_CIPHER + - WEAK_HASH + - WEAK_RANDOMNESS + - X_CONTENT_TYPE_HEADER_MISSING + - X_PATH_INJECTION + - XSS WidgetLiveSpan: description: The available timeframes depend on the widget you are using. enum: @@ -41427,6 +42172,189 @@ paths: x-unstable: '**Note**: This endpoint is in public beta. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/security/assets: + get: + description: 'Get a list of vulnerable assets. + + + ### Pagination + + + Please review the [Pagination section for the "List Vulnerabilities"](#pagination) + endpoint. + + + ### Filtering + + + Please review the [Filtering section for the "List Vulnerabilities"](#filtering) + endpoint. + + + ### Metadata + + + Please review the [Metadata section for the "List Vulnerabilities"](#metadata) + endpoint. + + ' + operationId: ListVulnerableAssets + parameters: + - description: Its value must come from the `links` section of the response + of the first request. Do not manually edit it. + example: b82cef018aab81ed1d4bb4xb35xxfc065da7efa685fbcecdbd338f3015e3afabbbfa3a911b4984_721ee28a-zecb-4e45-9960-c42065b574f4 + in: query + name: page[token] + required: false + schema: + type: string + - description: The page number to be retrieved. It should be equal or greater + than `1` + example: 1 + in: query + name: page[number] + required: false + schema: + format: int64 + minimum: 1 + type: integer + - description: Filter by name. + example: datadog-agent + in: query + name: filter[name] + required: false + schema: + type: string + - description: Filter by type. + example: Host + in: query + name: filter[type] + required: false + schema: + $ref: '#/components/schemas/AssetType' + - description: Filter by the first version of the asset since it has been vulnerable. + example: v1.15.1 + in: query + name: filter[version.first] + required: false + schema: + type: string + - description: Filter by the last detected version of the asset. + example: v1.15.1 + in: query + name: filter[version.last] + required: false + schema: + type: string + - description: Filter by the repository url associated to the asset. + example: github.com/DataDog/datadog-agent.git + in: query + name: filter[repository_url] + required: false + schema: + type: string + - description: Filter whether the asset is in production or not. + example: false + in: query + name: filter[risks.in_production] + required: false + schema: + type: boolean + - description: Filter whether the asset (Service) is under attack or not. + example: false + in: query + name: filter[risks.under_attack] + required: false + schema: + type: boolean + - description: Filter whether the asset (Host) is publicly accessible or not. + example: false + in: query + name: filter[risks.is_publicly_accessible] + required: false + schema: + type: boolean + - description: Filter whether the asset (Host) has privileged access or not. + example: false + in: query + name: filter[risks.has_privileged_access] + required: false + schema: + type: boolean + - description: Filter whether the asset (Host) has access to sensitive data + or not. + example: false + in: query + name: filter[risks.has_access_to_sensitive_data] + required: false + schema: + type: boolean + - description: Filter by environment. + example: staging + in: query + name: filter[environments] + required: false + schema: + type: string + - description: Filter by architecture. + example: arm64 + in: query + name: filter[arch] + required: false + schema: + type: string + - description: Filter by operating system name. + example: ubuntu + in: query + name: filter[operating_system.name] + required: false + schema: + type: string + - description: Filter by operating system version. + example: '24.04' + in: query + name: filter[operating_system.version] + required: false + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListVulnerableAssetsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Bad request: The server cannot process the request due to + invalid syntax in the request.' + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Forbidden: Access denied' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Not found: There is no request associated with the provided + token.' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List vulnerable assets + tags: + - Security Monitoring + x-unstable: '**Note**: Note: This endpoint is a private preview. + + If you are interested in accessing this API, please [fill this form](https://forms.gle/kMYC1sDr6WDUBDsx9).' /api/v2/security/cloud_workload/policy/download: get: description: 'The download endpoint generates a Cloud Workload Security policy @@ -41456,6 +42384,385 @@ paths: operator: OR permissions: - security_monitoring_cws_agent_rules_read + /api/v2/security/vulnerabilities: + get: + description: "Get a list of vulnerabilities.\n\n### Pagination\n\nPagination + is enabled by default in both `vulnerabilities` and `assets`. The size of + the page varies depending on the endpoint and cannot be modified. To automate + the request of the next page, you can use the links section in the response.\n\nThis + endpoint will return paginated responses. The pages are stored in the links + section of the response:\n\n```JSON\n{\n \"data\": [...],\n \"meta\": {...},\n + \ \"links\": {\n \"self\": \"https://.../api/v2/security/vulnerabilities\",\n + \ \"first\": \"https://.../api/v2/security/vulnerabilities?page[number]=1&page[token]=abc\",\n + \ \"last\": \"https://.../api/v2/security/vulnerabilities?page[number]=43&page[token]=abc\",\n + \ \"next\": \"https://.../api/v2/security/vulnerabilities?page[number]=2&page[token]=abc\"\n + \ }\n}\n```\n\n\n- `links.previous` is empty if the first page is requested.\n- + `links.next` is empty if the last page is requested.\n\n#### Token\n\nVulnerabilities + can be created, updated or deleted at any point in time.\n\nUpon the first + request, a token is created to ensure consistency across subsequent paginated + requests.\n\nA token is valid only for 24 hours.\n\n#### First request\n\nWe + consider a request to be the first request when there is no `page[token]` + parameter.\n\nThe response of this first request contains the newly created + token in the `links` section.\n\nThis token can then be used in the subsequent + paginated requests.\n\n#### Subsequent requests\n\nAny request containing + valid `page[token]` and `page[number]` parameters will be considered a subsequent + request.\n\nIf the `token` is invalid, a `404` response will be returned.\n\nIf + the page `number` is invalid, a `400` response will be returned.\n\n### Filtering\n\nThe + request can include some filter parameters to filter the data to be retrieved. + The format of the filter parameters follows the [JSON:API format](https://jsonapi.org/format/#fetching-filtering): + `filter[$prop_name]`, where `prop_name` is the property name in the entity + being filtered by.\n\nAll filters can include multiple values, where data + will be filtered with an OR clause: `filter[title]=Title1,Title2` will filter + all vulnerabilities where title is equal to `Title1` OR `Title2`.\n\nString + filters are case sensitive.\n\nBoolean filters accept `true` or `false` as + values.\n\nNumber filters must include an operator as a second filter input: + `filter[$prop_name][$operator]`. For example, for the vulnerabilities endpoint: + `filter[cvss.base.score][lte]=8`.\n\nAvailable operators are: `eq` (==), `lt` + (<), `lte` (<=), `gt` (>) and `gte` (>=).\n\n### Metadata\n\nFollowing [JSON:API + format](https://jsonapi.org/format/#document-meta), object including non-standard + meta-information.\n\nThis endpoint includes the meta member in the response. + For more details on each of the properties included in this section, check + the endpoints response tables.\n\n```JSON\n{\n \"data\": [...],\n \"meta\": + {\n \"total\": 1500,\n \"count\": 18732,\n \"token\": \"some_token\"\n + \ },\n \"links\": {...}\n}\n```\n" + operationId: ListVulnerabilities + parameters: + - description: Its value must come from the `links` section of the response + of the first request. Do not manually edit it. + example: b82cef018aab81ed1d4bb4xb35xxfc065da7efa685fbcecdbd338f3015e3afabbbfa3a911b4984_721ee28a-zecb-4e45-9960-c42065b574f4 + in: query + name: page[token] + required: false + schema: + type: string + - description: The page number to be retrieved. It should be equal or greater + than `1` + example: 1 + in: query + name: page[number] + required: false + schema: + format: int64 + minimum: 1 + type: integer + - description: Filter by vulnerability type. + example: WeakCipher + in: query + name: filter[type] + required: false + schema: + $ref: '#/components/schemas/VulnerabilityType' + - description: Filter by vulnerability base (i.e. from the original advisory) + severity score. + example: 5.5 + in: query + name: filter[cvss.base.score][`$op`] + required: false + schema: + format: double + maximum: 10 + minimum: 0 + type: number + - description: Filter by vulnerability base severity. + example: Medium + in: query + name: filter[cvss.base.severity] + required: false + schema: + $ref: '#/components/schemas/VulnerabilitySeverity' + - description: Filter by vulnerability base CVSS vector. + example: CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H + in: query + name: filter[cvss.base.vector] + required: false + schema: + type: string + - description: Filter by vulnerability Datadog severity score. + example: 4.3 + in: query + name: filter[cvss.datadog.score][`$op`] + required: false + schema: + format: double + maximum: 10 + minimum: 0 + type: number + - description: Filter by vulnerability Datadog severity. + example: Medium + in: query + name: filter[cvss.datadog.severity] + required: false + schema: + $ref: '#/components/schemas/VulnerabilitySeverity' + - description: Filter by vulnerability Datadog CVSS vector. + example: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H/E:U/RL:X/RC:X/CR:X/IR:X/AR:X/MAV:L/MAC:H/MPR:L/MUI:N/MS:U/MC:N/MI:N/MA:H + in: query + name: filter[cvss.datadog.vector] + required: false + schema: + type: string + - description: Filter by the status of the vulnerability. + example: Open + in: query + name: filter[status] + required: false + schema: + $ref: '#/components/schemas/VulnerabilityStatus' + - description: Filter by the tool of the vulnerability. + example: SCA + in: query + name: filter[tool] + required: false + schema: + $ref: '#/components/schemas/VulnerabilityTool' + - description: Filter by library name. + example: linux-aws-5.15 + in: query + name: filter[library.name] + required: false + schema: + type: string + - description: Filter by library version. + example: 5.15.0 + in: query + name: filter[library.version] + required: false + schema: + type: string + - description: Filter by advisory ID. + example: TRIVY-CVE-2023-0615 + in: query + name: filter[advisory_id] + required: false + schema: + type: string + - description: Filter by exploitation probability. + example: false + in: query + name: filter[risks.exploitation_probability] + required: false + schema: + type: boolean + - description: Filter by POC exploit availability. + example: false + in: query + name: filter[risks.poc_exploit_available] + required: false + schema: + type: boolean + - description: Filter by public exploit availability. + example: false + in: query + name: filter[risks.exploit_available] + required: false + schema: + type: boolean + - description: Filter by vulnerability [EPSS](https://www.first.org/epss/) severity + score. + example: 0.00042 + in: query + name: filter[risks.epss.score][`$op`] + required: false + schema: + format: double + maximum: 1 + minimum: 0 + type: number + - description: Filter by vulnerability [EPSS](https://www.first.org/epss/) severity. + example: Low + in: query + name: filter[risks.epss.severity] + required: false + schema: + $ref: '#/components/schemas/VulnerabilitySeverity' + - description: Filter by language. + example: ubuntu + in: query + name: filter[language] + required: false + schema: + type: string + - description: Filter by ecosystem. + example: Deb + in: query + name: filter[ecosystem] + required: false + schema: + $ref: '#/components/schemas/VulnerabilityEcosystem' + - description: Filter by vulnerability location. + example: com.example.Class:100 + in: query + name: filter[code_location.location] + required: false + schema: + type: string + - description: Filter by vulnerability file path. + example: src/Class.java:100 + in: query + name: filter[code_location.file_path] + required: false + schema: + type: string + - description: Filter by method. + example: FooBar + in: query + name: filter[code_location.method] + required: false + schema: + type: string + - description: Filter by fix availability. + example: false + in: query + name: filter[fix_available] + required: false + schema: + type: boolean + - description: Filter by vulnerability `repo_digest` (when the vulnerability + is related to `Image` asset). + example: sha256:0ae7da091191787229d321e3638e39c319a97d6e20f927d465b519d699215bf7 + in: query + name: filter[repo_digests] + required: false + schema: + type: string + - description: Filter by asset name. + example: datadog-agent + in: query + name: filter[asset.name] + required: false + schema: + type: string + - description: Filter by asset type. + example: Host + in: query + name: filter[asset.type] + required: false + schema: + $ref: '#/components/schemas/AssetType' + - description: Filter by the first version of the asset this vulnerability has + been detected on. + example: v1.15.1 + in: query + name: filter[asset.version.first] + required: false + schema: + type: string + - description: Filter by the last version of the asset this vulnerability has + been detected on. + example: v1.15.1 + in: query + name: filter[asset.version.last] + required: false + schema: + type: string + - description: Filter by the repository url associated to the asset. + example: github.com/DataDog/datadog-agent.git + in: query + name: filter[asset.repository_url] + required: false + schema: + type: string + - description: Filter whether the asset is in production or not. + example: false + in: query + name: filter[asset.risks.in_production] + required: false + schema: + type: boolean + - description: Filter whether the asset is under attack or not. + example: false + in: query + name: filter[asset.risks.under_attack] + required: false + schema: + type: boolean + - description: Filter whether the asset is publicly accessible or not. + example: false + in: query + name: filter[asset.risks.is_publicly_accessible] + required: false + schema: + type: boolean + - description: Filter whether the asset is publicly accessible or not. + example: false + in: query + name: filter[asset.risks.has_privileged_access] + required: false + schema: + type: boolean + - description: Filter whether the asset has access to sensitive data or not. + example: false + in: query + name: filter[asset.risks.has_access_to_sensitive_data] + required: false + schema: + type: boolean + - description: Filter by asset environments. + example: staging + in: query + name: filter[asset.environments] + required: false + schema: + type: string + - description: Filter by asset architecture. + example: arm64 + in: query + name: filter[asset.arch] + required: false + schema: + type: string + - description: Filter by asset operating system name. + example: ubuntu + in: query + name: filter[asset.operating_system.name] + required: false + schema: + type: string + - description: Filter by asset operating system version. + example: '24.04' + in: query + name: filter[asset.operating_system.version] + required: false + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ListVulnerabilitiesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Bad request: The server cannot process the request due to + invalid syntax in the request.' + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Forbidden: Access denied' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Not found: There is no request associated with the provided + token.' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List vulnerabilities + tags: + - Security Monitoring + x-unstable: '**Note**: Note: This endpoint is a private preview. + + If you are interested in accessing this API, please [fill this form](https://forms.gle/kMYC1sDr6WDUBDsx9).' /api/v2/security_monitoring/cloud_workload_security/agent_rules: get: description: Get the list of Agent rules. diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index c844575acae..dc54c96467c 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -382,6 +382,8 @@ func NewConfiguration() *Configuration { "v2.GetHistoricalJob": false, "v2.ListFindings": false, "v2.ListHistoricalJobs": false, + "v2.ListVulnerabilities": false, + "v2.ListVulnerableAssets": false, "v2.MuteFindings": false, "v2.RunHistoricalJob": false, "v2.CreateScorecardOutcomesBatch": false, diff --git a/api/datadogV2/api_security_monitoring.go b/api/datadogV2/api_security_monitoring.go index 334b89bab0d..0a550b7cd5d 100644 --- a/api/datadogV2/api_security_monitoring.go +++ b/api/datadogV2/api_security_monitoring.go @@ -2396,6 +2396,872 @@ func (a *SecurityMonitoringApi) ListSecurityMonitoringSuppressions(ctx _context. return localVarReturnValue, localVarHTTPResponse, nil } +// ListVulnerabilitiesOptionalParameters holds optional parameters for ListVulnerabilities. +type ListVulnerabilitiesOptionalParameters struct { + PageToken *string + PageNumber *int64 + FilterType *VulnerabilityType + FilterCvssBaseScoreOp *float64 + FilterCvssBaseSeverity *VulnerabilitySeverity + FilterCvssBaseVector *string + FilterCvssDatadogScoreOp *float64 + FilterCvssDatadogSeverity *VulnerabilitySeverity + FilterCvssDatadogVector *string + FilterStatus *VulnerabilityStatus + FilterTool *VulnerabilityTool + FilterLibraryName *string + FilterLibraryVersion *string + FilterAdvisoryId *string + FilterRisksExploitationProbability *bool + FilterRisksPocExploitAvailable *bool + FilterRisksExploitAvailable *bool + FilterRisksEpssScoreOp *float64 + FilterRisksEpssSeverity *VulnerabilitySeverity + FilterLanguage *string + FilterEcosystem *VulnerabilityEcosystem + FilterCodeLocationLocation *string + FilterCodeLocationFilePath *string + FilterCodeLocationMethod *string + FilterFixAvailable *bool + FilterRepoDigests *string + FilterAssetName *string + FilterAssetType *AssetType + FilterAssetVersionFirst *string + FilterAssetVersionLast *string + FilterAssetRepositoryUrl *string + FilterAssetRisksInProduction *bool + FilterAssetRisksUnderAttack *bool + FilterAssetRisksIsPubliclyAccessible *bool + FilterAssetRisksHasPrivilegedAccess *bool + FilterAssetRisksHasAccessToSensitiveData *bool + FilterAssetEnvironments *string + FilterAssetArch *string + FilterAssetOperatingSystemName *string + FilterAssetOperatingSystemVersion *string +} + +// NewListVulnerabilitiesOptionalParameters creates an empty struct for parameters. +func NewListVulnerabilitiesOptionalParameters() *ListVulnerabilitiesOptionalParameters { + this := ListVulnerabilitiesOptionalParameters{} + return &this +} + +// WithPageToken sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithPageToken(pageToken string) *ListVulnerabilitiesOptionalParameters { + r.PageToken = &pageToken + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithPageNumber(pageNumber int64) *ListVulnerabilitiesOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// WithFilterType sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterType(filterType VulnerabilityType) *ListVulnerabilitiesOptionalParameters { + r.FilterType = &filterType + return r +} + +// WithFilterCvssBaseScoreOp sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCvssBaseScoreOp(filterCvssBaseScoreOp float64) *ListVulnerabilitiesOptionalParameters { + r.FilterCvssBaseScoreOp = &filterCvssBaseScoreOp + return r +} + +// WithFilterCvssBaseSeverity sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCvssBaseSeverity(filterCvssBaseSeverity VulnerabilitySeverity) *ListVulnerabilitiesOptionalParameters { + r.FilterCvssBaseSeverity = &filterCvssBaseSeverity + return r +} + +// WithFilterCvssBaseVector sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCvssBaseVector(filterCvssBaseVector string) *ListVulnerabilitiesOptionalParameters { + r.FilterCvssBaseVector = &filterCvssBaseVector + return r +} + +// WithFilterCvssDatadogScoreOp sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCvssDatadogScoreOp(filterCvssDatadogScoreOp float64) *ListVulnerabilitiesOptionalParameters { + r.FilterCvssDatadogScoreOp = &filterCvssDatadogScoreOp + return r +} + +// WithFilterCvssDatadogSeverity sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCvssDatadogSeverity(filterCvssDatadogSeverity VulnerabilitySeverity) *ListVulnerabilitiesOptionalParameters { + r.FilterCvssDatadogSeverity = &filterCvssDatadogSeverity + return r +} + +// WithFilterCvssDatadogVector sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCvssDatadogVector(filterCvssDatadogVector string) *ListVulnerabilitiesOptionalParameters { + r.FilterCvssDatadogVector = &filterCvssDatadogVector + return r +} + +// WithFilterStatus sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterStatus(filterStatus VulnerabilityStatus) *ListVulnerabilitiesOptionalParameters { + r.FilterStatus = &filterStatus + return r +} + +// WithFilterTool sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterTool(filterTool VulnerabilityTool) *ListVulnerabilitiesOptionalParameters { + r.FilterTool = &filterTool + return r +} + +// WithFilterLibraryName sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterLibraryName(filterLibraryName string) *ListVulnerabilitiesOptionalParameters { + r.FilterLibraryName = &filterLibraryName + return r +} + +// WithFilterLibraryVersion sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterLibraryVersion(filterLibraryVersion string) *ListVulnerabilitiesOptionalParameters { + r.FilterLibraryVersion = &filterLibraryVersion + return r +} + +// WithFilterAdvisoryId sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAdvisoryId(filterAdvisoryId string) *ListVulnerabilitiesOptionalParameters { + r.FilterAdvisoryId = &filterAdvisoryId + return r +} + +// WithFilterRisksExploitationProbability sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterRisksExploitationProbability(filterRisksExploitationProbability bool) *ListVulnerabilitiesOptionalParameters { + r.FilterRisksExploitationProbability = &filterRisksExploitationProbability + return r +} + +// WithFilterRisksPocExploitAvailable sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterRisksPocExploitAvailable(filterRisksPocExploitAvailable bool) *ListVulnerabilitiesOptionalParameters { + r.FilterRisksPocExploitAvailable = &filterRisksPocExploitAvailable + return r +} + +// WithFilterRisksExploitAvailable sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterRisksExploitAvailable(filterRisksExploitAvailable bool) *ListVulnerabilitiesOptionalParameters { + r.FilterRisksExploitAvailable = &filterRisksExploitAvailable + return r +} + +// WithFilterRisksEpssScoreOp sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterRisksEpssScoreOp(filterRisksEpssScoreOp float64) *ListVulnerabilitiesOptionalParameters { + r.FilterRisksEpssScoreOp = &filterRisksEpssScoreOp + return r +} + +// WithFilterRisksEpssSeverity sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterRisksEpssSeverity(filterRisksEpssSeverity VulnerabilitySeverity) *ListVulnerabilitiesOptionalParameters { + r.FilterRisksEpssSeverity = &filterRisksEpssSeverity + return r +} + +// WithFilterLanguage sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterLanguage(filterLanguage string) *ListVulnerabilitiesOptionalParameters { + r.FilterLanguage = &filterLanguage + return r +} + +// WithFilterEcosystem sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterEcosystem(filterEcosystem VulnerabilityEcosystem) *ListVulnerabilitiesOptionalParameters { + r.FilterEcosystem = &filterEcosystem + return r +} + +// WithFilterCodeLocationLocation sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCodeLocationLocation(filterCodeLocationLocation string) *ListVulnerabilitiesOptionalParameters { + r.FilterCodeLocationLocation = &filterCodeLocationLocation + return r +} + +// WithFilterCodeLocationFilePath sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCodeLocationFilePath(filterCodeLocationFilePath string) *ListVulnerabilitiesOptionalParameters { + r.FilterCodeLocationFilePath = &filterCodeLocationFilePath + return r +} + +// WithFilterCodeLocationMethod sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterCodeLocationMethod(filterCodeLocationMethod string) *ListVulnerabilitiesOptionalParameters { + r.FilterCodeLocationMethod = &filterCodeLocationMethod + return r +} + +// WithFilterFixAvailable sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterFixAvailable(filterFixAvailable bool) *ListVulnerabilitiesOptionalParameters { + r.FilterFixAvailable = &filterFixAvailable + return r +} + +// WithFilterRepoDigests sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterRepoDigests(filterRepoDigests string) *ListVulnerabilitiesOptionalParameters { + r.FilterRepoDigests = &filterRepoDigests + return r +} + +// WithFilterAssetName sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetName(filterAssetName string) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetName = &filterAssetName + return r +} + +// WithFilterAssetType sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetType(filterAssetType AssetType) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetType = &filterAssetType + return r +} + +// WithFilterAssetVersionFirst sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetVersionFirst(filterAssetVersionFirst string) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetVersionFirst = &filterAssetVersionFirst + return r +} + +// WithFilterAssetVersionLast sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetVersionLast(filterAssetVersionLast string) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetVersionLast = &filterAssetVersionLast + return r +} + +// WithFilterAssetRepositoryUrl sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetRepositoryUrl(filterAssetRepositoryUrl string) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetRepositoryUrl = &filterAssetRepositoryUrl + return r +} + +// WithFilterAssetRisksInProduction sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetRisksInProduction(filterAssetRisksInProduction bool) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetRisksInProduction = &filterAssetRisksInProduction + return r +} + +// WithFilterAssetRisksUnderAttack sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetRisksUnderAttack(filterAssetRisksUnderAttack bool) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetRisksUnderAttack = &filterAssetRisksUnderAttack + return r +} + +// WithFilterAssetRisksIsPubliclyAccessible sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetRisksIsPubliclyAccessible(filterAssetRisksIsPubliclyAccessible bool) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetRisksIsPubliclyAccessible = &filterAssetRisksIsPubliclyAccessible + return r +} + +// WithFilterAssetRisksHasPrivilegedAccess sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetRisksHasPrivilegedAccess(filterAssetRisksHasPrivilegedAccess bool) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetRisksHasPrivilegedAccess = &filterAssetRisksHasPrivilegedAccess + return r +} + +// WithFilterAssetRisksHasAccessToSensitiveData sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetRisksHasAccessToSensitiveData(filterAssetRisksHasAccessToSensitiveData bool) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetRisksHasAccessToSensitiveData = &filterAssetRisksHasAccessToSensitiveData + return r +} + +// WithFilterAssetEnvironments sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetEnvironments(filterAssetEnvironments string) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetEnvironments = &filterAssetEnvironments + return r +} + +// WithFilterAssetArch sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetArch(filterAssetArch string) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetArch = &filterAssetArch + return r +} + +// WithFilterAssetOperatingSystemName sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetOperatingSystemName(filterAssetOperatingSystemName string) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetOperatingSystemName = &filterAssetOperatingSystemName + return r +} + +// WithFilterAssetOperatingSystemVersion sets the corresponding parameter name and returns the struct. +func (r *ListVulnerabilitiesOptionalParameters) WithFilterAssetOperatingSystemVersion(filterAssetOperatingSystemVersion string) *ListVulnerabilitiesOptionalParameters { + r.FilterAssetOperatingSystemVersion = &filterAssetOperatingSystemVersion + return r +} + +// ListVulnerabilities List vulnerabilities. +// Get a list of vulnerabilities. +// +// ### Pagination +// +// Pagination is enabled by default in both `vulnerabilities` and `assets`. The size of the page varies depending on the endpoint and cannot be modified. To automate the request of the next page, you can use the links section in the response. +// +// This endpoint will return paginated responses. The pages are stored in the links section of the response: +// +// ```JSON +// +// { +// "data": [...], +// "meta": {...}, +// "links": { +// "self": "https://.../api/v2/security/vulnerabilities", +// "first": "https://.../api/v2/security/vulnerabilities?page[number]=1&page[token]=abc", +// "last": "https://.../api/v2/security/vulnerabilities?page[number]=43&page[token]=abc", +// "next": "https://.../api/v2/security/vulnerabilities?page[number]=2&page[token]=abc" +// } +// } +// +// ``` +// +// - `links.previous` is empty if the first page is requested. +// - `links.next` is empty if the last page is requested. +// +// #### Token +// +// Vulnerabilities can be created, updated or deleted at any point in time. +// +// Upon the first request, a token is created to ensure consistency across subsequent paginated requests. +// +// A token is valid only for 24 hours. +// +// #### First request +// +// We consider a request to be the first request when there is no `page[token]` parameter. +// +// The response of this first request contains the newly created token in the `links` section. +// +// This token can then be used in the subsequent paginated requests. +// +// #### Subsequent requests +// +// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request. +// +// If the `token` is invalid, a `404` response will be returned. +// +// If the page `number` is invalid, a `400` response will be returned. +// +// ### Filtering +// +// The request can include some filter parameters to filter the data to be retrieved. The format of the filter parameters follows the [JSON:API format](https://jsonapi.org/format/#fetching-filtering): `filter[$prop_name]`, where `prop_name` is the property name in the entity being filtered by. +// +// All filters can include multiple values, where data will be filtered with an OR clause: `filter[title]=Title1,Title2` will filter all vulnerabilities where title is equal to `Title1` OR `Title2`. +// +// String filters are case sensitive. +// +// Boolean filters accept `true` or `false` as values. +// +// Number filters must include an operator as a second filter input: `filter[$prop_name][$operator]`. For example, for the vulnerabilities endpoint: `filter[cvss.base.score][lte]=8`. +// +// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=). +// +// ### Metadata +// +// Following [JSON:API format](https://jsonapi.org/format/#document-meta), object including non-standard meta-information. +// +// This endpoint includes the meta member in the response. For more details on each of the properties included in this section, check the endpoints response tables. +// +// ```JSON +// +// { +// "data": [...], +// "meta": { +// "total": 1500, +// "count": 18732, +// "token": "some_token" +// }, +// "links": {...} +// } +// +// ``` +func (a *SecurityMonitoringApi) ListVulnerabilities(ctx _context.Context, o ...ListVulnerabilitiesOptionalParameters) (ListVulnerabilitiesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ListVulnerabilitiesResponse + optionalParams ListVulnerabilitiesOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListVulnerabilitiesOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListVulnerabilities" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.ListVulnerabilities") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/vulnerabilities" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageToken != nil { + localVarQueryParams.Add("page[token]", datadog.ParameterToString(*optionalParams.PageToken, "")) + } + if optionalParams.PageNumber != nil { + localVarQueryParams.Add("page[number]", datadog.ParameterToString(*optionalParams.PageNumber, "")) + } + if optionalParams.FilterType != nil { + localVarQueryParams.Add("filter[type]", datadog.ParameterToString(*optionalParams.FilterType, "")) + } + if optionalParams.FilterCvssBaseScoreOp != nil { + localVarQueryParams.Add("filter[cvss.base.score][`$op`]", datadog.ParameterToString(*optionalParams.FilterCvssBaseScoreOp, "")) + } + if optionalParams.FilterCvssBaseSeverity != nil { + localVarQueryParams.Add("filter[cvss.base.severity]", datadog.ParameterToString(*optionalParams.FilterCvssBaseSeverity, "")) + } + if optionalParams.FilterCvssBaseVector != nil { + localVarQueryParams.Add("filter[cvss.base.vector]", datadog.ParameterToString(*optionalParams.FilterCvssBaseVector, "")) + } + if optionalParams.FilterCvssDatadogScoreOp != nil { + localVarQueryParams.Add("filter[cvss.datadog.score][`$op`]", datadog.ParameterToString(*optionalParams.FilterCvssDatadogScoreOp, "")) + } + if optionalParams.FilterCvssDatadogSeverity != nil { + localVarQueryParams.Add("filter[cvss.datadog.severity]", datadog.ParameterToString(*optionalParams.FilterCvssDatadogSeverity, "")) + } + if optionalParams.FilterCvssDatadogVector != nil { + localVarQueryParams.Add("filter[cvss.datadog.vector]", datadog.ParameterToString(*optionalParams.FilterCvssDatadogVector, "")) + } + if optionalParams.FilterStatus != nil { + localVarQueryParams.Add("filter[status]", datadog.ParameterToString(*optionalParams.FilterStatus, "")) + } + if optionalParams.FilterTool != nil { + localVarQueryParams.Add("filter[tool]", datadog.ParameterToString(*optionalParams.FilterTool, "")) + } + if optionalParams.FilterLibraryName != nil { + localVarQueryParams.Add("filter[library.name]", datadog.ParameterToString(*optionalParams.FilterLibraryName, "")) + } + if optionalParams.FilterLibraryVersion != nil { + localVarQueryParams.Add("filter[library.version]", datadog.ParameterToString(*optionalParams.FilterLibraryVersion, "")) + } + if optionalParams.FilterAdvisoryId != nil { + localVarQueryParams.Add("filter[advisory_id]", datadog.ParameterToString(*optionalParams.FilterAdvisoryId, "")) + } + if optionalParams.FilterRisksExploitationProbability != nil { + localVarQueryParams.Add("filter[risks.exploitation_probability]", datadog.ParameterToString(*optionalParams.FilterRisksExploitationProbability, "")) + } + if optionalParams.FilterRisksPocExploitAvailable != nil { + localVarQueryParams.Add("filter[risks.poc_exploit_available]", datadog.ParameterToString(*optionalParams.FilterRisksPocExploitAvailable, "")) + } + if optionalParams.FilterRisksExploitAvailable != nil { + localVarQueryParams.Add("filter[risks.exploit_available]", datadog.ParameterToString(*optionalParams.FilterRisksExploitAvailable, "")) + } + if optionalParams.FilterRisksEpssScoreOp != nil { + localVarQueryParams.Add("filter[risks.epss.score][`$op`]", datadog.ParameterToString(*optionalParams.FilterRisksEpssScoreOp, "")) + } + if optionalParams.FilterRisksEpssSeverity != nil { + localVarQueryParams.Add("filter[risks.epss.severity]", datadog.ParameterToString(*optionalParams.FilterRisksEpssSeverity, "")) + } + if optionalParams.FilterLanguage != nil { + localVarQueryParams.Add("filter[language]", datadog.ParameterToString(*optionalParams.FilterLanguage, "")) + } + if optionalParams.FilterEcosystem != nil { + localVarQueryParams.Add("filter[ecosystem]", datadog.ParameterToString(*optionalParams.FilterEcosystem, "")) + } + if optionalParams.FilterCodeLocationLocation != nil { + localVarQueryParams.Add("filter[code_location.location]", datadog.ParameterToString(*optionalParams.FilterCodeLocationLocation, "")) + } + if optionalParams.FilterCodeLocationFilePath != nil { + localVarQueryParams.Add("filter[code_location.file_path]", datadog.ParameterToString(*optionalParams.FilterCodeLocationFilePath, "")) + } + if optionalParams.FilterCodeLocationMethod != nil { + localVarQueryParams.Add("filter[code_location.method]", datadog.ParameterToString(*optionalParams.FilterCodeLocationMethod, "")) + } + if optionalParams.FilterFixAvailable != nil { + localVarQueryParams.Add("filter[fix_available]", datadog.ParameterToString(*optionalParams.FilterFixAvailable, "")) + } + if optionalParams.FilterRepoDigests != nil { + localVarQueryParams.Add("filter[repo_digests]", datadog.ParameterToString(*optionalParams.FilterRepoDigests, "")) + } + if optionalParams.FilterAssetName != nil { + localVarQueryParams.Add("filter[asset.name]", datadog.ParameterToString(*optionalParams.FilterAssetName, "")) + } + if optionalParams.FilterAssetType != nil { + localVarQueryParams.Add("filter[asset.type]", datadog.ParameterToString(*optionalParams.FilterAssetType, "")) + } + if optionalParams.FilterAssetVersionFirst != nil { + localVarQueryParams.Add("filter[asset.version.first]", datadog.ParameterToString(*optionalParams.FilterAssetVersionFirst, "")) + } + if optionalParams.FilterAssetVersionLast != nil { + localVarQueryParams.Add("filter[asset.version.last]", datadog.ParameterToString(*optionalParams.FilterAssetVersionLast, "")) + } + if optionalParams.FilterAssetRepositoryUrl != nil { + localVarQueryParams.Add("filter[asset.repository_url]", datadog.ParameterToString(*optionalParams.FilterAssetRepositoryUrl, "")) + } + if optionalParams.FilterAssetRisksInProduction != nil { + localVarQueryParams.Add("filter[asset.risks.in_production]", datadog.ParameterToString(*optionalParams.FilterAssetRisksInProduction, "")) + } + if optionalParams.FilterAssetRisksUnderAttack != nil { + localVarQueryParams.Add("filter[asset.risks.under_attack]", datadog.ParameterToString(*optionalParams.FilterAssetRisksUnderAttack, "")) + } + if optionalParams.FilterAssetRisksIsPubliclyAccessible != nil { + localVarQueryParams.Add("filter[asset.risks.is_publicly_accessible]", datadog.ParameterToString(*optionalParams.FilterAssetRisksIsPubliclyAccessible, "")) + } + if optionalParams.FilterAssetRisksHasPrivilegedAccess != nil { + localVarQueryParams.Add("filter[asset.risks.has_privileged_access]", datadog.ParameterToString(*optionalParams.FilterAssetRisksHasPrivilegedAccess, "")) + } + if optionalParams.FilterAssetRisksHasAccessToSensitiveData != nil { + localVarQueryParams.Add("filter[asset.risks.has_access_to_sensitive_data]", datadog.ParameterToString(*optionalParams.FilterAssetRisksHasAccessToSensitiveData, "")) + } + if optionalParams.FilterAssetEnvironments != nil { + localVarQueryParams.Add("filter[asset.environments]", datadog.ParameterToString(*optionalParams.FilterAssetEnvironments, "")) + } + if optionalParams.FilterAssetArch != nil { + localVarQueryParams.Add("filter[asset.arch]", datadog.ParameterToString(*optionalParams.FilterAssetArch, "")) + } + if optionalParams.FilterAssetOperatingSystemName != nil { + localVarQueryParams.Add("filter[asset.operating_system.name]", datadog.ParameterToString(*optionalParams.FilterAssetOperatingSystemName, "")) + } + if optionalParams.FilterAssetOperatingSystemVersion != nil { + localVarQueryParams.Add("filter[asset.operating_system.version]", datadog.ParameterToString(*optionalParams.FilterAssetOperatingSystemVersion, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListVulnerableAssetsOptionalParameters holds optional parameters for ListVulnerableAssets. +type ListVulnerableAssetsOptionalParameters struct { + PageToken *string + PageNumber *int64 + FilterName *string + FilterType *AssetType + FilterVersionFirst *string + FilterVersionLast *string + FilterRepositoryUrl *string + FilterRisksInProduction *bool + FilterRisksUnderAttack *bool + FilterRisksIsPubliclyAccessible *bool + FilterRisksHasPrivilegedAccess *bool + FilterRisksHasAccessToSensitiveData *bool + FilterEnvironments *string + FilterArch *string + FilterOperatingSystemName *string + FilterOperatingSystemVersion *string +} + +// NewListVulnerableAssetsOptionalParameters creates an empty struct for parameters. +func NewListVulnerableAssetsOptionalParameters() *ListVulnerableAssetsOptionalParameters { + this := ListVulnerableAssetsOptionalParameters{} + return &this +} + +// WithPageToken sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithPageToken(pageToken string) *ListVulnerableAssetsOptionalParameters { + r.PageToken = &pageToken + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithPageNumber(pageNumber int64) *ListVulnerableAssetsOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// WithFilterName sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterName(filterName string) *ListVulnerableAssetsOptionalParameters { + r.FilterName = &filterName + return r +} + +// WithFilterType sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterType(filterType AssetType) *ListVulnerableAssetsOptionalParameters { + r.FilterType = &filterType + return r +} + +// WithFilterVersionFirst sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterVersionFirst(filterVersionFirst string) *ListVulnerableAssetsOptionalParameters { + r.FilterVersionFirst = &filterVersionFirst + return r +} + +// WithFilterVersionLast sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterVersionLast(filterVersionLast string) *ListVulnerableAssetsOptionalParameters { + r.FilterVersionLast = &filterVersionLast + return r +} + +// WithFilterRepositoryUrl sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterRepositoryUrl(filterRepositoryUrl string) *ListVulnerableAssetsOptionalParameters { + r.FilterRepositoryUrl = &filterRepositoryUrl + return r +} + +// WithFilterRisksInProduction sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterRisksInProduction(filterRisksInProduction bool) *ListVulnerableAssetsOptionalParameters { + r.FilterRisksInProduction = &filterRisksInProduction + return r +} + +// WithFilterRisksUnderAttack sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterRisksUnderAttack(filterRisksUnderAttack bool) *ListVulnerableAssetsOptionalParameters { + r.FilterRisksUnderAttack = &filterRisksUnderAttack + return r +} + +// WithFilterRisksIsPubliclyAccessible sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterRisksIsPubliclyAccessible(filterRisksIsPubliclyAccessible bool) *ListVulnerableAssetsOptionalParameters { + r.FilterRisksIsPubliclyAccessible = &filterRisksIsPubliclyAccessible + return r +} + +// WithFilterRisksHasPrivilegedAccess sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterRisksHasPrivilegedAccess(filterRisksHasPrivilegedAccess bool) *ListVulnerableAssetsOptionalParameters { + r.FilterRisksHasPrivilegedAccess = &filterRisksHasPrivilegedAccess + return r +} + +// WithFilterRisksHasAccessToSensitiveData sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterRisksHasAccessToSensitiveData(filterRisksHasAccessToSensitiveData bool) *ListVulnerableAssetsOptionalParameters { + r.FilterRisksHasAccessToSensitiveData = &filterRisksHasAccessToSensitiveData + return r +} + +// WithFilterEnvironments sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterEnvironments(filterEnvironments string) *ListVulnerableAssetsOptionalParameters { + r.FilterEnvironments = &filterEnvironments + return r +} + +// WithFilterArch sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterArch(filterArch string) *ListVulnerableAssetsOptionalParameters { + r.FilterArch = &filterArch + return r +} + +// WithFilterOperatingSystemName sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterOperatingSystemName(filterOperatingSystemName string) *ListVulnerableAssetsOptionalParameters { + r.FilterOperatingSystemName = &filterOperatingSystemName + return r +} + +// WithFilterOperatingSystemVersion sets the corresponding parameter name and returns the struct. +func (r *ListVulnerableAssetsOptionalParameters) WithFilterOperatingSystemVersion(filterOperatingSystemVersion string) *ListVulnerableAssetsOptionalParameters { + r.FilterOperatingSystemVersion = &filterOperatingSystemVersion + return r +} + +// ListVulnerableAssets List vulnerable assets. +// Get a list of vulnerable assets. +// +// ### Pagination +// +// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint. +// +// ### Filtering +// +// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint. +// +// ### Metadata +// +// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint. +func (a *SecurityMonitoringApi) ListVulnerableAssets(ctx _context.Context, o ...ListVulnerableAssetsOptionalParameters) (ListVulnerableAssetsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ListVulnerableAssetsResponse + optionalParams ListVulnerableAssetsOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListVulnerableAssetsOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListVulnerableAssets" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.ListVulnerableAssets") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/assets" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageToken != nil { + localVarQueryParams.Add("page[token]", datadog.ParameterToString(*optionalParams.PageToken, "")) + } + if optionalParams.PageNumber != nil { + localVarQueryParams.Add("page[number]", datadog.ParameterToString(*optionalParams.PageNumber, "")) + } + if optionalParams.FilterName != nil { + localVarQueryParams.Add("filter[name]", datadog.ParameterToString(*optionalParams.FilterName, "")) + } + if optionalParams.FilterType != nil { + localVarQueryParams.Add("filter[type]", datadog.ParameterToString(*optionalParams.FilterType, "")) + } + if optionalParams.FilterVersionFirst != nil { + localVarQueryParams.Add("filter[version.first]", datadog.ParameterToString(*optionalParams.FilterVersionFirst, "")) + } + if optionalParams.FilterVersionLast != nil { + localVarQueryParams.Add("filter[version.last]", datadog.ParameterToString(*optionalParams.FilterVersionLast, "")) + } + if optionalParams.FilterRepositoryUrl != nil { + localVarQueryParams.Add("filter[repository_url]", datadog.ParameterToString(*optionalParams.FilterRepositoryUrl, "")) + } + if optionalParams.FilterRisksInProduction != nil { + localVarQueryParams.Add("filter[risks.in_production]", datadog.ParameterToString(*optionalParams.FilterRisksInProduction, "")) + } + if optionalParams.FilterRisksUnderAttack != nil { + localVarQueryParams.Add("filter[risks.under_attack]", datadog.ParameterToString(*optionalParams.FilterRisksUnderAttack, "")) + } + if optionalParams.FilterRisksIsPubliclyAccessible != nil { + localVarQueryParams.Add("filter[risks.is_publicly_accessible]", datadog.ParameterToString(*optionalParams.FilterRisksIsPubliclyAccessible, "")) + } + if optionalParams.FilterRisksHasPrivilegedAccess != nil { + localVarQueryParams.Add("filter[risks.has_privileged_access]", datadog.ParameterToString(*optionalParams.FilterRisksHasPrivilegedAccess, "")) + } + if optionalParams.FilterRisksHasAccessToSensitiveData != nil { + localVarQueryParams.Add("filter[risks.has_access_to_sensitive_data]", datadog.ParameterToString(*optionalParams.FilterRisksHasAccessToSensitiveData, "")) + } + if optionalParams.FilterEnvironments != nil { + localVarQueryParams.Add("filter[environments]", datadog.ParameterToString(*optionalParams.FilterEnvironments, "")) + } + if optionalParams.FilterArch != nil { + localVarQueryParams.Add("filter[arch]", datadog.ParameterToString(*optionalParams.FilterArch, "")) + } + if optionalParams.FilterOperatingSystemName != nil { + localVarQueryParams.Add("filter[operating_system.name]", datadog.ParameterToString(*optionalParams.FilterOperatingSystemName, "")) + } + if optionalParams.FilterOperatingSystemVersion != nil { + localVarQueryParams.Add("filter[operating_system.version]", datadog.ParameterToString(*optionalParams.FilterOperatingSystemVersion, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // MuteFindings Mute or unmute a batch of findings. // Mute or unmute findings. func (a *SecurityMonitoringApi) MuteFindings(ctx _context.Context, body BulkMuteFindingsRequest) (BulkMuteFindingsResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 72016bb2933..bf266e84330 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -315,6 +315,8 @@ // - [SecurityMonitoringApi.ListSecurityMonitoringRules] // - [SecurityMonitoringApi.ListSecurityMonitoringSignals] // - [SecurityMonitoringApi.ListSecurityMonitoringSuppressions] +// - [SecurityMonitoringApi.ListVulnerabilities] +// - [SecurityMonitoringApi.ListVulnerableAssets] // - [SecurityMonitoringApi.MuteFindings] // - [SecurityMonitoringApi.RunHistoricalJob] // - [SecurityMonitoringApi.SearchSecurityMonitoringSignals] diff --git a/api/datadogV2/model_advisory.go b/api/datadogV2/model_advisory.go new file mode 100644 index 00000000000..d4f1721ee93 --- /dev/null +++ b/api/datadogV2/model_advisory.go @@ -0,0 +1,168 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Advisory Advisory. +type Advisory struct { + // Advisory base severity. + BaseSeverity string `json:"base_severity"` + // Advisory id. + Id string `json:"id"` + // Advisory Datadog severity. + Severity *string `json:"severity,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAdvisory instantiates a new Advisory object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAdvisory(baseSeverity string, id string) *Advisory { + this := Advisory{} + this.BaseSeverity = baseSeverity + this.Id = id + return &this +} + +// NewAdvisoryWithDefaults instantiates a new Advisory object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAdvisoryWithDefaults() *Advisory { + this := Advisory{} + return &this +} + +// GetBaseSeverity returns the BaseSeverity field value. +func (o *Advisory) GetBaseSeverity() string { + if o == nil { + var ret string + return ret + } + return o.BaseSeverity +} + +// GetBaseSeverityOk returns a tuple with the BaseSeverity field value +// and a boolean to check if the value has been set. +func (o *Advisory) GetBaseSeverityOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.BaseSeverity, true +} + +// SetBaseSeverity sets field value. +func (o *Advisory) SetBaseSeverity(v string) { + o.BaseSeverity = v +} + +// GetId returns the Id field value. +func (o *Advisory) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *Advisory) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *Advisory) SetId(v string) { + o.Id = v +} + +// GetSeverity returns the Severity field value if set, zero value otherwise. +func (o *Advisory) GetSeverity() string { + if o == nil || o.Severity == nil { + var ret string + return ret + } + return *o.Severity +} + +// GetSeverityOk returns a tuple with the Severity field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Advisory) GetSeverityOk() (*string, bool) { + if o == nil || o.Severity == nil { + return nil, false + } + return o.Severity, true +} + +// HasSeverity returns a boolean if a field has been set. +func (o *Advisory) HasSeverity() bool { + return o != nil && o.Severity != nil +} + +// SetSeverity gets a reference to the given string and assigns it to the Severity field. +func (o *Advisory) SetSeverity(v string) { + o.Severity = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Advisory) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["base_severity"] = o.BaseSeverity + toSerialize["id"] = o.Id + if o.Severity != nil { + toSerialize["severity"] = o.Severity + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Advisory) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + BaseSeverity *string `json:"base_severity"` + Id *string `json:"id"` + Severity *string `json:"severity,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.BaseSeverity == nil { + return fmt.Errorf("required field base_severity missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"base_severity", "id", "severity"}) + } else { + return err + } + o.BaseSeverity = *all.BaseSeverity + o.Id = *all.Id + o.Severity = all.Severity + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_asset.go b/api/datadogV2/model_asset.go new file mode 100644 index 00000000000..b9fd0b6fd59 --- /dev/null +++ b/api/datadogV2/model_asset.go @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Asset A single vulnerable asset +type Asset struct { + // The JSON:API attributes of the asset. + Attributes AssetAttributes `json:"attributes"` + // The unique ID for this asset. + Id string `json:"id"` + // The JSON:API type. + Type AssetEntityType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAsset instantiates a new Asset object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAsset(attributes AssetAttributes, id string, typeVar AssetEntityType) *Asset { + this := Asset{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewAssetWithDefaults instantiates a new Asset object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAssetWithDefaults() *Asset { + this := Asset{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *Asset) GetAttributes() AssetAttributes { + if o == nil { + var ret AssetAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *Asset) GetAttributesOk() (*AssetAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *Asset) SetAttributes(v AssetAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *Asset) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *Asset) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *Asset) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *Asset) GetType() AssetEntityType { + if o == nil { + var ret AssetEntityType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *Asset) GetTypeOk() (*AssetEntityType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *Asset) SetType(v AssetEntityType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Asset) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Asset) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *AssetAttributes `json:"attributes"` + Id *string `json:"id"` + Type *AssetEntityType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_asset_attributes.go b/api/datadogV2/model_asset_attributes.go new file mode 100644 index 00000000000..54004a392be --- /dev/null +++ b/api/datadogV2/model_asset_attributes.go @@ -0,0 +1,321 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AssetAttributes The JSON:API attributes of the asset. +type AssetAttributes struct { + // Asset architecture. + Arch *string `json:"arch,omitempty"` + // List of environments where the asset is deployed. + Environments []string `json:"environments"` + // Asset name. + Name string `json:"name"` + // Asset operating system. + OperatingSystem *AssetAttributesOperatingSystem `json:"operating_system,omitempty"` + // Asset risks. + Risks AssetAttributesRisks `json:"risks"` + // The asset type + Type AssetType `json:"type"` + // Asset version. + Version *AssetAttributesVersion `json:"version,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAssetAttributes instantiates a new AssetAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAssetAttributes(environments []string, name string, risks AssetAttributesRisks, typeVar AssetType) *AssetAttributes { + this := AssetAttributes{} + this.Environments = environments + this.Name = name + this.Risks = risks + this.Type = typeVar + return &this +} + +// NewAssetAttributesWithDefaults instantiates a new AssetAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAssetAttributesWithDefaults() *AssetAttributes { + this := AssetAttributes{} + return &this +} + +// GetArch returns the Arch field value if set, zero value otherwise. +func (o *AssetAttributes) GetArch() string { + if o == nil || o.Arch == nil { + var ret string + return ret + } + return *o.Arch +} + +// GetArchOk returns a tuple with the Arch field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributes) GetArchOk() (*string, bool) { + if o == nil || o.Arch == nil { + return nil, false + } + return o.Arch, true +} + +// HasArch returns a boolean if a field has been set. +func (o *AssetAttributes) HasArch() bool { + return o != nil && o.Arch != nil +} + +// SetArch gets a reference to the given string and assigns it to the Arch field. +func (o *AssetAttributes) SetArch(v string) { + o.Arch = &v +} + +// GetEnvironments returns the Environments field value. +func (o *AssetAttributes) GetEnvironments() []string { + if o == nil { + var ret []string + return ret + } + return o.Environments +} + +// GetEnvironmentsOk returns a tuple with the Environments field value +// and a boolean to check if the value has been set. +func (o *AssetAttributes) GetEnvironmentsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Environments, true +} + +// SetEnvironments sets field value. +func (o *AssetAttributes) SetEnvironments(v []string) { + o.Environments = v +} + +// GetName returns the Name field value. +func (o *AssetAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *AssetAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *AssetAttributes) SetName(v string) { + o.Name = v +} + +// GetOperatingSystem returns the OperatingSystem field value if set, zero value otherwise. +func (o *AssetAttributes) GetOperatingSystem() AssetAttributesOperatingSystem { + if o == nil || o.OperatingSystem == nil { + var ret AssetAttributesOperatingSystem + return ret + } + return *o.OperatingSystem +} + +// GetOperatingSystemOk returns a tuple with the OperatingSystem field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributes) GetOperatingSystemOk() (*AssetAttributesOperatingSystem, bool) { + if o == nil || o.OperatingSystem == nil { + return nil, false + } + return o.OperatingSystem, true +} + +// HasOperatingSystem returns a boolean if a field has been set. +func (o *AssetAttributes) HasOperatingSystem() bool { + return o != nil && o.OperatingSystem != nil +} + +// SetOperatingSystem gets a reference to the given AssetAttributesOperatingSystem and assigns it to the OperatingSystem field. +func (o *AssetAttributes) SetOperatingSystem(v AssetAttributesOperatingSystem) { + o.OperatingSystem = &v +} + +// GetRisks returns the Risks field value. +func (o *AssetAttributes) GetRisks() AssetAttributesRisks { + if o == nil { + var ret AssetAttributesRisks + return ret + } + return o.Risks +} + +// GetRisksOk returns a tuple with the Risks field value +// and a boolean to check if the value has been set. +func (o *AssetAttributes) GetRisksOk() (*AssetAttributesRisks, bool) { + if o == nil { + return nil, false + } + return &o.Risks, true +} + +// SetRisks sets field value. +func (o *AssetAttributes) SetRisks(v AssetAttributesRisks) { + o.Risks = v +} + +// GetType returns the Type field value. +func (o *AssetAttributes) GetType() AssetType { + if o == nil { + var ret AssetType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *AssetAttributes) GetTypeOk() (*AssetType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *AssetAttributes) SetType(v AssetType) { + o.Type = v +} + +// GetVersion returns the Version field value if set, zero value otherwise. +func (o *AssetAttributes) GetVersion() AssetAttributesVersion { + if o == nil || o.Version == nil { + var ret AssetAttributesVersion + return ret + } + return *o.Version +} + +// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributes) GetVersionOk() (*AssetAttributesVersion, bool) { + if o == nil || o.Version == nil { + return nil, false + } + return o.Version, true +} + +// HasVersion returns a boolean if a field has been set. +func (o *AssetAttributes) HasVersion() bool { + return o != nil && o.Version != nil +} + +// SetVersion gets a reference to the given AssetAttributesVersion and assigns it to the Version field. +func (o *AssetAttributes) SetVersion(v AssetAttributesVersion) { + o.Version = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AssetAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Arch != nil { + toSerialize["arch"] = o.Arch + } + toSerialize["environments"] = o.Environments + toSerialize["name"] = o.Name + if o.OperatingSystem != nil { + toSerialize["operating_system"] = o.OperatingSystem + } + toSerialize["risks"] = o.Risks + toSerialize["type"] = o.Type + if o.Version != nil { + toSerialize["version"] = o.Version + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AssetAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Arch *string `json:"arch,omitempty"` + Environments *[]string `json:"environments"` + Name *string `json:"name"` + OperatingSystem *AssetAttributesOperatingSystem `json:"operating_system,omitempty"` + Risks *AssetAttributesRisks `json:"risks"` + Type *AssetType `json:"type"` + Version *AssetAttributesVersion `json:"version,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Environments == nil { + return fmt.Errorf("required field environments missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Risks == nil { + return fmt.Errorf("required field risks missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"arch", "environments", "name", "operating_system", "risks", "type", "version"}) + } else { + return err + } + + hasInvalidField := false + o.Arch = all.Arch + o.Environments = *all.Environments + o.Name = *all.Name + if all.OperatingSystem != nil && all.OperatingSystem.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.OperatingSystem = all.OperatingSystem + if all.Risks.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Risks = *all.Risks + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + if all.Version != nil && all.Version.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Version = all.Version + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_asset_attributes_operating_system.go b/api/datadogV2/model_asset_attributes_operating_system.go new file mode 100644 index 00000000000..25d87cad384 --- /dev/null +++ b/api/datadogV2/model_asset_attributes_operating_system.go @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AssetAttributesOperatingSystem Asset operating system. +type AssetAttributesOperatingSystem struct { + // Operating system version. + Description *string `json:"description,omitempty"` + // Operating system name. + Name string `json:"name"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAssetAttributesOperatingSystem instantiates a new AssetAttributesOperatingSystem object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAssetAttributesOperatingSystem(name string) *AssetAttributesOperatingSystem { + this := AssetAttributesOperatingSystem{} + this.Name = name + return &this +} + +// NewAssetAttributesOperatingSystemWithDefaults instantiates a new AssetAttributesOperatingSystem object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAssetAttributesOperatingSystemWithDefaults() *AssetAttributesOperatingSystem { + this := AssetAttributesOperatingSystem{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *AssetAttributesOperatingSystem) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributesOperatingSystem) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *AssetAttributesOperatingSystem) HasDescription() bool { + return o != nil && o.Description != nil +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *AssetAttributesOperatingSystem) SetDescription(v string) { + o.Description = &v +} + +// GetName returns the Name field value. +func (o *AssetAttributesOperatingSystem) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *AssetAttributesOperatingSystem) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *AssetAttributesOperatingSystem) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AssetAttributesOperatingSystem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AssetAttributesOperatingSystem) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "name"}) + } else { + return err + } + o.Description = all.Description + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_asset_attributes_risks.go b/api/datadogV2/model_asset_attributes_risks.go new file mode 100644 index 00000000000..ae5e1e9b0ca --- /dev/null +++ b/api/datadogV2/model_asset_attributes_risks.go @@ -0,0 +1,241 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AssetAttributesRisks Asset risks. +type AssetAttributesRisks struct { + // Whether the asset has access to sensitive data or not. + HasAccessToSensitiveData *bool `json:"has_access_to_sensitive_data,omitempty"` + // Whether the asset has privileged access or not. + HasPrivilegedAccess *bool `json:"has_privileged_access,omitempty"` + // Whether the asset is in production or not. + InProduction bool `json:"in_production"` + // Whether the asset is publicly accessible or not. + IsPubliclyAccessible *bool `json:"is_publicly_accessible,omitempty"` + // Whether the asset is under attack or not. + UnderAttack *bool `json:"under_attack,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAssetAttributesRisks instantiates a new AssetAttributesRisks object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAssetAttributesRisks(inProduction bool) *AssetAttributesRisks { + this := AssetAttributesRisks{} + this.InProduction = inProduction + return &this +} + +// NewAssetAttributesRisksWithDefaults instantiates a new AssetAttributesRisks object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAssetAttributesRisksWithDefaults() *AssetAttributesRisks { + this := AssetAttributesRisks{} + return &this +} + +// GetHasAccessToSensitiveData returns the HasAccessToSensitiveData field value if set, zero value otherwise. +func (o *AssetAttributesRisks) GetHasAccessToSensitiveData() bool { + if o == nil || o.HasAccessToSensitiveData == nil { + var ret bool + return ret + } + return *o.HasAccessToSensitiveData +} + +// GetHasAccessToSensitiveDataOk returns a tuple with the HasAccessToSensitiveData field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributesRisks) GetHasAccessToSensitiveDataOk() (*bool, bool) { + if o == nil || o.HasAccessToSensitiveData == nil { + return nil, false + } + return o.HasAccessToSensitiveData, true +} + +// HasHasAccessToSensitiveData returns a boolean if a field has been set. +func (o *AssetAttributesRisks) HasHasAccessToSensitiveData() bool { + return o != nil && o.HasAccessToSensitiveData != nil +} + +// SetHasAccessToSensitiveData gets a reference to the given bool and assigns it to the HasAccessToSensitiveData field. +func (o *AssetAttributesRisks) SetHasAccessToSensitiveData(v bool) { + o.HasAccessToSensitiveData = &v +} + +// GetHasPrivilegedAccess returns the HasPrivilegedAccess field value if set, zero value otherwise. +func (o *AssetAttributesRisks) GetHasPrivilegedAccess() bool { + if o == nil || o.HasPrivilegedAccess == nil { + var ret bool + return ret + } + return *o.HasPrivilegedAccess +} + +// GetHasPrivilegedAccessOk returns a tuple with the HasPrivilegedAccess field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributesRisks) GetHasPrivilegedAccessOk() (*bool, bool) { + if o == nil || o.HasPrivilegedAccess == nil { + return nil, false + } + return o.HasPrivilegedAccess, true +} + +// HasHasPrivilegedAccess returns a boolean if a field has been set. +func (o *AssetAttributesRisks) HasHasPrivilegedAccess() bool { + return o != nil && o.HasPrivilegedAccess != nil +} + +// SetHasPrivilegedAccess gets a reference to the given bool and assigns it to the HasPrivilegedAccess field. +func (o *AssetAttributesRisks) SetHasPrivilegedAccess(v bool) { + o.HasPrivilegedAccess = &v +} + +// GetInProduction returns the InProduction field value. +func (o *AssetAttributesRisks) GetInProduction() bool { + if o == nil { + var ret bool + return ret + } + return o.InProduction +} + +// GetInProductionOk returns a tuple with the InProduction field value +// and a boolean to check if the value has been set. +func (o *AssetAttributesRisks) GetInProductionOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.InProduction, true +} + +// SetInProduction sets field value. +func (o *AssetAttributesRisks) SetInProduction(v bool) { + o.InProduction = v +} + +// GetIsPubliclyAccessible returns the IsPubliclyAccessible field value if set, zero value otherwise. +func (o *AssetAttributesRisks) GetIsPubliclyAccessible() bool { + if o == nil || o.IsPubliclyAccessible == nil { + var ret bool + return ret + } + return *o.IsPubliclyAccessible +} + +// GetIsPubliclyAccessibleOk returns a tuple with the IsPubliclyAccessible field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributesRisks) GetIsPubliclyAccessibleOk() (*bool, bool) { + if o == nil || o.IsPubliclyAccessible == nil { + return nil, false + } + return o.IsPubliclyAccessible, true +} + +// HasIsPubliclyAccessible returns a boolean if a field has been set. +func (o *AssetAttributesRisks) HasIsPubliclyAccessible() bool { + return o != nil && o.IsPubliclyAccessible != nil +} + +// SetIsPubliclyAccessible gets a reference to the given bool and assigns it to the IsPubliclyAccessible field. +func (o *AssetAttributesRisks) SetIsPubliclyAccessible(v bool) { + o.IsPubliclyAccessible = &v +} + +// GetUnderAttack returns the UnderAttack field value if set, zero value otherwise. +func (o *AssetAttributesRisks) GetUnderAttack() bool { + if o == nil || o.UnderAttack == nil { + var ret bool + return ret + } + return *o.UnderAttack +} + +// GetUnderAttackOk returns a tuple with the UnderAttack field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributesRisks) GetUnderAttackOk() (*bool, bool) { + if o == nil || o.UnderAttack == nil { + return nil, false + } + return o.UnderAttack, true +} + +// HasUnderAttack returns a boolean if a field has been set. +func (o *AssetAttributesRisks) HasUnderAttack() bool { + return o != nil && o.UnderAttack != nil +} + +// SetUnderAttack gets a reference to the given bool and assigns it to the UnderAttack field. +func (o *AssetAttributesRisks) SetUnderAttack(v bool) { + o.UnderAttack = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AssetAttributesRisks) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.HasAccessToSensitiveData != nil { + toSerialize["has_access_to_sensitive_data"] = o.HasAccessToSensitiveData + } + if o.HasPrivilegedAccess != nil { + toSerialize["has_privileged_access"] = o.HasPrivilegedAccess + } + toSerialize["in_production"] = o.InProduction + if o.IsPubliclyAccessible != nil { + toSerialize["is_publicly_accessible"] = o.IsPubliclyAccessible + } + if o.UnderAttack != nil { + toSerialize["under_attack"] = o.UnderAttack + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AssetAttributesRisks) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + HasAccessToSensitiveData *bool `json:"has_access_to_sensitive_data,omitempty"` + HasPrivilegedAccess *bool `json:"has_privileged_access,omitempty"` + InProduction *bool `json:"in_production"` + IsPubliclyAccessible *bool `json:"is_publicly_accessible,omitempty"` + UnderAttack *bool `json:"under_attack,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.InProduction == nil { + return fmt.Errorf("required field in_production missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"has_access_to_sensitive_data", "has_privileged_access", "in_production", "is_publicly_accessible", "under_attack"}) + } else { + return err + } + o.HasAccessToSensitiveData = all.HasAccessToSensitiveData + o.HasPrivilegedAccess = all.HasPrivilegedAccess + o.InProduction = *all.InProduction + o.IsPubliclyAccessible = all.IsPubliclyAccessible + o.UnderAttack = all.UnderAttack + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_asset_attributes_version.go b/api/datadogV2/model_asset_attributes_version.go new file mode 100644 index 00000000000..0e516b7d5a3 --- /dev/null +++ b/api/datadogV2/model_asset_attributes_version.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AssetAttributesVersion Asset version. +type AssetAttributesVersion struct { + // Asset first version. + First *string `json:"first,omitempty"` + // Asset last version. + Last *string `json:"last,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewAssetAttributesVersion instantiates a new AssetAttributesVersion object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewAssetAttributesVersion() *AssetAttributesVersion { + this := AssetAttributesVersion{} + return &this +} + +// NewAssetAttributesVersionWithDefaults instantiates a new AssetAttributesVersion object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewAssetAttributesVersionWithDefaults() *AssetAttributesVersion { + this := AssetAttributesVersion{} + return &this +} + +// GetFirst returns the First field value if set, zero value otherwise. +func (o *AssetAttributesVersion) GetFirst() string { + if o == nil || o.First == nil { + var ret string + return ret + } + return *o.First +} + +// GetFirstOk returns a tuple with the First field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributesVersion) GetFirstOk() (*string, bool) { + if o == nil || o.First == nil { + return nil, false + } + return o.First, true +} + +// HasFirst returns a boolean if a field has been set. +func (o *AssetAttributesVersion) HasFirst() bool { + return o != nil && o.First != nil +} + +// SetFirst gets a reference to the given string and assigns it to the First field. +func (o *AssetAttributesVersion) SetFirst(v string) { + o.First = &v +} + +// GetLast returns the Last field value if set, zero value otherwise. +func (o *AssetAttributesVersion) GetLast() string { + if o == nil || o.Last == nil { + var ret string + return ret + } + return *o.Last +} + +// GetLastOk returns a tuple with the Last field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AssetAttributesVersion) GetLastOk() (*string, bool) { + if o == nil || o.Last == nil { + return nil, false + } + return o.Last, true +} + +// HasLast returns a boolean if a field has been set. +func (o *AssetAttributesVersion) HasLast() bool { + return o != nil && o.Last != nil +} + +// SetLast gets a reference to the given string and assigns it to the Last field. +func (o *AssetAttributesVersion) SetLast(v string) { + o.Last = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AssetAttributesVersion) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.First != nil { + toSerialize["first"] = o.First + } + if o.Last != nil { + toSerialize["last"] = o.Last + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AssetAttributesVersion) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + First *string `json:"first,omitempty"` + Last *string `json:"last,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"first", "last"}) + } else { + return err + } + o.First = all.First + o.Last = all.Last + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_asset_entity_type.go b/api/datadogV2/model_asset_entity_type.go new file mode 100644 index 00000000000..bd0c01067fb --- /dev/null +++ b/api/datadogV2/model_asset_entity_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AssetEntityType The JSON:API type. +type AssetEntityType string + +// List of AssetEntityType. +const ( + ASSETENTITYTYPE_ASSETS AssetEntityType = "assets" +) + +var allowedAssetEntityTypeEnumValues = []AssetEntityType{ + ASSETENTITYTYPE_ASSETS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AssetEntityType) GetAllowedValues() []AssetEntityType { + return allowedAssetEntityTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AssetEntityType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AssetEntityType(value) + return nil +} + +// NewAssetEntityTypeFromValue returns a pointer to a valid AssetEntityType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAssetEntityTypeFromValue(v string) (*AssetEntityType, error) { + ev := AssetEntityType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AssetEntityType: valid values are %v", v, allowedAssetEntityTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AssetEntityType) IsValid() bool { + for _, existing := range allowedAssetEntityTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AssetEntityType value. +func (v AssetEntityType) Ptr() *AssetEntityType { + return &v +} diff --git a/api/datadogV2/model_asset_type.go b/api/datadogV2/model_asset_type.go new file mode 100644 index 00000000000..ef6ef899452 --- /dev/null +++ b/api/datadogV2/model_asset_type.go @@ -0,0 +1,72 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AssetType The asset type +type AssetType string + +// List of AssetType. +const ( + ASSETTYPE_REPOSITORY AssetType = "Repository" + ASSETTYPE_SERVICE AssetType = "Service" + ASSETTYPE_HOST AssetType = "Host" + ASSETTYPE_HOSTIMAGE AssetType = "HostImage" + ASSETTYPE_IMAGE AssetType = "Image" +) + +var allowedAssetTypeEnumValues = []AssetType{ + ASSETTYPE_REPOSITORY, + ASSETTYPE_SERVICE, + ASSETTYPE_HOST, + ASSETTYPE_HOSTIMAGE, + ASSETTYPE_IMAGE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AssetType) GetAllowedValues() []AssetType { + return allowedAssetTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AssetType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AssetType(value) + return nil +} + +// NewAssetTypeFromValue returns a pointer to a valid AssetType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAssetTypeFromValue(v string) (*AssetType, error) { + ev := AssetType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AssetType: valid values are %v", v, allowedAssetTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AssetType) IsValid() bool { + for _, existing := range allowedAssetTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AssetType value. +func (v AssetType) Ptr() *AssetType { + return &v +} diff --git a/api/datadogV2/model_code_location.go b/api/datadogV2/model_code_location.go new file mode 100644 index 00000000000..a9ea7e08af7 --- /dev/null +++ b/api/datadogV2/model_code_location.go @@ -0,0 +1,171 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CodeLocation Code vulnerability location. +type CodeLocation struct { + // Vulnerability location file path. + FilePath *string `json:"file_path,omitempty"` + // Vulnerability extracted location. + Location string `json:"location"` + // Vulnerability location method. + Method *string `json:"method,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCodeLocation instantiates a new CodeLocation object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCodeLocation(location string) *CodeLocation { + this := CodeLocation{} + this.Location = location + return &this +} + +// NewCodeLocationWithDefaults instantiates a new CodeLocation object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCodeLocationWithDefaults() *CodeLocation { + this := CodeLocation{} + return &this +} + +// GetFilePath returns the FilePath field value if set, zero value otherwise. +func (o *CodeLocation) GetFilePath() string { + if o == nil || o.FilePath == nil { + var ret string + return ret + } + return *o.FilePath +} + +// GetFilePathOk returns a tuple with the FilePath field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CodeLocation) GetFilePathOk() (*string, bool) { + if o == nil || o.FilePath == nil { + return nil, false + } + return o.FilePath, true +} + +// HasFilePath returns a boolean if a field has been set. +func (o *CodeLocation) HasFilePath() bool { + return o != nil && o.FilePath != nil +} + +// SetFilePath gets a reference to the given string and assigns it to the FilePath field. +func (o *CodeLocation) SetFilePath(v string) { + o.FilePath = &v +} + +// GetLocation returns the Location field value. +func (o *CodeLocation) GetLocation() string { + if o == nil { + var ret string + return ret + } + return o.Location +} + +// GetLocationOk returns a tuple with the Location field value +// and a boolean to check if the value has been set. +func (o *CodeLocation) GetLocationOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Location, true +} + +// SetLocation sets field value. +func (o *CodeLocation) SetLocation(v string) { + o.Location = v +} + +// GetMethod returns the Method field value if set, zero value otherwise. +func (o *CodeLocation) GetMethod() string { + if o == nil || o.Method == nil { + var ret string + return ret + } + return *o.Method +} + +// GetMethodOk returns a tuple with the Method field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CodeLocation) GetMethodOk() (*string, bool) { + if o == nil || o.Method == nil { + return nil, false + } + return o.Method, true +} + +// HasMethod returns a boolean if a field has been set. +func (o *CodeLocation) HasMethod() bool { + return o != nil && o.Method != nil +} + +// SetMethod gets a reference to the given string and assigns it to the Method field. +func (o *CodeLocation) SetMethod(v string) { + o.Method = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CodeLocation) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.FilePath != nil { + toSerialize["file_path"] = o.FilePath + } + toSerialize["location"] = o.Location + if o.Method != nil { + toSerialize["method"] = o.Method + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CodeLocation) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + FilePath *string `json:"file_path,omitempty"` + Location *string `json:"location"` + Method *string `json:"method,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Location == nil { + return fmt.Errorf("required field location missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"file_path", "location", "method"}) + } else { + return err + } + o.FilePath = all.FilePath + o.Location = *all.Location + o.Method = all.Method + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cvss.go b/api/datadogV2/model_cvss.go new file mode 100644 index 00000000000..6f4215be488 --- /dev/null +++ b/api/datadogV2/model_cvss.go @@ -0,0 +1,175 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CVSS Vulnerability severity. +type CVSS struct { + // Vulnerability severity score. + Score float64 `json:"score"` + // The vulnerability severity. + Severity VulnerabilitySeverity `json:"severity"` + // Vulnerability CVSS vector. + Vector string `json:"vector"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCVSS instantiates a new CVSS object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCVSS(score float64, severity VulnerabilitySeverity, vector string) *CVSS { + this := CVSS{} + this.Score = score + this.Severity = severity + this.Vector = vector + return &this +} + +// NewCVSSWithDefaults instantiates a new CVSS object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCVSSWithDefaults() *CVSS { + this := CVSS{} + return &this +} + +// GetScore returns the Score field value. +func (o *CVSS) GetScore() float64 { + if o == nil { + var ret float64 + return ret + } + return o.Score +} + +// GetScoreOk returns a tuple with the Score field value +// and a boolean to check if the value has been set. +func (o *CVSS) GetScoreOk() (*float64, bool) { + if o == nil { + return nil, false + } + return &o.Score, true +} + +// SetScore sets field value. +func (o *CVSS) SetScore(v float64) { + o.Score = v +} + +// GetSeverity returns the Severity field value. +func (o *CVSS) GetSeverity() VulnerabilitySeverity { + if o == nil { + var ret VulnerabilitySeverity + return ret + } + return o.Severity +} + +// GetSeverityOk returns a tuple with the Severity field value +// and a boolean to check if the value has been set. +func (o *CVSS) GetSeverityOk() (*VulnerabilitySeverity, bool) { + if o == nil { + return nil, false + } + return &o.Severity, true +} + +// SetSeverity sets field value. +func (o *CVSS) SetSeverity(v VulnerabilitySeverity) { + o.Severity = v +} + +// GetVector returns the Vector field value. +func (o *CVSS) GetVector() string { + if o == nil { + var ret string + return ret + } + return o.Vector +} + +// GetVectorOk returns a tuple with the Vector field value +// and a boolean to check if the value has been set. +func (o *CVSS) GetVectorOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Vector, true +} + +// SetVector sets field value. +func (o *CVSS) SetVector(v string) { + o.Vector = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CVSS) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["score"] = o.Score + toSerialize["severity"] = o.Severity + toSerialize["vector"] = o.Vector + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CVSS) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Score *float64 `json:"score"` + Severity *VulnerabilitySeverity `json:"severity"` + Vector *string `json:"vector"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Score == nil { + return fmt.Errorf("required field score missing") + } + if all.Severity == nil { + return fmt.Errorf("required field severity missing") + } + if all.Vector == nil { + return fmt.Errorf("required field vector missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"score", "severity", "vector"}) + } else { + return err + } + + hasInvalidField := false + o.Score = *all.Score + if !all.Severity.IsValid() { + hasInvalidField = true + } else { + o.Severity = *all.Severity + } + o.Vector = *all.Vector + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_dependency_location.go b/api/datadogV2/model_dependency_location.go new file mode 100644 index 00000000000..a5f156a3fd3 --- /dev/null +++ b/api/datadogV2/model_dependency_location.go @@ -0,0 +1,229 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DependencyLocation Static library vulnerability location. +type DependencyLocation struct { + // Location column end. + ColumnEnd int64 `json:"column_end"` + // Location column start. + ColumnStart int64 `json:"column_start"` + // Location file name. + FileName string `json:"file_name"` + // Location line end. + LineEnd int64 `json:"line_end"` + // Location line start. + LineStart int64 `json:"line_start"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDependencyLocation instantiates a new DependencyLocation object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDependencyLocation(columnEnd int64, columnStart int64, fileName string, lineEnd int64, lineStart int64) *DependencyLocation { + this := DependencyLocation{} + this.ColumnEnd = columnEnd + this.ColumnStart = columnStart + this.FileName = fileName + this.LineEnd = lineEnd + this.LineStart = lineStart + return &this +} + +// NewDependencyLocationWithDefaults instantiates a new DependencyLocation object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDependencyLocationWithDefaults() *DependencyLocation { + this := DependencyLocation{} + return &this +} + +// GetColumnEnd returns the ColumnEnd field value. +func (o *DependencyLocation) GetColumnEnd() int64 { + if o == nil { + var ret int64 + return ret + } + return o.ColumnEnd +} + +// GetColumnEndOk returns a tuple with the ColumnEnd field value +// and a boolean to check if the value has been set. +func (o *DependencyLocation) GetColumnEndOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.ColumnEnd, true +} + +// SetColumnEnd sets field value. +func (o *DependencyLocation) SetColumnEnd(v int64) { + o.ColumnEnd = v +} + +// GetColumnStart returns the ColumnStart field value. +func (o *DependencyLocation) GetColumnStart() int64 { + if o == nil { + var ret int64 + return ret + } + return o.ColumnStart +} + +// GetColumnStartOk returns a tuple with the ColumnStart field value +// and a boolean to check if the value has been set. +func (o *DependencyLocation) GetColumnStartOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.ColumnStart, true +} + +// SetColumnStart sets field value. +func (o *DependencyLocation) SetColumnStart(v int64) { + o.ColumnStart = v +} + +// GetFileName returns the FileName field value. +func (o *DependencyLocation) GetFileName() string { + if o == nil { + var ret string + return ret + } + return o.FileName +} + +// GetFileNameOk returns a tuple with the FileName field value +// and a boolean to check if the value has been set. +func (o *DependencyLocation) GetFileNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.FileName, true +} + +// SetFileName sets field value. +func (o *DependencyLocation) SetFileName(v string) { + o.FileName = v +} + +// GetLineEnd returns the LineEnd field value. +func (o *DependencyLocation) GetLineEnd() int64 { + if o == nil { + var ret int64 + return ret + } + return o.LineEnd +} + +// GetLineEndOk returns a tuple with the LineEnd field value +// and a boolean to check if the value has been set. +func (o *DependencyLocation) GetLineEndOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.LineEnd, true +} + +// SetLineEnd sets field value. +func (o *DependencyLocation) SetLineEnd(v int64) { + o.LineEnd = v +} + +// GetLineStart returns the LineStart field value. +func (o *DependencyLocation) GetLineStart() int64 { + if o == nil { + var ret int64 + return ret + } + return o.LineStart +} + +// GetLineStartOk returns a tuple with the LineStart field value +// and a boolean to check if the value has been set. +func (o *DependencyLocation) GetLineStartOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.LineStart, true +} + +// SetLineStart sets field value. +func (o *DependencyLocation) SetLineStart(v int64) { + o.LineStart = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DependencyLocation) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["column_end"] = o.ColumnEnd + toSerialize["column_start"] = o.ColumnStart + toSerialize["file_name"] = o.FileName + toSerialize["line_end"] = o.LineEnd + toSerialize["line_start"] = o.LineStart + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DependencyLocation) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ColumnEnd *int64 `json:"column_end"` + ColumnStart *int64 `json:"column_start"` + FileName *string `json:"file_name"` + LineEnd *int64 `json:"line_end"` + LineStart *int64 `json:"line_start"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ColumnEnd == nil { + return fmt.Errorf("required field column_end missing") + } + if all.ColumnStart == nil { + return fmt.Errorf("required field column_start missing") + } + if all.FileName == nil { + return fmt.Errorf("required field file_name missing") + } + if all.LineEnd == nil { + return fmt.Errorf("required field line_end missing") + } + if all.LineStart == nil { + return fmt.Errorf("required field line_start missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"column_end", "column_start", "file_name", "line_end", "line_start"}) + } else { + return err + } + o.ColumnEnd = *all.ColumnEnd + o.ColumnStart = *all.ColumnStart + o.FileName = *all.FileName + o.LineEnd = *all.LineEnd + o.LineStart = *all.LineStart + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_epss.go b/api/datadogV2/model_epss.go new file mode 100644 index 00000000000..671b3ad803c --- /dev/null +++ b/api/datadogV2/model_epss.go @@ -0,0 +1,143 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// EPSS Vulnerability EPSS severity. +type EPSS struct { + // Vulnerability EPSS severity score. + Score float64 `json:"score"` + // The vulnerability severity. + Severity VulnerabilitySeverity `json:"severity"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewEPSS instantiates a new EPSS object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewEPSS(score float64, severity VulnerabilitySeverity) *EPSS { + this := EPSS{} + this.Score = score + this.Severity = severity + return &this +} + +// NewEPSSWithDefaults instantiates a new EPSS object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewEPSSWithDefaults() *EPSS { + this := EPSS{} + return &this +} + +// GetScore returns the Score field value. +func (o *EPSS) GetScore() float64 { + if o == nil { + var ret float64 + return ret + } + return o.Score +} + +// GetScoreOk returns a tuple with the Score field value +// and a boolean to check if the value has been set. +func (o *EPSS) GetScoreOk() (*float64, bool) { + if o == nil { + return nil, false + } + return &o.Score, true +} + +// SetScore sets field value. +func (o *EPSS) SetScore(v float64) { + o.Score = v +} + +// GetSeverity returns the Severity field value. +func (o *EPSS) GetSeverity() VulnerabilitySeverity { + if o == nil { + var ret VulnerabilitySeverity + return ret + } + return o.Severity +} + +// GetSeverityOk returns a tuple with the Severity field value +// and a boolean to check if the value has been set. +func (o *EPSS) GetSeverityOk() (*VulnerabilitySeverity, bool) { + if o == nil { + return nil, false + } + return &o.Severity, true +} + +// SetSeverity sets field value. +func (o *EPSS) SetSeverity(v VulnerabilitySeverity) { + o.Severity = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EPSS) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["score"] = o.Score + toSerialize["severity"] = o.Severity + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EPSS) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Score *float64 `json:"score"` + Severity *VulnerabilitySeverity `json:"severity"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Score == nil { + return fmt.Errorf("required field score missing") + } + if all.Severity == nil { + return fmt.Errorf("required field severity missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"score", "severity"}) + } else { + return err + } + + hasInvalidField := false + o.Score = *all.Score + if !all.Severity.IsValid() { + hasInvalidField = true + } else { + o.Severity = *all.Severity + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_library.go b/api/datadogV2/model_library.go new file mode 100644 index 00000000000..9abb11aca2c --- /dev/null +++ b/api/datadogV2/model_library.go @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Library Vulnerability library. +type Library struct { + // Vulnerability library name. + Name string `json:"name"` + // Vulnerability library version. + Version *string `json:"version,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewLibrary instantiates a new Library object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewLibrary(name string) *Library { + this := Library{} + this.Name = name + return &this +} + +// NewLibraryWithDefaults instantiates a new Library object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewLibraryWithDefaults() *Library { + this := Library{} + return &this +} + +// GetName returns the Name field value. +func (o *Library) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *Library) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *Library) SetName(v string) { + o.Name = v +} + +// GetVersion returns the Version field value if set, zero value otherwise. +func (o *Library) GetVersion() string { + if o == nil || o.Version == nil { + var ret string + return ret + } + return *o.Version +} + +// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Library) GetVersionOk() (*string, bool) { + if o == nil || o.Version == nil { + return nil, false + } + return o.Version, true +} + +// HasVersion returns a boolean if a field has been set. +func (o *Library) HasVersion() bool { + return o != nil && o.Version != nil +} + +// SetVersion gets a reference to the given string and assigns it to the Version field. +func (o *Library) SetVersion(v string) { + o.Version = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Library) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + if o.Version != nil { + toSerialize["version"] = o.Version + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Library) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + Version *string `json:"version,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name", "version"}) + } else { + return err + } + o.Name = *all.Name + o.Version = all.Version + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_links.go b/api/datadogV2/model_links.go new file mode 100644 index 00000000000..9ac8e4dcc9d --- /dev/null +++ b/api/datadogV2/model_links.go @@ -0,0 +1,235 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Links The JSON:API links related to pagination. +type Links struct { + // First page link. + First string `json:"first"` + // Last page link. + Last string `json:"last"` + // Next page link. + Next *string `json:"next,omitempty"` + // Previous page link. + Previous *string `json:"previous,omitempty"` + // Request link. + Self string `json:"self"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewLinks instantiates a new Links object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewLinks(first string, last string, self string) *Links { + this := Links{} + this.First = first + this.Last = last + this.Self = self + return &this +} + +// NewLinksWithDefaults instantiates a new Links object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewLinksWithDefaults() *Links { + this := Links{} + return &this +} + +// GetFirst returns the First field value. +func (o *Links) GetFirst() string { + if o == nil { + var ret string + return ret + } + return o.First +} + +// GetFirstOk returns a tuple with the First field value +// and a boolean to check if the value has been set. +func (o *Links) GetFirstOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.First, true +} + +// SetFirst sets field value. +func (o *Links) SetFirst(v string) { + o.First = v +} + +// GetLast returns the Last field value. +func (o *Links) GetLast() string { + if o == nil { + var ret string + return ret + } + return o.Last +} + +// GetLastOk returns a tuple with the Last field value +// and a boolean to check if the value has been set. +func (o *Links) GetLastOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Last, true +} + +// SetLast sets field value. +func (o *Links) SetLast(v string) { + o.Last = v +} + +// GetNext returns the Next field value if set, zero value otherwise. +func (o *Links) GetNext() string { + if o == nil || o.Next == nil { + var ret string + return ret + } + return *o.Next +} + +// GetNextOk returns a tuple with the Next field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Links) GetNextOk() (*string, bool) { + if o == nil || o.Next == nil { + return nil, false + } + return o.Next, true +} + +// HasNext returns a boolean if a field has been set. +func (o *Links) HasNext() bool { + return o != nil && o.Next != nil +} + +// SetNext gets a reference to the given string and assigns it to the Next field. +func (o *Links) SetNext(v string) { + o.Next = &v +} + +// GetPrevious returns the Previous field value if set, zero value otherwise. +func (o *Links) GetPrevious() string { + if o == nil || o.Previous == nil { + var ret string + return ret + } + return *o.Previous +} + +// GetPreviousOk returns a tuple with the Previous field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Links) GetPreviousOk() (*string, bool) { + if o == nil || o.Previous == nil { + return nil, false + } + return o.Previous, true +} + +// HasPrevious returns a boolean if a field has been set. +func (o *Links) HasPrevious() bool { + return o != nil && o.Previous != nil +} + +// SetPrevious gets a reference to the given string and assigns it to the Previous field. +func (o *Links) SetPrevious(v string) { + o.Previous = &v +} + +// GetSelf returns the Self field value. +func (o *Links) GetSelf() string { + if o == nil { + var ret string + return ret + } + return o.Self +} + +// GetSelfOk returns a tuple with the Self field value +// and a boolean to check if the value has been set. +func (o *Links) GetSelfOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Self, true +} + +// SetSelf sets field value. +func (o *Links) SetSelf(v string) { + o.Self = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Links) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["first"] = o.First + toSerialize["last"] = o.Last + if o.Next != nil { + toSerialize["next"] = o.Next + } + if o.Previous != nil { + toSerialize["previous"] = o.Previous + } + toSerialize["self"] = o.Self + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Links) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + First *string `json:"first"` + Last *string `json:"last"` + Next *string `json:"next,omitempty"` + Previous *string `json:"previous,omitempty"` + Self *string `json:"self"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.First == nil { + return fmt.Errorf("required field first missing") + } + if all.Last == nil { + return fmt.Errorf("required field last missing") + } + if all.Self == nil { + return fmt.Errorf("required field self missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"first", "last", "next", "previous", "self"}) + } else { + return err + } + o.First = *all.First + o.Last = *all.Last + o.Next = all.Next + o.Previous = all.Previous + o.Self = *all.Self + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_list_vulnerabilities_response.go b/api/datadogV2/model_list_vulnerabilities_response.go new file mode 100644 index 00000000000..9d38cb16c89 --- /dev/null +++ b/api/datadogV2/model_list_vulnerabilities_response.go @@ -0,0 +1,183 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListVulnerabilitiesResponse The expected response schema when listing vulnerabilities. +type ListVulnerabilitiesResponse struct { + // List of vulnerabilities. + Data []Vulnerability `json:"data"` + // The JSON:API links related to pagination. + Links *Links `json:"links,omitempty"` + // The metadata related to this request. + Meta *Metadata `json:"meta,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListVulnerabilitiesResponse instantiates a new ListVulnerabilitiesResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListVulnerabilitiesResponse(data []Vulnerability) *ListVulnerabilitiesResponse { + this := ListVulnerabilitiesResponse{} + this.Data = data + return &this +} + +// NewListVulnerabilitiesResponseWithDefaults instantiates a new ListVulnerabilitiesResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListVulnerabilitiesResponseWithDefaults() *ListVulnerabilitiesResponse { + this := ListVulnerabilitiesResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ListVulnerabilitiesResponse) GetData() []Vulnerability { + if o == nil { + var ret []Vulnerability + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ListVulnerabilitiesResponse) GetDataOk() (*[]Vulnerability, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ListVulnerabilitiesResponse) SetData(v []Vulnerability) { + o.Data = v +} + +// GetLinks returns the Links field value if set, zero value otherwise. +func (o *ListVulnerabilitiesResponse) GetLinks() Links { + if o == nil || o.Links == nil { + var ret Links + return ret + } + return *o.Links +} + +// GetLinksOk returns a tuple with the Links field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListVulnerabilitiesResponse) GetLinksOk() (*Links, bool) { + if o == nil || o.Links == nil { + return nil, false + } + return o.Links, true +} + +// HasLinks returns a boolean if a field has been set. +func (o *ListVulnerabilitiesResponse) HasLinks() bool { + return o != nil && o.Links != nil +} + +// SetLinks gets a reference to the given Links and assigns it to the Links field. +func (o *ListVulnerabilitiesResponse) SetLinks(v Links) { + o.Links = &v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *ListVulnerabilitiesResponse) GetMeta() Metadata { + if o == nil || o.Meta == nil { + var ret Metadata + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListVulnerabilitiesResponse) GetMetaOk() (*Metadata, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *ListVulnerabilitiesResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given Metadata and assigns it to the Meta field. +func (o *ListVulnerabilitiesResponse) SetMeta(v Metadata) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListVulnerabilitiesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Links != nil { + toSerialize["links"] = o.Links + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListVulnerabilitiesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]Vulnerability `json:"data"` + Links *Links `json:"links,omitempty"` + Meta *Metadata `json:"meta,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "links", "meta"}) + } else { + return err + } + + hasInvalidField := false + o.Data = *all.Data + if all.Links != nil && all.Links.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Links = all.Links + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_list_vulnerable_assets_response.go b/api/datadogV2/model_list_vulnerable_assets_response.go new file mode 100644 index 00000000000..e8b80fe33f3 --- /dev/null +++ b/api/datadogV2/model_list_vulnerable_assets_response.go @@ -0,0 +1,183 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListVulnerableAssetsResponse The expected response schema when listing vulnerable assets. +type ListVulnerableAssetsResponse struct { + // List of vulnerable assets. + Data []Asset `json:"data"` + // The JSON:API links related to pagination. + Links *Links `json:"links,omitempty"` + // The metadata related to this request. + Meta *Metadata `json:"meta,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListVulnerableAssetsResponse instantiates a new ListVulnerableAssetsResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewListVulnerableAssetsResponse(data []Asset) *ListVulnerableAssetsResponse { + this := ListVulnerableAssetsResponse{} + this.Data = data + return &this +} + +// NewListVulnerableAssetsResponseWithDefaults instantiates a new ListVulnerableAssetsResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewListVulnerableAssetsResponseWithDefaults() *ListVulnerableAssetsResponse { + this := ListVulnerableAssetsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ListVulnerableAssetsResponse) GetData() []Asset { + if o == nil { + var ret []Asset + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ListVulnerableAssetsResponse) GetDataOk() (*[]Asset, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ListVulnerableAssetsResponse) SetData(v []Asset) { + o.Data = v +} + +// GetLinks returns the Links field value if set, zero value otherwise. +func (o *ListVulnerableAssetsResponse) GetLinks() Links { + if o == nil || o.Links == nil { + var ret Links + return ret + } + return *o.Links +} + +// GetLinksOk returns a tuple with the Links field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListVulnerableAssetsResponse) GetLinksOk() (*Links, bool) { + if o == nil || o.Links == nil { + return nil, false + } + return o.Links, true +} + +// HasLinks returns a boolean if a field has been set. +func (o *ListVulnerableAssetsResponse) HasLinks() bool { + return o != nil && o.Links != nil +} + +// SetLinks gets a reference to the given Links and assigns it to the Links field. +func (o *ListVulnerableAssetsResponse) SetLinks(v Links) { + o.Links = &v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *ListVulnerableAssetsResponse) GetMeta() Metadata { + if o == nil || o.Meta == nil { + var ret Metadata + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListVulnerableAssetsResponse) GetMetaOk() (*Metadata, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *ListVulnerableAssetsResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given Metadata and assigns it to the Meta field. +func (o *ListVulnerableAssetsResponse) SetMeta(v Metadata) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListVulnerableAssetsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Links != nil { + toSerialize["links"] = o.Links + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListVulnerableAssetsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]Asset `json:"data"` + Links *Links `json:"links,omitempty"` + Meta *Metadata `json:"meta,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "links", "meta"}) + } else { + return err + } + + hasInvalidField := false + o.Data = *all.Data + if all.Links != nil && all.Links.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Links = all.Links + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_metadata.go b/api/datadogV2/model_metadata.go new file mode 100644 index 00000000000..5a3425bf172 --- /dev/null +++ b/api/datadogV2/model_metadata.go @@ -0,0 +1,165 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Metadata The metadata related to this request. +type Metadata struct { + // Number of entities included in the response. + Count int64 `json:"count"` + // The token that identifies the request. + Token string `json:"token"` + // Total number of entities across all pages. + Total int64 `json:"total"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewMetadata instantiates a new Metadata object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewMetadata(count int64, token string, total int64) *Metadata { + this := Metadata{} + this.Count = count + this.Token = token + this.Total = total + return &this +} + +// NewMetadataWithDefaults instantiates a new Metadata object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewMetadataWithDefaults() *Metadata { + this := Metadata{} + return &this +} + +// GetCount returns the Count field value. +func (o *Metadata) GetCount() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Count +} + +// GetCountOk returns a tuple with the Count field value +// and a boolean to check if the value has been set. +func (o *Metadata) GetCountOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Count, true +} + +// SetCount sets field value. +func (o *Metadata) SetCount(v int64) { + o.Count = v +} + +// GetToken returns the Token field value. +func (o *Metadata) GetToken() string { + if o == nil { + var ret string + return ret + } + return o.Token +} + +// GetTokenOk returns a tuple with the Token field value +// and a boolean to check if the value has been set. +func (o *Metadata) GetTokenOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Token, true +} + +// SetToken sets field value. +func (o *Metadata) SetToken(v string) { + o.Token = v +} + +// GetTotal returns the Total field value. +func (o *Metadata) GetTotal() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Total +} + +// GetTotalOk returns a tuple with the Total field value +// and a boolean to check if the value has been set. +func (o *Metadata) GetTotalOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Total, true +} + +// SetTotal sets field value. +func (o *Metadata) SetTotal(v int64) { + o.Total = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Metadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["count"] = o.Count + toSerialize["token"] = o.Token + toSerialize["total"] = o.Total + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Metadata) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Count *int64 `json:"count"` + Token *string `json:"token"` + Total *int64 `json:"total"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Count == nil { + return fmt.Errorf("required field count missing") + } + if all.Token == nil { + return fmt.Errorf("required field token missing") + } + if all.Total == nil { + return fmt.Errorf("required field total missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"count", "token", "total"}) + } else { + return err + } + o.Count = *all.Count + o.Token = *all.Token + o.Total = *all.Total + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_remediation.go b/api/datadogV2/model_remediation.go new file mode 100644 index 00000000000..34296adaa59 --- /dev/null +++ b/api/datadogV2/model_remediation.go @@ -0,0 +1,325 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Remediation Vulnerability remediation. +type Remediation struct { + // Whether the vulnerability can be resolved when recompiling the package or not. + AutoSolvable bool `json:"auto_solvable"` + // Avoided advisories. + AvoidedAdvisories []Advisory `json:"avoided_advisories"` + // Remediation fixed advisories. + FixedAdvisories []Advisory `json:"fixed_advisories"` + // Library name remediating the vulnerability. + LibraryName string `json:"library_name"` + // Library version remediating the vulnerability. + LibraryVersion string `json:"library_version"` + // New advisories. + NewAdvisories []Advisory `json:"new_advisories"` + // Remaining advisories. + RemainingAdvisories []Advisory `json:"remaining_advisories"` + // Remediation type. + Type string `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewRemediation instantiates a new Remediation object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewRemediation(autoSolvable bool, avoidedAdvisories []Advisory, fixedAdvisories []Advisory, libraryName string, libraryVersion string, newAdvisories []Advisory, remainingAdvisories []Advisory, typeVar string) *Remediation { + this := Remediation{} + this.AutoSolvable = autoSolvable + this.AvoidedAdvisories = avoidedAdvisories + this.FixedAdvisories = fixedAdvisories + this.LibraryName = libraryName + this.LibraryVersion = libraryVersion + this.NewAdvisories = newAdvisories + this.RemainingAdvisories = remainingAdvisories + this.Type = typeVar + return &this +} + +// NewRemediationWithDefaults instantiates a new Remediation object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewRemediationWithDefaults() *Remediation { + this := Remediation{} + return &this +} + +// GetAutoSolvable returns the AutoSolvable field value. +func (o *Remediation) GetAutoSolvable() bool { + if o == nil { + var ret bool + return ret + } + return o.AutoSolvable +} + +// GetAutoSolvableOk returns a tuple with the AutoSolvable field value +// and a boolean to check if the value has been set. +func (o *Remediation) GetAutoSolvableOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.AutoSolvable, true +} + +// SetAutoSolvable sets field value. +func (o *Remediation) SetAutoSolvable(v bool) { + o.AutoSolvable = v +} + +// GetAvoidedAdvisories returns the AvoidedAdvisories field value. +func (o *Remediation) GetAvoidedAdvisories() []Advisory { + if o == nil { + var ret []Advisory + return ret + } + return o.AvoidedAdvisories +} + +// GetAvoidedAdvisoriesOk returns a tuple with the AvoidedAdvisories field value +// and a boolean to check if the value has been set. +func (o *Remediation) GetAvoidedAdvisoriesOk() (*[]Advisory, bool) { + if o == nil { + return nil, false + } + return &o.AvoidedAdvisories, true +} + +// SetAvoidedAdvisories sets field value. +func (o *Remediation) SetAvoidedAdvisories(v []Advisory) { + o.AvoidedAdvisories = v +} + +// GetFixedAdvisories returns the FixedAdvisories field value. +func (o *Remediation) GetFixedAdvisories() []Advisory { + if o == nil { + var ret []Advisory + return ret + } + return o.FixedAdvisories +} + +// GetFixedAdvisoriesOk returns a tuple with the FixedAdvisories field value +// and a boolean to check if the value has been set. +func (o *Remediation) GetFixedAdvisoriesOk() (*[]Advisory, bool) { + if o == nil { + return nil, false + } + return &o.FixedAdvisories, true +} + +// SetFixedAdvisories sets field value. +func (o *Remediation) SetFixedAdvisories(v []Advisory) { + o.FixedAdvisories = v +} + +// GetLibraryName returns the LibraryName field value. +func (o *Remediation) GetLibraryName() string { + if o == nil { + var ret string + return ret + } + return o.LibraryName +} + +// GetLibraryNameOk returns a tuple with the LibraryName field value +// and a boolean to check if the value has been set. +func (o *Remediation) GetLibraryNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.LibraryName, true +} + +// SetLibraryName sets field value. +func (o *Remediation) SetLibraryName(v string) { + o.LibraryName = v +} + +// GetLibraryVersion returns the LibraryVersion field value. +func (o *Remediation) GetLibraryVersion() string { + if o == nil { + var ret string + return ret + } + return o.LibraryVersion +} + +// GetLibraryVersionOk returns a tuple with the LibraryVersion field value +// and a boolean to check if the value has been set. +func (o *Remediation) GetLibraryVersionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.LibraryVersion, true +} + +// SetLibraryVersion sets field value. +func (o *Remediation) SetLibraryVersion(v string) { + o.LibraryVersion = v +} + +// GetNewAdvisories returns the NewAdvisories field value. +func (o *Remediation) GetNewAdvisories() []Advisory { + if o == nil { + var ret []Advisory + return ret + } + return o.NewAdvisories +} + +// GetNewAdvisoriesOk returns a tuple with the NewAdvisories field value +// and a boolean to check if the value has been set. +func (o *Remediation) GetNewAdvisoriesOk() (*[]Advisory, bool) { + if o == nil { + return nil, false + } + return &o.NewAdvisories, true +} + +// SetNewAdvisories sets field value. +func (o *Remediation) SetNewAdvisories(v []Advisory) { + o.NewAdvisories = v +} + +// GetRemainingAdvisories returns the RemainingAdvisories field value. +func (o *Remediation) GetRemainingAdvisories() []Advisory { + if o == nil { + var ret []Advisory + return ret + } + return o.RemainingAdvisories +} + +// GetRemainingAdvisoriesOk returns a tuple with the RemainingAdvisories field value +// and a boolean to check if the value has been set. +func (o *Remediation) GetRemainingAdvisoriesOk() (*[]Advisory, bool) { + if o == nil { + return nil, false + } + return &o.RemainingAdvisories, true +} + +// SetRemainingAdvisories sets field value. +func (o *Remediation) SetRemainingAdvisories(v []Advisory) { + o.RemainingAdvisories = v +} + +// GetType returns the Type field value. +func (o *Remediation) GetType() string { + if o == nil { + var ret string + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *Remediation) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *Remediation) SetType(v string) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Remediation) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["auto_solvable"] = o.AutoSolvable + toSerialize["avoided_advisories"] = o.AvoidedAdvisories + toSerialize["fixed_advisories"] = o.FixedAdvisories + toSerialize["library_name"] = o.LibraryName + toSerialize["library_version"] = o.LibraryVersion + toSerialize["new_advisories"] = o.NewAdvisories + toSerialize["remaining_advisories"] = o.RemainingAdvisories + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Remediation) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AutoSolvable *bool `json:"auto_solvable"` + AvoidedAdvisories *[]Advisory `json:"avoided_advisories"` + FixedAdvisories *[]Advisory `json:"fixed_advisories"` + LibraryName *string `json:"library_name"` + LibraryVersion *string `json:"library_version"` + NewAdvisories *[]Advisory `json:"new_advisories"` + RemainingAdvisories *[]Advisory `json:"remaining_advisories"` + Type *string `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AutoSolvable == nil { + return fmt.Errorf("required field auto_solvable missing") + } + if all.AvoidedAdvisories == nil { + return fmt.Errorf("required field avoided_advisories missing") + } + if all.FixedAdvisories == nil { + return fmt.Errorf("required field fixed_advisories missing") + } + if all.LibraryName == nil { + return fmt.Errorf("required field library_name missing") + } + if all.LibraryVersion == nil { + return fmt.Errorf("required field library_version missing") + } + if all.NewAdvisories == nil { + return fmt.Errorf("required field new_advisories missing") + } + if all.RemainingAdvisories == nil { + return fmt.Errorf("required field remaining_advisories missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"auto_solvable", "avoided_advisories", "fixed_advisories", "library_name", "library_version", "new_advisories", "remaining_advisories", "type"}) + } else { + return err + } + o.AutoSolvable = *all.AutoSolvable + o.AvoidedAdvisories = *all.AvoidedAdvisories + o.FixedAdvisories = *all.FixedAdvisories + o.LibraryName = *all.LibraryName + o.LibraryVersion = *all.LibraryVersion + o.NewAdvisories = *all.NewAdvisories + o.RemainingAdvisories = *all.RemainingAdvisories + o.Type = *all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_vulnerabilities_type.go b/api/datadogV2/model_vulnerabilities_type.go new file mode 100644 index 00000000000..d79bead1f4d --- /dev/null +++ b/api/datadogV2/model_vulnerabilities_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilitiesType The JSON:API type. +type VulnerabilitiesType string + +// List of VulnerabilitiesType. +const ( + VULNERABILITIESTYPE_VULNERABILITIES VulnerabilitiesType = "vulnerabilities" +) + +var allowedVulnerabilitiesTypeEnumValues = []VulnerabilitiesType{ + VULNERABILITIESTYPE_VULNERABILITIES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *VulnerabilitiesType) GetAllowedValues() []VulnerabilitiesType { + return allowedVulnerabilitiesTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *VulnerabilitiesType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = VulnerabilitiesType(value) + return nil +} + +// NewVulnerabilitiesTypeFromValue returns a pointer to a valid VulnerabilitiesType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewVulnerabilitiesTypeFromValue(v string) (*VulnerabilitiesType, error) { + ev := VulnerabilitiesType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for VulnerabilitiesType: valid values are %v", v, allowedVulnerabilitiesTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v VulnerabilitiesType) IsValid() bool { + for _, existing := range allowedVulnerabilitiesTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to VulnerabilitiesType value. +func (v VulnerabilitiesType) Ptr() *VulnerabilitiesType { + return &v +} diff --git a/api/datadogV2/model_vulnerability.go b/api/datadogV2/model_vulnerability.go new file mode 100644 index 00000000000..50dc183013d --- /dev/null +++ b/api/datadogV2/model_vulnerability.go @@ -0,0 +1,213 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Vulnerability A single vulnerability +type Vulnerability struct { + // The JSON:API attributes of the vulnerability. + Attributes VulnerabilityAttributes `json:"attributes"` + // The unique ID for this vulnerability. + Id string `json:"id"` + // Related entities object. + Relationships VulnerabilityRelationships `json:"relationships"` + // The JSON:API type. + Type VulnerabilitiesType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVulnerability instantiates a new Vulnerability object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVulnerability(attributes VulnerabilityAttributes, id string, relationships VulnerabilityRelationships, typeVar VulnerabilitiesType) *Vulnerability { + this := Vulnerability{} + this.Attributes = attributes + this.Id = id + this.Relationships = relationships + this.Type = typeVar + return &this +} + +// NewVulnerabilityWithDefaults instantiates a new Vulnerability object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVulnerabilityWithDefaults() *Vulnerability { + this := Vulnerability{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *Vulnerability) GetAttributes() VulnerabilityAttributes { + if o == nil { + var ret VulnerabilityAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *Vulnerability) GetAttributesOk() (*VulnerabilityAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *Vulnerability) SetAttributes(v VulnerabilityAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *Vulnerability) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *Vulnerability) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *Vulnerability) SetId(v string) { + o.Id = v +} + +// GetRelationships returns the Relationships field value. +func (o *Vulnerability) GetRelationships() VulnerabilityRelationships { + if o == nil { + var ret VulnerabilityRelationships + return ret + } + return o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value +// and a boolean to check if the value has been set. +func (o *Vulnerability) GetRelationshipsOk() (*VulnerabilityRelationships, bool) { + if o == nil { + return nil, false + } + return &o.Relationships, true +} + +// SetRelationships sets field value. +func (o *Vulnerability) SetRelationships(v VulnerabilityRelationships) { + o.Relationships = v +} + +// GetType returns the Type field value. +func (o *Vulnerability) GetType() VulnerabilitiesType { + if o == nil { + var ret VulnerabilitiesType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *Vulnerability) GetTypeOk() (*VulnerabilitiesType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *Vulnerability) SetType(v VulnerabilitiesType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Vulnerability) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["relationships"] = o.Relationships + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Vulnerability) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *VulnerabilityAttributes `json:"attributes"` + Id *string `json:"id"` + Relationships *VulnerabilityRelationships `json:"relationships"` + Type *VulnerabilitiesType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Relationships == nil { + return fmt.Errorf("required field relationships missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = *all.Relationships + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_vulnerability_attributes.go b/api/datadogV2/model_vulnerability_attributes.go new file mode 100644 index 00000000000..822e9f99c40 --- /dev/null +++ b/api/datadogV2/model_vulnerability_attributes.go @@ -0,0 +1,764 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityAttributes The JSON:API attributes of the vulnerability. +type VulnerabilityAttributes struct { + // Vulnerability advisory ID. + AdvisoryId *string `json:"advisory_id,omitempty"` + // Code vulnerability location. + CodeLocation *CodeLocation `json:"code_location,omitempty"` + // Vulnerability CVE list. + CveList []string `json:"cve_list"` + // Vulnerability severities. + Cvss VulnerabilityAttributesCvss `json:"cvss"` + // Static library vulnerability location. + DependencyLocations *VulnerabilityAttributesDependencyLocations `json:"dependency_locations,omitempty"` + // Vulnerability description. + Description string `json:"description"` + // The related vulnerability asset ecosystem. + Ecosystem *VulnerabilityEcosystem `json:"ecosystem,omitempty"` + // Vulnerability exposure time in seconds. + ExposureTime int64 `json:"exposure_time"` + // First detection of the vulnerability in [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) format + FirstDetection string `json:"first_detection"` + // Whether the vulnerability has a remediation or not. + FixAvailable bool `json:"fix_available"` + // Vulnerability language. + Language string `json:"language"` + // Last detection of the vulnerability in [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339) format + LastDetection string `json:"last_detection"` + // Vulnerability library. + Library *Library `json:"library,omitempty"` + // List of remediations. + Remediations []Remediation `json:"remediations"` + // Vulnerability `repo_digest` list (when the vulnerability is related to `Image` asset). + RepoDigests []string `json:"repo_digests,omitempty"` + // Vulnerability risks. + Risks VulnerabilityRisks `json:"risks"` + // The vulnerability status. + Status VulnerabilityStatus `json:"status"` + // Vulnerability title. + Title string `json:"title"` + // The vulnerability tool. + Tool VulnerabilityTool `json:"tool"` + // The vulnerability type. + Type VulnerabilityType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVulnerabilityAttributes instantiates a new VulnerabilityAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVulnerabilityAttributes(cveList []string, cvss VulnerabilityAttributesCvss, description string, exposureTime int64, firstDetection string, fixAvailable bool, language string, lastDetection string, remediations []Remediation, risks VulnerabilityRisks, status VulnerabilityStatus, title string, tool VulnerabilityTool, typeVar VulnerabilityType) *VulnerabilityAttributes { + this := VulnerabilityAttributes{} + this.CveList = cveList + this.Cvss = cvss + this.Description = description + this.ExposureTime = exposureTime + this.FirstDetection = firstDetection + this.FixAvailable = fixAvailable + this.Language = language + this.LastDetection = lastDetection + this.Remediations = remediations + this.Risks = risks + this.Status = status + this.Title = title + this.Tool = tool + this.Type = typeVar + return &this +} + +// NewVulnerabilityAttributesWithDefaults instantiates a new VulnerabilityAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVulnerabilityAttributesWithDefaults() *VulnerabilityAttributes { + this := VulnerabilityAttributes{} + return &this +} + +// GetAdvisoryId returns the AdvisoryId field value if set, zero value otherwise. +func (o *VulnerabilityAttributes) GetAdvisoryId() string { + if o == nil || o.AdvisoryId == nil { + var ret string + return ret + } + return *o.AdvisoryId +} + +// GetAdvisoryIdOk returns a tuple with the AdvisoryId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetAdvisoryIdOk() (*string, bool) { + if o == nil || o.AdvisoryId == nil { + return nil, false + } + return o.AdvisoryId, true +} + +// HasAdvisoryId returns a boolean if a field has been set. +func (o *VulnerabilityAttributes) HasAdvisoryId() bool { + return o != nil && o.AdvisoryId != nil +} + +// SetAdvisoryId gets a reference to the given string and assigns it to the AdvisoryId field. +func (o *VulnerabilityAttributes) SetAdvisoryId(v string) { + o.AdvisoryId = &v +} + +// GetCodeLocation returns the CodeLocation field value if set, zero value otherwise. +func (o *VulnerabilityAttributes) GetCodeLocation() CodeLocation { + if o == nil || o.CodeLocation == nil { + var ret CodeLocation + return ret + } + return *o.CodeLocation +} + +// GetCodeLocationOk returns a tuple with the CodeLocation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetCodeLocationOk() (*CodeLocation, bool) { + if o == nil || o.CodeLocation == nil { + return nil, false + } + return o.CodeLocation, true +} + +// HasCodeLocation returns a boolean if a field has been set. +func (o *VulnerabilityAttributes) HasCodeLocation() bool { + return o != nil && o.CodeLocation != nil +} + +// SetCodeLocation gets a reference to the given CodeLocation and assigns it to the CodeLocation field. +func (o *VulnerabilityAttributes) SetCodeLocation(v CodeLocation) { + o.CodeLocation = &v +} + +// GetCveList returns the CveList field value. +func (o *VulnerabilityAttributes) GetCveList() []string { + if o == nil { + var ret []string + return ret + } + return o.CveList +} + +// GetCveListOk returns a tuple with the CveList field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetCveListOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.CveList, true +} + +// SetCveList sets field value. +func (o *VulnerabilityAttributes) SetCveList(v []string) { + o.CveList = v +} + +// GetCvss returns the Cvss field value. +func (o *VulnerabilityAttributes) GetCvss() VulnerabilityAttributesCvss { + if o == nil { + var ret VulnerabilityAttributesCvss + return ret + } + return o.Cvss +} + +// GetCvssOk returns a tuple with the Cvss field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetCvssOk() (*VulnerabilityAttributesCvss, bool) { + if o == nil { + return nil, false + } + return &o.Cvss, true +} + +// SetCvss sets field value. +func (o *VulnerabilityAttributes) SetCvss(v VulnerabilityAttributesCvss) { + o.Cvss = v +} + +// GetDependencyLocations returns the DependencyLocations field value if set, zero value otherwise. +func (o *VulnerabilityAttributes) GetDependencyLocations() VulnerabilityAttributesDependencyLocations { + if o == nil || o.DependencyLocations == nil { + var ret VulnerabilityAttributesDependencyLocations + return ret + } + return *o.DependencyLocations +} + +// GetDependencyLocationsOk returns a tuple with the DependencyLocations field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetDependencyLocationsOk() (*VulnerabilityAttributesDependencyLocations, bool) { + if o == nil || o.DependencyLocations == nil { + return nil, false + } + return o.DependencyLocations, true +} + +// HasDependencyLocations returns a boolean if a field has been set. +func (o *VulnerabilityAttributes) HasDependencyLocations() bool { + return o != nil && o.DependencyLocations != nil +} + +// SetDependencyLocations gets a reference to the given VulnerabilityAttributesDependencyLocations and assigns it to the DependencyLocations field. +func (o *VulnerabilityAttributes) SetDependencyLocations(v VulnerabilityAttributesDependencyLocations) { + o.DependencyLocations = &v +} + +// GetDescription returns the Description field value. +func (o *VulnerabilityAttributes) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *VulnerabilityAttributes) SetDescription(v string) { + o.Description = v +} + +// GetEcosystem returns the Ecosystem field value if set, zero value otherwise. +func (o *VulnerabilityAttributes) GetEcosystem() VulnerabilityEcosystem { + if o == nil || o.Ecosystem == nil { + var ret VulnerabilityEcosystem + return ret + } + return *o.Ecosystem +} + +// GetEcosystemOk returns a tuple with the Ecosystem field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetEcosystemOk() (*VulnerabilityEcosystem, bool) { + if o == nil || o.Ecosystem == nil { + return nil, false + } + return o.Ecosystem, true +} + +// HasEcosystem returns a boolean if a field has been set. +func (o *VulnerabilityAttributes) HasEcosystem() bool { + return o != nil && o.Ecosystem != nil +} + +// SetEcosystem gets a reference to the given VulnerabilityEcosystem and assigns it to the Ecosystem field. +func (o *VulnerabilityAttributes) SetEcosystem(v VulnerabilityEcosystem) { + o.Ecosystem = &v +} + +// GetExposureTime returns the ExposureTime field value. +func (o *VulnerabilityAttributes) GetExposureTime() int64 { + if o == nil { + var ret int64 + return ret + } + return o.ExposureTime +} + +// GetExposureTimeOk returns a tuple with the ExposureTime field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetExposureTimeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.ExposureTime, true +} + +// SetExposureTime sets field value. +func (o *VulnerabilityAttributes) SetExposureTime(v int64) { + o.ExposureTime = v +} + +// GetFirstDetection returns the FirstDetection field value. +func (o *VulnerabilityAttributes) GetFirstDetection() string { + if o == nil { + var ret string + return ret + } + return o.FirstDetection +} + +// GetFirstDetectionOk returns a tuple with the FirstDetection field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetFirstDetectionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.FirstDetection, true +} + +// SetFirstDetection sets field value. +func (o *VulnerabilityAttributes) SetFirstDetection(v string) { + o.FirstDetection = v +} + +// GetFixAvailable returns the FixAvailable field value. +func (o *VulnerabilityAttributes) GetFixAvailable() bool { + if o == nil { + var ret bool + return ret + } + return o.FixAvailable +} + +// GetFixAvailableOk returns a tuple with the FixAvailable field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetFixAvailableOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.FixAvailable, true +} + +// SetFixAvailable sets field value. +func (o *VulnerabilityAttributes) SetFixAvailable(v bool) { + o.FixAvailable = v +} + +// GetLanguage returns the Language field value. +func (o *VulnerabilityAttributes) GetLanguage() string { + if o == nil { + var ret string + return ret + } + return o.Language +} + +// GetLanguageOk returns a tuple with the Language field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetLanguageOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Language, true +} + +// SetLanguage sets field value. +func (o *VulnerabilityAttributes) SetLanguage(v string) { + o.Language = v +} + +// GetLastDetection returns the LastDetection field value. +func (o *VulnerabilityAttributes) GetLastDetection() string { + if o == nil { + var ret string + return ret + } + return o.LastDetection +} + +// GetLastDetectionOk returns a tuple with the LastDetection field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetLastDetectionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.LastDetection, true +} + +// SetLastDetection sets field value. +func (o *VulnerabilityAttributes) SetLastDetection(v string) { + o.LastDetection = v +} + +// GetLibrary returns the Library field value if set, zero value otherwise. +func (o *VulnerabilityAttributes) GetLibrary() Library { + if o == nil || o.Library == nil { + var ret Library + return ret + } + return *o.Library +} + +// GetLibraryOk returns a tuple with the Library field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetLibraryOk() (*Library, bool) { + if o == nil || o.Library == nil { + return nil, false + } + return o.Library, true +} + +// HasLibrary returns a boolean if a field has been set. +func (o *VulnerabilityAttributes) HasLibrary() bool { + return o != nil && o.Library != nil +} + +// SetLibrary gets a reference to the given Library and assigns it to the Library field. +func (o *VulnerabilityAttributes) SetLibrary(v Library) { + o.Library = &v +} + +// GetRemediations returns the Remediations field value. +func (o *VulnerabilityAttributes) GetRemediations() []Remediation { + if o == nil { + var ret []Remediation + return ret + } + return o.Remediations +} + +// GetRemediationsOk returns a tuple with the Remediations field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetRemediationsOk() (*[]Remediation, bool) { + if o == nil { + return nil, false + } + return &o.Remediations, true +} + +// SetRemediations sets field value. +func (o *VulnerabilityAttributes) SetRemediations(v []Remediation) { + o.Remediations = v +} + +// GetRepoDigests returns the RepoDigests field value if set, zero value otherwise. +func (o *VulnerabilityAttributes) GetRepoDigests() []string { + if o == nil || o.RepoDigests == nil { + var ret []string + return ret + } + return o.RepoDigests +} + +// GetRepoDigestsOk returns a tuple with the RepoDigests field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetRepoDigestsOk() (*[]string, bool) { + if o == nil || o.RepoDigests == nil { + return nil, false + } + return &o.RepoDigests, true +} + +// HasRepoDigests returns a boolean if a field has been set. +func (o *VulnerabilityAttributes) HasRepoDigests() bool { + return o != nil && o.RepoDigests != nil +} + +// SetRepoDigests gets a reference to the given []string and assigns it to the RepoDigests field. +func (o *VulnerabilityAttributes) SetRepoDigests(v []string) { + o.RepoDigests = v +} + +// GetRisks returns the Risks field value. +func (o *VulnerabilityAttributes) GetRisks() VulnerabilityRisks { + if o == nil { + var ret VulnerabilityRisks + return ret + } + return o.Risks +} + +// GetRisksOk returns a tuple with the Risks field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetRisksOk() (*VulnerabilityRisks, bool) { + if o == nil { + return nil, false + } + return &o.Risks, true +} + +// SetRisks sets field value. +func (o *VulnerabilityAttributes) SetRisks(v VulnerabilityRisks) { + o.Risks = v +} + +// GetStatus returns the Status field value. +func (o *VulnerabilityAttributes) GetStatus() VulnerabilityStatus { + if o == nil { + var ret VulnerabilityStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetStatusOk() (*VulnerabilityStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *VulnerabilityAttributes) SetStatus(v VulnerabilityStatus) { + o.Status = v +} + +// GetTitle returns the Title field value. +func (o *VulnerabilityAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *VulnerabilityAttributes) SetTitle(v string) { + o.Title = v +} + +// GetTool returns the Tool field value. +func (o *VulnerabilityAttributes) GetTool() VulnerabilityTool { + if o == nil { + var ret VulnerabilityTool + return ret + } + return o.Tool +} + +// GetToolOk returns a tuple with the Tool field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetToolOk() (*VulnerabilityTool, bool) { + if o == nil { + return nil, false + } + return &o.Tool, true +} + +// SetTool sets field value. +func (o *VulnerabilityAttributes) SetTool(v VulnerabilityTool) { + o.Tool = v +} + +// GetType returns the Type field value. +func (o *VulnerabilityAttributes) GetType() VulnerabilityType { + if o == nil { + var ret VulnerabilityType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributes) GetTypeOk() (*VulnerabilityType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *VulnerabilityAttributes) SetType(v VulnerabilityType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VulnerabilityAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AdvisoryId != nil { + toSerialize["advisory_id"] = o.AdvisoryId + } + if o.CodeLocation != nil { + toSerialize["code_location"] = o.CodeLocation + } + toSerialize["cve_list"] = o.CveList + toSerialize["cvss"] = o.Cvss + if o.DependencyLocations != nil { + toSerialize["dependency_locations"] = o.DependencyLocations + } + toSerialize["description"] = o.Description + if o.Ecosystem != nil { + toSerialize["ecosystem"] = o.Ecosystem + } + toSerialize["exposure_time"] = o.ExposureTime + toSerialize["first_detection"] = o.FirstDetection + toSerialize["fix_available"] = o.FixAvailable + toSerialize["language"] = o.Language + toSerialize["last_detection"] = o.LastDetection + if o.Library != nil { + toSerialize["library"] = o.Library + } + toSerialize["remediations"] = o.Remediations + if o.RepoDigests != nil { + toSerialize["repo_digests"] = o.RepoDigests + } + toSerialize["risks"] = o.Risks + toSerialize["status"] = o.Status + toSerialize["title"] = o.Title + toSerialize["tool"] = o.Tool + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VulnerabilityAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AdvisoryId *string `json:"advisory_id,omitempty"` + CodeLocation *CodeLocation `json:"code_location,omitempty"` + CveList *[]string `json:"cve_list"` + Cvss *VulnerabilityAttributesCvss `json:"cvss"` + DependencyLocations *VulnerabilityAttributesDependencyLocations `json:"dependency_locations,omitempty"` + Description *string `json:"description"` + Ecosystem *VulnerabilityEcosystem `json:"ecosystem,omitempty"` + ExposureTime *int64 `json:"exposure_time"` + FirstDetection *string `json:"first_detection"` + FixAvailable *bool `json:"fix_available"` + Language *string `json:"language"` + LastDetection *string `json:"last_detection"` + Library *Library `json:"library,omitempty"` + Remediations *[]Remediation `json:"remediations"` + RepoDigests []string `json:"repo_digests,omitempty"` + Risks *VulnerabilityRisks `json:"risks"` + Status *VulnerabilityStatus `json:"status"` + Title *string `json:"title"` + Tool *VulnerabilityTool `json:"tool"` + Type *VulnerabilityType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CveList == nil { + return fmt.Errorf("required field cve_list missing") + } + if all.Cvss == nil { + return fmt.Errorf("required field cvss missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.ExposureTime == nil { + return fmt.Errorf("required field exposure_time missing") + } + if all.FirstDetection == nil { + return fmt.Errorf("required field first_detection missing") + } + if all.FixAvailable == nil { + return fmt.Errorf("required field fix_available missing") + } + if all.Language == nil { + return fmt.Errorf("required field language missing") + } + if all.LastDetection == nil { + return fmt.Errorf("required field last_detection missing") + } + if all.Remediations == nil { + return fmt.Errorf("required field remediations missing") + } + if all.Risks == nil { + return fmt.Errorf("required field risks missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + if all.Tool == nil { + return fmt.Errorf("required field tool missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"advisory_id", "code_location", "cve_list", "cvss", "dependency_locations", "description", "ecosystem", "exposure_time", "first_detection", "fix_available", "language", "last_detection", "library", "remediations", "repo_digests", "risks", "status", "title", "tool", "type"}) + } else { + return err + } + + hasInvalidField := false + o.AdvisoryId = all.AdvisoryId + if all.CodeLocation != nil && all.CodeLocation.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.CodeLocation = all.CodeLocation + o.CveList = *all.CveList + if all.Cvss.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Cvss = *all.Cvss + if all.DependencyLocations != nil && all.DependencyLocations.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.DependencyLocations = all.DependencyLocations + o.Description = *all.Description + if all.Ecosystem != nil && !all.Ecosystem.IsValid() { + hasInvalidField = true + } else { + o.Ecosystem = all.Ecosystem + } + o.ExposureTime = *all.ExposureTime + o.FirstDetection = *all.FirstDetection + o.FixAvailable = *all.FixAvailable + o.Language = *all.Language + o.LastDetection = *all.LastDetection + if all.Library != nil && all.Library.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Library = all.Library + o.Remediations = *all.Remediations + o.RepoDigests = all.RepoDigests + if all.Risks.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Risks = *all.Risks + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + o.Title = *all.Title + if !all.Tool.IsValid() { + hasInvalidField = true + } else { + o.Tool = *all.Tool + } + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_vulnerability_attributes_cvss.go b/api/datadogV2/model_vulnerability_attributes_cvss.go new file mode 100644 index 00000000000..108a6fd56f4 --- /dev/null +++ b/api/datadogV2/model_vulnerability_attributes_cvss.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityAttributesCvss Vulnerability severities. +type VulnerabilityAttributesCvss struct { + // Vulnerability severity. + Base CVSS `json:"base"` + // Vulnerability severity. + Datadog CVSS `json:"datadog"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVulnerabilityAttributesCvss instantiates a new VulnerabilityAttributesCvss object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVulnerabilityAttributesCvss(base CVSS, datadog CVSS) *VulnerabilityAttributesCvss { + this := VulnerabilityAttributesCvss{} + this.Base = base + this.Datadog = datadog + return &this +} + +// NewVulnerabilityAttributesCvssWithDefaults instantiates a new VulnerabilityAttributesCvss object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVulnerabilityAttributesCvssWithDefaults() *VulnerabilityAttributesCvss { + this := VulnerabilityAttributesCvss{} + return &this +} + +// GetBase returns the Base field value. +func (o *VulnerabilityAttributesCvss) GetBase() CVSS { + if o == nil { + var ret CVSS + return ret + } + return o.Base +} + +// GetBaseOk returns a tuple with the Base field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributesCvss) GetBaseOk() (*CVSS, bool) { + if o == nil { + return nil, false + } + return &o.Base, true +} + +// SetBase sets field value. +func (o *VulnerabilityAttributesCvss) SetBase(v CVSS) { + o.Base = v +} + +// GetDatadog returns the Datadog field value. +func (o *VulnerabilityAttributesCvss) GetDatadog() CVSS { + if o == nil { + var ret CVSS + return ret + } + return o.Datadog +} + +// GetDatadogOk returns a tuple with the Datadog field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributesCvss) GetDatadogOk() (*CVSS, bool) { + if o == nil { + return nil, false + } + return &o.Datadog, true +} + +// SetDatadog sets field value. +func (o *VulnerabilityAttributesCvss) SetDatadog(v CVSS) { + o.Datadog = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VulnerabilityAttributesCvss) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["base"] = o.Base + toSerialize["datadog"] = o.Datadog + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VulnerabilityAttributesCvss) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Base *CVSS `json:"base"` + Datadog *CVSS `json:"datadog"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Base == nil { + return fmt.Errorf("required field base missing") + } + if all.Datadog == nil { + return fmt.Errorf("required field datadog missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"base", "datadog"}) + } else { + return err + } + + hasInvalidField := false + if all.Base.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Base = *all.Base + if all.Datadog.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Datadog = *all.Datadog + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_vulnerability_attributes_dependency_locations.go b/api/datadogV2/model_vulnerability_attributes_dependency_locations.go new file mode 100644 index 00000000000..faf51f26c26 --- /dev/null +++ b/api/datadogV2/model_vulnerability_attributes_dependency_locations.go @@ -0,0 +1,186 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityAttributesDependencyLocations Static library vulnerability location. +type VulnerabilityAttributesDependencyLocations struct { + // Static library vulnerability location. + Block DependencyLocation `json:"block"` + // Static library vulnerability location. + Name *DependencyLocation `json:"name,omitempty"` + // Static library vulnerability location. + Version *DependencyLocation `json:"version,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVulnerabilityAttributesDependencyLocations instantiates a new VulnerabilityAttributesDependencyLocations object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVulnerabilityAttributesDependencyLocations(block DependencyLocation) *VulnerabilityAttributesDependencyLocations { + this := VulnerabilityAttributesDependencyLocations{} + this.Block = block + return &this +} + +// NewVulnerabilityAttributesDependencyLocationsWithDefaults instantiates a new VulnerabilityAttributesDependencyLocations object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVulnerabilityAttributesDependencyLocationsWithDefaults() *VulnerabilityAttributesDependencyLocations { + this := VulnerabilityAttributesDependencyLocations{} + return &this +} + +// GetBlock returns the Block field value. +func (o *VulnerabilityAttributesDependencyLocations) GetBlock() DependencyLocation { + if o == nil { + var ret DependencyLocation + return ret + } + return o.Block +} + +// GetBlockOk returns a tuple with the Block field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributesDependencyLocations) GetBlockOk() (*DependencyLocation, bool) { + if o == nil { + return nil, false + } + return &o.Block, true +} + +// SetBlock sets field value. +func (o *VulnerabilityAttributesDependencyLocations) SetBlock(v DependencyLocation) { + o.Block = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *VulnerabilityAttributesDependencyLocations) GetName() DependencyLocation { + if o == nil || o.Name == nil { + var ret DependencyLocation + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributesDependencyLocations) GetNameOk() (*DependencyLocation, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *VulnerabilityAttributesDependencyLocations) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given DependencyLocation and assigns it to the Name field. +func (o *VulnerabilityAttributesDependencyLocations) SetName(v DependencyLocation) { + o.Name = &v +} + +// GetVersion returns the Version field value if set, zero value otherwise. +func (o *VulnerabilityAttributesDependencyLocations) GetVersion() DependencyLocation { + if o == nil || o.Version == nil { + var ret DependencyLocation + return ret + } + return *o.Version +} + +// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityAttributesDependencyLocations) GetVersionOk() (*DependencyLocation, bool) { + if o == nil || o.Version == nil { + return nil, false + } + return o.Version, true +} + +// HasVersion returns a boolean if a field has been set. +func (o *VulnerabilityAttributesDependencyLocations) HasVersion() bool { + return o != nil && o.Version != nil +} + +// SetVersion gets a reference to the given DependencyLocation and assigns it to the Version field. +func (o *VulnerabilityAttributesDependencyLocations) SetVersion(v DependencyLocation) { + o.Version = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VulnerabilityAttributesDependencyLocations) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["block"] = o.Block + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Version != nil { + toSerialize["version"] = o.Version + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VulnerabilityAttributesDependencyLocations) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Block *DependencyLocation `json:"block"` + Name *DependencyLocation `json:"name,omitempty"` + Version *DependencyLocation `json:"version,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Block == nil { + return fmt.Errorf("required field block missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"block", "name", "version"}) + } else { + return err + } + + hasInvalidField := false + if all.Block.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Block = *all.Block + if all.Name != nil && all.Name.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Name = all.Name + if all.Version != nil && all.Version.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Version = all.Version + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_vulnerability_ecosystem.go b/api/datadogV2/model_vulnerability_ecosystem.go new file mode 100644 index 00000000000..5505a9d7691 --- /dev/null +++ b/api/datadogV2/model_vulnerability_ecosystem.go @@ -0,0 +1,84 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityEcosystem The related vulnerability asset ecosystem. +type VulnerabilityEcosystem string + +// List of VulnerabilityEcosystem. +const ( + VULNERABILITYECOSYSTEM_PYPI VulnerabilityEcosystem = "PyPI" + VULNERABILITYECOSYSTEM_MAVEN VulnerabilityEcosystem = "Maven" + VULNERABILITYECOSYSTEM_NUGET VulnerabilityEcosystem = "NuGet" + VULNERABILITYECOSYSTEM_NPM VulnerabilityEcosystem = "Npm" + VULNERABILITYECOSYSTEM_RUBY_GEMS VulnerabilityEcosystem = "RubyGems" + VULNERABILITYECOSYSTEM_GO VulnerabilityEcosystem = "Go" + VULNERABILITYECOSYSTEM_PACKAGIST VulnerabilityEcosystem = "Packagist" + VULNERABILITYECOSYSTEM_D_DEB VulnerabilityEcosystem = "Ddeb" + VULNERABILITYECOSYSTEM_RPM VulnerabilityEcosystem = "Rpm" + VULNERABILITYECOSYSTEM_APK VulnerabilityEcosystem = "Apk" + VULNERABILITYECOSYSTEM_WINDOWS VulnerabilityEcosystem = "Windows" +) + +var allowedVulnerabilityEcosystemEnumValues = []VulnerabilityEcosystem{ + VULNERABILITYECOSYSTEM_PYPI, + VULNERABILITYECOSYSTEM_MAVEN, + VULNERABILITYECOSYSTEM_NUGET, + VULNERABILITYECOSYSTEM_NPM, + VULNERABILITYECOSYSTEM_RUBY_GEMS, + VULNERABILITYECOSYSTEM_GO, + VULNERABILITYECOSYSTEM_PACKAGIST, + VULNERABILITYECOSYSTEM_D_DEB, + VULNERABILITYECOSYSTEM_RPM, + VULNERABILITYECOSYSTEM_APK, + VULNERABILITYECOSYSTEM_WINDOWS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *VulnerabilityEcosystem) GetAllowedValues() []VulnerabilityEcosystem { + return allowedVulnerabilityEcosystemEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *VulnerabilityEcosystem) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = VulnerabilityEcosystem(value) + return nil +} + +// NewVulnerabilityEcosystemFromValue returns a pointer to a valid VulnerabilityEcosystem +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewVulnerabilityEcosystemFromValue(v string) (*VulnerabilityEcosystem, error) { + ev := VulnerabilityEcosystem(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for VulnerabilityEcosystem: valid values are %v", v, allowedVulnerabilityEcosystemEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v VulnerabilityEcosystem) IsValid() bool { + for _, existing := range allowedVulnerabilityEcosystemEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to VulnerabilityEcosystem value. +func (v VulnerabilityEcosystem) Ptr() *VulnerabilityEcosystem { + return &v +} diff --git a/api/datadogV2/model_vulnerability_relationships.go b/api/datadogV2/model_vulnerability_relationships.go new file mode 100644 index 00000000000..022650535c8 --- /dev/null +++ b/api/datadogV2/model_vulnerability_relationships.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityRelationships Related entities object. +type VulnerabilityRelationships struct { + // Relationship type. + Affects VulnerabilityRelationshipsAffects `json:"affects"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVulnerabilityRelationships instantiates a new VulnerabilityRelationships object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVulnerabilityRelationships(affects VulnerabilityRelationshipsAffects) *VulnerabilityRelationships { + this := VulnerabilityRelationships{} + this.Affects = affects + return &this +} + +// NewVulnerabilityRelationshipsWithDefaults instantiates a new VulnerabilityRelationships object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVulnerabilityRelationshipsWithDefaults() *VulnerabilityRelationships { + this := VulnerabilityRelationships{} + return &this +} + +// GetAffects returns the Affects field value. +func (o *VulnerabilityRelationships) GetAffects() VulnerabilityRelationshipsAffects { + if o == nil { + var ret VulnerabilityRelationshipsAffects + return ret + } + return o.Affects +} + +// GetAffectsOk returns a tuple with the Affects field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityRelationships) GetAffectsOk() (*VulnerabilityRelationshipsAffects, bool) { + if o == nil { + return nil, false + } + return &o.Affects, true +} + +// SetAffects sets field value. +func (o *VulnerabilityRelationships) SetAffects(v VulnerabilityRelationshipsAffects) { + o.Affects = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VulnerabilityRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["affects"] = o.Affects + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VulnerabilityRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Affects *VulnerabilityRelationshipsAffects `json:"affects"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Affects == nil { + return fmt.Errorf("required field affects missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"affects"}) + } else { + return err + } + + hasInvalidField := false + if all.Affects.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Affects = *all.Affects + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_vulnerability_relationships_affects.go b/api/datadogV2/model_vulnerability_relationships_affects.go new file mode 100644 index 00000000000..40871adb10e --- /dev/null +++ b/api/datadogV2/model_vulnerability_relationships_affects.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityRelationshipsAffects Relationship type. +type VulnerabilityRelationshipsAffects struct { + // Asset affected by this vulnerability. + Data VulnerabilityRelationshipsAffectsData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVulnerabilityRelationshipsAffects instantiates a new VulnerabilityRelationshipsAffects object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVulnerabilityRelationshipsAffects(data VulnerabilityRelationshipsAffectsData) *VulnerabilityRelationshipsAffects { + this := VulnerabilityRelationshipsAffects{} + this.Data = data + return &this +} + +// NewVulnerabilityRelationshipsAffectsWithDefaults instantiates a new VulnerabilityRelationshipsAffects object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVulnerabilityRelationshipsAffectsWithDefaults() *VulnerabilityRelationshipsAffects { + this := VulnerabilityRelationshipsAffects{} + return &this +} + +// GetData returns the Data field value. +func (o *VulnerabilityRelationshipsAffects) GetData() VulnerabilityRelationshipsAffectsData { + if o == nil { + var ret VulnerabilityRelationshipsAffectsData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityRelationshipsAffects) GetDataOk() (*VulnerabilityRelationshipsAffectsData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *VulnerabilityRelationshipsAffects) SetData(v VulnerabilityRelationshipsAffectsData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VulnerabilityRelationshipsAffects) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VulnerabilityRelationshipsAffects) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *VulnerabilityRelationshipsAffectsData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_vulnerability_relationships_affects_data.go b/api/datadogV2/model_vulnerability_relationships_affects_data.go new file mode 100644 index 00000000000..e60be166565 --- /dev/null +++ b/api/datadogV2/model_vulnerability_relationships_affects_data.go @@ -0,0 +1,143 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityRelationshipsAffectsData Asset affected by this vulnerability. +type VulnerabilityRelationshipsAffectsData struct { + // The unique ID for this related asset. + Id string `json:"id"` + // The JSON:API type. + Type AssetEntityType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVulnerabilityRelationshipsAffectsData instantiates a new VulnerabilityRelationshipsAffectsData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVulnerabilityRelationshipsAffectsData(id string, typeVar AssetEntityType) *VulnerabilityRelationshipsAffectsData { + this := VulnerabilityRelationshipsAffectsData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewVulnerabilityRelationshipsAffectsDataWithDefaults instantiates a new VulnerabilityRelationshipsAffectsData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVulnerabilityRelationshipsAffectsDataWithDefaults() *VulnerabilityRelationshipsAffectsData { + this := VulnerabilityRelationshipsAffectsData{} + return &this +} + +// GetId returns the Id field value. +func (o *VulnerabilityRelationshipsAffectsData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityRelationshipsAffectsData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *VulnerabilityRelationshipsAffectsData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *VulnerabilityRelationshipsAffectsData) GetType() AssetEntityType { + if o == nil { + var ret AssetEntityType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityRelationshipsAffectsData) GetTypeOk() (*AssetEntityType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *VulnerabilityRelationshipsAffectsData) SetType(v AssetEntityType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VulnerabilityRelationshipsAffectsData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VulnerabilityRelationshipsAffectsData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *AssetEntityType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_vulnerability_risks.go b/api/datadogV2/model_vulnerability_risks.go new file mode 100644 index 00000000000..8b7f881b04d --- /dev/null +++ b/api/datadogV2/model_vulnerability_risks.go @@ -0,0 +1,241 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityRisks Vulnerability risks. +type VulnerabilityRisks struct { + // Vulnerability EPSS severity. + Epss *EPSS `json:"epss,omitempty"` + // Vulnerability public exploit availability. + ExploitAvailable bool `json:"exploit_available"` + // Vulnerability exploit sources. + ExploitSources []string `json:"exploit_sources"` + // Vulnerability exploitation probability. + ExploitationProbability bool `json:"exploitation_probability"` + // Vulnerability POC exploit availability. + PocExploitAvailable bool `json:"poc_exploit_available"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewVulnerabilityRisks instantiates a new VulnerabilityRisks object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewVulnerabilityRisks(exploitAvailable bool, exploitSources []string, exploitationProbability bool, pocExploitAvailable bool) *VulnerabilityRisks { + this := VulnerabilityRisks{} + this.ExploitAvailable = exploitAvailable + this.ExploitSources = exploitSources + this.ExploitationProbability = exploitationProbability + this.PocExploitAvailable = pocExploitAvailable + return &this +} + +// NewVulnerabilityRisksWithDefaults instantiates a new VulnerabilityRisks object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewVulnerabilityRisksWithDefaults() *VulnerabilityRisks { + this := VulnerabilityRisks{} + return &this +} + +// GetEpss returns the Epss field value if set, zero value otherwise. +func (o *VulnerabilityRisks) GetEpss() EPSS { + if o == nil || o.Epss == nil { + var ret EPSS + return ret + } + return *o.Epss +} + +// GetEpssOk returns a tuple with the Epss field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *VulnerabilityRisks) GetEpssOk() (*EPSS, bool) { + if o == nil || o.Epss == nil { + return nil, false + } + return o.Epss, true +} + +// HasEpss returns a boolean if a field has been set. +func (o *VulnerabilityRisks) HasEpss() bool { + return o != nil && o.Epss != nil +} + +// SetEpss gets a reference to the given EPSS and assigns it to the Epss field. +func (o *VulnerabilityRisks) SetEpss(v EPSS) { + o.Epss = &v +} + +// GetExploitAvailable returns the ExploitAvailable field value. +func (o *VulnerabilityRisks) GetExploitAvailable() bool { + if o == nil { + var ret bool + return ret + } + return o.ExploitAvailable +} + +// GetExploitAvailableOk returns a tuple with the ExploitAvailable field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityRisks) GetExploitAvailableOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.ExploitAvailable, true +} + +// SetExploitAvailable sets field value. +func (o *VulnerabilityRisks) SetExploitAvailable(v bool) { + o.ExploitAvailable = v +} + +// GetExploitSources returns the ExploitSources field value. +func (o *VulnerabilityRisks) GetExploitSources() []string { + if o == nil { + var ret []string + return ret + } + return o.ExploitSources +} + +// GetExploitSourcesOk returns a tuple with the ExploitSources field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityRisks) GetExploitSourcesOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.ExploitSources, true +} + +// SetExploitSources sets field value. +func (o *VulnerabilityRisks) SetExploitSources(v []string) { + o.ExploitSources = v +} + +// GetExploitationProbability returns the ExploitationProbability field value. +func (o *VulnerabilityRisks) GetExploitationProbability() bool { + if o == nil { + var ret bool + return ret + } + return o.ExploitationProbability +} + +// GetExploitationProbabilityOk returns a tuple with the ExploitationProbability field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityRisks) GetExploitationProbabilityOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.ExploitationProbability, true +} + +// SetExploitationProbability sets field value. +func (o *VulnerabilityRisks) SetExploitationProbability(v bool) { + o.ExploitationProbability = v +} + +// GetPocExploitAvailable returns the PocExploitAvailable field value. +func (o *VulnerabilityRisks) GetPocExploitAvailable() bool { + if o == nil { + var ret bool + return ret + } + return o.PocExploitAvailable +} + +// GetPocExploitAvailableOk returns a tuple with the PocExploitAvailable field value +// and a boolean to check if the value has been set. +func (o *VulnerabilityRisks) GetPocExploitAvailableOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.PocExploitAvailable, true +} + +// SetPocExploitAvailable sets field value. +func (o *VulnerabilityRisks) SetPocExploitAvailable(v bool) { + o.PocExploitAvailable = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o VulnerabilityRisks) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Epss != nil { + toSerialize["epss"] = o.Epss + } + toSerialize["exploit_available"] = o.ExploitAvailable + toSerialize["exploit_sources"] = o.ExploitSources + toSerialize["exploitation_probability"] = o.ExploitationProbability + toSerialize["poc_exploit_available"] = o.PocExploitAvailable + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *VulnerabilityRisks) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Epss *EPSS `json:"epss,omitempty"` + ExploitAvailable *bool `json:"exploit_available"` + ExploitSources *[]string `json:"exploit_sources"` + ExploitationProbability *bool `json:"exploitation_probability"` + PocExploitAvailable *bool `json:"poc_exploit_available"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ExploitAvailable == nil { + return fmt.Errorf("required field exploit_available missing") + } + if all.ExploitSources == nil { + return fmt.Errorf("required field exploit_sources missing") + } + if all.ExploitationProbability == nil { + return fmt.Errorf("required field exploitation_probability missing") + } + if all.PocExploitAvailable == nil { + return fmt.Errorf("required field poc_exploit_available missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"epss", "exploit_available", "exploit_sources", "exploitation_probability", "poc_exploit_available"}) + } else { + return err + } + + hasInvalidField := false + if all.Epss != nil && all.Epss.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Epss = all.Epss + o.ExploitAvailable = *all.ExploitAvailable + o.ExploitSources = *all.ExploitSources + o.ExploitationProbability = *all.ExploitationProbability + o.PocExploitAvailable = *all.PocExploitAvailable + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_vulnerability_severity.go b/api/datadogV2/model_vulnerability_severity.go new file mode 100644 index 00000000000..d83d361ab9c --- /dev/null +++ b/api/datadogV2/model_vulnerability_severity.go @@ -0,0 +1,74 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilitySeverity The vulnerability severity. +type VulnerabilitySeverity string + +// List of VulnerabilitySeverity. +const ( + VULNERABILITYSEVERITY_UNKNOWN VulnerabilitySeverity = "Unknown" + VULNERABILITYSEVERITY_NONE VulnerabilitySeverity = "None" + VULNERABILITYSEVERITY_LOW VulnerabilitySeverity = "Low" + VULNERABILITYSEVERITY_MEDIUM VulnerabilitySeverity = "Medium" + VULNERABILITYSEVERITY_HIGH VulnerabilitySeverity = "High" + VULNERABILITYSEVERITY_CRITICAL VulnerabilitySeverity = "Critical" +) + +var allowedVulnerabilitySeverityEnumValues = []VulnerabilitySeverity{ + VULNERABILITYSEVERITY_UNKNOWN, + VULNERABILITYSEVERITY_NONE, + VULNERABILITYSEVERITY_LOW, + VULNERABILITYSEVERITY_MEDIUM, + VULNERABILITYSEVERITY_HIGH, + VULNERABILITYSEVERITY_CRITICAL, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *VulnerabilitySeverity) GetAllowedValues() []VulnerabilitySeverity { + return allowedVulnerabilitySeverityEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *VulnerabilitySeverity) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = VulnerabilitySeverity(value) + return nil +} + +// NewVulnerabilitySeverityFromValue returns a pointer to a valid VulnerabilitySeverity +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewVulnerabilitySeverityFromValue(v string) (*VulnerabilitySeverity, error) { + ev := VulnerabilitySeverity(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for VulnerabilitySeverity: valid values are %v", v, allowedVulnerabilitySeverityEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v VulnerabilitySeverity) IsValid() bool { + for _, existing := range allowedVulnerabilitySeverityEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to VulnerabilitySeverity value. +func (v VulnerabilitySeverity) Ptr() *VulnerabilitySeverity { + return &v +} diff --git a/api/datadogV2/model_vulnerability_status.go b/api/datadogV2/model_vulnerability_status.go new file mode 100644 index 00000000000..75e50700506 --- /dev/null +++ b/api/datadogV2/model_vulnerability_status.go @@ -0,0 +1,72 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityStatus The vulnerability status. +type VulnerabilityStatus string + +// List of VulnerabilityStatus. +const ( + VULNERABILITYSTATUS_OPEN VulnerabilityStatus = "Open" + VULNERABILITYSTATUS_MUTED VulnerabilityStatus = "Muted" + VULNERABILITYSTATUS_REMEDIATED VulnerabilityStatus = "Remediated" + VULNERABILITYSTATUS_INPROGRESS VulnerabilityStatus = "InProgress" + VULNERABILITYSTATUS_AUTOCLOSED VulnerabilityStatus = "AutoClosed" +) + +var allowedVulnerabilityStatusEnumValues = []VulnerabilityStatus{ + VULNERABILITYSTATUS_OPEN, + VULNERABILITYSTATUS_MUTED, + VULNERABILITYSTATUS_REMEDIATED, + VULNERABILITYSTATUS_INPROGRESS, + VULNERABILITYSTATUS_AUTOCLOSED, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *VulnerabilityStatus) GetAllowedValues() []VulnerabilityStatus { + return allowedVulnerabilityStatusEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *VulnerabilityStatus) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = VulnerabilityStatus(value) + return nil +} + +// NewVulnerabilityStatusFromValue returns a pointer to a valid VulnerabilityStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewVulnerabilityStatusFromValue(v string) (*VulnerabilityStatus, error) { + ev := VulnerabilityStatus(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for VulnerabilityStatus: valid values are %v", v, allowedVulnerabilityStatusEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v VulnerabilityStatus) IsValid() bool { + for _, existing := range allowedVulnerabilityStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to VulnerabilityStatus value. +func (v VulnerabilityStatus) Ptr() *VulnerabilityStatus { + return &v +} diff --git a/api/datadogV2/model_vulnerability_tool.go b/api/datadogV2/model_vulnerability_tool.go new file mode 100644 index 00000000000..7c46c59c888 --- /dev/null +++ b/api/datadogV2/model_vulnerability_tool.go @@ -0,0 +1,68 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityTool The vulnerability tool. +type VulnerabilityTool string + +// List of VulnerabilityTool. +const ( + VULNERABILITYTOOL_IAST VulnerabilityTool = "IAST" + VULNERABILITYTOOL_SCA VulnerabilityTool = "SCA" + VULNERABILITYTOOL_INFRA VulnerabilityTool = "Infra" +) + +var allowedVulnerabilityToolEnumValues = []VulnerabilityTool{ + VULNERABILITYTOOL_IAST, + VULNERABILITYTOOL_SCA, + VULNERABILITYTOOL_INFRA, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *VulnerabilityTool) GetAllowedValues() []VulnerabilityTool { + return allowedVulnerabilityToolEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *VulnerabilityTool) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = VulnerabilityTool(value) + return nil +} + +// NewVulnerabilityToolFromValue returns a pointer to a valid VulnerabilityTool +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewVulnerabilityToolFromValue(v string) (*VulnerabilityTool, error) { + ev := VulnerabilityTool(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for VulnerabilityTool: valid values are %v", v, allowedVulnerabilityToolEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v VulnerabilityTool) IsValid() bool { + for _, existing := range allowedVulnerabilityToolEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to VulnerabilityTool value. +func (v VulnerabilityTool) Ptr() *VulnerabilityTool { + return &v +} diff --git a/api/datadogV2/model_vulnerability_type.go b/api/datadogV2/model_vulnerability_type.go new file mode 100644 index 00000000000..bf87461f3ef --- /dev/null +++ b/api/datadogV2/model_vulnerability_type.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// VulnerabilityType The vulnerability type. +type VulnerabilityType string + +// List of VulnerabilityType. +const ( + VULNERABILITYTYPE_ADMIN_CONSOLE_ACTIVE VulnerabilityType = "AdminConsoleActive" + VULNERABILITYTYPE_CODE_INJECTION VulnerabilityType = "CodeInjection" + VULNERABILITYTYPE_COMMAND_INJECTION VulnerabilityType = "CommandInjection" + VULNERABILITYTYPE_COMPONENT_WITH_KNOWN_VULNERABILITY VulnerabilityType = "ComponentWithKnownVulnerability" + VULNERABILITYTYPE_DANGEROUS_WORKFLOWS VulnerabilityType = "DangerousWorkflows" + VULNERABILITYTYPE_DEFAULT_APP_DEPLOYED VulnerabilityType = "DefaultAppDeployed" + VULNERABILITYTYPE_DEFAULT_HTML_ESCAPE_INVALID VulnerabilityType = "DefaultHtmlEscapeInvalid" + VULNERABILITYTYPE_DIRECTORY_LISTING_LEAK VulnerabilityType = "DirectoryListingLeak" + VULNERABILITYTYPE_EMAIL_HTML_INJECTION VulnerabilityType = "EmailHtmlInjection" + VULNERABILITYTYPE_END_OF_LIFE VulnerabilityType = "EndOfLife" + VULNERABILITYTYPE_HARDCODED_PASSWORD VulnerabilityType = "HardcodedPassword" + VULNERABILITYTYPE_HARDCODED_SECRET VulnerabilityType = "HardcodedSecret" + VULNERABILITYTYPE_HEADER_INJECTION VulnerabilityType = "HeaderInjection" + VULNERABILITYTYPE_HSTS_HEADER_MISSING VulnerabilityType = "HstsHeaderMissing" + VULNERABILITYTYPE_INSECURE_AUTH_PROTOCOL VulnerabilityType = "InsecureAuthProtocol" + VULNERABILITYTYPE_INSECURE_COOKIE VulnerabilityType = "InsecureCookie" + VULNERABILITYTYPE_INSECURE_JSP_LAYOUT VulnerabilityType = "InsecureJspLayout" + VULNERABILITYTYPE_LDAP_INJECTION VulnerabilityType = "LdapInjection" + VULNERABILITYTYPE_MALICIOUS_PACKAGE VulnerabilityType = "MaliciousPackage" + VULNERABILITYTYPE_MANDATORY_REMEDIATION VulnerabilityType = "MandatoryRemediation" + VULNERABILITYTYPE_NO_HTTP_ONLY_COOKIE VulnerabilityType = "NoHttpOnlyCookie" + VULNERABILITYTYPE_NO_SAME_SITE_COOKIE VulnerabilityType = "NoSameSiteCookie" + VULNERABILITYTYPE_NO_SQL_MONGO_DB_INJECTION VulnerabilityType = "NoSqlMongoDbInjection" + VULNERABILITYTYPE_PATH_TRAVERSAL VulnerabilityType = "PathTraversal" + VULNERABILITYTYPE_REFLECTION_INJECTION VulnerabilityType = "ReflectionInjection" + VULNERABILITYTYPE_RISKY_LICENSE VulnerabilityType = "RiskyLicense" + VULNERABILITYTYPE_SESSION_REWRITING VulnerabilityType = "SessionRewriting" + VULNERABILITYTYPE_SESSION_TIMEOUT VulnerabilityType = "SessionTimeout" + VULNERABILITYTYPE_SQL_INJECTION VulnerabilityType = "SqlInjection" + VULNERABILITYTYPE_SSRF VulnerabilityType = "Ssrf" + VULNERABILITYTYPE_STACK_TRACE_LEAK VulnerabilityType = "StackTraceLeak" + VULNERABILITYTYPE_TRUST_BOUNDARY_VIOLATION VulnerabilityType = "TrustBoundaryViolation" + VULNERABILITYTYPE_UNMAINTAINED VulnerabilityType = "Unmaintained" + VULNERABILITYTYPE_UNTRUSTED_DESERIALIZATION VulnerabilityType = "UntrustedDeserialization" + VULNERABILITYTYPE_UNVALIDATED_REDIRECT VulnerabilityType = "UnvalidatedRedirect" + VULNERABILITYTYPE_VERB_TAMPERING VulnerabilityType = "VerbTampering" + VULNERABILITYTYPE_WEAK_CIPHER VulnerabilityType = "WeakCipher" + VULNERABILITYTYPE_WEAK_HASH VulnerabilityType = "WeakHash" + VULNERABILITYTYPE_WEAK_RANDOMNESS VulnerabilityType = "WeakRandomness" + VULNERABILITYTYPE_X_CONTENT_TYPE_HEADER_MISSING VulnerabilityType = "XContentTypeHeaderMissing" + VULNERABILITYTYPE_X_PATH_INJECTION VulnerabilityType = "XPathInjection" + VULNERABILITYTYPE_XSS VulnerabilityType = "Xss" +) + +var allowedVulnerabilityTypeEnumValues = []VulnerabilityType{ + VULNERABILITYTYPE_ADMIN_CONSOLE_ACTIVE, + VULNERABILITYTYPE_CODE_INJECTION, + VULNERABILITYTYPE_COMMAND_INJECTION, + VULNERABILITYTYPE_COMPONENT_WITH_KNOWN_VULNERABILITY, + VULNERABILITYTYPE_DANGEROUS_WORKFLOWS, + VULNERABILITYTYPE_DEFAULT_APP_DEPLOYED, + VULNERABILITYTYPE_DEFAULT_HTML_ESCAPE_INVALID, + VULNERABILITYTYPE_DIRECTORY_LISTING_LEAK, + VULNERABILITYTYPE_EMAIL_HTML_INJECTION, + VULNERABILITYTYPE_END_OF_LIFE, + VULNERABILITYTYPE_HARDCODED_PASSWORD, + VULNERABILITYTYPE_HARDCODED_SECRET, + VULNERABILITYTYPE_HEADER_INJECTION, + VULNERABILITYTYPE_HSTS_HEADER_MISSING, + VULNERABILITYTYPE_INSECURE_AUTH_PROTOCOL, + VULNERABILITYTYPE_INSECURE_COOKIE, + VULNERABILITYTYPE_INSECURE_JSP_LAYOUT, + VULNERABILITYTYPE_LDAP_INJECTION, + VULNERABILITYTYPE_MALICIOUS_PACKAGE, + VULNERABILITYTYPE_MANDATORY_REMEDIATION, + VULNERABILITYTYPE_NO_HTTP_ONLY_COOKIE, + VULNERABILITYTYPE_NO_SAME_SITE_COOKIE, + VULNERABILITYTYPE_NO_SQL_MONGO_DB_INJECTION, + VULNERABILITYTYPE_PATH_TRAVERSAL, + VULNERABILITYTYPE_REFLECTION_INJECTION, + VULNERABILITYTYPE_RISKY_LICENSE, + VULNERABILITYTYPE_SESSION_REWRITING, + VULNERABILITYTYPE_SESSION_TIMEOUT, + VULNERABILITYTYPE_SQL_INJECTION, + VULNERABILITYTYPE_SSRF, + VULNERABILITYTYPE_STACK_TRACE_LEAK, + VULNERABILITYTYPE_TRUST_BOUNDARY_VIOLATION, + VULNERABILITYTYPE_UNMAINTAINED, + VULNERABILITYTYPE_UNTRUSTED_DESERIALIZATION, + VULNERABILITYTYPE_UNVALIDATED_REDIRECT, + VULNERABILITYTYPE_VERB_TAMPERING, + VULNERABILITYTYPE_WEAK_CIPHER, + VULNERABILITYTYPE_WEAK_HASH, + VULNERABILITYTYPE_WEAK_RANDOMNESS, + VULNERABILITYTYPE_X_CONTENT_TYPE_HEADER_MISSING, + VULNERABILITYTYPE_X_PATH_INJECTION, + VULNERABILITYTYPE_XSS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *VulnerabilityType) GetAllowedValues() []VulnerabilityType { + return allowedVulnerabilityTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *VulnerabilityType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = VulnerabilityType(value) + return nil +} + +// NewVulnerabilityTypeFromValue returns a pointer to a valid VulnerabilityType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewVulnerabilityTypeFromValue(v string) (*VulnerabilityType, error) { + ev := VulnerabilityType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for VulnerabilityType: valid values are %v", v, allowedVulnerabilityTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v VulnerabilityType) IsValid() bool { + for _, existing := range allowedVulnerabilityTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to VulnerabilityType value. +func (v VulnerabilityType) Ptr() *VulnerabilityType { + return &v +} diff --git a/examples/v2/security-monitoring/ListVulnerabilities.go b/examples/v2/security-monitoring/ListVulnerabilities.go new file mode 100644 index 00000000000..24c3b9daa66 --- /dev/null +++ b/examples/v2/security-monitoring/ListVulnerabilities.go @@ -0,0 +1,30 @@ +// List vulnerabilities returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListVulnerabilities", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.ListVulnerabilities(ctx, *datadogV2.NewListVulnerabilitiesOptionalParameters().WithFilterCvssBaseSeverity(datadogV2.VULNERABILITYSEVERITY_HIGH).WithFilterAssetType(datadogV2.ASSETTYPE_SERVICE).WithFilterTool(datadogV2.VULNERABILITYTOOL_INFRA)) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.ListVulnerabilities`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.ListVulnerabilities`:\n%s\n", responseContent) +} diff --git a/examples/v2/security-monitoring/ListVulnerableAssets.go b/examples/v2/security-monitoring/ListVulnerableAssets.go new file mode 100644 index 00000000000..a4296e46572 --- /dev/null +++ b/examples/v2/security-monitoring/ListVulnerableAssets.go @@ -0,0 +1,30 @@ +// List vulnerable assets returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListVulnerableAssets", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + resp, r, err := api.ListVulnerableAssets(ctx, *datadogV2.NewListVulnerableAssetsOptionalParameters().WithFilterType(datadogV2.ASSETTYPE_HOST).WithFilterRepositoryUrl("github.com/datadog/dd-go").WithFilterRisksInProduction(true)) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.ListVulnerableAssets`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.ListVulnerableAssets`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.freeze new file mode 100644 index 00000000000..993ef8618f9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.freeze @@ -0,0 +1 @@ +2024-12-19T16:15:23.508Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.yaml new file mode 100644 index 00000000000..db251833798 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/security/vulnerabilities?page%5Btoken%5D=unknown&page%5Bnumber%5D=1 + response: + body: '{"errors":[{"status":"404","title":"Not Found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_OK_response.freeze new file mode 100644 index 00000000000..54fde8e3a79 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-12-19T16:15:24.088Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_OK_response.yaml new file mode 100644 index 00000000000..5acabc316ba --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerabilities_returns_OK_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/security/vulnerabilities?filter%5Bcvss.base.severity%5D=High&filter%5Basset.type%5D=Service&filter%5Btool%5D=Infra + response: + body: '{"data":[]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.freeze new file mode 100644 index 00000000000..920745b7e74 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.freeze @@ -0,0 +1 @@ +2024-12-19T16:15:24.530Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.yaml new file mode 100644 index 00000000000..c6dcfeeaef9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_Not_found_There_is_no_request_associated_with_the_provided_token._response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/security/assets?page%5Btoken%5D=unknown&page%5Bnumber%5D=1 + response: + body: '{"errors":[{"status":"404","title":"Not Found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_OK_response.freeze new file mode 100644 index 00000000000..8a2d3319405 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-12-19T16:15:24.699Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_OK_response.yaml new file mode 100644 index 00000000000..b7495b54258 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_List_vulnerable_assets_returns_OK_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/security/assets?filter%5Btype%5D=Host&filter%5Brepository_url%5D=github.com%2Fdatadog%2Fdd-go&filter%5Brisks.in_production%5D=true + response: + body: '{"data":[]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v2/security_monitoring.feature b/tests/scenarios/features/v2/security_monitoring.feature index a2d77f04939..1c3c32c5a85 100644 --- a/tests/scenarios/features/v2/security_monitoring.feature +++ b/tests/scenarios/features/v2/security_monitoring.feature @@ -638,6 +638,58 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @skip @team:DataDog/asm-vm + Scenario: List vulnerabilities returns "Bad request: The server cannot process the request due to invalid syntax in the request." response + Given operation "ListVulnerabilities" enabled + And new "ListVulnerabilities" request + When the request is sent + Then the response status is 400 Bad request: The server cannot process the request due to invalid syntax in the request. + + @team:DataDog/asm-vm + Scenario: List vulnerabilities returns "Not found: There is no request associated with the provided token." response + Given operation "ListVulnerabilities" enabled + And new "ListVulnerabilities" request + And request contains "page[token]" parameter with value "unknown" + And request contains "page[number]" parameter with value 1 + When the request is sent + Then the response status is 404 Not found: There is no request associated with the provided token. + + @team:DataDog/asm-vm + Scenario: List vulnerabilities returns "OK" response + Given operation "ListVulnerabilities" enabled + And new "ListVulnerabilities" request + And request contains "filter[cvss.base.severity]" parameter with value "High" + And request contains "filter[asset.type]" parameter with value "Service" + And request contains "filter[tool]" parameter with value "Infra" + When the request is sent + Then the response status is 200 OK + + @skip @team:DataDog/asm-vm + Scenario: List vulnerable assets returns "Bad request: The server cannot process the request due to invalid syntax in the request." response + Given operation "ListVulnerableAssets" enabled + And new "ListVulnerableAssets" request + When the request is sent + Then the response status is 400 Bad request: The server cannot process the request due to invalid syntax in the request. + + @team:DataDog/asm-vm + Scenario: List vulnerable assets returns "Not found: There is no request associated with the provided token." response + Given operation "ListVulnerableAssets" enabled + And new "ListVulnerableAssets" request + And request contains "page[token]" parameter with value "unknown" + And request contains "page[number]" parameter with value 1 + When the request is sent + Then the response status is 404 Not found: There is no request associated with the provided token. + + @team:DataDog/asm-vm + Scenario: List vulnerable assets returns "OK" response + Given operation "ListVulnerableAssets" enabled + And new "ListVulnerableAssets" request + And request contains "filter[type]" parameter with value "Host" + And request contains "filter[repository_url]" parameter with value "github.com/datadog/dd-go" + And request contains "filter[risks.in_production]" parameter with value true + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Modify the triage assignee of a security signal returns "Bad Request" response Given new "EditSecurityMonitoringSignalAssignee" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index b1ed2db693d..b54d9e43a45 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1994,12 +1994,24 @@ "type": "idempotent" } }, + "ListVulnerableAssets": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "DownloadCloudWorkloadPolicyFile": { "tag": "CSM Threats", "undo": { "type": "safe" } }, + "ListVulnerabilities": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListCloudWorkloadSecurityAgentRules": { "tag": "CSM Threats", "undo": {