-
Notifications
You must be signed in to change notification settings - Fork 825
Add fuzz targets for OSS-Fuzz integration (RLE + FormulaParser) #1020
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
Changes from 4 commits
e89cc60
f8441f3
8ac19e2
c24ce57
59be6fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Excel Formula Dictionary for FormulaParserFuzzer | ||
pjfanning marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "SUM" | ||
| "AVERAGE" | ||
| "COUNT" | ||
| "IF" | ||
| "VLOOKUP" | ||
| "Table1" | ||
| "[" | ||
| "]" | ||
| "[[" | ||
| "]]" | ||
| "#" | ||
| "#All" | ||
| "#Headers" | ||
| "#Data" | ||
| "#Totals" | ||
| "#This Row" | ||
| "'" | ||
| "!" | ||
| ":" | ||
| "," | ||
| "(" | ||
| ")" | ||
| "\"" | ||
| "+" | ||
| "-" | ||
| "*" | ||
| "/" | ||
| "^" | ||
| "&" | ||
| "=" | ||
| "<" | ||
| ">" | ||
| "<=" | ||
| ">=" | ||
| "<>" | ||
| "$" | ||
| "." | ||
| " " | ||
| "@" | ||
| "A1" | ||
| "B2" | ||
| "C3" | ||
| "Sheet1" | ||
| "Sheet2" | ||
| "NamedRange" | ||
| "Column1" | ||
| "Column2" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* ==================================================================== | ||
| 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 | ||
|
|
||
| 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.apache.poi.fuzz; | ||
|
|
||
| import com.code_intelligence.jazzer.api.FuzzedDataProvider; | ||
| import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook; | ||
| import org.apache.poi.hssf.usermodel.HSSFWorkbook; | ||
| import org.apache.poi.ss.formula.FormulaParser; | ||
| import org.apache.poi.ss.formula.FormulaType; | ||
| import org.apache.poi.ss.formula.FormulaParseException; | ||
| import org.apache.poi.util.RecordFormatException; | ||
|
|
||
| import java.nio.BufferUnderflowException; | ||
| import java.util.NoSuchElementException; | ||
|
|
||
| /** | ||
| * Fuzz target for the Apache POI Formula Parser. | ||
| * Used by Google's OSS-Fuzz for continuous security testing. | ||
| */ | ||
| public class FormulaParserFuzzer { | ||
| private static HSSFWorkbook workbook; | ||
| private static HSSFEvaluationWorkbook evalWorkbook; | ||
|
|
||
| public static void fuzzerInitialize() { | ||
| workbook = new HSSFWorkbook(); | ||
| evalWorkbook = HSSFEvaluationWorkbook.create(workbook); | ||
| } | ||
|
|
||
| public static void fuzzerTestOneInput(FuzzedDataProvider data) { | ||
| try { | ||
| FormulaType formulaType = data.pickValue(FormulaType.values()); | ||
| int sheetIndex = data.consumeInt(-1, 10); | ||
| String formula = data.consumeRemainingAsString(); | ||
|
|
||
| if (formula == null || formula.isEmpty()) { | ||
| return; | ||
| } | ||
|
|
||
| FormulaParser.parse(formula, evalWorkbook, formulaType, sheetIndex); | ||
|
|
||
| } catch (FormulaParseException | IllegalArgumentException | IllegalStateException | | ||
| IndexOutOfBoundsException | ArithmeticException | NegativeArraySizeException | | ||
| RecordFormatException | BufferUnderflowException | | ||
| UnsupportedOperationException | NoSuchElementException e) { | ||
| // Expected exceptions on malformed formula syntax | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* ==================================================================== | ||
| 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 | ||
|
|
||
| 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.apache.poi.fuzz; | ||
|
|
||
| import org.apache.poi.util.RLEDecompressingInputStream; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Fuzz target for RLEDecompressingInputStream. | ||
| * Used by Google's OSS-Fuzz for continuous security testing. | ||
| */ | ||
| public class POIRleFuzzer { | ||
| public static void fuzzerInitialize() { | ||
| } | ||
|
|
||
| public static void fuzzerTestOneInput(byte[] input) { | ||
| try (RLEDecompressingInputStream rleStream = | ||
| new RLEDecompressingInputStream(new ByteArrayInputStream(input))) { | ||
|
|
||
| byte[] buffer = new byte[1024]; | ||
| while (rleStream.read(buffer) != -1) { | ||
| // Trigger decompression logic | ||
| } | ||
| } catch (IOException | IllegalArgumentException | IllegalStateException | IndexOutOfBoundsException e) { | ||
| // Expected exceptions on malformed input | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more | |
| requires org.junit.jupiter.api; | ||
| requires org.junit.jupiter.params; | ||
| requires org.mockito; | ||
| requires static com.code_intelligence.jazzer.api; | ||
|
||
|
|
||
| exports org.apache.poi.hpsf.basic to org.junit.platform.commons; | ||
| exports org.apache.poi.hssf.record.pivot to org.junit.platform.commons; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.