Skip to content

Commit

Permalink
try to fix fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
neithanmo committed Nov 13, 2024
1 parent b12f84b commit 653507e
Showing 1 changed file with 88 additions and 67 deletions.
155 changes: 88 additions & 67 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,80 +265,101 @@ jobs:
draft: false
prerelease: false

fuzzing:
runs-on: ubuntu-latest
container:
image: zondax/rust-ci:latest
fuzzing:
runs-on: ubuntu-latest
container:
image: zondax/rust-ci:latest
steps:
- uses: actions/checkout@v3

steps:
- uses: actions/checkout@v3
# Disable sccache for this job
- name: Disable sccache
run: |
unset RUSTC_WRAPPER
unset SCCACHE_DIR
unset SCCACHE_CACHE_SIZE
- name: Install honggfuzz
run: cargo install honggfuzz
# Install system dependencies for honggfuzz
- name: Install system dependencies
run: |
apt-get update && apt-get install -y \
build-essential \
binutils-dev \
libunwind-dev \
libblocksruntime-dev \
liblzma-dev
- name: Generate corpus
run: |
cd app/hfuzz-parser/corpus
cargo run
- name: Install honggfuzz
run: |
unset RUSTC_WRAPPER
cargo install honggfuzz
# Different fuzzing durations based on trigger
- name: Quick fuzz (PR)
if: github.event_name == 'pull_request'
run: |
cd app/hfuzz-parser
timeout 5m cargo hfuzz run transaction ../hfuzz_corpus/
continue-on-error: true
- name: Generate corpus
run: |
cd app/hfuzz-parser/corpus
unset RUSTC_WRAPPER
cargo run
- name: Medium fuzz (main)
if: github.event_name == 'push'
run: |
cd app/hfuzz-parser
timeout 15m cargo hfuzz run transaction ../hfuzz_corpus/
continue-on-error: true
# Different fuzzing durations based on trigger
- name: Quick fuzz (PR)
if: github.event_name == 'pull_request'
run: |
cd app/hfuzz-parser
unset RUSTC_WRAPPER
timeout 5m cargo hfuzz run transaction ../hfuzz_corpus/
continue-on-error: true

- name: Extended fuzz (weekly)
if: github.event_name == 'schedule'
run: |
cd app/hfuzz-parser
timeout 30m cargo hfuzz run transaction ../hfuzz_corpus/
continue-on-error: true
- name: Medium fuzz (main)
if: github.event_name == 'push'
run: |
cd app/hfuzz-parser
unset RUSTC_WRAPPER
timeout 15m cargo hfuzz run transaction ../hfuzz_corpus/
continue-on-error: true

- name: Check for crashes
run: |
if ls app/hfuzz-parser/hfuzz_workspace/transaction/SIGABRT.PC.* 1> /dev/null 2>&1; then
echo "::error::Crashes found during fuzzing!"
exit 1
fi
- name: Extended fuzz (weekly)
if: github.event_name == 'schedule'
run: |
cd app/hfuzz-parser
timeout 30m cargo hfuzz run transaction ../hfuzz_corpus/
continue-on-error: true

# Upload artifacts in case of crashes - corrected path
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: crash-reports
path: |
app/hfuzz-parser/hfuzz_workspace/transaction/SIGABRT.PC.*
app/hfuzz-parser/hfuzz_workspace/transaction/HONGGFUZZ.REPORT.TXT
app/hfuzz-parser/hfuzz_workspace/transaction/input/
- name: Check for crashes
run: |
if ls app/hfuzz-parser/hfuzz_workspace/transaction/SIGABRT.PC.* 1> /dev/null 2>&1; then
echo "::error::Crashes found during fuzzing!"
exit 1
fi
# Save corpus for future runs
- name: Cache corpus
uses: actions/cache@v3
with:
path: hfuzz_corpus
key: ${{ runner.os }}-fuzz-corpus-${{ github.sha }}
restore-keys: |
${{ runner.os }}-fuzz-corpus-
# Upload artifacts in case of crashes - corrected path
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: crash-reports
path: |
app/hfuzz-parser/hfuzz_workspace/transaction/SIGABRT.PC.*
app/hfuzz-parser/hfuzz_workspace/transaction/HONGGFUZZ.REPORT.TXT
app/hfuzz-parser/hfuzz_workspace/transaction/input/
# Notify on failures
- name: Notify on failure
if: failure()
uses: actions/github-script@v6
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Fuzzing found crashes',
body: 'Fuzzing job failed. Check the artifacts in the workflow run.'
})
# Save corpus for future runs
- name: Cache corpus
uses: actions/cache@v3
with:
path: hfuzz_corpus
key: ${{ runner.os }}-fuzz-corpus-${{ github.sha }}
restore-keys: |
${{ runner.os }}-fuzz-corpus-
# Notify on failures
- name: Notify on failure
if: failure()
uses: actions/github-script@v6
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Fuzzing found crashes',
body: 'Fuzzing job failed. Check the artifacts in the workflow run.'
})

1 comment on commit 653507e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format (v12.0.1) reports: 18 file(s) not formatted
  • app/src/crypto.c
  • app/src/addr.c
  • app/src/apdu_handler.c
  • app/src/parser.c
  • app/src/common/main.c
  • app/src/common/tx.c
  • app/src/common/actions.c
  • app/src/c_api/rust.c
  • app/rust/include/rslib.h
  • app/src/coin.h
  • app/src/addr.h
  • app/src/crypto.h
  • app/src/parser.h
  • app/src/parser_common.h
  • app/src/coin_standard.h
  • app/src/parser_txdef.h
  • app/src/common/tx.h
  • app/src/common/actions.h
clang-tidy (v12.0.1) reports: 15 concern(s)
  • app/src/apdu_handler.c:89:1: warning: [clang-diagnostic-return-type]

    non-void function does not return a value in all control paths

    }
    ^
  • app/src/addr.h:24:1: error: [clang-diagnostic-error]

    unknown type name 'zxerr_t'

    zxerr_t addr_getNumItems(uint8_t *num_items);
    ^
  • app/src/addr.h:24:26: error: [clang-diagnostic-error]

    unknown type name 'uint8_t'

    zxerr_t addr_getNumItems(uint8_t *num_items);
                             ^
  • app/src/addr.h:27:1: error: [clang-diagnostic-error]

    unknown type name 'zxerr_t'

    zxerr_t addr_getItem(int8_t displayIdx,
    ^
  • app/src/addr.h:27:22: error: [clang-diagnostic-error]

    unknown type name 'int8_t'

    zxerr_t addr_getItem(int8_t displayIdx,
                         ^
  • app/src/addr.h:28:36: error: [clang-diagnostic-error]

    unknown type name 'uint16_t'

                         char *outKey, uint16_t outKeyLen,
                                       ^
  • app/src/addr.h:29:38: error: [clang-diagnostic-error]

    unknown type name 'uint16_t'

                         char *outValue, uint16_t outValueLen,
                                         ^
  • app/src/addr.h:30:22: error: [clang-diagnostic-error]

    unknown type name 'uint8_t'

                         uint8_t pageIdx, uint8_t *pageCount);
                         ^
  • app/src/addr.h:30:39: error: [clang-diagnostic-error]

    unknown type name 'uint8_t'

                         uint8_t pageIdx, uint8_t *pageCount);
                                          ^
  • app/src/common/actions.h:83:17: warning: [clang-diagnostic-unused-function]

    unused function 'app_sign'

    __Z_INLINE void app_sign() {
                    ^
  • app/src/common/actions.h:200:17: warning: [clang-diagnostic-unused-function]

    unused function 'app_reject'

    __Z_INLINE void app_reject() {
                    ^
  • app/src/common/actions.h:207:20: warning: [clang-diagnostic-unused-function]

    unused function 'app_fill_address'

    __Z_INLINE uint8_t app_fill_address(address_kind_e kind) {
                       ^
  • app/src/common/actions.h:223:20: warning: [clang-diagnostic-unused-function]

    unused function 'app_fill_auth_pubkey'

    __Z_INLINE uint8_t app_fill_auth_pubkey(address_kind_e kind) {
                       ^
  • app/src/common/actions.h:240:17: warning: [clang-diagnostic-unused-function]

    unused function 'app_reply_address'

    __Z_INLINE void app_reply_address() {
                    ^
  • app/src/common/actions.h:245:17: warning: [clang-diagnostic-unused-function]

    unused function 'app_reply_error'

    __Z_INLINE void app_reply_error() {
                    ^

Have any feedback or feature suggestions? Share it here.

Please sign in to comment.