/
appsec.go
28 lines (23 loc) · 972 Bytes
/
appsec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2022 Datadog, Inc.
//go:build appsec
// +build appsec
package appsec
import (
"golang.org/x/net/context"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
"gopkg.in/DataDog/dd-trace-go.v1/internal/appsec"
"gopkg.in/DataDog/dd-trace-go.v1/internal/appsec/dyngo/instrumentation/httpsec"
)
// MonitorParsedBody is an SDK solution for users to ask AppSec to perform rule matching on the parsed request body.
// `body`: the parsed body value to be used for rule matching.
// `ctx`: the context of the http.Request that for which the matching is to be performed.
func MonitorParsedBody(ctx context.Context, body interface{}) {
if appsec.Enabled() {
if span, ok := tracer.SpanFromContext(ctx); ok {
httpsec.MonitorParsedBody(span, body)
}
}
}