Skip to content

Commit

Permalink
exclude ConcurrentLinkedHashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
yawkat committed Jan 5, 2025
1 parent 78ff7dd commit bda0922
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
10 changes: 8 additions & 2 deletions fuzzing-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ dependencies {
}

tasks.withType<PrepareClusterFuzzTask> {
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<JazzerTask>("jazzer") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public ClassNameMatcher(Collection<String> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<String> 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.
* <p>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<String> getIntrospectorExcludes();
public final void introspector(Action<? super Introspector> action) {
action.execute(getIntrospector());
}

@TaskAction
public void run() throws IOException {
Expand Down Expand Up @@ -120,14 +119,14 @@ public void prepareIntrospectorJars() throws IOException {
forIntrospector.add(dst);
}
try (ClasspathAccess classpathAccess = new ClasspathAccess(forIntrospector)) {
Set<String> includePatterns = getIntrospectorIncludes().getOrNull();
Set<String> 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 {
Expand Down Expand Up @@ -207,4 +206,21 @@ static Map<String, String> assignTargetNames(Collection<String> 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<String> 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.
* <p>This takes precedence over {@link #getIncludes()}.
*/
@Input
SetProperty<String> getExcludes();
}
}

0 comments on commit bda0922

Please sign in to comment.