-
Notifications
You must be signed in to change notification settings - Fork 165
Maximize API #1036
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
Merged
Merged
Maximize API #1036
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2bfc7fe
fix: harden CoverageMap env var parsing and validation
kyakdan 8f3b5a6
feat: add ExtraCountersTracker for generic coverage counter management
kyakdan af28d6d
feat: add JazzerApiException for API error handling
kyakdan 05768ef
feat: add maximize() hill-climbing API to Jazzer
kyakdan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
examples/junit/src/test/java/com/example/ReactorFuzzTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright 2026 Code Intelligence GmbH | ||
| * | ||
| * 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 | ||
| * | ||
| * http://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 com.example; | ||
|
|
||
| import com.code_intelligence.jazzer.api.Jazzer; | ||
| import com.code_intelligence.jazzer.junit.FuzzTest; | ||
| import com.code_intelligence.jazzer.mutation.annotation.NotNull; | ||
|
|
||
| public class ReactorFuzzTest { | ||
|
|
||
| @FuzzTest | ||
| public void fuzz(@NotNull String input) { | ||
| for (char c : input.toCharArray()) { | ||
| if (c < 32 || c > 126) return; | ||
| } | ||
| controlReactor(input); | ||
| } | ||
|
|
||
| private void controlReactor(String commands) { | ||
| long temperature = 0; // Starts cold | ||
|
|
||
| for (char cmd : commands.toCharArray()) { | ||
| // Complex, chaotic feedback loop. | ||
| // It is hard to predict which character increases temperature | ||
| // because it depends on the CURRENT temperature. | ||
| if ((temperature ^ cmd) % 3 == 0) { | ||
| temperature += (cmd % 10); // Heat up slightly | ||
| } else if ((temperature ^ cmd) % 3 == 1) { | ||
| temperature -= (cmd % 8); // Cool down slightly | ||
| } else { | ||
| temperature += 1; // Tiny increase | ||
| } | ||
|
|
||
| // Prevent dropping below absolute zero for simulation sanity | ||
| if (temperature < 0) temperature = 0; | ||
| } | ||
| // THE GOAL: MAXIMIZATION | ||
| // We need to drive 'temperature' to an extreme value. | ||
| // Standard coverage is 100% constant here (it just loops). | ||
| Jazzer.maximize(temperature, 0, 4500); | ||
| if (temperature >= 4500) { | ||
| throw new RuntimeException("Meltdown! Temperature maximized."); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/code_intelligence/jazzer/api/JazzerApiException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright 2026 Code Intelligence GmbH | ||
| * | ||
| * 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 | ||
| * | ||
| * http://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 com.code_intelligence.jazzer.api; | ||
|
|
||
| /** | ||
| * Signals error from the Jazzer API (e.g. invalid arguments to {@link Jazzer#maximize}). | ||
| * | ||
| * <p>This exception is treated as a fatal error by the fuzzing engine rather than as a finding in | ||
| * the code under test. When thrown during fuzzing, it stops the current fuzz test with an error | ||
| * instead of reporting a bug in the fuzz target. | ||
| */ | ||
| public final class JazzerApiException extends RuntimeException { | ||
| public JazzerApiException(String message) { | ||
| super(message); | ||
| } | ||
|
|
||
| public JazzerApiException(String message, Throwable cause) { | ||
| super(message, cause); | ||
| } | ||
|
|
||
| public JazzerApiException(Throwable cause) { | ||
| super(cause); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.