Skip to content

Commit

Permalink
Rename helpers, instrumentations, tests and refactor folders to speci…
Browse files Browse the repository at this point in the history
…fy versions
  • Loading branch information
Mariovido committed Sep 16, 2024
1 parent 4924ac1 commit 622d2a6
Show file tree
Hide file tree
Showing 29 changed files with 127 additions and 100 deletions.
3 changes: 3 additions & 0 deletions dd-java-agent/instrumentation/jackson-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ dependencies {

testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion)
testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion)

latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.+'
latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.+'
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ dependencies {

testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion)
testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion)

latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.15.+'
latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.15.+'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fasterxml.jackson.core.json;

import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer212Helper;

public final class JsonParser212Helper {
private JsonParser212Helper() {}

public static boolean fetchIntern(UTF8StreamJsonParser jsonParser) {
return ByteQuadsCanonicalizer212Helper.fetchIntern(jsonParser._symbols);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.fasterxml.jackson.core.sym;

public final class ByteQuadsCanonicalizer2_6Helper {
private ByteQuadsCanonicalizer2_6Helper() {}
public final class ByteQuadsCanonicalizer212Helper {
private ByteQuadsCanonicalizer212Helper() {}

public static boolean fetchIntern(ByteQuadsCanonicalizer symbols) {
return symbols._intern;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package datadog.trace.instrumentation.jackson.core;
package datadog.trace.instrumentation.jackson_2_12.core;

import static datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers.hasClassNamed;
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.declaresMethod;
Expand All @@ -11,7 +11,7 @@

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.json.Json2_12ParserHelper;
import com.fasterxml.jackson.core.json.JsonParser212Helper;
import com.fasterxml.jackson.core.json.UTF8StreamJsonParser;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
Expand All @@ -26,21 +26,21 @@
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumenterModule.class)
public class Json2_12ParserInstrumentation extends InstrumenterModule.Iast
public class JsonParserInstrumentation extends InstrumenterModule.Iast
implements Instrumenter.ForTypeHierarchy {

static final String TARGET_TYPE = "com.fasterxml.jackson.core.JsonParser";
static final ElementMatcher.Junction<ClassLoader> VERSION_POST_2_8_0_AND_PRE_2_12_0 =
hasClassNamed("com.fasterxml.jackson.core.StreamReadCapability")
.and(not(hasClassNamed("com.fasterxml.jackson.core.StreamWriteConstraints")));

public Json2_12ParserInstrumentation() {
public JsonParserInstrumentation() {
super("jackson", "jackson-2_12");
}

@Override
public void methodAdvice(MethodTransformer transformer) {
final String className = Json2_12ParserInstrumentation.class.getName();
final String className = JsonParserInstrumentation.class.getName();
transformer.applyAdvice(
namedOneOf("getCurrentName", "nextFieldName")
.and(isPublic())
Expand Down Expand Up @@ -75,8 +75,8 @@ public Map<String, String> contextStore() {
@Override
public String[] helperClassNames() {
return new String[] {
"com.fasterxml.jackson.core.json" + ".Json2_12ParserHelper",
"com.fasterxml.jackson.core.sym" + ".ByteQuadsCanonicalizer2_12Helper",
"com.fasterxml.jackson.core.json" + ".JsonParser212Helper",
"com.fasterxml.jackson.core.sym" + ".ByteQuadsCanonicalizer212Helper",
};
}

Expand All @@ -92,7 +92,7 @@ public static void onExit(@Advice.This JsonParser jsonParser, @Advice.Return Str
InstrumentationContext.get(JsonParser.class, NamedContext.class);
final NamedContext context = NamedContext.getOrCreate(store, jsonParser);
if (jsonParser instanceof UTF8StreamJsonParser
&& Json2_12ParserHelper.fetchIntern((UTF8StreamJsonParser) jsonParser)) {
&& JsonParser212Helper.fetchIntern((UTF8StreamJsonParser) jsonParser)) {
context.setCurrentName(result);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package datadog.trace.instrumentation.jackson212.core

import com.fasterxml.jackson.databind.ObjectMapper
import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.iast.InstrumentationBridge
Expand All @@ -8,7 +10,7 @@ import groovy.json.JsonOutput

import java.nio.charset.Charset

class Json12ParserInstrumentationTest extends AgentTestRunner {
class JsonParserInstrumentationTest extends AgentTestRunner {

private final static String JSON_STRING = '{"root":"root_value","nested":{"nested_array":["array_0","array_1"]}}'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ muzzle {
group = 'com.fasterxml.jackson.core'
module = 'jackson-core'
versions = "[2.16.0,)"
// assertInverse = true
}
}

Expand All @@ -18,4 +17,7 @@ dependencies {

testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion)
testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion)

latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.+'
latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.+'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fasterxml.jackson.core.json;

import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer216Helper;

public final class JsonParser216Helper {
private JsonParser216Helper() {}

public static boolean fetchInterner(UTF8StreamJsonParser jsonParser) {
return ByteQuadsCanonicalizer216Helper.fetchInterner(jsonParser._symbols);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.fasterxml.jackson.core.sym;

public final class ByteQuadsCanonicalizer2_16Helper {
private ByteQuadsCanonicalizer2_16Helper() {}
public final class ByteQuadsCanonicalizer216Helper {
private ByteQuadsCanonicalizer216Helper() {}

public static boolean fetchInterner(ByteQuadsCanonicalizer symbols) {
return symbols._interner != null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package datadog.trace.instrumentation.jackson.core;
package datadog.trace.instrumentation.jackson_2_16.core;

import static datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers.hasClassNamed;
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.declaresMethod;
Expand All @@ -11,7 +11,7 @@

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.json.Json2_16ParserHelper;
import com.fasterxml.jackson.core.json.JsonParser216Helper;
import com.fasterxml.jackson.core.json.UTF8StreamJsonParser;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
Expand All @@ -26,20 +26,20 @@
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumenterModule.class)
public class Json2_16ParserInstrumentation extends InstrumenterModule.Iast
public class JsonParserInstrumentation extends InstrumenterModule.Iast
implements Instrumenter.ForTypeHierarchy {

static final String TARGET_TYPE = "com.fasterxml.jackson.core.JsonParser";
static final ElementMatcher.Junction<ClassLoader> VERSION_POST_2_16_0 =
hasClassNamed("com.fasterxml.jackson.core.StreamWriteConstraints");

public Json2_16ParserInstrumentation() {
public JsonParserInstrumentation() {
super("jackson", "jackson-2_16");
}

@Override
public void methodAdvice(MethodTransformer transformer) {
final String className = Json2_16ParserInstrumentation.class.getName();
final String className = JsonParserInstrumentation.class.getName();
transformer.applyAdvice(
namedOneOf("getCurrentName", "nextFieldName")
.and(isPublic())
Expand Down Expand Up @@ -74,8 +74,8 @@ public Map<String, String> contextStore() {
@Override
public String[] helperClassNames() {
return new String[] {
"com.fasterxml.jackson.core.json" + ".Json2_16ParserHelper",
"com.fasterxml.jackson.core.sym" + ".ByteQuadsCanonicalizer2_16Helper",
"com.fasterxml.jackson.core.json" + ".JsonParser216Helper",
"com.fasterxml.jackson.core.sym" + ".ByteQuadsCanonicalizer216Helper",
};
}

Expand All @@ -91,7 +91,7 @@ public static void onExit(@Advice.This JsonParser jsonParser, @Advice.Return Str
InstrumentationContext.get(JsonParser.class, NamedContext.class);
final NamedContext context = NamedContext.getOrCreate(store, jsonParser);
if (jsonParser instanceof UTF8StreamJsonParser
&& Json2_16ParserHelper.fetchInterner((UTF8StreamJsonParser) jsonParser)) {
&& JsonParser216Helper.fetchInterner((UTF8StreamJsonParser) jsonParser)) {
context.setCurrentName(result);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package datadog.trace.instrumentation.jackson216.core

import com.fasterxml.jackson.databind.ObjectMapper
import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.iast.InstrumentationBridge
Expand All @@ -8,7 +10,7 @@ import groovy.json.JsonOutput

import java.nio.charset.Charset

class Json216ParserInstrumentationTest extends AgentTestRunner {
class JsonParserInstrumentationTest extends AgentTestRunner {

private final static String JSON_STRING = '{"root":"root_value","nested":{"nested_array":["array_0","array_1"]}}'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ dependencies {

testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion)
testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion)

latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.7.+'
latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.+'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fasterxml.jackson.core.json;

import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer26Helper;

public final class JsonParser26Helper {
private JsonParser26Helper() {}

public static boolean fetchIntern(UTF8StreamJsonParser jsonParser) {
return ByteQuadsCanonicalizer26Helper.fetchIntern(jsonParser._symbols);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.fasterxml.jackson.core.sym;

public final class ByteQuadsCanonicalizer2_12Helper {
private ByteQuadsCanonicalizer2_12Helper() {}
public final class ByteQuadsCanonicalizer26Helper {
private ByteQuadsCanonicalizer26Helper() {}

public static boolean fetchIntern(ByteQuadsCanonicalizer symbols) {
return symbols._intern;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package datadog.trace.instrumentation.jackson.core;
package datadog.trace.instrumentation.jackson_2_6.core;

import static datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers.hasClassNamed;
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.declaresMethod;
Expand All @@ -11,7 +11,7 @@

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.json.Json2_6ParserHelper;
import com.fasterxml.jackson.core.json.JsonParser26Helper;
import com.fasterxml.jackson.core.json.UTF8StreamJsonParser;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
Expand All @@ -26,21 +26,21 @@
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumenterModule.class)
public class Json2_6ParserInstrumentation extends InstrumenterModule.Iast
public class JsonParserInstrumentation extends InstrumenterModule.Iast
implements Instrumenter.ForTypeHierarchy {

static final String TARGET_TYPE = "com.fasterxml.jackson.core.JsonParser";
static final ElementMatcher.Junction<ClassLoader> VERSION_POST_2_6_0_AND_PRE_2_8_0 =
hasClassNamed("com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer")
.and(not(hasClassNamed("com.fasterxml.jackson.core.JsonpCharacterEscapes")));

public Json2_6ParserInstrumentation() {
public JsonParserInstrumentation() {
super("jackson", "jackson-2_6");
}

@Override
public void methodAdvice(MethodTransformer transformer) {
final String className = Json2_6ParserInstrumentation.class.getName();
final String className = JsonParserInstrumentation.class.getName();
transformer.applyAdvice(
namedOneOf("getCurrentName", "nextFieldName")
.and(isPublic())
Expand Down Expand Up @@ -75,8 +75,8 @@ public Map<String, String> contextStore() {
@Override
public String[] helperClassNames() {
return new String[] {
"com.fasterxml.jackson.core.json" + ".Json2_6ParserHelper",
"com.fasterxml.jackson.core.sym" + ".ByteQuadsCanonicalizer2_6Helper",
"com.fasterxml.jackson.core.json" + ".JsonParser26Helper",
"com.fasterxml.jackson.core.sym" + ".ByteQuadsCanonicalizer26Helper",
};
}

Expand All @@ -92,7 +92,7 @@ public static void onExit(@Advice.This JsonParser jsonParser, @Advice.Return Str
InstrumentationContext.get(JsonParser.class, NamedContext.class);
final NamedContext context = NamedContext.getOrCreate(store, jsonParser);
if (jsonParser instanceof UTF8StreamJsonParser
&& Json2_6ParserHelper.fetchIntern((UTF8StreamJsonParser) jsonParser)) {
&& JsonParser26Helper.fetchIntern((UTF8StreamJsonParser) jsonParser)) {
context.setCurrentName(result);
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package datadog.trace.instrumentation.jackson26.core

import com.fasterxml.jackson.databind.ObjectMapper
import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.api.iast.InstrumentationBridge
Expand All @@ -8,7 +10,7 @@ import groovy.json.JsonOutput

import java.nio.charset.Charset

class Json8ParserInstrumentationTest extends AgentTestRunner {
class JsonParserInstrumentationTest extends AgentTestRunner {

private final static String JSON_STRING = '{"root":"root_value","nested":{"nested_array":["array_0","array_1"]}}'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ dependencies {

testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion)
testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion)

latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.11.+'
latestDepTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.+'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fasterxml.jackson.core.json;

import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer28Helper;

public final class JsonParser28Helper {
private JsonParser28Helper() {}

public static boolean fetchIntern(UTF8StreamJsonParser jsonParser) {
return ByteQuadsCanonicalizer28Helper.fetchIntern(jsonParser._symbols);
}
}
Loading

0 comments on commit 622d2a6

Please sign in to comment.