-
Notifications
You must be signed in to change notification settings - Fork 310
[COMPRESS-720] Integrate OSS-Fuzz fuzzers and enable CIFuzz #762
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
Open
vishalcoc44
wants to merge
4
commits into
apache:master
Choose a base branch
from
vishalcoc44:COMPRESS-720-fuzzing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
64515f2
[COMPRESS-720] Integrate OSS-Fuzz fuzzers and enable CIFuzz
vishalcoc44 8b37b7f
Address COMPRESS-720: Remove jazzer-junit dependency and isolate fuzz…
vishalcoc44 32d36f0
COMPRESS-720: Refactor BaseTests to AbstractTests and make it abstract
vishalcoc44 d623369
Refactor fuzzer base class: Rename to AbstractTests and add BaseTests…
vishalcoc44 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: CIFuzz | ||
| on: [pull_request] | ||
| permissions: {} | ||
| jobs: | ||
| Fuzzing: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Build Fuzzers | ||
| id: build | ||
| uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master | ||
| with: | ||
| oss-fuzz-project-name: 'apache-commons-compress' | ||
| dry-run: false | ||
| - name: Run Fuzzers | ||
| uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master | ||
| with: | ||
| oss-fuzz-project-name: 'apache-commons-compress' | ||
| 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 |
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
54 changes: 54 additions & 0 deletions
54
src/test/java/org/apache/commons/compress/fuzz/AbstractTests.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,54 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.commons.compress.fuzz; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.logging.LogManager; | ||
|
|
||
| import org.apache.commons.compress.archivers.ArchiveEntry; | ||
| import org.apache.commons.compress.archivers.ArchiveInputStream; | ||
| import org.apache.commons.compress.compressors.CompressorInputStream; | ||
|
|
||
| /** | ||
| * Class with common functionality shared among fuzzing harnesses. | ||
| */ | ||
| public abstract class AbstractTests { | ||
| public static void fuzzerInitialize() { | ||
| LogManager.getLogManager().reset(); | ||
| } | ||
|
|
||
| /** | ||
| * Fuzz archiver streams by reading every entry. | ||
| */ | ||
| public static void fuzzArchiveInputStream(ArchiveInputStream is) throws IOException { | ||
| ArchiveEntry entry; | ||
| while ((entry = is.getNextEntry()) != null) { | ||
| is.read(new byte[1024]); | ||
| } | ||
| is.close(); | ||
| } | ||
|
|
||
| /** | ||
| * Fuzz compressor streams by reading them. | ||
| */ | ||
| public static void fuzzCompressorInputStream(CompressorInputStream is) throws IOException { | ||
| is.read(new byte[1024]); | ||
| is.close(); | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/test/java/org/apache/commons/compress/fuzz/ArchiverArFuzzer.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,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.commons.compress.fuzz; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| import org.apache.commons.compress.archivers.ar.ArArchiveInputStream; | ||
|
|
||
| public class ArchiverArFuzzer extends AbstractTests { | ||
| public static void fuzzerTestOneInput(byte[] data) { | ||
| try { | ||
| fuzzArchiveInputStream(new ArArchiveInputStream(new ByteArrayInputStream(data))); | ||
| } catch (IOException ignored) { | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/test/java/org/apache/commons/compress/fuzz/ArchiverArjFuzzer.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,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.commons.compress.fuzz; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| import org.apache.commons.compress.archivers.arj.ArjArchiveInputStream; | ||
|
|
||
| public class ArchiverArjFuzzer extends AbstractTests { | ||
| public static void fuzzerTestOneInput(byte[] data) { | ||
| try { | ||
| fuzzArchiveInputStream(new ArjArchiveInputStream(new ByteArrayInputStream(data))); | ||
| } catch (IOException ignored) { | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/test/java/org/apache/commons/compress/fuzz/ArchiverCpioFuzzer.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,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.commons.compress.fuzz; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream; | ||
|
|
||
| public class ArchiverCpioFuzzer extends AbstractTests { | ||
| public static void fuzzerTestOneInput(byte[] data) { | ||
| try { | ||
| fuzzArchiveInputStream(new CpioArchiveInputStream(new ByteArrayInputStream(data))); | ||
| } catch (IllegalArgumentException | IOException ignored) { | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/test/java/org/apache/commons/compress/fuzz/ArchiverDumpFuzzer.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,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.commons.compress.fuzz; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| import org.apache.commons.compress.archivers.dump.DumpArchiveInputStream; | ||
|
|
||
| public class ArchiverDumpFuzzer extends AbstractTests { | ||
| public static void fuzzerTestOneInput(byte[] data) { | ||
| try { | ||
| fuzzArchiveInputStream(new DumpArchiveInputStream(new ByteArrayInputStream(data))); | ||
| } catch (IOException ignored) { | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/test/java/org/apache/commons/compress/fuzz/ArchiverTarStreamFuzzer.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,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.commons.compress.fuzz; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; | ||
|
|
||
| public class ArchiverTarStreamFuzzer extends AbstractTests { | ||
| public static void fuzzerTestOneInput(byte[] data) { | ||
| try { | ||
| fuzzArchiveInputStream(new TarArchiveInputStream(new ByteArrayInputStream(data))); | ||
| } catch (IOException ignored) { | ||
| } | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/test/java/org/apache/commons/compress/fuzz/ArchiverZipStreamFuzzer.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,34 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.commons.compress.fuzz; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; | ||
|
|
||
| public class ArchiverZipStreamFuzzer extends AbstractTests { | ||
| public static void fuzzerTestOneInput(byte[] data) { | ||
| try { | ||
| fuzzArchiveInputStream(new ZipArchiveInputStream(new ByteArrayInputStream(data))); | ||
| } catch (IOException ignored) { | ||
| } | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/test/java/org/apache/commons/compress/fuzz/BaseTests.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,30 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.commons.compress.fuzz; | ||
|
|
||
| /** | ||
| * Temporary shim to maintain compatibility with legacy OSS-Fuzz build scripts | ||
| * which hardcode the class name "BaseTests". | ||
| * | ||
| * TODO: Remove this class once the oss-fuzz project configuration is updated | ||
| * to use AbstractTests. | ||
| */ | ||
| public abstract class BaseTests extends AbstractTests { | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to NOT compile this code? It seems like a typo away from breaking something.