Skip to content

Commit

Permalink
Merge branch 'master' into alejandro.gonzalez/session_rewriting_detec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
jandro996 authored Apr 1, 2024
2 parents 41cbeec + e49f1a1 commit db8f077
Show file tree
Hide file tree
Showing 72 changed files with 1,087 additions and 447 deletions.
44 changes: 25 additions & 19 deletions .github/workflows/lib-injection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,32 @@ jobs:
permissions:
contents: read
packages: write
strategy:
matrix:
lib-injection-connection: [ 'network','uds']
lib-injection-use-admission-controller: ['', 'use-admission-controller']
weblog-variant: [ 'dd-lib-java-init-test-app']
fail-fast: false
env:
TEST_LIBRARY: java
WEBLOG_VARIANT: ${{ matrix.weblog-variant }}
LIBRARY_INJECTION_CONNECTION: ${{ matrix.lib-injection-connection }}
LIBRARY_INJECTION_ADMISSION_CONTROLLER: ${{ matrix.lib-injection-use-admission-controller }}
WEBLOG_VARIANT: dd-lib-java-init-test-app
DOCKER_REGISTRY_IMAGES_PATH: ghcr.io/datadog
DOCKER_IMAGE_TAG: ${{ github.sha }}
MODE: manual
steps:
- name: lib-injection test runner
id: lib-injection-test-runner
uses: DataDog/system-tests/lib-injection/runner@89d754340046eafcc72dc5c5fd6ea651ca7b920e # main
with:
docker-registry: ghcr.io
docker-registry-username: ${{ github.repository_owner }}
docker-registry-password: ${{ secrets.GITHUB_TOKEN }}
test-script: ./lib-injection/run-manual-lib-injection.sh
BUILDX_PLATFORMS: linux/amd64
steps:
- name: Checkout system tests
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # 2.3.4
with:
repository: 'DataDog/system-tests'

- name: Install runner
uses: ./.github/actions/install_runner

- name: Run K8s Lib Injection Tests
run: ./run.sh K8S_LIB_INJECTION_BASIC

- name: Compress logs
id: compress_logs
if: always()
run: tar -czvf artifact.tar.gz $(ls | grep logs)

- name: Upload artifact
if: always()
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # 2.3.1
with:
name: logs_k8s_lib_injection
path: artifact.tar.gz
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ nexusPublishing {
if (forceLocal && !isCI) {
local {
// For testing use with https://hub.docker.com/r/sonatype/nexus
// docker run --rm -d -p 8081:8081 --name nexus sonatype/nexus
// docker run --rm -d -p 8081:8081 --name nexus sonatype/nexus:oss
// ./gradlew publishToLocal
// Doesn't work for testing releases though... (due to staging)
nexusUrl = uri("http://localhost:8081/nexus/content/repositories/releases/")
snapshotRepositoryUrl = uri("http://localhost:8081/nexus/content/repositories/snapshots/")
username = "admin"
password = "admin123"
allowInsecureProtocol = true
}
} else {
sonatype {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
implementation(gradleApi())
implementation(localGroovy())

implementation("net.bytebuddy", "byte-buddy-gradle-plugin", "1.14.9")
implementation("net.bytebuddy", "byte-buddy-gradle-plugin", "1.14.12")

implementation("org.eclipse.aether", "aether-connector-basic", "1.1.0")
implementation("org.eclipse.aether", "aether-transport-http", "1.1.0")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/call-site-instrumentation-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
implementation("org.ow2.asm", "asm-tree", "9.0")
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")

testImplementation("net.bytebuddy", "byte-buddy", "1.11.10")
testImplementation("net.bytebuddy", "byte-buddy", "1.14.12")
testImplementation("org.spockframework", "spock-core", "2.0-groovy-3.0")
testImplementation("org.objenesis", "objenesis", "3.0.1")
testImplementation("org.codehaus.groovy", "groovy-all", "3.0.17")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CallSiteInstrumentationPluginTest extends Specification {
}
dependencies {
implementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.12.12'
implementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.14.12'
implementation group: 'com.google.auto.service', name: 'auto-service-annotations', version: '1.0-rc7'
}
'''
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/test/groovy/InstrumentPluginTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InstrumentPluginTest extends Specification {
}
dependencies {
compileOnly group: 'net.bytebuddy', name: 'byte-buddy', version: '1.14.9' // just to build TestPlugin
compileOnly group: 'net.bytebuddy', name: 'byte-buddy', version: '1.14.12' // just to build TestPlugin
}
apply plugin: 'instrument'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ DBInfo.Builder doParse(final String jdbcUrl, final DBInfo.Builder builder) {
MARIA_SUBPROTO() {
@Override
DBInfo.Builder doParse(final String jdbcUrl, final DBInfo.Builder builder) {
if (jdbcUrl.startsWith("**internally_generated**")) {
// there is nothing to parse
builder.host(null);
builder.port(null);
return builder;
}
final int hostEndLoc;
final int clusterSepLoc = jdbcUrl.indexOf(',');
final int ipv6End = jdbcUrl.startsWith("[") ? jdbcUrl.indexOf(']') : -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,16 @@ public static ClassFileTransformer installBytebuddyAgent(
agentBuilder = agentBuilder.with(listener);
}

InstrumenterModules modules = InstrumenterModules.load();
int maxInstrumentationId = modules.maxInstrumentationId();
InstrumenterIndex instrumenterIndex = InstrumenterIndex.readIndex();

// pre-size state before registering instrumentations to reduce number of allocations
InstrumenterState.setMaxInstrumentationId(maxInstrumentationId);
InstrumenterState.initialize(instrumenterIndex.instrumentationCount());

// This needs to be a separate loop through all instrumentations before we start adding
// advice so that we can exclude field injection, since that will try to check exclusion
// immediately and we don't have the ability to express dependencies between different
// instrumentations to control the load order.
for (InstrumenterModule module : modules) {
for (InstrumenterModule module : instrumenterIndex.modules()) {
if (module instanceof ExcludeFilterProvider) {
ExcludeFilterProvider provider = (ExcludeFilterProvider) module;
ExcludeFilter.add(provider.excludedClasses());
Expand All @@ -189,10 +188,10 @@ public static ClassFileTransformer installBytebuddyAgent(
}

CombiningTransformerBuilder transformerBuilder =
new CombiningTransformerBuilder(agentBuilder, maxInstrumentationId);
new CombiningTransformerBuilder(agentBuilder, instrumenterIndex);

int installedCount = 0;
for (InstrumenterModule module : modules) {
for (InstrumenterModule module : instrumenterIndex.modules()) {
if (!module.isApplicable(enabledSystems)) {
if (DEBUG) {
log.debug("Not applicable - instrumentation.class={}", module.getClass().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ final class CombiningMatcher implements AgentBuilder.RawMatcher {
static final ThreadLocal<BitSet> recordedMatches =
ThreadLocal.withInitial(() -> new BitSet(MAX_COMBINED_ID_HINT));

private final KnownTypesIndex knownTypesIndex = KnownTypesIndex.readIndex();

private final BitSet knownTypesMask;
private final MatchRecorder[] matchers;

private static final KnownTypesIndex knownTypesIndex = KnownTypesIndex.readIndex();

CombiningMatcher(BitSet knownTypesMask, List<MatchRecorder> matchers) {
this.knownTypesMask = knownTypesMask;
this.matchers = matchers.toArray(new MatchRecorder[0]);
Expand Down
Loading

0 comments on commit db8f077

Please sign in to comment.