Skip to content

Commit

Permalink
Add missing checks for an active request context
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-alvarez-alvarez committed Mar 14, 2024
1 parent bf8602f commit e78a54c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import datadog.trace.api.iast.Source;
import datadog.trace.api.iast.SourceTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;

/**
* Detects when a header name is directly called from user code. This uses call site instrumentation
Expand All @@ -27,7 +28,7 @@ public static String after(@CallSite.This HttpHeader header, @CallSite.Return St
return result;
}
try {
final IastContext ctx = IastContext.Provider.get();
final IastContext ctx = IastContext.Provider.get(AgentTracer.activeSpan());
if (ctx == null) {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datadog.trace.api.iast.Source;
import datadog.trace.api.iast.SourceTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import org.apache.pekko.http.javadsl.model.HttpHeader;

/**
Expand All @@ -28,7 +29,7 @@ public static String after(@CallSite.This HttpHeader header, @CallSite.Return St
return result;
}
try {
final IastContext ctx = IastContext.Provider.get();
final IastContext ctx = IastContext.Provider.get(AgentTracer.activeSpan());
if (ctx == null) {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datadog.trace.api.iast.Source;
import datadog.trace.api.iast.SourceTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import jakarta.servlet.http.HttpServletRequest;

/**
Expand All @@ -30,7 +31,7 @@ public static String afterPath(
final PropagationModule module = InstrumentationBridge.PROPAGATION;
if (module != null) {
try {
final IastContext ctx = IastContext.Provider.get();
final IastContext ctx = IastContext.Provider.get(AgentTracer.activeSpan());
if (ctx != null) {
module.taint(ctx, retValue, SourceTypes.REQUEST_PATH);
}
Expand All @@ -52,7 +53,7 @@ public static StringBuffer afterGetRequestURL(
final PropagationModule module = InstrumentationBridge.PROPAGATION;
if (module != null) {
try {
final IastContext ctx = IastContext.Provider.get();
final IastContext ctx = IastContext.Provider.get(AgentTracer.activeSpan());
if (ctx != null) {
module.taint(ctx, retValue, SourceTypes.REQUEST_URI);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datadog.trace.api.iast.Source;
import datadog.trace.api.iast.SourceTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import javax.servlet.http.HttpServletRequest;

/**
Expand All @@ -30,7 +31,7 @@ public static String afterPath(
final PropagationModule module = InstrumentationBridge.PROPAGATION;
if (module != null) {
try {
final IastContext ctx = IastContext.Provider.get();
final IastContext ctx = IastContext.Provider.get(AgentTracer.activeSpan());
if (ctx != null) {
module.taint(ctx, retValue, SourceTypes.REQUEST_PATH);
}
Expand All @@ -52,7 +53,7 @@ public static StringBuffer afterGetRequestURL(
final PropagationModule module = InstrumentationBridge.PROPAGATION;
if (module != null) {
try {
final IastContext ctx = IastContext.Provider.get();
final IastContext ctx = IastContext.Provider.get(AgentTracer.activeSpan());
if (ctx != null) {
module.taint(ctx, retValue, SourceTypes.REQUEST_URI);
}
Expand Down

0 comments on commit e78a54c

Please sign in to comment.