From bda0922495eaac95097c41b505b4ed3403161a65 Mon Sep 17 00:00:00 2001 From: yawkat Date: Sun, 5 Jan 2025 13:48:42 +0100 Subject: [PATCH] exclude ConcurrentLinkedHashMap --- fuzzing-tests/build.gradle.kts | 10 ++++- .../fuzzing/jazzer/ClassNameMatcher.java | 2 +- .../jazzer/PrepareClusterFuzzTask.java | 44 +++++++++++++------ 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/fuzzing-tests/build.gradle.kts b/fuzzing-tests/build.gradle.kts index 0c64c66..837c7ab 100644 --- a/fuzzing-tests/build.gradle.kts +++ b/fuzzing-tests/build.gradle.kts @@ -33,8 +33,14 @@ dependencies { } tasks.withType { - introspectorIncludes = listOf("io.micronaut.*") - introspectorExcludes = listOf("io.micronaut.context.*") + introspector { + includes = listOf("io.micronaut.*") + excludes = listOf( + "io.micronaut.context.*", + "io.micronaut.core.util.clhm.ConcurrentLinkedHashMap*", + "io.micronaut.core.util.clhm.ConcurrentLinkedHashMap*", + ) + } } tasks.named("jazzer") { diff --git a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/ClassNameMatcher.java b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/ClassNameMatcher.java index da49a81..0b5fa85 100644 --- a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/ClassNameMatcher.java +++ b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/ClassNameMatcher.java @@ -14,7 +14,7 @@ public ClassNameMatcher(Collection patterns) { exactMatch = new HashSet<>(); prefixes = new ArrayList<>(); for (String pattern : patterns) { - if (pattern.endsWith(".*")) { + if (pattern.endsWith("*")) { prefixes.add(pattern.substring(0, pattern.length() - 1)); } else { exactMatch.add(pattern); diff --git a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java index a126763..69cd33d 100644 --- a/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java +++ b/jazzer-plugin/src/main/java/io/micronaut/fuzzing/jazzer/PrepareClusterFuzzTask.java @@ -1,10 +1,11 @@ package io.micronaut.fuzzing.jazzer; import io.micronaut.fuzzing.processor.DefinedFuzzTarget; +import org.gradle.api.Action; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.SetProperty; import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.Optional; +import org.gradle.api.tasks.Nested; import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.TaskAction; import org.slf4j.Logger; @@ -37,21 +38,19 @@ public abstract class PrepareClusterFuzzTask extends BaseJazzerTask { public abstract DirectoryProperty getOutputDirectory(); /** - * Class name patterns to include in the introspector report. By default, all dependencies are - * included, but this can be too much for the report. + * Introspector-specific settings. Note that these don't affect the actual fuzzing, only the + * introspector report. */ - @Input - @Optional - public abstract SetProperty getIntrospectorIncludes(); + @Nested + public abstract Introspector getIntrospector(); /** - * Class name patterns to exclude in the introspector report. By default, all dependencies are - * included, but this can be too much for the report. - *

This takes precedence over {@link #getIntrospectorIncludes()}. + * Introspector-specific settings. Note that these don't affect the actual fuzzing, only the + * introspector report. */ - @Input - @Optional - public abstract SetProperty getIntrospectorExcludes(); + public final void introspector(Action action) { + action.execute(getIntrospector()); + } @TaskAction public void run() throws IOException { @@ -120,14 +119,14 @@ public void prepareIntrospectorJars() throws IOException { forIntrospector.add(dst); } try (ClasspathAccess classpathAccess = new ClasspathAccess(forIntrospector)) { - Set includePatterns = getIntrospectorIncludes().getOrNull(); + Set includePatterns = getIntrospector().getIncludes().getOrNull(); ClassNameMatcher introspectorIncludes; if (includePatterns == null || includePatterns.isEmpty()) { introspectorIncludes = null; } else { introspectorIncludes = new ClassNameMatcher(includePatterns); } - ClassNameMatcher introspectorExcludes = new ClassNameMatcher(getIntrospectorExcludes().orElse(Set.of()).get()); + ClassNameMatcher introspectorExcludes = new ClassNameMatcher(getIntrospector().getExcludes().orElse(Set.of()).get()); classpathAccess.walkFileTree(root -> new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { @@ -207,4 +206,21 @@ static Map assignTargetNames(Collection targetClasses) { } return targetNames; } + + public interface Introspector { + /** + * Class name patterns to include in the introspector report. By default, all dependencies are + * included, but this can be too much for the report. + */ + @Input + SetProperty getIncludes(); + + /** + * Class name patterns to exclude in the introspector report. By default, all dependencies are + * included, but this can be too much for the report. + *

This takes precedence over {@link #getIncludes()}. + */ + @Input + SetProperty getExcludes(); + } }