Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7fcc441
Add fuzzing targets for snappy-java
vishalcoc44 Mar 13, 2026
0e8f777
minor changes
vishalcoc44 Mar 13, 2026
e5ee759
Update src/test/java/org/xerial/snappy/fuzz/BitShuffleFuzzer.java
vishalcoc44 Mar 13, 2026
ec6e0eb
Update src/test/java/org/xerial/snappy/fuzz/BitShuffleFuzzer.java
vishalcoc44 Mar 13, 2026
975dcf4
Update src/test/java/org/xerial/snappy/fuzz/BitShuffleFuzzer.java
vishalcoc44 Mar 13, 2026
abc1da5
Update src/test/java/org/xerial/snappy/fuzz/SnappyCombinedFuzzer.java
vishalcoc44 Mar 13, 2026
8d1a144
resolved detection and reporting of crashes
vishalcoc44 Mar 13, 2026
5ce9139
Update src/test/java/org/xerial/snappy/fuzz/SnappyCombinedFuzzer.java
vishalcoc44 Mar 13, 2026
a2552c5
Update src/test/java/org/xerial/snappy/fuzz/SnappyCombinedFuzzer.java
vishalcoc44 Mar 13, 2026
11e14eb
Update src/test/java/org/xerial/snappy/fuzz/BitShuffleFuzzer.java
vishalcoc44 Mar 13, 2026
f0f429f
Update src/test/java/org/xerial/snappy/fuzz/SnappyStreamFuzzer.java
vishalcoc44 Mar 13, 2026
0216f92
Update src/test/java/org/xerial/snappy/fuzz/SnappyStreamFuzzer.java
vishalcoc44 Mar 13, 2026
d4cd518
-
vishalcoc44 Mar 13, 2026
3bd4cd5
-
vishalcoc44 Mar 13, 2026
66a6e9a
-
vishalcoc44 Mar 14, 2026
ba47422
-
vishalcoc44 Mar 14, 2026
363eb19
-
vishalcoc44 Mar 14, 2026
cf0ca81
-
vishalcoc44 Mar 14, 2026
4fb7af6
-
vishalcoc44 Mar 14, 2026
528015f
-
vishalcoc44 Mar 14, 2026
ff76e20
-
vishalcoc44 Mar 14, 2026
4640f7b
Update src/test/java/org/xerial/snappy/fuzz/SnappyCombinedFuzzer.java
vishalcoc44 Mar 14, 2026
b0566b6
-
vishalcoc44 Mar 14, 2026
97aca26
Merge branch 'adding-new-fuzzers' of https://github.com/vishalcoc44/s…
vishalcoc44 Mar 14, 2026
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
32 changes: 32 additions & 0 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CIFuzz
on: [pull_request]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'snappy-java'
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'snappy-java'
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
58 changes: 58 additions & 0 deletions src/test/java/org/xerial/snappy/fuzz/BitShuffleFuzzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2023 Google LLC
//
// 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 org.xerial.snappy.fuzz;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import org.xerial.snappy.Snappy;
import org.xerial.snappy.BitShuffle;
import java.util.Objects;

public class BitShuffleFuzzer {
private static final int SIZE = 4096;

public static void fuzzerTestOneInput(FuzzedDataProvider data) {
fuzzBitshuffle(data.consumeInts(SIZE), BitShuffle::shuffle, BitShuffle::unshuffleIntArray, "int[]");
fuzzBitshuffle(data.consumeLongs(SIZE), BitShuffle::shuffle, BitShuffle::unshuffleLongArray, "long[]");
fuzzBitshuffle(data.consumeShorts(SIZE), BitShuffle::shuffle, BitShuffle::unshuffleShortArray, "short[]");
fuzzBitshuffle(data.consumeFloats(SIZE), BitShuffle::shuffle, BitShuffle::unshuffleFloatArray, "float[]");
fuzzBitshuffle(data.consumeDoubles(SIZE), BitShuffle::shuffle, BitShuffle::unshuffleDoubleArray, "double[]");
}

@FunctionalInterface
private interface ShuffleFn<T> {
byte[] apply(T input) throws Exception;
}

@FunctionalInterface
private interface UnshuffleFn<T> {
T apply(byte[] input) throws Exception;
}

private static <T> void fuzzBitshuffle(T original, ShuffleFn<T> shuffle, UnshuffleFn<T> unshuffle, String typeName) {
try {
byte[] shuffledByteArray = shuffle.apply(original);
byte[] compressed = Snappy.compress(shuffledByteArray);
byte[] uncompressed = Snappy.uncompress(compressed);
T result = unshuffle.apply(uncompressed);
if (!Objects.deepEquals(original, result)) {
throw new IllegalStateException("Original and uncompressed " + typeName + " data are different");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
22 changes: 22 additions & 0 deletions src/test/java/org/xerial/snappy/fuzz/FuzzBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Google LLC
//
// 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 org.xerial.snappy.fuzz;

@FunctionalInterface
public interface FuzzBlock {
void run() throws Exception;
}
Loading
Loading