Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove propagation from IAST metrics #5161

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import datadog.trace.agent.tooling.csi.CallSite;
import datadog.trace.api.iast.IastAdvice;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.propagation.CodecModule;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.codec.binary.Base64;

@IastAdvice.Propagation(PropagationTypes.STRING)
@IastAdvice.Propagation
@CallSite(spi = IastAdvice.class)
// TODO complete propagation support
public class Base64CallSite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import datadog.trace.api.iast.IastAdvice;
import datadog.trace.api.iast.IastAdvice.Propagation;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.propagation.StringModule;

@Propagation(PropagationTypes.STRING)
@Propagation
@CallSite(spi = IastAdvice.class, minJavaVersion = 11)
public class StringCallSite {
@CallSite.After("java.lang.String java.lang.String.repeat(int)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import datadog.trace.api.iast.IastAdvice;
import datadog.trace.api.iast.IastAdvice.Propagation;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.propagation.StringModule;
import de.thetaphi.forbiddenapis.SuppressForbidden;
import java.lang.invoke.ConstantCallSite;
Expand All @@ -22,7 +21,7 @@
import org.slf4j.LoggerFactory;

@SuppressForbidden
@Propagation(PropagationTypes.STRING)
@Propagation
@CallSite(spi = IastAdvice.class, minJavaVersion = 9)
public class StringConcatFactoryCallSite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import datadog.trace.api.iast.IastAdvice;
import datadog.trace.api.iast.IastAdvice.Propagation;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.propagation.StringModule;
import datadog.trace.util.stacktrace.StackUtils;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@Propagation(PropagationTypes.STRING)
@Propagation
@CallSite(spi = IastAdvice.class)
public class StringBuilderCallSite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import datadog.trace.api.iast.IastAdvice;
import datadog.trace.api.iast.IastAdvice.Propagation;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.propagation.CodecModule;
import datadog.trace.api.iast.propagation.StringModule;
import datadog.trace.util.stacktrace.StackUtils;
Expand All @@ -15,7 +14,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@Propagation(PropagationTypes.STRING)
@Propagation
@CallSite(spi = IastAdvice.class)
public class StringCallSite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import datadog.trace.agent.tooling.csi.CallSite;
import datadog.trace.api.iast.IastAdvice;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import java.net.URI;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@IastAdvice.Propagation(PropagationTypes.URI)
@IastAdvice.Propagation
@CallSite(spi = IastAdvice.class)
public class URICallSite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import datadog.trace.api.iast.IastAdvice.Propagation;
import datadog.trace.api.iast.IastAdvice.Sink;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.VulnerabilityTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import datadog.trace.api.iast.sink.SsrfModule;
Expand All @@ -17,7 +16,7 @@
@CallSite(spi = IastAdvice.class)
public class URLCallSite {

@Propagation(PropagationTypes.URL)
@Propagation
@CallSite.After("void java.net.URL.<init>(java.lang.String)")
@CallSite.After(
"void java.net.URL.<init>(java.lang.String, java.lang.String, int, java.lang.String)")
Expand All @@ -42,7 +41,7 @@ public static URL afterCtor(
return result;
}

@Propagation(PropagationTypes.URL)
@Propagation
@CallSite.After("java.lang.String java.net.URL.toString()")
@CallSite.After("java.lang.String java.net.URL.toExternalForm()")
public static String afterToString(
Expand All @@ -58,7 +57,7 @@ public static String afterToString(
return result;
}

@Propagation(PropagationTypes.URL)
@Propagation
@CallSite.After("java.net.URI java.net.URL.toURI()")
public static URI afterToURI(@CallSite.This final URL url, @CallSite.Return final URI result) {
final PropagationModule module = InstrumentationBridge.PROPAGATION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import datadog.trace.api.iast.IastAdvice;
import datadog.trace.api.iast.IastAdvice.Propagation;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.propagation.CodecModule;
import javax.annotation.Nullable;

@Propagation(PropagationTypes.URL)
@Propagation
@CallSite(spi = IastAdvice.class)
public class URLDecoderCallSite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import datadog.trace.api.iast.IastAdvice.Propagation;
import datadog.trace.api.iast.IastAdvice.Source;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.SourceTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import datadog.trace.api.iast.source.WebModule;
Expand Down Expand Up @@ -108,7 +107,7 @@ public static Enumeration<String> afterGetHeaderNames(
}
}

@Propagation(PropagationTypes.COOKIE)
@Propagation
@CallSite.After("javax.servlet.http.Cookie[] javax.servlet.http.HttpServletRequest.getCookies()")
@CallSite.After(
"javax.servlet.http.Cookie[] javax.servlet.http.HttpServletRequestWrapper.getCookies()")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import datadog.trace.api.iast.IastAdvice.Propagation;
import datadog.trace.api.iast.IastAdvice.Source;
import datadog.trace.api.iast.InstrumentationBridge;
import datadog.trace.api.iast.PropagationTypes;
import datadog.trace.api.iast.SourceTypes;
import datadog.trace.api.iast.propagation.PropagationModule;
import datadog.trace.api.iast.source.WebModule;
Expand Down Expand Up @@ -103,7 +102,7 @@ public static String[] afterGetParameterValues(
return parameterValues;
}

@Propagation(PropagationTypes.BODY)
@Propagation
@CallSite.After("javax.servlet.ServletInputStream javax.servlet.ServletRequest.getInputStream()")
@CallSite.After(
"javax.servlet.ServletInputStream javax.servlet.http.HttpServletRequest.getInputStream()")
Expand All @@ -125,7 +124,7 @@ public static ServletInputStream afterGetInputStream(
return inputStream;
}

@Propagation(PropagationTypes.BODY)
@Propagation
@CallSite.After("java.io.BufferedReader javax.servlet.ServletRequest.getReader()")
@CallSite.After("java.io.BufferedReader javax.servlet.http.HttpServletRequest.getReader()")
@CallSite.After("java.io.BufferedReader javax.servlet.http.HttpServletRequestWrapper.getReader()")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public interface IastAdvice {
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@interface Propagation {
/** Propagation type (STRING, JSON, URL ...) */
String value();

Kind kind() default Kind.PROPAGATION;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import static datadog.trace.api.iast.telemetry.IastMetric.Scope.GLOBAL;
import static datadog.trace.api.iast.telemetry.IastMetric.Scope.REQUEST;
import static datadog.trace.api.iast.telemetry.IastMetric.Tags.PROPAGATION_TYPE;
import static datadog.trace.api.iast.telemetry.IastMetric.Tags.SOURCE_TYPE;
import static datadog.trace.api.iast.telemetry.IastMetric.Tags.VULNERABILITY_TYPE;
import static datadog.trace.api.iast.telemetry.Verbosity.DEBUG;
import static datadog.trace.api.iast.telemetry.Verbosity.INFORMATION;
import static datadog.trace.api.iast.telemetry.Verbosity.MANDATORY;

public enum IastMetric {
INSTRUMENTED_PROPAGATION("instrumented.propagation", true, GLOBAL, MANDATORY, PROPAGATION_TYPE),
INSTRUMENTED_PROPAGATION("instrumented.propagation", true, GLOBAL, MANDATORY),
INSTRUMENTED_SOURCE("instrumented.source", true, GLOBAL, MANDATORY, SOURCE_TYPE),
INSTRUMENTED_SINK("instrumented.sink", true, GLOBAL, MANDATORY, VULNERABILITY_TYPE),
EXECUTED_PROPAGATION("executed.propagation", true, REQUEST, DEBUG, PROPAGATION_TYPE),
EXECUTED_PROPAGATION("executed.propagation", true, REQUEST, DEBUG),
EXECUTED_SOURCE("executed.source", true, REQUEST, INFORMATION, SOURCE_TYPE),
EXECUTED_SINK("executed.sink", true, REQUEST, INFORMATION, VULNERABILITY_TYPE),
EXECUTED_TAINTED("executed.tainted", true, REQUEST, DEBUG),
Expand Down Expand Up @@ -75,8 +74,6 @@ private Tags() {}

public static final String VULNERABILITY_TYPE = "vulnerability_type";
public static final String SOURCE_TYPE = "source_type";

public static final String PROPAGATION_TYPE = "propagation_type";
}

public enum Scope {
Expand Down