Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSM Agentless Read Endpoint #2165

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-07 19:53:43.056949",
"spec_repo_commit": "d63fa330"
"regenerated": "2025-01-08 14:02:25.736805",
"spec_repo_commit": "1920836f"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-07 19:53:43.071705",
"spec_repo_commit": "d63fa330"
"regenerated": "2025-01-08 14:02:25.752564",
"spec_repo_commit": "1920836f"
}
}
}
74 changes: 74 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,57 @@ components:
$ref: '#/components/schemas/AwsCURConfig'
type: array
type: object
AwsScanOptionsAttributes:
description: Attributes for the AWS scan options.
properties:
lambda:
description: Indicates if scanning of Lambda functions is enabled.
example: true
type: boolean
sensitive_data:
description: Indicates if scanning for sensitive data is enabled.
example: false
type: boolean
vuln_containers_os:
description: Indicates if scanning for vulnerabilities in containers is
enabled.
example: true
type: boolean
vuln_host_os:
description: Indicates if scanning for vulnerabilities in hosts is enabled.
example: true
type: boolean
type: object
AwsScanOptionsData:
description: Single AWS Scan Options entry.
properties:
attributes:
$ref: '#/components/schemas/AwsScanOptionsAttributes'
id:
description: The ID of the AWS account.
example: '184366314700'
type: string
type:
$ref: '#/components/schemas/AwsScanOptionsType'
type: object
AwsScanOptionsResponse:
description: Response object that includes a list of AWS scan options.
properties:
data:
description: A list of AWS scan options.
items:
$ref: '#/components/schemas/AwsScanOptionsData'
type: array
type: object
AwsScanOptionsType:
default: aws_scan_options
description: The type of the resource. The value should always be `aws_scan_options`.
enum:
- aws_scan_options
example: aws_scan_options
type: string
x-enum-varnames:
- AWS_SCAN_OPTIONS
AzureUCConfig:
description: Azure config.
properties:
Expand Down Expand Up @@ -30222,6 +30273,24 @@ info:
version: '1.0'
openapi: 3.0.0
paths:
/api/v2/agentless_scanning/accounts/aws:
get:
description: Fetches the scan options configured for AWS accounts.
operationId: ListAwsScanOptions
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/AwsScanOptionsResponse'
description: OK
'403':
$ref: '#/components/responses/NotAuthorizedResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: Get AWS Scan Options
tags:
- Agentless Scanning
/api/v2/api_keys:
get:
description: List all API keys available for your account.
Expand Down Expand Up @@ -48131,6 +48200,11 @@ tags:
externalDocs:
url: https://docs.datadoghq.com/integrations/amazon_web_services/#log-collection
name: AWS Logs Integration
- description: "Datadog Agentless Scanning provides visibility into risks and vulnerabilities\nwithin
your hosts, running containers, and serverless functions\u2014all without\nrequiring
teams to install Agents on every host or where Agents cannot be installed.\nGo
to https://www.datadoghq.com/blog/agentless-scanning/ to learn more"
name: Agentless Scanning
- description: Datadog App Builder provides a low-code solution to rapidly develop
and integrate secure, customized applications into your monitoring stack that
are built to accelerate remediation at scale. These API endpoints allow you to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024-12-18T15:40:11.636Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/v2/agentless-scanning/ListAwsScanOptions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Get AWS Scan Options returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::AgentlessScanningAPI.new
p api_instance.list_aws_scan_options()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Suggested change
p api_instance.list_aws_scan_options()
p api_instance.list_aws_scan_options
Do not use parentheses with methods that take no arguments (...read more)

The rule "Avoid parentheses when methods take no arguments" is part of the Ruby style guide. It suggests that when a method takes no arguments, you should not use parentheses. This is because the use of parentheses in such a case is redundant and unnecessary, and it can make your code more difficult to read and understand.

This rule is important because it promotes cleaner, more readable code. In Ruby, clean and readable code is highly valued. By following this rule, you can ensure your code is easier to understand and maintain, which is crucial for long-term project success.

To adhere to this rule, remove the parentheses when calling a method that does not require any arguments. For example, instead of writing 'test'.upcase(), you should write 'test'.upcase. Similarly, instead of Kernel.exit!(), write Kernel.exit!. However, note that there is an exception for super - super by itself is different from super(), so in this case, parentheses may be necessary.

View in Datadog  Leave us feedback  Documentation

16 changes: 16 additions & 0 deletions features/v2/agentless_scanning.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@endpoint(agentless-scanning) @endpoint(agentless-scanning-v2)
Feature: Agentless Scanning
Datadog Agentless Scanning provides visibility into risks and
vulnerabilities within your hosts, running containers, and serverless
functions—all without requiring teams to install Agents on every host or
where Agents cannot be installed. Go to
https://www.datadoghq.com/blog/agentless-scanning/ to learn more

@team:DataDog/k9-cloud-security-platform
Scenario: Get AWS Scan Options returns "OK" response
Given a valid "apiKeyAuth" key in the system
And a valid "appKeyAuth" key in the system
And an instance of "AgentlessScanning" API
And new "ListAwsScanOptions" request
When the request is sent
Then the response status is 200 OK
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"ListAwsScanOptions": {
"tag": "Agentless Scanning",
"undo": {
"type": "safe"
}
},
"ListAPIKeys": {
"tag": "Key Management",
"undo": {
Expand Down
5 changes: 5 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,10 @@ def overrides
"v2.aws_regions_include_all" => "AWSRegionsIncludeAll",
"v2.aws_regions_include_only" => "AWSRegionsIncludeOnly",
"v2.aws_resources_config" => "AWSResourcesConfig",
"v2.aws_scan_options_attributes" => "AwsScanOptionsAttributes",
"v2.aws_scan_options_data" => "AwsScanOptionsData",
"v2.aws_scan_options_response" => "AwsScanOptionsResponse",
"v2.aws_scan_options_type" => "AwsScanOptionsType",
"v2.aws_traces_config" => "AWSTracesConfig",
"v2.azure_uc_config" => "AzureUCConfig",
"v2.azure_uc_config_pair" => "AzureUCConfigPair",
Expand Down Expand Up @@ -2824,6 +2828,7 @@ def overrides
"v1.usage_metering_api" => "UsageMeteringAPI",
"v1.users_api" => "UsersAPI",
"v1.webhooks_integration_api" => "WebhooksIntegrationAPI",
"v2.agentless_scanning_api" => "AgentlessScanningAPI",
"v2.api_management_api" => "APIManagementAPI",
"v2.apm_retention_filters_api" => "APMRetentionFiltersAPI",
"v2.apps_api" => "AppsAPI",
Expand Down
86 changes: 86 additions & 0 deletions lib/datadog_api_client/v2/api/agentless_scanning_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
=begin
#Datadog API V2 Collection

#Collection of all Datadog Public endpoints.

The version of the OpenAPI document: 1.0
Contact: [email protected]
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator

Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
This product includes software developed at Datadog (https://www.datadoghq.com/).
Copyright 2020-Present Datadog, Inc.

=end

require 'cgi'

module DatadogAPIClient::V2
class AgentlessScanningAPI
attr_accessor :api_client

def initialize(api_client = DatadogAPIClient::APIClient.default)
@api_client = api_client
end

# Get AWS Scan Options.
#
# @see #list_aws_scan_options_with_http_info
def list_aws_scan_options(opts = {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Avoid using a hash as an optional parameter (...read more)

The rule "Avoid hash optional parameters" is a guideline that encourages developers to explicitly declare parameters instead of using a hash for optional parameters. This is because using a hash for optional parameters can make the code harder to understand and maintain. It can also lead to unexpected behavior if a developer accidentally includes a key in the hash that the method does not expect.

This rule is important because it promotes code readability and maintainability. It also helps prevent potential bugs that may occur due to unexpected keys in the optional hash. By explicitly declaring each parameter, developers can easily see what parameters a method expects, making the code easier to read and understand.

To adhere to this rule, instead of using a hash for optional parameters, explicitly declare each parameter in the method definition. For example, instead of using options = {} in the method definition, declare each parameter like name, email, age. This way, anyone reading the code can easily understand what parameters the method expects and in what order.

View in Datadog  Leave us feedback  Documentation

data, _status_code, _headers = list_aws_scan_options_with_http_info(opts)
data
end

# Get AWS Scan Options.
#
# Fetches the scan options configured for AWS accounts.
#
# @param opts [Hash] the optional parameters
# @return [Array<(AwsScanOptionsResponse, Integer, Hash)>] AwsScanOptionsResponse data, response status code and response headers
def list_aws_scan_options_with_http_info(opts = {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Avoid using a hash as an optional parameter (...read more)

The rule "Avoid hash optional parameters" is a guideline that encourages developers to explicitly declare parameters instead of using a hash for optional parameters. This is because using a hash for optional parameters can make the code harder to understand and maintain. It can also lead to unexpected behavior if a developer accidentally includes a key in the hash that the method does not expect.

This rule is important because it promotes code readability and maintainability. It also helps prevent potential bugs that may occur due to unexpected keys in the optional hash. By explicitly declaring each parameter, developers can easily see what parameters a method expects, making the code easier to read and understand.

To adhere to this rule, instead of using a hash for optional parameters, explicitly declare each parameter in the method definition. For example, instead of using options = {} in the method definition, declare each parameter like name, email, age. This way, anyone reading the code can easily understand what parameters the method expects and in what order.

View in Datadog  Leave us feedback  Documentation


if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: AgentlessScanningAPI.list_aws_scan_options ...'
end
# resource path
local_var_path = '/api/v2/agentless_scanning/accounts/aws'

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Suggested change
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
header_params['Accept'] = @api_client.select_header_accept(%w[application/json])
Consider using the %w syntax instead (...read more)

The rule "Prefer %w to the literal array syntax" is a Ruby style guideline that encourages the use of %w notation instead of the traditional array syntax when defining arrays of strings. This rule is part of the Ruby community's efforts to promote readability and simplicity in Ruby code.

This rule is important because it helps to keep the code concise and easy to read. The %w notation allows you to define an array of strings without having to use quotes and commas. This can make the code cleaner and easier to understand, especially when dealing with large arrays.

To follow this rule, replace the traditional array syntax with the %w notation. For example, instead of writing ['foo', 'bar', 'baz'], you should write %w[foo bar baz]. This will create the same array, but in a more readable and concise way. By following this rule, you can help to make your Ruby code cleaner and easier to understand.

View in Datadog  Leave us feedback  Documentation


# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body]

# return_type
return_type = opts[:debug_return_type] || 'AwsScanOptionsResponse'

# auth_names
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Suggested change
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]
auth_names = opts[:debug_auth_names] || %i[apiKeyAuth appKeyAuth]
Consider using the %i syntax instead (...read more)

The rule "Prefer %i to the literal array syntax" is a guideline that encourages the use of the %i syntax for arrays of symbols. This is a part of the Ruby style guide that aims to promote conciseness and readability.

Symbols are immutable, reusable objects often used in Ruby instead of strings when the value does not need to be changed. When declaring an array of symbols, using the %i syntax can make your code cleaner and easier to read.

To adhere to this rule, instead of declaring an array of symbols using the literal array syntax like [:foo, :bar, :baz], use the %i syntax like %i[foo bar baz]. It's a good practice to consistently use %i for arrays of symbols as it enhances code readability and maintainability.

View in Datadog  Leave us feedback  Documentation


new_options = opts.merge(
:operation => :list_aws_scan_options,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type,
:api_version => "V2"
)

data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: AgentlessScanningAPI#list_aws_scan_options\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
Loading
Loading