Enabling App and API Protection for Go
This product is not supported for your selected
Datadog site. (
).
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、
お気軽にご連絡ください。
You can monitor App and API Protection for Go apps running in Docker, Kubernetes, and Amazon ECS.
前提条件
Prerequisite
Enabling Application & API Protection (AAP)
Get started
Install Orchestrion:
$ go install github.com/DataDog/orchestrion@latest
2. **Register Orchestrion as a Go module** in your project directory:
```console
$ orchestrion pin
Datadog has a series of pluggable packages which provide out-of-the-box support for instrumenting a series of Go libraries and frameworks.
A list of these packages can be found in the compatibility requirements page.
Import these packages into your application and follow the configuration instructions listed alongside each integration.
Recompile your program with Orchestrion:
$ orchestrion go build my-program
More options on how to use orchestrion can be found in the Orchestrion usage.
Note: If you are building without CGO on linux. Please read Building Go applications with CGO disabled for more information.
Redeploy your Go service and enable AAP by setting the DD_APPSEC_ENABLED
environment variable to true
:
$ env DD_APPSEC_ENABLED=true ./my-program
Or one of the following methods, depending on where your application runs:
Add the following environment variable value to your Docker command line:
$ docker run -e DD_APPSEC_ENABLED=true [...]
Add the following environment variable value to your application container’s Dockerfile:
ENV DD_APPSEC_ENABLED=true
A more detailed guide on how to create a fitting dockerfile is available [here][3].
Update your application’s deployment configuration file for APM and add the AAP environment variable:
spec:
template:
spec:
containers:
- name: <CONTAINER_NAME>
image: <CONTAINER_IMAGE>/<TAG>
env:
- name: DD_APPSEC_ENABLED
value: "true"
Update your application’s ECS task definition JSON file, by adding this in the environment section:
"environment": [
...,
{
"name": "DD_APPSEC_ENABLED",
"value": "true"
}
]
4. Verify setup
To verify that App and API Protection is working correctly:
Send some traffic to your application
Check the Application Signals Explorer in Datadog
Look for security signals and vulnerabilities
ライブラリは、アプリケーションからセキュリティデータを収集し、Agent に送信します。Agent は、そのデータを Datadog に送信し、すぐに使える検出ルールによって、攻撃者のテクニックや潜在的な誤構成にフラグが立てられるため、是正措置を講じることができます。
Application Security Management の脅威検出の動作を見るには、既知の攻撃パターンをアプリケーションに送信してください。例えば、次の curl スクリプトを含むファイルを実行して、Security Scanner Detected ルールをトリガーします。
for ((i=1;i<=250;i++));
do
# Target existing service’s routes
curl https://your-application-url/existing-route -A Arachni/v1.0;
# Target non existing service’s routes
curl https://your-application-url/non-existing-route -A Arachni/v1.0;
done
アプリケーションを有効にして実行すると、数分後に Datadog の Application Trace and Signals Explorer に脅威情報が表示されます。
Building without CGO
If you are building your Go application without CGO, you can still enable AAP by following these steps:
- Add the
appsec
build tag when compiling your application:$ CGO_ENABLED=0 orchestrion go build -tags appsec my-program
Using CGO_ENABLED=0
usually guarantees a statically-linked binary. This will NOT be the case in this setup.
Install libc.so.6
and libpthread.so.0
on your system, as these libraries are required by the Datadog WAF:
This can be done by installing the glibc
package on your system via your package manager. Read more on Creating a Dockerfile for AAP
Redeploy your Go service with the DD_APPSEC_ENABLED=true
environment variable set, as described above.
Using AAP without APM tracing
If you want to use Application & API Protection without APM tracing functionality, you can deploy with tracing disabled:
- Configure your tracing library with the
DD_APM_TRACING_ENABLED=false
environment variable in addition to the DD_APPSEC_ENABLED=true
environment variable. - This configuration will reduce the amount of APM data sent to Datadog to the minimum required by App and API Protection products.
For more details, see [Standalone App and API Protection][standalone_billing_guide].
[standalone_billing_guide]: /security/application_security/guide/standalone_application_security/
Further Reading