From 76f6908968a4300301bcdb5b3c010eedf2337e60 Mon Sep 17 00:00:00 2001 From: Chakib Hamie Date: Thu, 29 May 2025 18:07:02 +0200 Subject: [PATCH] [Datadog] Fix python-security/avoid-random violation Co-authored-by: datadog-datadog-staging-us1-all[bot] <92110531+datadog-datadog-staging-us1-all[bot]@users.noreply.github.com> --- ddtrace/vendor/dogstatsd/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ddtrace/vendor/dogstatsd/base.py b/ddtrace/vendor/dogstatsd/base.py index fc25045da60..78c6a4665f6 100644 --- a/ddtrace/vendor/dogstatsd/base.py +++ b/ddtrace/vendor/dogstatsd/base.py @@ -1,3 +1,4 @@ +import secrets #!/usr/bin/env python # Unless explicitly stated otherwise all files in this repository are licensed under @@ -912,7 +913,7 @@ def _report(self, metric, metric_type, value, tags, sample_rate): if sample_rate is None: sample_rate = self.default_sample_rate - if sample_rate != 1 and random() > sample_rate: + if sample_rate != 1 and secrets.randbelow(100) / 100 > sample_rate: return # Resolve the full tag list