forked from ArashPartow/exprtk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd7b1ff
commit 8b932b6
Showing
7 changed files
with
7,426 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,55 @@ | ||
name: Mayhem | ||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
workflow_call: | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
jobs: | ||
build: | ||
name: ${{ matrix.os }} shared=${{ matrix.shared }} ${{ matrix.build_type }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
shared: [false] | ||
build_type: [Release] | ||
include: | ||
- os: ubuntu-latest | ||
triplet: x64-linux | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
file: mayhem/Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
- name: Start analysis | ||
uses: forallsecure/mcode-action@v1 | ||
with: | ||
mayhem-token: ${{ secrets.MAYHEM_TOKEN }} | ||
args: --image ${{ steps.meta.outputs.tags }} --cmd /out/exprtk_fuzzer --target | ||
exprtk_fuzzer --file mayhem/exprtk_fuzzer.mayhemfile | ||
sarif-output: sarif | ||
- name: Upload SARIF file(s) | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: sarif |
This file contains 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,25 @@ | ||
# Copyright 2020 Google Inc. | ||
# | ||
# 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. | ||
# | ||
################################################################################ | ||
|
||
FROM gcr.io/oss-fuzz-base/base-builder | ||
RUN apt-get update && apt-get install -y make autoconf automake libtool | ||
COPY . exprtk | ||
RUN rm -rf exprtk/mayhem | ||
WORKDIR exprtk | ||
COPY mayhem/build.sh mayhem/exprtk_fuzzer.cpp mayhem/exprtk_test_expressions.dict $SRC/ | ||
|
||
ENV FUZZING_LANGUAGE=c++ SANITIZER=address | ||
RUN compile |
Empty file.
This file contains 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,24 @@ | ||
#!/bin/bash -eu | ||
# Copyright 2020 Google Inc. | ||
# | ||
# 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. | ||
# | ||
################################################################################ | ||
|
||
cp $SRC/*.dict $OUT/ | ||
|
||
CXXFLAGS="${CXXFLAGS} -O2 -fno-sanitize=integer-divide-by-zero,float-divide-by-zero" | ||
|
||
$CXX -std=c++11 $CXXFLAGS -I. -I$SRC/exprtk \ | ||
$SRC/exprtk_fuzzer.cpp -o $OUT/exprtk_fuzzer \ | ||
$LIB_FUZZING_ENGINE |
This file contains 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,79 @@ | ||
// Copyright 2020 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. | ||
|
||
#include <cstdint> | ||
#include <string> | ||
|
||
#define exprtk_enable_range_runtime_checks | ||
#include "exprtk.hpp" | ||
|
||
|
||
template <typename T> | ||
void run(const std::string& expression_string) | ||
{ | ||
typedef exprtk::symbol_table<T> symbol_table_t; | ||
typedef exprtk::expression<T> expression_t; | ||
typedef exprtk::parser<T> parser_t; | ||
typedef exprtk::loop_runtime_check loop_runtime_check_t; | ||
|
||
T x = T(1.2345); | ||
T y = T(2.2345); | ||
T z = T(3.2345); | ||
T w = T(4.2345); | ||
|
||
symbol_table_t symbol_table; | ||
symbol_table.add_variable("x",x); | ||
symbol_table.add_variable("y",y); | ||
symbol_table.add_variable("z",z); | ||
symbol_table.add_variable("w",w); | ||
symbol_table.add_constants(); | ||
|
||
expression_t expression; | ||
expression.register_symbol_table(symbol_table); | ||
|
||
loop_runtime_check_t loop_runtime_check; | ||
loop_runtime_check.loop_set = loop_runtime_check_t::e_all_loops; | ||
loop_runtime_check.max_loop_iterations = 100000; | ||
|
||
parser_t parser; | ||
|
||
parser.register_loop_runtime_check(loop_runtime_check); | ||
|
||
if (parser.compile(expression_string, expression)) | ||
{ | ||
const std::size_t max_expression_size = 64 * 1024; | ||
|
||
if (expression_string.size() <= max_expression_size) | ||
{ | ||
try | ||
{ | ||
expression.value(); | ||
} | ||
catch (std::runtime_error& rte) | ||
{} | ||
|
||
parser.clear_loop_runtime_check(); | ||
} | ||
} | ||
} | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) | ||
{ | ||
const std::string expression(reinterpret_cast<const char*>(data), size); | ||
|
||
run<double>(expression); | ||
run<float> (expression); | ||
|
||
return 0; | ||
} |
This file contains 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,4 @@ | ||
project: PROJECT | ||
target: exprtk_fuzzer | ||
cmds: | ||
- cmd: /out/exprtk_fuzzer |
Oops, something went wrong.