Skip to content
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

Fuzzing Setup #7

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CI Fuzz
# Set a CI/CD variable called "CI_SENSE_API_TOKEN" with an API token
# generated in CI Fuzz web interface and a variable called "CI_FUZZ_DOWNLOAD_TOKEN"
# with a download token from https://downloads.code-intelligence.com.
# To download the CI Fuzz maven extension or gradle plugin set the secrets
# MAVEN_REGISTRY_USERNAME and MAVEN_REGISTRY_PASSWORD with the credentials
# from https://downloads.code-intelligence.com.

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
# Timeout until the pipeline is marked as 'success'
# if during that time no failing findings are found.
TIMEOUT: "5m"
# Minimum severity for findings that causes the pipeline to fail.
# Findings with lower severity are still reported but do not fail
# the pipeline.
# Possible values: 'LOW', 'MEDIUM', 'HIGH', 'CRITICAL'
MIN_FINDINGS_SEVERITY: LOW
# The CI Sense URL.
CI_SENSE_HTTP_URL: https://app.code-intelligence.com
CI_SENSE_GRPC_URL: grpc.code-intelligence.com:443
# The CI Sense project name.
PROJECT: prj-Rp8lKbLPrG2Z
# Directory in which the repository will be cloned.
CHECKOUT_DIR: checkout-dir/
jobs:
fuzz_tests:
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout Repository
uses: actions/checkout@v2
with:
path: ${{ env.CHECKOUT_DIR }}
# Uncomment to configure access to CI Fuzz maven repository.
# - uses: s4u/maven-settings-action@v2.8.0
# with:
# servers: '[{"id": "code-intelligence", "username": "${{ secrets.MAVEN_REGISTRY_USERNAME }}", "password": "${{ secrets.MAVEN_REGISTRY_PASSWORD }}"}]'
- id: install-cifuzz
name: Install cifuzz
uses: CodeIntelligenceTesting/github-actions/install-cifuzz@v6
with:
download_token: ${{ secrets.CI_FUZZ_DOWNLOAD_TOKEN }}
version: 'latest'
- id: run-fuzz-tests
name: Run Fuzz Tests
uses: CodeIntelligenceTesting/github-actions/run-fuzz-tests@v6
with:
ci_sense_api_token: ${{ secrets.CI_SENSE_API_TOKEN }}
project_name: ${{ env.PROJECT }}
repository_dir: ${{ env.CHECKOUT_DIR }}
timeout: ${{ env.TIMEOUT }}
min_findings_severity: ${{ env.MIN_FINDINGS_SEVERITY }}
ci_sense_http_url: ${{ env.CI_SENSE_HTTP_URL }}
- id: save-results
name: Save Fuzz Test Results
uses: CodeIntelligenceTesting/github-actions/save-results@v6
if: ${{ success() || failure() }}
with:
ci_sense_api_token: ${{ secrets.CI_SENSE_API_TOKEN }}
ci_sense_http_url: ${{ env.CI_SENSE_HTTP_URL }}
ci_sense_grpc_url: ${{ env.CI_SENSE_GRPC_URL }}
project_name: ${{ env.PROJECT }}
started_run: ${{ steps.run-fuzz-tests.outputs.started_run }}
- id: upload-artifact
uses: actions/upload-artifact@v2
if: ${{ (success() || failure()) }}
with:
name: ci_fuzz_results
path: |
findings.json
coverage.json
web_app_address.txt
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/external)
enable_testing()
include(googletest)

find_package(cifuzz NO_SYSTEM_ENVIRONMENT_PATH)
enable_fuzz_testing()

add_subdirectory(src/explore_me)
add_subdirectory(src/automotive)
add_subdirectory(src/automotive)
100 changes: 100 additions & 0 deletions CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "cifuzz (Coverage)",
"displayName": "cifuzz (Coverage)",
"binaryDir": "${sourceDir}/.cifuzz-build/replayer/gcov",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CIFUZZ_ENGINE": "replayer",
"CIFUZZ_SANITIZERS": "gcov",
"CIFUZZ_TESTING": {
"type": "BOOL",
"value": "ON"
},
"CMAKE_BUILD_RPATH_USE_ORIGIN": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "cifuzz (Fuzzing)",
"displayName": "cifuzz (Fuzzing)",
"binaryDir": "${sourceDir}/.cifuzz-build/libfuzzer/address+undefined",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CIFUZZ_ENGINE": "libfuzzer",
"CIFUZZ_SANITIZERS": "address;undefined",
"CIFUZZ_TESTING": {
"type": "BOOL",
"value": "ON"
},
"CMAKE_BUILD_RPATH_USE_ORIGIN": {
"type": "BOOL",
"value": "ON"
}
},
"environment": {
"CC": "clang",
"CXX": "clang++"
}
},
{
"name": "cifuzz (Regression Test)",
"displayName": "cifuzz (Regression Test)",
"binaryDir": "${sourceDir}/.cifuzz-build/replayer/address+undefined",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CIFUZZ_ENGINE": "replayer",
"CIFUZZ_SANITIZERS": "address;undefined",
"CIFUZZ_TESTING": {
"type": "BOOL",
"value": "ON"
},
"CMAKE_BUILD_RPATH_USE_ORIGIN": {
"type": "BOOL",
"value": "ON"
}
}
}
],
"buildPresets": [
{
"name": "cifuzz (Coverage)",
"displayName": "cifuzz (Coverage)",
"configurePreset": "cifuzz (Coverage)",
"configuration": "RelWithDebInfo"
},
{
"name": "cifuzz (Fuzzing)",
"displayName": "cifuzz (Fuzzing)",
"configurePreset": "cifuzz (Fuzzing)",
"configuration": "RelWithDebInfo"
},
{
"name": "cifuzz (Regression Test)",
"displayName": "cifuzz (Regression Test)",
"configurePreset": "cifuzz (Regression Test)",
"configuration": "RelWithDebInfo"
}
],
"testPresets": [
{
"name": "cifuzz (Regression Test)",
"displayName": "cifuzz (Regression Test)",
"configurePreset": "cifuzz (Regression Test)",
"filter": {
"include": {
"label": "^cifuzz_regression_test$"
}
}
}
]
}
46 changes: 46 additions & 0 deletions cifuzz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Configuration for a CI Fuzz project
## Generated on 2023-06-06

## The build system used to build this project. If not set, cifuzz tries
## to detect the build system automatically.
## Valid values: "bazel", "cmake", "maven", "gradle", "other".
#build-system: cmake

## If the build system type is "other", this command is used by
## `cifuzz run` to build the fuzz test.
#build-command: "make my_fuzz_test"

## Directories containing sample inputs for the code under test.
## See https://llvm.org/docs/LibFuzzer.html#corpus
#seed-corpus-dirs:
# - path/to/seed-corpus

## A file containing input language keywords or other interesting byte
## sequences.
## See https://llvm.org/docs/LibFuzzer.html#dictionaries
#dict: path/to/dictionary.dct

## Command-line arguments to pass to libFuzzer.
## See https://llvm.org/docs/LibFuzzer.html#options
engine-args:
- -use_value_profile=1

## Maximum time to run fuzz tests. The default is to run indefinitely.
timeout: 5m

## By default, fuzz tests are executed in a sandbox to prevent accidental
## damage to the system. Set to false to run fuzz tests unsandboxed.
## Only supported on Linux.
#use-sandbox: false

## Set to true to print output of the `cifuzz run` command as JSON.
#print-json: true

## Set to true to disable desktop notifications
#no-notifications: true

## Set URL of the CI App
#server: https://app.code-intelligence.com

## Set the project name on the CI App
#project: my-project-1a2b3c4d
11 changes: 10 additions & 1 deletion src/automotive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ target_include_directories(automotive PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/gps
${CMAKE_CURRENT_SOURCE_DIR}/key_management
${CMAKE_CURRENT_SOURCE_DIR}/time
)
)

add_fuzz_test(automotive_fuzzer
fuzz_test.cpp
mocks.cpp
)

target_link_libraries(automotive_fuzzer
automotive
)
Loading
Loading