forked from LedgerHQ/app-plugin-paraswap
-
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
Showing
1,005 changed files
with
15,700 additions
and
5,531 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
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,14 @@ | ||
FROM ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest AS LITE_BUILDER | ||
|
||
# Base image with clang toolchain | ||
FROM gcr.io/oss-fuzz-base/base-builder:v1 | ||
|
||
# Copy the project's source code. | ||
COPY . $SRC/app-plugin-paraswap | ||
COPY --from=LITE_BUILDER /opt/nanox-secure-sdk $SRC/app-plugin-paraswap/BOLOS_SDK | ||
|
||
# Working directory for build.sh | ||
WORKDIR $SRC/app-plugin-paraswap | ||
|
||
# Copy build.sh into $SRC dir. | ||
COPY ./.clusterfuzzlite/build.sh $SRC/ |
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,9 @@ | ||
#!/bin/bash -eu | ||
|
||
# build fuzzers | ||
|
||
pushd fuzzing | ||
cmake -DBOLOS_SDK=../BOLOS_SDK -Bbuild -H. | ||
make -C build | ||
mv ./build/fuzz "${OUT}" | ||
popd |
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 @@ | ||
language: c |
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,41 @@ | ||
name: ClusterFuzzLite cron tasks | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main # Use your actual default branch here. | ||
schedule: | ||
- cron: '0 13 * * 6' # At 01:00 PM, only on Saturday | ||
permissions: read-all | ||
jobs: | ||
Fuzzing: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- mode: batch | ||
sanitizer: address | ||
- mode: batch | ||
sanitizer: memory | ||
- mode: prune | ||
sanitizer: address | ||
- mode: coverage | ||
sanitizer: coverage | ||
steps: | ||
- name: Build Fuzzers (${{ matrix.mode }} - ${{ matrix.sanitizer }}) | ||
id: build | ||
uses: google/clusterfuzzlite/actions/build_fuzzers@v1 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
language: c # Change this to the language you are fuzzing. | ||
sanitizer: ${{ matrix.sanitizer }} | ||
- name: Run Fuzzers (${{ matrix.mode }} - ${{ matrix.sanitizer }}) | ||
id: run | ||
uses: google/clusterfuzzlite/actions/run_fuzzers@v1 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
fuzz-seconds: 300 # 5 minutes | ||
mode: ${{ matrix.mode }} | ||
sanitizer: ${{ matrix.sanitizer }} | ||
|
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,43 @@ | ||
name: ClusterFuzzLite PR fuzzing | ||
on: | ||
pull_request: | ||
paths: | ||
- '**' | ||
permissions: read-all | ||
jobs: | ||
PR: | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ matrix.sanitizer }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
sanitizer: [address, undefined, memory] # Override this with the sanitizers you want. | ||
steps: | ||
- name: Build Fuzzers (${{ matrix.sanitizer }}) | ||
id: build | ||
uses: google/clusterfuzzlite/actions/build_fuzzers@v1 | ||
with: | ||
language: c # Change this to the language you are fuzzing. | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
sanitizer: ${{ matrix.sanitizer }} | ||
# Optional but recommended: used to only run fuzzers that are affected | ||
# by the PR. | ||
# storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/OWNER/STORAGE-REPO-NAME.git | ||
# storage-repo-branch: main # Optional. Defaults to "main" | ||
# storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages". | ||
- name: Run Fuzzers (${{ matrix.sanitizer }}) | ||
id: run | ||
uses: google/clusterfuzzlite/actions/run_fuzzers@v1 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
fuzz-seconds: 300 # 5 minutes | ||
mode: 'code-change' | ||
sanitizer: ${{ matrix.sanitizer }} | ||
output-sarif: true | ||
# Optional but recommended: used to download the corpus produced by | ||
# batch fuzzing. | ||
# storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/OWNER/STORAGE-REPO-NAME.git | ||
# storage-repo-branch: main # Optional. Defaults to "main" | ||
# storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages". |
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
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 |
---|---|---|
|
@@ -11,16 +11,7 @@ on: | |
|
||
jobs: | ||
job_lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
|
||
- name: Lint | ||
uses: DoozyX/[email protected] | ||
with: | ||
source: "./" | ||
extensions: "h,c" | ||
clangFormatVersion: 12.0.1 | ||
name: Check linting using the reusable workflow | ||
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_lint.yml@v1 | ||
with: | ||
source: "./src" |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "ethereum-plugin-sdk"] | ||
path = ethereum-plugin-sdk | ||
url = git@github.com:LedgerHQ/ethereum-plugin-sdk.git | ||
url = https://github.com/LedgerHQ/ethereum-plugin-sdk.git |
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
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
Submodule ethereum-plugin-sdk
updated
37 files
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,121 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
if(${CMAKE_VERSION} VERSION_LESS 3.10) | ||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) | ||
endif() | ||
|
||
# project information | ||
project(Fuzzer | ||
VERSION 1.0 | ||
DESCRIPTION "Contract parser of Paraswap plugin app" | ||
LANGUAGES C) | ||
|
||
# guard against bad build-type strings | ||
if (NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Release") | ||
endif() | ||
|
||
if (NOT CMAKE_C_COMPILER_ID MATCHES "Clang") | ||
message(FATAL_ERROR "Fuzzer needs to be built with Clang") | ||
endif() | ||
|
||
if (NOT DEFINED BOLOS_SDK) | ||
message(FATAL_ERROR "BOLOS_SDK environment variable not found.") | ||
endif() | ||
|
||
# guard against in-source builds | ||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) | ||
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ") | ||
endif() | ||
|
||
# specify C standard | ||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_C_STANDARD_REQUIRED True) | ||
|
||
# compatible with ClusterFuzzLite | ||
if (NOT DEFINED ENV{LIB_FUZZING_ENGINE}) | ||
set(COMPILATION_FLAGS_ "-fsanitize=fuzzer,address,undefined,signed-integer-overflow") | ||
else() | ||
set(COMPILATION_FLAGS_ "$ENV{LIB_FUZZING_ENGINE} $ENV{CFLAGS}") | ||
endif() | ||
string(REPLACE " " ";" COMPILATION_FLAGS ${COMPILATION_FLAGS_}) | ||
|
||
add_compile_options(-Wall -Wextra -g -pedantic) | ||
# Just to limit compilation warnings of the plugin sources | ||
add_compile_options(-Wno-implicit-function-declaration) | ||
# Flag depending on the Build Type | ||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ggdb2 -O3") | ||
|
||
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../src") | ||
set(ETH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ethereum-plugin-sdk") | ||
|
||
add_compile_definitions( | ||
APPNAME="Paraswap" | ||
) | ||
|
||
add_compile_definitions( | ||
IO_HID_EP_LENGTH=64 | ||
HAVE_ECC | ||
HAVE_ECC_WEIERSTRASS | ||
HAVE_SECP_CURVES | ||
HAVE_ECC_TWISTED_EDWARDS | ||
HAVE_ED_CURVES | ||
HAVE_ECDSA | ||
HAVE_EDDSA | ||
HAVE_HASH | ||
HAVE_BLAKE2 | ||
HAVE_SHA224 | ||
HAVE_SHA256 | ||
HAVE_SHA3 | ||
HAVE_SHA512 | ||
) | ||
|
||
include_directories( | ||
${BOLOS_SDK}/include | ||
${BOLOS_SDK}/lib_standard_app | ||
${BOLOS_SDK}/lib_cxng/include | ||
${BOLOS_SDK}/lib_cxng/src | ||
${BOLOS_SDK}/target/nanox/include | ||
${ETH_DIR}/src | ||
${SRC_DIR} | ||
) | ||
|
||
# Take all source files from the application and the sdk | ||
file(GLOB_RECURSE APPLICATION_SRC | ||
# Take all plugin sources | ||
${SRC_DIR}/*.c | ||
|
||
# Take all sdk sources | ||
${ETH_DIR}/src/*.c | ||
) | ||
# Filter out main.c from the SDK and the entire dbg folder | ||
list(FILTER APPLICATION_SRC EXCLUDE REGEX "${ETH_DIR}/src/main|${SRC_DIR}/dbg/") | ||
|
||
add_executable(fuzz | ||
${APPLICATION_SRC} | ||
|
||
# fuzzing specific files | ||
fuzz_plugin.c | ||
mocks.c | ||
|
||
# sdk utils | ||
${BOLOS_SDK}/src/ledger_assert.c | ||
${BOLOS_SDK}/lib_standard_app/format.c | ||
|
||
# cxng | ||
${BOLOS_SDK}/lib_cxng/src/cx_hash.c | ||
${BOLOS_SDK}/lib_cxng/src/cx_sha256.c | ||
${BOLOS_SDK}/lib_cxng/src/cx_sha512.c | ||
${BOLOS_SDK}/lib_cxng/src/cx_sha3.c | ||
${BOLOS_SDK}/lib_cxng/src/cx_blake2b.c | ||
${BOLOS_SDK}/lib_cxng/src/cx_utils.c | ||
${BOLOS_SDK}/lib_cxng/src/cx_ram.c | ||
) | ||
|
||
target_compile_options(fuzz PUBLIC ${COMPILATION_FLAGS}) | ||
target_link_options(fuzz PUBLIC ${COMPILATION_FLAGS}) | ||
|
||
if (CMAKE_C_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-gdwarf-4) | ||
endif() |
Oops, something went wrong.