Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish jazzer plugin #103

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,16 @@ plugins {
id "io.micronaut.build.internal.docs"
id "io.micronaut.build.internal.quality-reporting"
}

// These tasks are used in the release workflow, but the jazzer plugin is an included build
["publishAllPublicationsToBuildRepository", "publishToSonatype", "closeAndReleaseSonatypeStagingRepository"].each {t ->
if (tasks.names.find { it == t } == null) {
tasks.register(t) {
dependsOn(gradle.includedBuilds.find { it.name == "micronaut-jazzer-plugin" }.task(":$t"))
}
} else {
tasks.named(t) {
dependsOn(gradle.includedBuilds.find { it.name == "micronaut-jazzer-plugin" }.task(":$t"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ plugins {
id 'io.micronaut.build.internal.fuzzing-base'
id "io.micronaut.build.internal.module"
}

micronautBuild {
binaryCompatibility {
enabledAfter "1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.fuzzing.processor;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.fuzzing.processor;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
15 changes: 15 additions & 0 deletions fuzzing-api/src/main/java/io/micronaut/fuzzing/Dict.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.fuzzing;

import java.lang.annotation.ElementType;
Expand Down
15 changes: 15 additions & 0 deletions fuzzing-api/src/main/java/io/micronaut/fuzzing/DictResource.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.fuzzing;

import java.lang.annotation.ElementType;
Expand Down
15 changes: 15 additions & 0 deletions fuzzing-api/src/main/java/io/micronaut/fuzzing/FuzzTarget.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.fuzzing;

import java.lang.annotation.ElementType;
Expand Down
15 changes: 15 additions & 0 deletions fuzzing-api/src/main/java/io/micronaut/fuzzing/HttpDict.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.fuzzing;

import java.lang.annotation.ElementType;
Expand Down
1 change: 1 addition & 0 deletions fuzzing-tests/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
micronautPublish=false
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.fuzzing.http;

import io.netty.buffer.ByteBuf;
Expand All @@ -13,7 +28,7 @@
* This class splits a byte input into multiple chunks in a fuzzer-friendly way, using the
* {@link ByteSeparator#SEPARATOR}. Take care to add the separator to the fuzzer dictionary!
*/
public class ByteSeparator {
public final class ByteSeparator {
static final String SEPARATOR = "SEP";
private static final ByteBuf SEPARATOR_BYTES = Unpooled.copiedBuffer(SEPARATOR, StandardCharsets.UTF_8);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ final class CustomResourceLeakDetector<T> extends ResourceLeakDetector<T> {
}
}

private static final List<Leak> leaks = new CopyOnWriteArrayList<>();
private static final List<ResourceLeakDetector<?>> detectors = new CopyOnWriteArrayList<>();
private static final List<Leak> LEAKS = new CopyOnWriteArrayList<>();
private static final List<ResourceLeakDetector<?>> DETECTORS = new CopyOnWriteArrayList<>();

private static volatile ResourceLeakHint currentHint = new FixedHint(null);

public CustomResourceLeakDetector(Class<?> resourceType, int samplingInterval) {
super(resourceType, samplingInterval);
DETECTORS.add(this);
}

static void register() {
ResourceLeakDetector.setLevel(Level.PARANOID);
ResourceLeakDetectorFactory.setResourceLeakDetectorFactory(new ResourceLeakDetectorFactory() {
Expand All @@ -60,25 +65,20 @@ public static void setCurrentInput(byte[] input) {
currentHint = new FixedHint(input);
}

public CustomResourceLeakDetector(Class<?> resourceType, int samplingInterval) {
super(resourceType, samplingInterval);
detectors.add(this);
}

@Override
protected boolean needReport() {
return true;
}

@Override
protected void reportTracedLeak(String resourceType, String records) {
leaks.add(new Leak(resourceType, records));
LEAKS.add(new Leak(resourceType, records));
super.reportTracedLeak(resourceType, records);
}

@Override
protected void reportUntracedLeak(String resourceType) {
leaks.add(new Leak(resourceType, null));
LEAKS.add(new Leak(resourceType, null));
super.reportUntracedLeak(resourceType);
}

Expand All @@ -88,9 +88,9 @@ protected Object getInitialHint(String resourceType) {
}

static void reportLeaks() {
if (!leaks.isEmpty()) {
if (!LEAKS.isEmpty()) {
StringBuilder msg = new StringBuilder("Reported leaks! Probably unrelated to this particular run, though.\n");
for (Leak leak : leaks) {
for (Leak leak : LEAKS) {
msg.append(leak.resourceType).append("\n");
msg.append(leak.records).append("\n");
}
Expand All @@ -101,7 +101,7 @@ static void reportLeaks() {
static void reportStillOpen() {
Logger logger = LoggerFactory.getLogger(CustomResourceLeakDetector.class);
String found = null;
for (ResourceLeakDetector<?> detector : detectors) {
for (ResourceLeakDetector<?> detector : DETECTORS) {
Set<?> s = (Set<?>) ALL_LEAKS_FIELD.get(detector);
for (Object o : s) {
String v = o.toString();
Expand All @@ -118,9 +118,10 @@ static void reportStillOpen() {
}
}

private record Leak(String resourceType, String records) {}
private record Leak(String resourceType, String records) {
}

private static class FixedHint implements ResourceLeakHint {
private static final class FixedHint implements ResourceLeakHint {
private final String msg;

private FixedHint(byte[] associatedInput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@
import io.micronaut.http.annotation.Post;
import jakarta.inject.Singleton;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Singleton
@Controller
public class SimpleController {
private static final Logger LOG = LoggerFactory.getLogger(SimpleController.class);

public final class SimpleController {
static final String ECHO_PUBLISHER = "/echo-publisher";
static final String ECHO_ARRAY = "/echo-array";
static final String ECHO_STRING = "/echo-string";
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
projectVersion=1.0.0-SNAPSHOT
projectGroup=io.micronaut.fuzzing

micronautPublish=false

title=Micronaut fuzzing
projectDesc=TODO
projectUrl=https://micronaut.io
Expand Down
1 change: 1 addition & 0 deletions jazzer-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("java-gradle-plugin")
id("io.micronaut.build.internal.publishing")
}

repositories {
Expand Down
1 change: 1 addition & 0 deletions jazzer-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
projectDesc=A Gradle plugin integrating with Jazzer
4 changes: 2 additions & 2 deletions jazzer-plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rootProject.name = "jazzer-plugin"
rootProject.name = "micronaut-jazzer-plugin"

plugins {
id("io.micronaut.build.shared.settings") version "7.3.0"
id("io.micronaut.build.shared.settings") version "7.3.1"
}

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
Expand Down
6 changes: 4 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ pluginManagement {
gradlePluginPortal()
mavenCentral()
}
includeBuild("jazzer-plugin")
includeBuild("jazzer-plugin") {
name = "micronaut-jazzer-plugin"
}
}

plugins {
id("io.micronaut.build.shared.settings") version "7.3.0"
id("io.micronaut.build.shared.settings") version "7.3.1"
}

rootProject.name = "fuzzing-parent"
Expand Down
Loading