Skip to content

Commit

Permalink
suggestions from @Julio-Guerra
Browse files Browse the repository at this point in the history
Signed-off-by: Eliott Bouhana <[email protected]>
  • Loading branch information
eliottness committed Dec 19, 2024
1 parent d400974 commit 2be912c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ddtrace/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ func (t *tracer) Inject(ctx ddtrace.SpanContext, carrier interface{}) error {

if t.config.tracingAsTransport {
// in tracing as transport mode, only propagate when there is an upstream appsec event
// TODO: replace with _dd.p.ts in the next iteration standardizing this for other products, comparing enabled products in `t.config` with their corresponding `_dd.p.ts` bitfields
if ctx, ok := ctx.(*spanContext); ok && ctx.trace != nil && ctx.trace.propagatingTag("_dd.p.appsec") != "1" {
return nil
}
Expand Down Expand Up @@ -784,6 +785,7 @@ func (t *tracer) Extract(carrier interface{}) (ddtrace.SpanContext, error) {
ctx, err := t.config.propagator.Extract(carrier)
if t.config.tracingAsTransport {
// in tracing as transport mode, reset upstream sampling decision to make sure we keep 1 trace/minute
// TODO: replace with _dd.p.ts in the next iteration standardizing this for other products, comparing enabled products in `t.config` with their corresponding `_dd.p.ts` bitfields
if ctx, ok := ctx.(*spanContext); ok && ctx.trace.propagatingTag("_dd.p.appsec") != "1" {
ctx.trace.priority = nil
}
Expand Down
8 changes: 4 additions & 4 deletions internal/appsec/listener/waf/waf.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ func (waf *Feature) onStart(op *waf.ContextOperation, _ waf.ContextArgs) {

func (*Feature) SetupActionHandlers(op *waf.ContextOperation) {
// Set the blocking tag on the operation when a blocking event is received
dyngo.OnData(op, func(_ *events.BlockingSecurityEvent) {
dyngo.OnData(op, func(*events.BlockingSecurityEvent) {
log.Debug("appsec: blocking event detected")
op.SetTag(BlockedRequestTag, true)
})

// Register the stacktrace if one is requested by a WAF action
dyngo.OnData(op, func(err *actions.StackTraceAction) {
dyngo.OnData(op, func(action *actions.StackTraceAction) {
log.Debug("appsec: registering stack trace for security purposes")
op.AddStackTraces(err.Event)
op.AddStackTraces(action.Event)
})

dyngo.OnData(op, func(_ *waf.SecurityEvent) {
dyngo.OnData(op, func(*waf.SecurityEvent) {
log.Debug("appsec: WAF detected a suspicious event")
SetEventSpanTags(op)
})
Expand Down

0 comments on commit 2be912c

Please sign in to comment.