Skip to content

Commit 75c474f

Browse files
committed
upgrade setup to work with orchestrion
Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
1 parent b828dfd commit 75c474f

File tree

3 files changed

+52
-24
lines changed

3 files changed

+52
-24
lines changed

content/en/security/application_security/setup/go/_index.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,37 @@ You can monitor App and API Protection for Go apps running in Docker, Kubernetes
3232

3333
# Prerequisite
3434

35-
- Your service is [supported][2].
36-
- You have one of the latest two version of [Go][4] installed (following the [Official Release Policy][5])
35+
- Your service framework and tools are [compatible][2] with the [Application & API Protection (AAP)][1] product.
36+
- Your deployment environment is [supported][5].
37+
- You have one of the latest two version of [Go][4] installed (following the [Official Release Policy][5]).
3738

38-
## Enabling threat detection
39+
## Enabling Application & API Protection (AAP)
3940
### Get started
4041

41-
1. **Add to your program's go.mod dependencies** the latest version of the Datadog Go library (version 1.53.0 or later). {{% tracing-go-v2 %}}
42+
1. **Install Orchestrion**:
4243

43-
```shell
44-
$ go get -v -u github.com/DataDog/dd-trace-go/v2/ddtrace/tracer
44+
```console
45+
$ go install github.com/DataDog/orchestrion@latest
46+
```
47+
48+
2. **Register Orchestrion as a Go module** in your project directory:
49+
```console
50+
$ orchestrion pin
4551
```
4652

47-
2. Datadog has a series of pluggable packages which provide out-of-the-box support for instrumenting a series of Go libraries and frameworks.
48-
A list of these packages can be found in the [compatibility requirements][1] page. Import these packages into your application and follow the configuration instructions listed alongside each integration.
53+
3. Datadog has a series of pluggable packages which provide out-of-the-box support for instrumenting a series of Go libraries and frameworks.
54+
A list of these packages can be found in the [compatibility requirements][1] page.
55+
Import these packages into your application and follow the configuration instructions listed alongside each integration.
4956

50-
3. **Recompile your program** with AAP enabled:
57+
4. **Recompile your program** with Orchestrion:
5158
```console
52-
$ go build -v -tags appsec my-program
59+
$ orchestrion go build my-program
5360
```
61+
More options on how to use orchestrion can be found in the [Orchestrion usage][7].
5462

55-
**Notes**:
56-
- The Go build tag `appsec` is not necessary if CGO is enabled with `CGO_ENABLED=1`.
57-
- Datadog WAF needs the following shared libraries on Linux: `libc.so.6` and `libpthread.so.0`.
58-
- When using the build tag `appsec` and CGO is disabled, the produced binary is still linked dynamically to these libraries.
59-
- The Go build tag `datadog.no_waf` can be used to disable AAP at build time in any situation where the requirements above are a hinderance.
63+
Note: If you are building without CGO on linux. Please read [Building Go applications with CGO disabled][6] for more information.
6064

61-
4. **Redeploy your Go service and enable AAP** by setting the `DD_APPSEC_ENABLED` environment variable to `true`:
65+
5. **Redeploy your Go service and enable AAP** by setting the `DD_APPSEC_ENABLED` environment variable to `true`:
6266
```console
6367
$ env DD_APPSEC_ENABLED=true ./my-program
6468
```
@@ -83,7 +87,7 @@ Add the following environment variable value to your application container's Doc
8387
ENV DD_APPSEC_ENABLED=true
8488
```
8589

86-
A more detailed guide on how to create a fiting dockerfile is available [here][3]
90+
A more detailed guide on how to create a fitting dockerfile is available [here][3].
8791

8892
{{% /tab %}}
8993
{{% tab "Kubernetes" %}}
@@ -121,10 +125,28 @@ Update your application's ECS task definition JSON file, by adding this in the e
121125

122126
{{< /tabs >}}
123127

128+
{{% app_and_api_protection_verify_setup %}}
129+
124130
{{% appsec-getstarted-2 %}}
125131

126132
{{< img src="/security/application_security/appsec-getstarted-threat-and-vuln_2.mp4" alt="Video showing Signals explorer and details, and Vulnerabilities explorer and details." video="true" >}}
127133

134+
### Building without CGO
135+
136+
If you are building your Go application without CGO, you can still enable AAP by following these steps:
137+
138+
1. **Add the `appsec` build tag** when compiling your application:
139+
```console
140+
$ CGO_ENABLED=0 orchestrion go build -tags appsec my-program
141+
```
142+
143+
Using `CGO_ENABLED=0` usually guarantees a statically-linked binary. This will NOT be the case in this setup.
144+
145+
2. **Install `libc.so.6` and `libpthread.so.0`** on your system, as these libraries are required by the Datadog WAF:
146+
This can be done by installing the `glibc` package on your system via your package manager. Read more on [Creating a Dockerfile for AAP][3]
147+
148+
3. **Redeploy your Go service** with the `DD_APPSEC_ENABLED=true` environment variable set, as described above.
149+
128150
## Using AAP without APM tracing
129151

130152
If you want to use Application & API Protection without APM tracing functionality, you can deploy with tracing disabled:
@@ -144,3 +166,5 @@ For more details, see [Standalone App and API Protection][standalone_billing_gui
144166
[3]: /security/application_security/setup/go/dockerfile
145167
[4]: https://go.dev/
146168
[5]: https://go.dev/doc/devel/release#policy
169+
[6]: /security/application_security/setup/go#building-without-cgo
170+
[7]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/go/?tab=compiletimeinstrumentation#usage

content/en/security/application_security/setup/go/dockerfile.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ further_reading:
1818
# Introdution
1919

2020
App and API Protection for Go installation requirements can be abstract and the Go toolchain
21-
cross-compilations capabilities can make it hard to understand what as to be do precisely.
21+
cross-compilations capabilities can make it hard to understand what has to be done precisely.
2222

23-
In these cases, a more precise way to materialized these examples like a Dockerfile can be interesting.
24-
The goal of this guide is to step by step on a working Dockerfile.
23+
In these cases, a more precise way to materialize these examples like a Dockerfile can be interesting.
24+
The goal of this guide is to be a step-by-step guide to a working Dockerfile.
2525

2626
## Wallthrough
2727

@@ -41,8 +41,10 @@ FROM golang AS build
4141
WORKDIR /app
4242
COPY . .
4343

44-
# The appsec build tag is optional if CGO is enabled
45-
RUN go build -v -tags appsec -o main .
44+
RUN go install github.com/DataDog/orchestrion@latest
45+
46+
# The appsec build tag is mandatory if CGO is disabled, which is the default in alpine.
47+
RUN orchestrion go build -v -tags appsec -o main .
4648

4749
FROM alpine
4850
COPY --from=build /app/main /usr/local/bin
@@ -58,6 +60,7 @@ ENTRYPOINT [ "/usr/local/bin/main" ]
5860
```
5961

6062
Multiple remarks can be made here:
63+
* The first stage uses [Orchestrion][5] compile-time instrumentation to instrument the Go application with the App and API Protection features.
6164
* The flag `-tags appsec` or CGO being enabled are requirements at build time for C++ Datadog's WAF. If none of these requirements are met, your service will be marked as not compatible is Datadog's UI.
6265
* the `libc6-compat` package is required because Datadog's WAF needs the following shared libraries on Linux: `libc.so.6` and `libpthread.so.0`. If you are using `CGO_ENABLED=0` and `-tags` appsec at the same time and those shared libraries are not present at runtime you app will refuse to start with the error `No such file or directory`.
6366

@@ -84,3 +87,4 @@ If you encounter issues while setting up App and API Protection for your applica
8487
[2]: /security/application_security/setup/go/troubleshooting
8588
[3]: https://github.com/DataDog/appsec-go-test-app/blob/main/examples/docker
8689
[4]: https://github.com/DataDog/appsec-go-test-app
90+
[5]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/go/?tab=compiletimeinstrumentation

content/en/security/application_security/setup/go/troubleshooting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ TODO
2828

2929
If you're still experiencing problems:
3030
1. Check the [Application Security Monitoring troubleshooting guide][1]
31-
2. Review the [Java tracer documentation][2]
31+
2. Review the [Go tracer documentation][2]
3232
3. Contact [Datadog support][3]
3333

3434
[1]: /security/application_security/troubleshooting
35-
[2]: /tracing/trace_collection/compatibility/java
35+
[2]: /tracing/trace_collection/compatibility/go
3636
[3]: /help

0 commit comments

Comments
 (0)