-
Notifications
You must be signed in to change notification settings - Fork 388
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
supporting cws multi-policy in terraform #2681
base: master
Are you sure you want to change the base?
Conversation
6322019
to
5da3fb7
Compare
import ( | ||
"context" | ||
"fmt" | ||
mathrand "math/rand" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Code Vulnerability
mathrand "math/rand" | |
mathrand "crypto/rand" |
The math/rand library does not generate cryptographically secure random numbers. (...read more)
Using the math/rand
package in Go for generating random numbers may lead to vulnerabilities in certain security-critical contexts. Here's why it is recommended to exercise caution when using this package:
- Pseudorandomness: The
math/rand
package generates pseudorandom numbers, which are generated from a deterministic algorithm and a seed value. These numbers are not truly random and may exhibit patterns or predictable sequences. In security-critical applications, such as cryptography or secure password generation, true randomness is essential to prevent guessing or predicting the random values. - Predictable seed value: By default, the
math/rand
package uses a predictable seed value based on the current time. This means that if multiple processes or instances of the software start at the same time or use the same seed, they will generate the exact same sequence of random numbers. This predictability can be exploited by an attacker to reproduce the random values and potentially compromise the security of the system. - Insufficient entropy: In security-sensitive contexts, it is crucial to have a good source of entropy, which is a measure of unpredictability. The
math/rand
package does not provide a direct way to access system-level entropy sources. It relies on a fixed seed or a manually set seed value, which may not have sufficient entropy to generate adequately random numbers for cryptographic operations or other security-critical tasks. - SecureRandom: In contrast to
math/rand
, thecrypto/rand
package in Go provides a secure random number generator that uses a system-level entropy source. It generates cryptographically secure random numbers suitable for security-sensitive applications. It is recommended to usecrypto/rand
for generating random numbers in scenarios that require strong randomness and security.
To mitigate vulnerabilities and ensure the secure generation of random values, it is recommended to use the crypto/rand
package instead of math/rand
for security-critical applications. The crypto/rand
package provides a more reliable source of random numbers, leveraging the underlying operating system's entropy source for improved security.
Always consider the specific requirements of your application and the context in which random numbers are used. Following best practices and using appropriate cryptographic libraries can help mitigate vulnerabilities and ensure the security of your Go applications.
func (r *csmThreatsPoliciesListResource) applyBatchPolicies(ctx context.Context, entries []csmThreatsPoliciesListEntryModel, diags *diag.Diagnostics) ([]csmThreatsPoliciesListEntryModel, error) { | ||
listResp, httpResp, err := r.api.ListCSMThreatsAgentPolicies(r.auth) | ||
if err != nil { | ||
if httpResp != nil && httpResp.StatusCode == 404 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean httpResp.StatusCode != 404
?
@@ -97,3 +97,4 @@ require ( | |||
) | |||
|
|||
go 1.23 | |||
replace github.com/DataDog/datadog-api-client-go/v2 v2.34.1-0.20241226155556-e60f30b0e84e => ../datadog-api-spec/generated/datadog-api-client-go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is only for local testing and you don't plan to check this in?
|
||
### Optional | ||
|
||
- `entries` (Block Set) A set of policies that belong to this list/batch. All non-listed policies get deleted. (see [below for nested schema](#nestedblock--entries)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should also mention that customers are supposed to create exactly one policy list.
Adding new resources and data sources to support the CWS multi-policy feature.
datadog_csm_threats_agent_rules
such that users could pass in thepolicy_id
as an optional attribute to fetch rules in a specific policy.datadog_csm_threats_policies
for users to list their policies.datadog_csm_threats_policy
for users to manage their CWS policies.datadog_csm_threats_multi_policy_agent_rule
for users to manage their rules in a policy.How to deploy policy resources:
TODO: record the tests after the DD SDK is updated.