Enabling Code Security for Python
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel,
n'hésitez pas à nous contacter.
You can detect code-level vulnerabilities and monitor application security in Python applicationss running in Docker, Kubernetes, Amazon ECS, and AWS Fargate.
NOTE: Code-Level Vulnerability detection in Python is in Preview.
Follow these steps to enable Code Security in your service:
Update your Datadog Agent to at least version 7.41.1.
Update your Datadog Tracing Library to at least the minimum version needed to turn on Code Security. For details, see Library Compatibility page.
Add the DD_IAST_ENABLED=true
environment variable to your application configuration.
From the command line:
DD_IAST_ENABLED=true ddtrace-run python app.py
Or one of the following methods, depending on where your application runs:
Update your configuration container for APM by adding the following argument in your docker run
command:
docker run [...] -e DD_IAST_ENABLED=true [...]
Add the following environment variable value to your container Dockerfile:
Update your deployment configuration file for APM and add the IAST environment variable:
spec:
template:
spec:
containers:
- name: <CONTAINER_NAME>
image: <CONTAINER_IMAGE>/<TAG>
env:
- name: DD_IAST_ENABLED
value: "true"
Update your ECS task definition JSON file, by adding this in the environment section:
"environment": [
...,
{
"name": "DD_IAST_ENABLED",
"value": "true"
}
]
- Restart your service.
- To see Code Security in action, browse your service and find code-level vulnerabilities in the Vulnerability Explorer.
If you need additional assistance, contact Datadog support.
Third-Party Library Compatibility Note
Code Security modifies Python code at runtime. This could cause conflicts with other third-party Python libraries that perform similar code transformations, particularly with the following, though not limited to them:
- Numba
- JAX
- TorchScript
- TensorFlow
- Bytecode
- Codetransformer
- PyPy
Additionally, Code Security does not correctly propagate taint ranges over native (compiled) code. Therefore, if your codebase heavily relies on modules written in C or C++,
using the CPython API, or on intermediate language systems like Cython, the results might be less accurate than expected.
Further Reading
Documentation, liens et articles supplémentaires utiles: