Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
smola committed Nov 25, 2024
1 parent 4925a50 commit c994881
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ private static InetAddress doResolve(AgentSpan.Context.Extracted context, Mutabl
result = coalesce(result, addr);
}

addr = tryHeader(context.getXForwarded(), FORWARDED_PARSER);
if (addr != null) {
if (!isIpAddrPrivate(addr)) {
return addr;
}
result = coalesce(result, addr);
}

addr = tryHeader(context.getForwardedFor(), PLAIN_IP_ADDRESS_PARSER);
if (addr != null) {
if (!isIpAddrPrivate(addr)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ class ClientIpAddressResolverSpecification extends Specification {
'x-real-ip' | '42' | '0.0.0.42'

'x-client-ip' | '2.2.2.2' | '2.2.2.2'
'x-forwarded' | 'for="[2001::1]:1111"' | '2001::1'
'x-forwarded' | 'fOr="[2001::1]:1111"' | '2001::1'
'x-forwarded' | 'for=some_host' | null
'x-forwarded' | 'for=127.0.0.1, FOR=1.1.1.1' | '1.1.1.1'
'x-forwarded' |'for="\"foobar";proto=http,FOR="1.1.1.1"' | '1.1.1.1'
'x-forwarded' | 'for="8.8.8.8:2222",' | '8.8.8.8'
'x-forwarded' | 'for="8.8.8.8' | null // quote not closed
'x-forwarded' | 'far="8.8.8.8",for=4.4.4.4;' | '4.4.4.4'
'x-forwarded' | ' for=127.0.0.1,for= for=,for=;"for = for="" ,; for=8.8.8.8;' | '8.8.8.8'

'x-cluster-client-ip' | '2.2.2.2' | '2.2.2.2'

Expand Down Expand Up @@ -119,9 +110,6 @@ class ClientIpAddressResolverSpecification extends Specification {
then:
1 * context.getXClientIp() >> null

then:
1 * context.getXForwarded() >> null

then:
1 * context.getForwardedFor() >> null

Expand Down Expand Up @@ -174,7 +162,6 @@ class ClientIpAddressResolverSpecification extends Specification {
1 * context.getXForwardedFor() >> '127.0.0.1'
1 * context.getXRealIp() >> '127.0.0.2'
1 * context.getXClientIp() >> '127.0.0.3'
1 * context.getXForwarded() >> 'for=127.0.0.4'
1 * context.getXClusterClientIp() >> '127.0.0.5'
1 * context.getForwardedFor() >> '127.0.0.6'
1 * context.getTrueClientIp() >> '127.0.0.9'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
def request = new Request.Builder()
.url(url)
.addHeader("User-Agent", "Arachni/v1")
.addHeader("X-Forwarded", 'for="[::ffff:1.2.3.4]"')
.addHeader("X-Forwarded-For", '[::ffff:1.2.3.4]')
.build()
def response = client.newCall(request).execute()
def responseBodyStr = response.body().string()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import static datadog.trace.core.propagation.HttpCodec.X_CLUSTER_CLIENT_IP_KEY;
import static datadog.trace.core.propagation.HttpCodec.X_FORWARDED_FOR_KEY;
import static datadog.trace.core.propagation.HttpCodec.X_FORWARDED_HOST_KEY;
import static datadog.trace.core.propagation.HttpCodec.X_FORWARDED_KEY;
import static datadog.trace.core.propagation.HttpCodec.X_FORWARDED_PORT_KEY;
import static datadog.trace.core.propagation.HttpCodec.X_FORWARDED_PROTO_KEY;
import static datadog.trace.core.propagation.HttpCodec.X_REAL_IP_KEY;
Expand Down Expand Up @@ -122,10 +121,6 @@ protected final boolean handledXForwarding(String key, String value) {
getHeaders().xForwardedPort = value;
return true;
}
if (X_FORWARDED_KEY.equalsIgnoreCase(key)) {
getHeaders().xForwarded = value;
return true;
}
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class HttpCodec {
static final String FORWARDED_FOR_KEY = "forwarded-for";
static final String X_FORWARDED_PROTO_KEY = "x-forwarded-proto";
static final String X_FORWARDED_HOST_KEY = "x-forwarded-host";
static final String X_FORWARDED_KEY = "x-forwarded";
static final String X_FORWARDED_FOR_KEY = "x-forwarded-for";
static final String X_FORWARDED_PORT_KEY = "x-forwarded-port";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ interface Extracted extends Context {

String getForwardedFor();

String getXForwarded();

String getXForwardedFor();

String getXClusterClientIp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,6 @@ public String getForwardedFor() {
return null;
}

@Override
public String getXForwarded() {
return null;
}

@Override
public String getXForwardedFor() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ public String getForwardedFor() {
return httpHeaders.forwardedFor;
}

@Override
public String getXForwarded() {
return httpHeaders.xForwarded;
}

@Override
public String getXForwardedFor() {
return httpHeaders.xForwardedFor;
Expand Down Expand Up @@ -264,12 +259,11 @@ public static class HttpHeaders {
public String fastlyClientIp;
public String cfConnectingIp;
public String cfConnectingIpv6;
public String xForwarded;
public String forwarded;
public String xForwardedProto;
public String xForwardedHost;
public String xForwardedPort;
public String xForwardedFor;
public String forwarded;
public String forwardedFor;
public String xClusterClientIp;
public String xRealIp;
Expand Down

0 comments on commit c994881

Please sign in to comment.