diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 07cf64fab0e..2053789b98d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -17581,6 +17581,244 @@ components: required: - data type: object + CycloneDXAdvisory: + description: Advisory reference for a vulnerability. + properties: + url: + description: URL to the advisory. + example: https://example.com/advisory/CVE-2021-1234 + type: string + type: object + CycloneDXAffect: + description: Reference to a component affected by a vulnerability. + properties: + ref: + description: Reference to a component's bom-ref. + example: a3390fca-c315-41ae-ae05-af5e7859cdee + type: string + required: + - ref + type: object + CycloneDXAssetComponent: + description: The asset component represents the system or host being scanned. + properties: + bom-ref: + description: Optional reference to a component in the components list. + example: asset-ref-123 + type: string + name: + description: The name of the asset. + example: i-12345 + type: string + type: + description: The type of the asset component. + example: operating-system + type: string + required: + - name + type: object + CycloneDXBOM: + description: CycloneDX 1.5 Bill of Materials (BOM) for importing vulnerabilities. + properties: + bomFormat: + description: The format of the BOM. Must be "CycloneDX". + example: CycloneDX + type: string + components: + description: List of components (libraries, applications, or operating systems) + that are affected by vulnerabilities. + items: + $ref: '#/components/schemas/CycloneDXComponent' + type: array + metadata: + $ref: '#/components/schemas/CycloneDXMetadata' + specVersion: + description: The version of the CycloneDX specification. Must be "1.5". + example: '1.5' + type: string + version: + description: The version of the BOM. + example: 1 + format: int64 + type: integer + vulnerabilities: + description: List of vulnerabilities to be imported. + items: + $ref: '#/components/schemas/CycloneDXVulnerability' + type: array + required: + - bomFormat + - specVersion + - version + - metadata + - vulnerabilities + - components + type: object + CycloneDXComponent: + description: A component (library, application, or operating system) in the + BOM. + properties: + bom-ref: + description: Unique reference identifier for this component. + example: a3390fca-c315-41ae-ae05-af5e7859cdee + type: string + name: + description: The name of the component. + example: lodash + type: string + purl: + description: Package URL for the component. Required for library components. + example: pkg:npm/lodash@4.17.21 + type: string + type: + $ref: '#/components/schemas/CycloneDXComponentType' + version: + description: The version of the component. + example: 4.17.21 + type: string + required: + - bom-ref + - type + - name + - version + type: object + CycloneDXComponentType: + description: The type of the component. Supported types are library, application, + and operating-system. + enum: + - library + - application + - operating-system + example: library + type: string + x-enum-varnames: + - LIBRARY + - APPLICATION + - OPERATING_SYSTEM + CycloneDXMetadata: + description: Metadata for the CycloneDX BOM. + properties: + component: + $ref: '#/components/schemas/CycloneDXAssetComponent' + tools: + $ref: '#/components/schemas/CycloneDXTools' + required: + - component + - tools + type: object + CycloneDXRating: + description: Vulnerability rating information. + properties: + score: + description: The CVSS score. + example: 9.0 + format: double + type: number + severity: + description: The severity level. + example: high + type: string + vector: + description: The CVSS vector string. + example: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N + type: string + type: object + CycloneDXReference: + description: External reference for a vulnerability. + properties: + id: + description: Identifier of the reference. + example: GHSA-35m5-8cvj-8783 + type: string + source: + $ref: '#/components/schemas/CycloneDXReferenceSource' + type: object + CycloneDXReferenceSource: + description: Source information for a reference. + properties: + url: + description: URL to the source. + example: https://example.com + type: string + type: object + CycloneDXToolComponent: + description: Tool component that detected the vulnerabilities. + properties: + name: + description: The name of the tool. + example: my-scanner + type: string + type: + description: The type of the tool. + example: application + type: string + required: + - name + type: object + CycloneDXTools: + description: Tools used to generate the BOM. + properties: + components: + description: List of tool components. Only one tool is supported. + items: + $ref: '#/components/schemas/CycloneDXToolComponent' + maxItems: 1 + minItems: 1 + type: array + required: + - components + type: object + CycloneDXVulnerability: + description: A vulnerability in the CycloneDX BOM. + properties: + advisories: + description: List of advisory references. + items: + $ref: '#/components/schemas/CycloneDXAdvisory' + type: array + affects: + description: List of component references affected by this vulnerability. + items: + $ref: '#/components/schemas/CycloneDXAffect' + minItems: 1 + type: array + cwes: + description: List of CWE (Common Weakness Enumeration) identifiers. + example: + - 123 + - 345 + items: + type: integer + type: array + description: + description: Description of the vulnerability. + example: Sample vulnerability detected in the application. + type: string + detail: + description: Detailed information about the vulnerability. + example: Details about the vulnerability + type: string + id: + description: The unique identifier of the vulnerability (e.g., CVE ID). + example: CVE-2021-1234 + type: string + ratings: + description: List of vulnerability ratings. Must contain exactly one rating. + items: + $ref: '#/components/schemas/CycloneDXRating' + maxItems: 1 + minItems: 1 + type: array + references: + description: List of external references for the vulnerability. + items: + $ref: '#/components/schemas/CycloneDXReference' + type: array + required: + - id + - ratings + - affects + type: object DORACustomTags: description: A list of user-defined tags. The tags must follow the `key:value` pattern. Up to 100 may be added per event. @@ -53101,6 +53339,16 @@ components: meta: $ref: '#/components/schemas/SecurityFilterMeta' type: object + SecurityFindingType: + description: The type of security finding. + enum: + - vulnerability + - configuration_finding + example: vulnerability + type: string + x-enum-varnames: + - VULNERABILITY + - CONFIGURATION_FINDING SecurityFindingsAttributes: description: The JSON object containing all attributes of the security finding. properties: @@ -64143,6 +64391,18 @@ components: type: $ref: '#/components/schemas/ThreatHuntingJobDataType' type: object + ThreatIntelIndicatorType: + description: The type of threat indicator. + enum: + - ip_address + - domain + - sha256 + example: ip_address + type: string + x-enum-varnames: + - IP_ADDRESS + - DOMAIN + - SHA256 TimeAggregation: description: 'Time aggregation period (in seconds) is used to aggregate the results of the notification rule evaluation. @@ -93298,6 +93558,68 @@ paths: permissions: - security_monitoring_findings_read - appsec_vm_read + post: + description: 'Allows external integrations to send security findings to Datadog. + This endpoint accepts finding data in a custom format and returns an empty + response on success. + + + **Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + operationId: CreateSecurityFinding + parameters: + - description: The vendor providing the security finding. Must be lowercase. + example: vendor-name + in: header + name: vendor + required: true + schema: + type: string + - description: The type of security finding. + in: header + name: finding_type + required: true + schema: + $ref: '#/components/schemas/SecurityFindingType' + requestBody: + content: + application/json: + schema: + additionalProperties: {} + description: Security finding data in a custom format. + type: object + required: true + responses: + '200': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create security finding + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_findings_write + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/security/findings/cases: delete: description: 'Detach security findings from their case. @@ -94050,6 +94372,92 @@ paths: operator: OR permissions: - security_monitoring_notification_profiles_write + /api/v2/security/threat-intel-feed: + post: + description: 'Import threat intelligence feeds with support for IP addresses, + domains, and SHA256 hashes. This endpoint requires specific headers to identify + the vendor and indicator type. + + + **Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + operationId: ImportThreatIntel + parameters: + - description: The vendor providing the threat intelligence feed. + example: vendor-name + in: header + name: ti_vendor + required: true + schema: + type: string + - description: The type of threat indicator. Valid values are ip_address, domain, + or sha256. + in: header + name: ti_indicator + required: true + schema: + $ref: '#/components/schemas/ThreatIntelIndicatorType' + - description: Optional integration account identifier. + in: header + name: ti_integration_account + required: false + schema: + type: string + requestBody: + content: + application/json: + schema: + description: Threat intelligence feed data. + type: object + application/octet-stream: + schema: + description: Threat intelligence feed data in binary format. + format: binary + type: string + required: true + responses: + '200': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Internal Server Error + '503': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Service Unavailable + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Import threat intelligence feed + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - reference_tables_write + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/security/vulnerabilities: get: description: "Get a list of vulnerabilities.\n\n### Pagination\n\nPagination @@ -94463,6 +94871,58 @@ paths: x-unstable: '**Note**: This endpoint is a private preview. If you are interested in accessing this API, [fill out this form](https://forms.gle/kMYC1sDr6WDUBDsx9).' + post: + description: 'Import vulnerabilities in CycloneDX 1.5 format. This endpoint + validates the payload against the CycloneDX 1.5 schema and additional mandatory + field requirements. + + + **Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + operationId: ImportSecurityVulnerabilities + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CycloneDXBOM' + required: true + responses: + '200': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Import vulnerabilities + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_findings_write + x-unstable: '**Note**: This endpoint is in preview and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/security/vulnerabilities/notification_rules: get: description: Returns the list of notification rules for security vulnerabilities. diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 0bd8d7bc78e..eac9307399f 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -682,6 +682,7 @@ func NewConfiguration() *Configuration { "v2.ActivateContentPack": false, "v2.CancelThreatHuntingJob": false, "v2.ConvertJobResultToSignal": false, + "v2.CreateSecurityFinding": false, "v2.DeactivateContentPack": false, "v2.DeleteThreatHuntingJob": false, "v2.GetContentPacksStates": false, @@ -691,6 +692,8 @@ func NewConfiguration() *Configuration { "v2.GetSecurityMonitoringHistsignal": false, "v2.GetSecurityMonitoringHistsignalsByJobId": false, "v2.GetThreatHuntingJob": false, + "v2.ImportSecurityVulnerabilities": false, + "v2.ImportThreatIntel": false, "v2.ListFindings": false, "v2.ListMultipleRulesets": false, "v2.ListScannedAssetsMetadata": false, diff --git a/api/datadogV2/api_security_monitoring.go b/api/datadogV2/api_security_monitoring.go index 9fadf2d7bd8..26285284011 100644 --- a/api/datadogV2/api_security_monitoring.go +++ b/api/datadogV2/api_security_monitoring.go @@ -996,6 +996,101 @@ func (a *SecurityMonitoringApi) CreateSecurityFilter(ctx _context.Context, body return localVarReturnValue, localVarHTTPResponse, nil } +// CreateSecurityFinding Create security finding. +// Allows external integrations to send security findings to Datadog. This endpoint accepts finding data in a custom format and returns an empty response on success. +// +// **Note**: This endpoint is in preview and is subject to change. +// If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). +func (a *SecurityMonitoringApi) CreateSecurityFinding(ctx _context.Context, vendor string, findingType SecurityFindingType, body map[string]interface{}) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + ) + + operationId := "v2.CreateSecurityFinding" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return 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.CreateSecurityFinding") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/findings" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + localVarHeaderParams["vendor"] = datadog.ParameterToString(vendor, "") + + localVarHeaderParams["finding_type"] = datadog.ParameterToString(findingType, "") + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // CreateSecurityMonitoringCriticalAsset Create a critical asset. // Create a new critical asset. func (a *SecurityMonitoringApi) CreateSecurityMonitoringCriticalAsset(ctx _context.Context, body SecurityMonitoringCriticalAssetCreateRequest) (SecurityMonitoringCriticalAssetResponse, *_nethttp.Response, error) { @@ -4508,6 +4603,221 @@ func (a *SecurityMonitoringApi) GetVulnerabilityNotificationRules(ctx _context.C return localVarReturnValue, localVarHTTPResponse, nil } +// ImportSecurityVulnerabilities Import vulnerabilities. +// Import vulnerabilities in CycloneDX 1.5 format. This endpoint validates the payload against the CycloneDX 1.5 schema and additional mandatory field requirements. +// +// **Note**: This endpoint is in preview and is subject to change. +// If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). +func (a *SecurityMonitoringApi) ImportSecurityVulnerabilities(ctx _context.Context, body CycloneDXBOM) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + ) + + operationId := "v2.ImportSecurityVulnerabilities" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return 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.ImportSecurityVulnerabilities") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/vulnerabilities" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 500 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// ImportThreatIntelOptionalParameters holds optional parameters for ImportThreatIntel. +type ImportThreatIntelOptionalParameters struct { + TiIntegrationAccount *string +} + +// NewImportThreatIntelOptionalParameters creates an empty struct for parameters. +func NewImportThreatIntelOptionalParameters() *ImportThreatIntelOptionalParameters { + this := ImportThreatIntelOptionalParameters{} + return &this +} + +// WithTiIntegrationAccount sets the corresponding parameter name and returns the struct. +func (r *ImportThreatIntelOptionalParameters) WithTiIntegrationAccount(tiIntegrationAccount string) *ImportThreatIntelOptionalParameters { + r.TiIntegrationAccount = &tiIntegrationAccount + return r +} + +// ImportThreatIntel Import threat intelligence feed. +// Import threat intelligence feeds with support for IP addresses, domains, and SHA256 hashes. This endpoint requires specific headers to identify the vendor and indicator type. +// +// **Note**: This endpoint is in preview and is subject to change. +// If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). +func (a *SecurityMonitoringApi) ImportThreatIntel(ctx _context.Context, tiVendor string, tiIndicator ThreatIntelIndicatorType, body interface{}, o ...ImportThreatIntelOptionalParameters) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + optionalParams ImportThreatIntelOptionalParameters + ) + + if len(o) > 1 { + return nil, datadog.ReportError("only one argument of type ImportThreatIntelOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ImportThreatIntel" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return 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.ImportThreatIntel") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/security/threat-intel-feed" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + localVarHeaderParams["ti_vendor"] = datadog.ParameterToString(tiVendor, "") + + localVarHeaderParams["ti_indicator"] = datadog.ParameterToString(tiIndicator, "") + + if optionalParams.TiIntegrationAccount != nil { + localVarHeaderParams["ti_integration_account"] = datadog.ParameterToString(*optionalParams.TiIntegrationAccount, "") + } + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 500 || localVarHTTPResponse.StatusCode == 503 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // ListAssetsSBOMsOptionalParameters holds optional parameters for ListAssetsSBOMs. type ListAssetsSBOMsOptionalParameters struct { PageToken *string diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index ea3dfbf8f3b..5ce6fae6318 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -612,6 +612,7 @@ // - [SecurityMonitoringApi.CreateCustomFramework] // - [SecurityMonitoringApi.CreateJiraIssues] // - [SecurityMonitoringApi.CreateSecurityFilter] +// - [SecurityMonitoringApi.CreateSecurityFinding] // - [SecurityMonitoringApi.CreateSecurityMonitoringCriticalAsset] // - [SecurityMonitoringApi.CreateSecurityMonitoringRule] // - [SecurityMonitoringApi.CreateSecurityMonitoringSuppression] @@ -653,6 +654,8 @@ // - [SecurityMonitoringApi.GetThreatHuntingJob] // - [SecurityMonitoringApi.GetVulnerabilityNotificationRule] // - [SecurityMonitoringApi.GetVulnerabilityNotificationRules] +// - [SecurityMonitoringApi.ImportSecurityVulnerabilities] +// - [SecurityMonitoringApi.ImportThreatIntel] // - [SecurityMonitoringApi.ListAssetsSBOMs] // - [SecurityMonitoringApi.ListFindings] // - [SecurityMonitoringApi.ListMultipleRulesets] diff --git a/api/datadogV2/model_cyclone_dx_advisory.go b/api/datadogV2/model_cyclone_dx_advisory.go new file mode 100644 index 00000000000..0af2e0830a0 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_advisory.go @@ -0,0 +1,102 @@ +// 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" +) + +// CycloneDXAdvisory Advisory reference for a vulnerability. +type CycloneDXAdvisory struct { + // URL to the advisory. + Url *string `json:"url,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:"-"` +} + +// NewCycloneDXAdvisory instantiates a new CycloneDXAdvisory 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 NewCycloneDXAdvisory() *CycloneDXAdvisory { + this := CycloneDXAdvisory{} + return &this +} + +// NewCycloneDXAdvisoryWithDefaults instantiates a new CycloneDXAdvisory 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 NewCycloneDXAdvisoryWithDefaults() *CycloneDXAdvisory { + this := CycloneDXAdvisory{} + return &this +} + +// GetUrl returns the Url field value if set, zero value otherwise. +func (o *CycloneDXAdvisory) GetUrl() string { + if o == nil || o.Url == nil { + var ret string + return ret + } + return *o.Url +} + +// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXAdvisory) GetUrlOk() (*string, bool) { + if o == nil || o.Url == nil { + return nil, false + } + return o.Url, true +} + +// HasUrl returns a boolean if a field has been set. +func (o *CycloneDXAdvisory) HasUrl() bool { + return o != nil && o.Url != nil +} + +// SetUrl gets a reference to the given string and assigns it to the Url field. +func (o *CycloneDXAdvisory) SetUrl(v string) { + o.Url = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXAdvisory) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Url != nil { + toSerialize["url"] = o.Url + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXAdvisory) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Url *string `json:"url,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{"url"}) + } else { + return err + } + o.Url = all.Url + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_affect.go b/api/datadogV2/model_cyclone_dx_affect.go new file mode 100644 index 00000000000..4cae9e0947a --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_affect.go @@ -0,0 +1,101 @@ +// 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" +) + +// CycloneDXAffect Reference to a component affected by a vulnerability. +type CycloneDXAffect struct { + // Reference to a component's bom-ref. + Ref string `json:"ref"` + // 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:"-"` +} + +// NewCycloneDXAffect instantiates a new CycloneDXAffect 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 NewCycloneDXAffect(ref string) *CycloneDXAffect { + this := CycloneDXAffect{} + this.Ref = ref + return &this +} + +// NewCycloneDXAffectWithDefaults instantiates a new CycloneDXAffect 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 NewCycloneDXAffectWithDefaults() *CycloneDXAffect { + this := CycloneDXAffect{} + return &this +} + +// GetRef returns the Ref field value. +func (o *CycloneDXAffect) GetRef() string { + if o == nil { + var ret string + return ret + } + return o.Ref +} + +// GetRefOk returns a tuple with the Ref field value +// and a boolean to check if the value has been set. +func (o *CycloneDXAffect) GetRefOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Ref, true +} + +// SetRef sets field value. +func (o *CycloneDXAffect) SetRef(v string) { + o.Ref = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXAffect) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["ref"] = o.Ref + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXAffect) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Ref *string `json:"ref"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Ref == nil { + return fmt.Errorf("required field ref missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"ref"}) + } else { + return err + } + o.Ref = *all.Ref + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_asset_component.go b/api/datadogV2/model_cyclone_dx_asset_component.go new file mode 100644 index 00000000000..7aff34ed795 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_asset_component.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" +) + +// CycloneDXAssetComponent The asset component represents the system or host being scanned. +type CycloneDXAssetComponent struct { + // Optional reference to a component in the components list. + BomRef *string `json:"bom-ref,omitempty"` + // The name of the asset. + Name string `json:"name"` + // The type of the asset component. + Type *string `json:"type,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:"-"` +} + +// NewCycloneDXAssetComponent instantiates a new CycloneDXAssetComponent 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 NewCycloneDXAssetComponent(name string) *CycloneDXAssetComponent { + this := CycloneDXAssetComponent{} + this.Name = name + return &this +} + +// NewCycloneDXAssetComponentWithDefaults instantiates a new CycloneDXAssetComponent 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 NewCycloneDXAssetComponentWithDefaults() *CycloneDXAssetComponent { + this := CycloneDXAssetComponent{} + return &this +} + +// GetBomRef returns the BomRef field value if set, zero value otherwise. +func (o *CycloneDXAssetComponent) GetBomRef() string { + if o == nil || o.BomRef == nil { + var ret string + return ret + } + return *o.BomRef +} + +// GetBomRefOk returns a tuple with the BomRef field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXAssetComponent) GetBomRefOk() (*string, bool) { + if o == nil || o.BomRef == nil { + return nil, false + } + return o.BomRef, true +} + +// HasBomRef returns a boolean if a field has been set. +func (o *CycloneDXAssetComponent) HasBomRef() bool { + return o != nil && o.BomRef != nil +} + +// SetBomRef gets a reference to the given string and assigns it to the BomRef field. +func (o *CycloneDXAssetComponent) SetBomRef(v string) { + o.BomRef = &v +} + +// GetName returns the Name field value. +func (o *CycloneDXAssetComponent) 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 *CycloneDXAssetComponent) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CycloneDXAssetComponent) SetName(v string) { + o.Name = v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *CycloneDXAssetComponent) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXAssetComponent) GetTypeOk() (*string, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *CycloneDXAssetComponent) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *CycloneDXAssetComponent) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXAssetComponent) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.BomRef != nil { + toSerialize["bom-ref"] = o.BomRef + } + toSerialize["name"] = o.Name + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXAssetComponent) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + BomRef *string `json:"bom-ref,omitempty"` + Name *string `json:"name"` + Type *string `json:"type,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{"bom-ref", "name", "type"}) + } else { + return err + } + o.BomRef = all.BomRef + o.Name = *all.Name + o.Type = all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_component.go b/api/datadogV2/model_cyclone_dx_component.go new file mode 100644 index 00000000000..4f8021d0588 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_component.go @@ -0,0 +1,242 @@ +// 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" +) + +// CycloneDXComponent A component (library, application, or operating system) in the BOM. +type CycloneDXComponent struct { + // Unique reference identifier for this component. + BomRef string `json:"bom-ref"` + // The name of the component. + Name string `json:"name"` + // Package URL for the component. Required for library components. + Purl *string `json:"purl,omitempty"` + // The type of the component. Supported types are library, application, and operating-system. + Type CycloneDXComponentType `json:"type"` + // The version of the component. + Version string `json:"version"` + // 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:"-"` +} + +// NewCycloneDXComponent instantiates a new CycloneDXComponent 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 NewCycloneDXComponent(bomRef string, name string, typeVar CycloneDXComponentType, version string) *CycloneDXComponent { + this := CycloneDXComponent{} + this.BomRef = bomRef + this.Name = name + this.Type = typeVar + this.Version = version + return &this +} + +// NewCycloneDXComponentWithDefaults instantiates a new CycloneDXComponent 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 NewCycloneDXComponentWithDefaults() *CycloneDXComponent { + this := CycloneDXComponent{} + return &this +} + +// GetBomRef returns the BomRef field value. +func (o *CycloneDXComponent) GetBomRef() string { + if o == nil { + var ret string + return ret + } + return o.BomRef +} + +// GetBomRefOk returns a tuple with the BomRef field value +// and a boolean to check if the value has been set. +func (o *CycloneDXComponent) GetBomRefOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.BomRef, true +} + +// SetBomRef sets field value. +func (o *CycloneDXComponent) SetBomRef(v string) { + o.BomRef = v +} + +// GetName returns the Name field value. +func (o *CycloneDXComponent) 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 *CycloneDXComponent) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CycloneDXComponent) SetName(v string) { + o.Name = v +} + +// GetPurl returns the Purl field value if set, zero value otherwise. +func (o *CycloneDXComponent) GetPurl() string { + if o == nil || o.Purl == nil { + var ret string + return ret + } + return *o.Purl +} + +// GetPurlOk returns a tuple with the Purl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXComponent) GetPurlOk() (*string, bool) { + if o == nil || o.Purl == nil { + return nil, false + } + return o.Purl, true +} + +// HasPurl returns a boolean if a field has been set. +func (o *CycloneDXComponent) HasPurl() bool { + return o != nil && o.Purl != nil +} + +// SetPurl gets a reference to the given string and assigns it to the Purl field. +func (o *CycloneDXComponent) SetPurl(v string) { + o.Purl = &v +} + +// GetType returns the Type field value. +func (o *CycloneDXComponent) GetType() CycloneDXComponentType { + if o == nil { + var ret CycloneDXComponentType + 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 *CycloneDXComponent) GetTypeOk() (*CycloneDXComponentType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CycloneDXComponent) SetType(v CycloneDXComponentType) { + o.Type = v +} + +// GetVersion returns the Version field value. +func (o *CycloneDXComponent) GetVersion() string { + if o == nil { + var ret string + return ret + } + return o.Version +} + +// GetVersionOk returns a tuple with the Version field value +// and a boolean to check if the value has been set. +func (o *CycloneDXComponent) GetVersionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Version, true +} + +// SetVersion sets field value. +func (o *CycloneDXComponent) SetVersion(v string) { + o.Version = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXComponent) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["bom-ref"] = o.BomRef + toSerialize["name"] = o.Name + if o.Purl != nil { + toSerialize["purl"] = o.Purl + } + toSerialize["type"] = o.Type + toSerialize["version"] = o.Version + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXComponent) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + BomRef *string `json:"bom-ref"` + Name *string `json:"name"` + Purl *string `json:"purl,omitempty"` + Type *CycloneDXComponentType `json:"type"` + Version *string `json:"version"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.BomRef == nil { + return fmt.Errorf("required field bom-ref missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + if all.Version == nil { + return fmt.Errorf("required field version missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"bom-ref", "name", "purl", "type", "version"}) + } else { + return err + } + + hasInvalidField := false + o.BomRef = *all.BomRef + o.Name = *all.Name + o.Purl = all.Purl + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + 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_cyclone_dx_component_type.go b/api/datadogV2/model_cyclone_dx_component_type.go new file mode 100644 index 00000000000..0aa4b5c0a4c --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_component_type.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" +) + +// CycloneDXComponentType The type of the component. Supported types are library, application, and operating-system. +type CycloneDXComponentType string + +// List of CycloneDXComponentType. +const ( + CYCLONEDXCOMPONENTTYPE_LIBRARY CycloneDXComponentType = "library" + CYCLONEDXCOMPONENTTYPE_APPLICATION CycloneDXComponentType = "application" + CYCLONEDXCOMPONENTTYPE_OPERATING_SYSTEM CycloneDXComponentType = "operating-system" +) + +var allowedCycloneDXComponentTypeEnumValues = []CycloneDXComponentType{ + CYCLONEDXCOMPONENTTYPE_LIBRARY, + CYCLONEDXCOMPONENTTYPE_APPLICATION, + CYCLONEDXCOMPONENTTYPE_OPERATING_SYSTEM, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CycloneDXComponentType) GetAllowedValues() []CycloneDXComponentType { + return allowedCycloneDXComponentTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CycloneDXComponentType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CycloneDXComponentType(value) + return nil +} + +// NewCycloneDXComponentTypeFromValue returns a pointer to a valid CycloneDXComponentType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCycloneDXComponentTypeFromValue(v string) (*CycloneDXComponentType, error) { + ev := CycloneDXComponentType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CycloneDXComponentType: valid values are %v", v, allowedCycloneDXComponentTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CycloneDXComponentType) IsValid() bool { + for _, existing := range allowedCycloneDXComponentTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CycloneDXComponentType value. +func (v CycloneDXComponentType) Ptr() *CycloneDXComponentType { + return &v +} diff --git a/api/datadogV2/model_cyclone_dx_metadata.go b/api/datadogV2/model_cyclone_dx_metadata.go new file mode 100644 index 00000000000..3d3ed86f972 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_metadata.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" +) + +// CycloneDXMetadata Metadata for the CycloneDX BOM. +type CycloneDXMetadata struct { + // The asset component represents the system or host being scanned. + Component CycloneDXAssetComponent `json:"component"` + // Tools used to generate the BOM. + Tools CycloneDXTools `json:"tools"` + // 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:"-"` +} + +// NewCycloneDXMetadata instantiates a new CycloneDXMetadata 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 NewCycloneDXMetadata(component CycloneDXAssetComponent, tools CycloneDXTools) *CycloneDXMetadata { + this := CycloneDXMetadata{} + this.Component = component + this.Tools = tools + return &this +} + +// NewCycloneDXMetadataWithDefaults instantiates a new CycloneDXMetadata 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 NewCycloneDXMetadataWithDefaults() *CycloneDXMetadata { + this := CycloneDXMetadata{} + return &this +} + +// GetComponent returns the Component field value. +func (o *CycloneDXMetadata) GetComponent() CycloneDXAssetComponent { + if o == nil { + var ret CycloneDXAssetComponent + return ret + } + return o.Component +} + +// GetComponentOk returns a tuple with the Component field value +// and a boolean to check if the value has been set. +func (o *CycloneDXMetadata) GetComponentOk() (*CycloneDXAssetComponent, bool) { + if o == nil { + return nil, false + } + return &o.Component, true +} + +// SetComponent sets field value. +func (o *CycloneDXMetadata) SetComponent(v CycloneDXAssetComponent) { + o.Component = v +} + +// GetTools returns the Tools field value. +func (o *CycloneDXMetadata) GetTools() CycloneDXTools { + if o == nil { + var ret CycloneDXTools + return ret + } + return o.Tools +} + +// GetToolsOk returns a tuple with the Tools field value +// and a boolean to check if the value has been set. +func (o *CycloneDXMetadata) GetToolsOk() (*CycloneDXTools, bool) { + if o == nil { + return nil, false + } + return &o.Tools, true +} + +// SetTools sets field value. +func (o *CycloneDXMetadata) SetTools(v CycloneDXTools) { + o.Tools = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["component"] = o.Component + toSerialize["tools"] = o.Tools + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXMetadata) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Component *CycloneDXAssetComponent `json:"component"` + Tools *CycloneDXTools `json:"tools"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Component == nil { + return fmt.Errorf("required field component missing") + } + if all.Tools == nil { + return fmt.Errorf("required field tools missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"component", "tools"}) + } else { + return err + } + + hasInvalidField := false + if all.Component.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Component = *all.Component + if all.Tools.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Tools = *all.Tools + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_rating.go b/api/datadogV2/model_cyclone_dx_rating.go new file mode 100644 index 00000000000..b5599e8eaa6 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_rating.go @@ -0,0 +1,172 @@ +// 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" +) + +// CycloneDXRating Vulnerability rating information. +type CycloneDXRating struct { + // The CVSS score. + Score *float64 `json:"score,omitempty"` + // The severity level. + Severity *string `json:"severity,omitempty"` + // The CVSS vector string. + Vector *string `json:"vector,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:"-"` +} + +// NewCycloneDXRating instantiates a new CycloneDXRating 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 NewCycloneDXRating() *CycloneDXRating { + this := CycloneDXRating{} + return &this +} + +// NewCycloneDXRatingWithDefaults instantiates a new CycloneDXRating 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 NewCycloneDXRatingWithDefaults() *CycloneDXRating { + this := CycloneDXRating{} + return &this +} + +// GetScore returns the Score field value if set, zero value otherwise. +func (o *CycloneDXRating) GetScore() float64 { + if o == nil || o.Score == nil { + var ret float64 + return ret + } + return *o.Score +} + +// GetScoreOk returns a tuple with the Score field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXRating) GetScoreOk() (*float64, bool) { + if o == nil || o.Score == nil { + return nil, false + } + return o.Score, true +} + +// HasScore returns a boolean if a field has been set. +func (o *CycloneDXRating) HasScore() bool { + return o != nil && o.Score != nil +} + +// SetScore gets a reference to the given float64 and assigns it to the Score field. +func (o *CycloneDXRating) SetScore(v float64) { + o.Score = &v +} + +// GetSeverity returns the Severity field value if set, zero value otherwise. +func (o *CycloneDXRating) 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 *CycloneDXRating) 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 *CycloneDXRating) 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 *CycloneDXRating) SetSeverity(v string) { + o.Severity = &v +} + +// GetVector returns the Vector field value if set, zero value otherwise. +func (o *CycloneDXRating) GetVector() string { + if o == nil || o.Vector == nil { + var ret string + return ret + } + return *o.Vector +} + +// GetVectorOk returns a tuple with the Vector field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXRating) GetVectorOk() (*string, bool) { + if o == nil || o.Vector == nil { + return nil, false + } + return o.Vector, true +} + +// HasVector returns a boolean if a field has been set. +func (o *CycloneDXRating) HasVector() bool { + return o != nil && o.Vector != nil +} + +// SetVector gets a reference to the given string and assigns it to the Vector field. +func (o *CycloneDXRating) SetVector(v string) { + o.Vector = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXRating) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Score != nil { + toSerialize["score"] = o.Score + } + if o.Severity != nil { + toSerialize["severity"] = o.Severity + } + if o.Vector != nil { + toSerialize["vector"] = o.Vector + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXRating) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Score *float64 `json:"score,omitempty"` + Severity *string `json:"severity,omitempty"` + Vector *string `json:"vector,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{"score", "severity", "vector"}) + } else { + return err + } + o.Score = all.Score + o.Severity = all.Severity + o.Vector = all.Vector + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_reference.go b/api/datadogV2/model_cyclone_dx_reference.go new file mode 100644 index 00000000000..16fb10142b0 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_reference.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CycloneDXReference External reference for a vulnerability. +type CycloneDXReference struct { + // Identifier of the reference. + Id *string `json:"id,omitempty"` + // Source information for a reference. + Source *CycloneDXReferenceSource `json:"source,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:"-"` +} + +// NewCycloneDXReference instantiates a new CycloneDXReference 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 NewCycloneDXReference() *CycloneDXReference { + this := CycloneDXReference{} + return &this +} + +// NewCycloneDXReferenceWithDefaults instantiates a new CycloneDXReference 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 NewCycloneDXReferenceWithDefaults() *CycloneDXReference { + this := CycloneDXReference{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *CycloneDXReference) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXReference) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *CycloneDXReference) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *CycloneDXReference) SetId(v string) { + o.Id = &v +} + +// GetSource returns the Source field value if set, zero value otherwise. +func (o *CycloneDXReference) GetSource() CycloneDXReferenceSource { + if o == nil || o.Source == nil { + var ret CycloneDXReferenceSource + return ret + } + return *o.Source +} + +// GetSourceOk returns a tuple with the Source field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXReference) GetSourceOk() (*CycloneDXReferenceSource, bool) { + if o == nil || o.Source == nil { + return nil, false + } + return o.Source, true +} + +// HasSource returns a boolean if a field has been set. +func (o *CycloneDXReference) HasSource() bool { + return o != nil && o.Source != nil +} + +// SetSource gets a reference to the given CycloneDXReferenceSource and assigns it to the Source field. +func (o *CycloneDXReference) SetSource(v CycloneDXReferenceSource) { + o.Source = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXReference) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Source != nil { + toSerialize["source"] = o.Source + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXReference) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + Source *CycloneDXReferenceSource `json:"source,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{"id", "source"}) + } else { + return err + } + + hasInvalidField := false + o.Id = all.Id + if all.Source != nil && all.Source.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Source = all.Source + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_reference_source.go b/api/datadogV2/model_cyclone_dx_reference_source.go new file mode 100644 index 00000000000..77428b9b229 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_reference_source.go @@ -0,0 +1,102 @@ +// 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" +) + +// CycloneDXReferenceSource Source information for a reference. +type CycloneDXReferenceSource struct { + // URL to the source. + Url *string `json:"url,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:"-"` +} + +// NewCycloneDXReferenceSource instantiates a new CycloneDXReferenceSource 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 NewCycloneDXReferenceSource() *CycloneDXReferenceSource { + this := CycloneDXReferenceSource{} + return &this +} + +// NewCycloneDXReferenceSourceWithDefaults instantiates a new CycloneDXReferenceSource 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 NewCycloneDXReferenceSourceWithDefaults() *CycloneDXReferenceSource { + this := CycloneDXReferenceSource{} + return &this +} + +// GetUrl returns the Url field value if set, zero value otherwise. +func (o *CycloneDXReferenceSource) GetUrl() string { + if o == nil || o.Url == nil { + var ret string + return ret + } + return *o.Url +} + +// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXReferenceSource) GetUrlOk() (*string, bool) { + if o == nil || o.Url == nil { + return nil, false + } + return o.Url, true +} + +// HasUrl returns a boolean if a field has been set. +func (o *CycloneDXReferenceSource) HasUrl() bool { + return o != nil && o.Url != nil +} + +// SetUrl gets a reference to the given string and assigns it to the Url field. +func (o *CycloneDXReferenceSource) SetUrl(v string) { + o.Url = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXReferenceSource) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Url != nil { + toSerialize["url"] = o.Url + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXReferenceSource) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Url *string `json:"url,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{"url"}) + } else { + return err + } + o.Url = all.Url + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_tool_component.go b/api/datadogV2/model_cyclone_dx_tool_component.go new file mode 100644 index 00000000000..c4dc55c7a4f --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_tool_component.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" +) + +// CycloneDXToolComponent Tool component that detected the vulnerabilities. +type CycloneDXToolComponent struct { + // The name of the tool. + Name string `json:"name"` + // The type of the tool. + Type *string `json:"type,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:"-"` +} + +// NewCycloneDXToolComponent instantiates a new CycloneDXToolComponent 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 NewCycloneDXToolComponent(name string) *CycloneDXToolComponent { + this := CycloneDXToolComponent{} + this.Name = name + return &this +} + +// NewCycloneDXToolComponentWithDefaults instantiates a new CycloneDXToolComponent 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 NewCycloneDXToolComponentWithDefaults() *CycloneDXToolComponent { + this := CycloneDXToolComponent{} + return &this +} + +// GetName returns the Name field value. +func (o *CycloneDXToolComponent) 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 *CycloneDXToolComponent) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CycloneDXToolComponent) SetName(v string) { + o.Name = v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *CycloneDXToolComponent) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXToolComponent) GetTypeOk() (*string, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *CycloneDXToolComponent) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *CycloneDXToolComponent) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXToolComponent) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXToolComponent) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + Type *string `json:"type,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", "type"}) + } else { + return err + } + o.Name = *all.Name + o.Type = all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_tools.go b/api/datadogV2/model_cyclone_dx_tools.go new file mode 100644 index 00000000000..00644e04002 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_tools.go @@ -0,0 +1,101 @@ +// 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" +) + +// CycloneDXTools Tools used to generate the BOM. +type CycloneDXTools struct { + // List of tool components. Only one tool is supported. + Components []CycloneDXToolComponent `json:"components"` + // 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:"-"` +} + +// NewCycloneDXTools instantiates a new CycloneDXTools 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 NewCycloneDXTools(components []CycloneDXToolComponent) *CycloneDXTools { + this := CycloneDXTools{} + this.Components = components + return &this +} + +// NewCycloneDXToolsWithDefaults instantiates a new CycloneDXTools 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 NewCycloneDXToolsWithDefaults() *CycloneDXTools { + this := CycloneDXTools{} + return &this +} + +// GetComponents returns the Components field value. +func (o *CycloneDXTools) GetComponents() []CycloneDXToolComponent { + if o == nil { + var ret []CycloneDXToolComponent + return ret + } + return o.Components +} + +// GetComponentsOk returns a tuple with the Components field value +// and a boolean to check if the value has been set. +func (o *CycloneDXTools) GetComponentsOk() (*[]CycloneDXToolComponent, bool) { + if o == nil { + return nil, false + } + return &o.Components, true +} + +// SetComponents sets field value. +func (o *CycloneDXTools) SetComponents(v []CycloneDXToolComponent) { + o.Components = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXTools) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["components"] = o.Components + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXTools) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Components *[]CycloneDXToolComponent `json:"components"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Components == nil { + return fmt.Errorf("required field components missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"components"}) + } else { + return err + } + o.Components = *all.Components + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dx_vulnerability.go b/api/datadogV2/model_cyclone_dx_vulnerability.go new file mode 100644 index 00000000000..f7aa94a9410 --- /dev/null +++ b/api/datadogV2/model_cyclone_dx_vulnerability.go @@ -0,0 +1,340 @@ +// 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" +) + +// CycloneDXVulnerability A vulnerability in the CycloneDX BOM. +type CycloneDXVulnerability struct { + // List of advisory references. + Advisories []CycloneDXAdvisory `json:"advisories,omitempty"` + // List of component references affected by this vulnerability. + Affects []CycloneDXAffect `json:"affects"` + // List of CWE (Common Weakness Enumeration) identifiers. + Cwes []int32 `json:"cwes,omitempty"` + // Description of the vulnerability. + Description *string `json:"description,omitempty"` + // Detailed information about the vulnerability. + Detail *string `json:"detail,omitempty"` + // The unique identifier of the vulnerability (e.g., CVE ID). + Id string `json:"id"` + // List of vulnerability ratings. Must contain exactly one rating. + Ratings []CycloneDXRating `json:"ratings"` + // List of external references for the vulnerability. + References []CycloneDXReference `json:"references,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:"-"` +} + +// NewCycloneDXVulnerability instantiates a new CycloneDXVulnerability 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 NewCycloneDXVulnerability(affects []CycloneDXAffect, id string, ratings []CycloneDXRating) *CycloneDXVulnerability { + this := CycloneDXVulnerability{} + this.Affects = affects + this.Id = id + this.Ratings = ratings + return &this +} + +// NewCycloneDXVulnerabilityWithDefaults instantiates a new CycloneDXVulnerability 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 NewCycloneDXVulnerabilityWithDefaults() *CycloneDXVulnerability { + this := CycloneDXVulnerability{} + return &this +} + +// GetAdvisories returns the Advisories field value if set, zero value otherwise. +func (o *CycloneDXVulnerability) GetAdvisories() []CycloneDXAdvisory { + if o == nil || o.Advisories == nil { + var ret []CycloneDXAdvisory + return ret + } + return o.Advisories +} + +// GetAdvisoriesOk returns a tuple with the Advisories field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXVulnerability) GetAdvisoriesOk() (*[]CycloneDXAdvisory, bool) { + if o == nil || o.Advisories == nil { + return nil, false + } + return &o.Advisories, true +} + +// HasAdvisories returns a boolean if a field has been set. +func (o *CycloneDXVulnerability) HasAdvisories() bool { + return o != nil && o.Advisories != nil +} + +// SetAdvisories gets a reference to the given []CycloneDXAdvisory and assigns it to the Advisories field. +func (o *CycloneDXVulnerability) SetAdvisories(v []CycloneDXAdvisory) { + o.Advisories = v +} + +// GetAffects returns the Affects field value. +func (o *CycloneDXVulnerability) GetAffects() []CycloneDXAffect { + if o == nil { + var ret []CycloneDXAffect + 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 *CycloneDXVulnerability) GetAffectsOk() (*[]CycloneDXAffect, bool) { + if o == nil { + return nil, false + } + return &o.Affects, true +} + +// SetAffects sets field value. +func (o *CycloneDXVulnerability) SetAffects(v []CycloneDXAffect) { + o.Affects = v +} + +// GetCwes returns the Cwes field value if set, zero value otherwise. +func (o *CycloneDXVulnerability) GetCwes() []int32 { + if o == nil || o.Cwes == nil { + var ret []int32 + return ret + } + return o.Cwes +} + +// GetCwesOk returns a tuple with the Cwes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXVulnerability) GetCwesOk() (*[]int32, bool) { + if o == nil || o.Cwes == nil { + return nil, false + } + return &o.Cwes, true +} + +// HasCwes returns a boolean if a field has been set. +func (o *CycloneDXVulnerability) HasCwes() bool { + return o != nil && o.Cwes != nil +} + +// SetCwes gets a reference to the given []int32 and assigns it to the Cwes field. +func (o *CycloneDXVulnerability) SetCwes(v []int32) { + o.Cwes = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CycloneDXVulnerability) 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 *CycloneDXVulnerability) 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 *CycloneDXVulnerability) 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 *CycloneDXVulnerability) SetDescription(v string) { + o.Description = &v +} + +// GetDetail returns the Detail field value if set, zero value otherwise. +func (o *CycloneDXVulnerability) GetDetail() string { + if o == nil || o.Detail == nil { + var ret string + return ret + } + return *o.Detail +} + +// GetDetailOk returns a tuple with the Detail field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXVulnerability) GetDetailOk() (*string, bool) { + if o == nil || o.Detail == nil { + return nil, false + } + return o.Detail, true +} + +// HasDetail returns a boolean if a field has been set. +func (o *CycloneDXVulnerability) HasDetail() bool { + return o != nil && o.Detail != nil +} + +// SetDetail gets a reference to the given string and assigns it to the Detail field. +func (o *CycloneDXVulnerability) SetDetail(v string) { + o.Detail = &v +} + +// GetId returns the Id field value. +func (o *CycloneDXVulnerability) 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 *CycloneDXVulnerability) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CycloneDXVulnerability) SetId(v string) { + o.Id = v +} + +// GetRatings returns the Ratings field value. +func (o *CycloneDXVulnerability) GetRatings() []CycloneDXRating { + if o == nil { + var ret []CycloneDXRating + return ret + } + return o.Ratings +} + +// GetRatingsOk returns a tuple with the Ratings field value +// and a boolean to check if the value has been set. +func (o *CycloneDXVulnerability) GetRatingsOk() (*[]CycloneDXRating, bool) { + if o == nil { + return nil, false + } + return &o.Ratings, true +} + +// SetRatings sets field value. +func (o *CycloneDXVulnerability) SetRatings(v []CycloneDXRating) { + o.Ratings = v +} + +// GetReferences returns the References field value if set, zero value otherwise. +func (o *CycloneDXVulnerability) GetReferences() []CycloneDXReference { + if o == nil || o.References == nil { + var ret []CycloneDXReference + return ret + } + return o.References +} + +// GetReferencesOk returns a tuple with the References field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CycloneDXVulnerability) GetReferencesOk() (*[]CycloneDXReference, bool) { + if o == nil || o.References == nil { + return nil, false + } + return &o.References, true +} + +// HasReferences returns a boolean if a field has been set. +func (o *CycloneDXVulnerability) HasReferences() bool { + return o != nil && o.References != nil +} + +// SetReferences gets a reference to the given []CycloneDXReference and assigns it to the References field. +func (o *CycloneDXVulnerability) SetReferences(v []CycloneDXReference) { + o.References = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXVulnerability) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Advisories != nil { + toSerialize["advisories"] = o.Advisories + } + toSerialize["affects"] = o.Affects + if o.Cwes != nil { + toSerialize["cwes"] = o.Cwes + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if o.Detail != nil { + toSerialize["detail"] = o.Detail + } + toSerialize["id"] = o.Id + toSerialize["ratings"] = o.Ratings + if o.References != nil { + toSerialize["references"] = o.References + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXVulnerability) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Advisories []CycloneDXAdvisory `json:"advisories,omitempty"` + Affects *[]CycloneDXAffect `json:"affects"` + Cwes []int32 `json:"cwes,omitempty"` + Description *string `json:"description,omitempty"` + Detail *string `json:"detail,omitempty"` + Id *string `json:"id"` + Ratings *[]CycloneDXRating `json:"ratings"` + References []CycloneDXReference `json:"references,omitempty"` + }{} + 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") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Ratings == nil { + return fmt.Errorf("required field ratings missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"advisories", "affects", "cwes", "description", "detail", "id", "ratings", "references"}) + } else { + return err + } + o.Advisories = all.Advisories + o.Affects = *all.Affects + o.Cwes = all.Cwes + o.Description = all.Description + o.Detail = all.Detail + o.Id = *all.Id + o.Ratings = *all.Ratings + o.References = all.References + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_cyclone_dxbom.go b/api/datadogV2/model_cyclone_dxbom.go new file mode 100644 index 00000000000..3f8bdf59f8d --- /dev/null +++ b/api/datadogV2/model_cyclone_dxbom.go @@ -0,0 +1,270 @@ +// 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" +) + +// CycloneDXBOM CycloneDX 1.5 Bill of Materials (BOM) for importing vulnerabilities. +type CycloneDXBOM struct { + // The format of the BOM. Must be "CycloneDX". + BomFormat string `json:"bomFormat"` + // List of components (libraries, applications, or operating systems) that are affected by vulnerabilities. + Components []CycloneDXComponent `json:"components"` + // Metadata for the CycloneDX BOM. + Metadata CycloneDXMetadata `json:"metadata"` + // The version of the CycloneDX specification. Must be "1.5". + SpecVersion string `json:"specVersion"` + // The version of the BOM. + Version int64 `json:"version"` + // List of vulnerabilities to be imported. + Vulnerabilities []CycloneDXVulnerability `json:"vulnerabilities"` + // 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:"-"` +} + +// NewCycloneDXBOM instantiates a new CycloneDXBOM 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 NewCycloneDXBOM(bomFormat string, components []CycloneDXComponent, metadata CycloneDXMetadata, specVersion string, version int64, vulnerabilities []CycloneDXVulnerability) *CycloneDXBOM { + this := CycloneDXBOM{} + this.BomFormat = bomFormat + this.Components = components + this.Metadata = metadata + this.SpecVersion = specVersion + this.Version = version + this.Vulnerabilities = vulnerabilities + return &this +} + +// NewCycloneDXBOMWithDefaults instantiates a new CycloneDXBOM 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 NewCycloneDXBOMWithDefaults() *CycloneDXBOM { + this := CycloneDXBOM{} + return &this +} + +// GetBomFormat returns the BomFormat field value. +func (o *CycloneDXBOM) GetBomFormat() string { + if o == nil { + var ret string + return ret + } + return o.BomFormat +} + +// GetBomFormatOk returns a tuple with the BomFormat field value +// and a boolean to check if the value has been set. +func (o *CycloneDXBOM) GetBomFormatOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.BomFormat, true +} + +// SetBomFormat sets field value. +func (o *CycloneDXBOM) SetBomFormat(v string) { + o.BomFormat = v +} + +// GetComponents returns the Components field value. +func (o *CycloneDXBOM) GetComponents() []CycloneDXComponent { + if o == nil { + var ret []CycloneDXComponent + return ret + } + return o.Components +} + +// GetComponentsOk returns a tuple with the Components field value +// and a boolean to check if the value has been set. +func (o *CycloneDXBOM) GetComponentsOk() (*[]CycloneDXComponent, bool) { + if o == nil { + return nil, false + } + return &o.Components, true +} + +// SetComponents sets field value. +func (o *CycloneDXBOM) SetComponents(v []CycloneDXComponent) { + o.Components = v +} + +// GetMetadata returns the Metadata field value. +func (o *CycloneDXBOM) GetMetadata() CycloneDXMetadata { + if o == nil { + var ret CycloneDXMetadata + return ret + } + return o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value +// and a boolean to check if the value has been set. +func (o *CycloneDXBOM) GetMetadataOk() (*CycloneDXMetadata, bool) { + if o == nil { + return nil, false + } + return &o.Metadata, true +} + +// SetMetadata sets field value. +func (o *CycloneDXBOM) SetMetadata(v CycloneDXMetadata) { + o.Metadata = v +} + +// GetSpecVersion returns the SpecVersion field value. +func (o *CycloneDXBOM) GetSpecVersion() string { + if o == nil { + var ret string + return ret + } + return o.SpecVersion +} + +// GetSpecVersionOk returns a tuple with the SpecVersion field value +// and a boolean to check if the value has been set. +func (o *CycloneDXBOM) GetSpecVersionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.SpecVersion, true +} + +// SetSpecVersion sets field value. +func (o *CycloneDXBOM) SetSpecVersion(v string) { + o.SpecVersion = v +} + +// GetVersion returns the Version field value. +func (o *CycloneDXBOM) GetVersion() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Version +} + +// GetVersionOk returns a tuple with the Version field value +// and a boolean to check if the value has been set. +func (o *CycloneDXBOM) GetVersionOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Version, true +} + +// SetVersion sets field value. +func (o *CycloneDXBOM) SetVersion(v int64) { + o.Version = v +} + +// GetVulnerabilities returns the Vulnerabilities field value. +func (o *CycloneDXBOM) GetVulnerabilities() []CycloneDXVulnerability { + if o == nil { + var ret []CycloneDXVulnerability + return ret + } + return o.Vulnerabilities +} + +// GetVulnerabilitiesOk returns a tuple with the Vulnerabilities field value +// and a boolean to check if the value has been set. +func (o *CycloneDXBOM) GetVulnerabilitiesOk() (*[]CycloneDXVulnerability, bool) { + if o == nil { + return nil, false + } + return &o.Vulnerabilities, true +} + +// SetVulnerabilities sets field value. +func (o *CycloneDXBOM) SetVulnerabilities(v []CycloneDXVulnerability) { + o.Vulnerabilities = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CycloneDXBOM) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["bomFormat"] = o.BomFormat + toSerialize["components"] = o.Components + toSerialize["metadata"] = o.Metadata + toSerialize["specVersion"] = o.SpecVersion + toSerialize["version"] = o.Version + toSerialize["vulnerabilities"] = o.Vulnerabilities + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CycloneDXBOM) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + BomFormat *string `json:"bomFormat"` + Components *[]CycloneDXComponent `json:"components"` + Metadata *CycloneDXMetadata `json:"metadata"` + SpecVersion *string `json:"specVersion"` + Version *int64 `json:"version"` + Vulnerabilities *[]CycloneDXVulnerability `json:"vulnerabilities"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.BomFormat == nil { + return fmt.Errorf("required field bomFormat missing") + } + if all.Components == nil { + return fmt.Errorf("required field components missing") + } + if all.Metadata == nil { + return fmt.Errorf("required field metadata missing") + } + if all.SpecVersion == nil { + return fmt.Errorf("required field specVersion missing") + } + if all.Version == nil { + return fmt.Errorf("required field version missing") + } + if all.Vulnerabilities == nil { + return fmt.Errorf("required field vulnerabilities missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"bomFormat", "components", "metadata", "specVersion", "version", "vulnerabilities"}) + } else { + return err + } + + hasInvalidField := false + o.BomFormat = *all.BomFormat + o.Components = *all.Components + if all.Metadata.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Metadata = *all.Metadata + o.SpecVersion = *all.SpecVersion + o.Version = *all.Version + o.Vulnerabilities = *all.Vulnerabilities + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_security_finding_type.go b/api/datadogV2/model_security_finding_type.go new file mode 100644 index 00000000000..357853dee33 --- /dev/null +++ b/api/datadogV2/model_security_finding_type.go @@ -0,0 +1,66 @@ +// 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" +) + +// SecurityFindingType The type of security finding. +type SecurityFindingType string + +// List of SecurityFindingType. +const ( + SECURITYFINDINGTYPE_VULNERABILITY SecurityFindingType = "vulnerability" + SECURITYFINDINGTYPE_CONFIGURATION_FINDING SecurityFindingType = "configuration_finding" +) + +var allowedSecurityFindingTypeEnumValues = []SecurityFindingType{ + SECURITYFINDINGTYPE_VULNERABILITY, + SECURITYFINDINGTYPE_CONFIGURATION_FINDING, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SecurityFindingType) GetAllowedValues() []SecurityFindingType { + return allowedSecurityFindingTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SecurityFindingType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SecurityFindingType(value) + return nil +} + +// NewSecurityFindingTypeFromValue returns a pointer to a valid SecurityFindingType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSecurityFindingTypeFromValue(v string) (*SecurityFindingType, error) { + ev := SecurityFindingType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SecurityFindingType: valid values are %v", v, allowedSecurityFindingTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SecurityFindingType) IsValid() bool { + for _, existing := range allowedSecurityFindingTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SecurityFindingType value. +func (v SecurityFindingType) Ptr() *SecurityFindingType { + return &v +} diff --git a/api/datadogV2/model_threat_intel_indicator_type.go b/api/datadogV2/model_threat_intel_indicator_type.go new file mode 100644 index 00000000000..2c62c257a00 --- /dev/null +++ b/api/datadogV2/model_threat_intel_indicator_type.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" +) + +// ThreatIntelIndicatorType The type of threat indicator. +type ThreatIntelIndicatorType string + +// List of ThreatIntelIndicatorType. +const ( + THREATINTELINDICATORTYPE_IP_ADDRESS ThreatIntelIndicatorType = "ip_address" + THREATINTELINDICATORTYPE_DOMAIN ThreatIntelIndicatorType = "domain" + THREATINTELINDICATORTYPE_SHA256 ThreatIntelIndicatorType = "sha256" +) + +var allowedThreatIntelIndicatorTypeEnumValues = []ThreatIntelIndicatorType{ + THREATINTELINDICATORTYPE_IP_ADDRESS, + THREATINTELINDICATORTYPE_DOMAIN, + THREATINTELINDICATORTYPE_SHA256, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ThreatIntelIndicatorType) GetAllowedValues() []ThreatIntelIndicatorType { + return allowedThreatIntelIndicatorTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ThreatIntelIndicatorType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ThreatIntelIndicatorType(value) + return nil +} + +// NewThreatIntelIndicatorTypeFromValue returns a pointer to a valid ThreatIntelIndicatorType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewThreatIntelIndicatorTypeFromValue(v string) (*ThreatIntelIndicatorType, error) { + ev := ThreatIntelIndicatorType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ThreatIntelIndicatorType: valid values are %v", v, allowedThreatIntelIndicatorTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ThreatIntelIndicatorType) IsValid() bool { + for _, existing := range allowedThreatIntelIndicatorTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ThreatIntelIndicatorType value. +func (v ThreatIntelIndicatorType) Ptr() *ThreatIntelIndicatorType { + return &v +} diff --git a/examples/v2/security-monitoring/CreateSecurityFinding.go b/examples/v2/security-monitoring/CreateSecurityFinding.go new file mode 100644 index 00000000000..bab6576fd1b --- /dev/null +++ b/examples/v2/security-monitoring/CreateSecurityFinding.go @@ -0,0 +1,26 @@ +// Create security finding returns "OK" response + +package main + +import ( + "context" + "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.CreateSecurityFinding", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + r, err := api.CreateSecurityFinding(ctx, "vendor", datadogV2.SECURITYFINDINGTYPE_VULNERABILITY) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.CreateSecurityFinding`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/security-monitoring/ImportSecurityVulnerabilities.go b/examples/v2/security-monitoring/ImportSecurityVulnerabilities.go new file mode 100644 index 00000000000..02ef8bf286f --- /dev/null +++ b/examples/v2/security-monitoring/ImportSecurityVulnerabilities.go @@ -0,0 +1,91 @@ +// Import vulnerabilities returns "OK" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.CycloneDXBOM{ + BomFormat: "CycloneDX", + Components: []datadogV2.CycloneDXComponent{ + { + BomRef: "a3390fca-c315-41ae-ae05-af5e7859cdee", + Name: "lodash", + Purl: datadog.PtrString("pkg:npm/lodash@4.17.21"), + Type: datadogV2.CYCLONEDXCOMPONENTTYPE_LIBRARY, + Version: "4.17.21", + }, + }, + Metadata: datadogV2.CycloneDXMetadata{ + Component: datadogV2.CycloneDXAssetComponent{ + BomRef: datadog.PtrString("asset-ref-123"), + Name: "i-12345", + Type: datadog.PtrString("operating-system"), + }, + Tools: datadogV2.CycloneDXTools{ + Components: []datadogV2.CycloneDXToolComponent{ + { + Name: "my-scanner", + Type: datadog.PtrString("application"), + }, + }, + }, + }, + SpecVersion: "1.5", + Version: 1, + Vulnerabilities: []datadogV2.CycloneDXVulnerability{ + { + Advisories: []datadogV2.CycloneDXAdvisory{ + { + Url: datadog.PtrString("https://example.com/advisory/CVE-2021-1234"), + }, + }, + Affects: []datadogV2.CycloneDXAffect{ + { + Ref: "a3390fca-c315-41ae-ae05-af5e7859cdee", + }, + }, + Cwes: []int32{ + 123, + 345, + }, + Description: datadog.PtrString("Sample vulnerability detected in the application."), + Detail: datadog.PtrString("Details about the vulnerability"), + Id: "CVE-2021-1234", + Ratings: []datadogV2.CycloneDXRating{ + { + Score: datadog.PtrFloat64(9.0), + Severity: datadog.PtrString("high"), + Vector: datadog.PtrString("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N"), + }, + }, + References: []datadogV2.CycloneDXReference{ + { + Id: datadog.PtrString("GHSA-35m5-8cvj-8783"), + Source: &datadogV2.CycloneDXReferenceSource{ + Url: datadog.PtrString("https://example.com"), + }, + }, + }, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ImportSecurityVulnerabilities", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + r, err := api.ImportSecurityVulnerabilities(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.ImportSecurityVulnerabilities`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/security-monitoring/ImportThreatIntel.go b/examples/v2/security-monitoring/ImportThreatIntel.go new file mode 100644 index 00000000000..8e53ec26811 --- /dev/null +++ b/examples/v2/security-monitoring/ImportThreatIntel.go @@ -0,0 +1,26 @@ +// Import threat intelligence feed returns "OK" response + +package main + +import ( + "context" + "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.ImportThreatIntel", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSecurityMonitoringApi(apiClient) + r, err := api.ImportThreatIntel(ctx, "ti_vendor", datadogV2.THREATINTELINDICATORTYPE_IP_ADDRESS, *datadogV2.NewImportThreatIntelOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.ImportThreatIntel`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/tests/scenarios/features/v2/security_monitoring.feature b/tests/scenarios/features/v2/security_monitoring.feature index 5695a7ea4a5..3ad8d5c9636 100644 --- a/tests/scenarios/features/v2/security_monitoring.feature +++ b/tests/scenarios/features/v2/security_monitoring.feature @@ -708,6 +708,24 @@ Feature: Security Monitoring When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/asm-vm + Scenario: Create security finding returns "Bad Request" response + Given operation "CreateSecurityFinding" enabled + And new "CreateSecurityFinding" request + And request contains "vendor" parameter from "REPLACE.ME" + And request contains "finding_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-vm + Scenario: Create security finding returns "OK" response + Given operation "CreateSecurityFinding" enabled + And new "CreateSecurityFinding" request + And request contains "vendor" parameter from "REPLACE.ME" + And request contains "finding_type" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Deactivate content pack returns "Accepted" response Given operation "DeactivateContentPack" enabled @@ -1397,6 +1415,40 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 The list of notification rules. + @generated @skip @team:DataDog/asm-vm + Scenario: Import threat intelligence feed returns "Bad Request" response + Given operation "ImportThreatIntel" enabled + And new "ImportThreatIntel" request + And request contains "ti_vendor" parameter from "REPLACE.ME" + And request contains "ti_indicator" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-vm + Scenario: Import threat intelligence feed returns "OK" response + Given operation "ImportThreatIntel" enabled + And new "ImportThreatIntel" request + And request contains "ti_vendor" parameter from "REPLACE.ME" + And request contains "ti_indicator" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-vm + Scenario: Import vulnerabilities returns "Bad Request" response + Given operation "ImportSecurityVulnerabilities" enabled + And new "ImportSecurityVulnerabilities" request + And body with value {"bomFormat": "CycloneDX", "components": [{"bom-ref": "a3390fca-c315-41ae-ae05-af5e7859cdee", "name": "lodash", "purl": "pkg:npm/lodash@4.17.21", "type": "library", "version": "4.17.21"}], "metadata": {"component": {"bom-ref": "asset-ref-123", "name": "i-12345", "type": "operating-system"}, "tools": {"components": [{"name": "my-scanner", "type": "application"}]}}, "specVersion": "1.5", "version": 1, "vulnerabilities": [{"advisories": [{"url": "https://example.com/advisory/CVE-2021-1234"}], "affects": [{"ref": "a3390fca-c315-41ae-ae05-af5e7859cdee"}], "cwes": [123, 345], "description": "Sample vulnerability detected in the application.", "detail": "Details about the vulnerability", "id": "CVE-2021-1234", "ratings": [{"score": 9.0, "severity": "high", "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N"}], "references": [{"id": "GHSA-35m5-8cvj-8783", "source": {"url": "https://example.com"}}]}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-vm + Scenario: Import vulnerabilities returns "OK" response + Given operation "ImportSecurityVulnerabilities" enabled + And new "ImportSecurityVulnerabilities" request + And body with value {"bomFormat": "CycloneDX", "components": [{"bom-ref": "a3390fca-c315-41ae-ae05-af5e7859cdee", "name": "lodash", "purl": "pkg:npm/lodash@4.17.21", "type": "library", "version": "4.17.21"}], "metadata": {"component": {"bom-ref": "asset-ref-123", "name": "i-12345", "type": "operating-system"}, "tools": {"components": [{"name": "my-scanner", "type": "application"}]}}, "specVersion": "1.5", "version": 1, "vulnerabilities": [{"advisories": [{"url": "https://example.com/advisory/CVE-2021-1234"}], "affects": [{"ref": "a3390fca-c315-41ae-ae05-af5e7859cdee"}], "cwes": [123, 345], "description": "Sample vulnerability detected in the application.", "detail": "Details about the vulnerability", "id": "CVE-2021-1234", "ratings": [{"score": 9.0, "severity": "high", "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N"}], "references": [{"id": "GHSA-35m5-8cvj-8783", "source": {"url": "https://example.com"}}]}]} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-vm Scenario: List assets SBOMs returns "Bad request: The server cannot process the request due to invalid syntax in the request." response Given new "ListAssetsSBOMs" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 75d0d7f71ed..110c6b94f87 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4304,6 +4304,12 @@ "type": "safe" } }, + "CreateSecurityFinding": { + "tag": "Security Monitoring", + "undo": { + "type": "unsafe" + } + }, "DetachCase": { "tag": "Security Monitoring", "undo": { @@ -4409,12 +4415,24 @@ "type": "idempotent" } }, + "ImportThreatIntel": { + "tag": "Security Monitoring", + "undo": { + "type": "unsafe" + } + }, "ListVulnerabilities": { "tag": "Security Monitoring", "undo": { "type": "safe" } }, + "ImportSecurityVulnerabilities": { + "tag": "Security Monitoring", + "undo": { + "type": "unsafe" + } + }, "GetVulnerabilityNotificationRules": { "tag": "Security Monitoring", "undo": {