diff --git a/.clusterfuzzlite/Dockerfile b/.clusterfuzzlite/Dockerfile new file mode 100644 index 000000000..4e0007a88 --- /dev/null +++ b/.clusterfuzzlite/Dockerfile @@ -0,0 +1,18 @@ +# Copyright (c) 2023-2026, Nubificus LTD +# +# 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-go:v1@sha256:1dbadefbb28c6bfd796c64d9c2115977deb8f19494533cc5a3b724c3441df23d +COPY . $SRC/urunc +WORKDIR $SRC/urunc +COPY .clusterfuzzlite/build.sh $SRC/ diff --git a/.clusterfuzzlite/build.sh b/.clusterfuzzlite/build.sh new file mode 100755 index 000000000..c569d503a --- /dev/null +++ b/.clusterfuzzlite/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash -eu + +# Copyright (c) 2023-2026, Nubificus LTD +# +# 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. + +# Only meant to run inside ClusterFuzzLite or OSS-Fuzz, which provide +# compile_native_go_fuzzer_v2. + +compile_native_go_fuzzer_v2 github.com/urunc-dev/urunc/pkg/unikontainers FuzzGetUnikernelConfig FuzzGetUnikernelConfig diff --git a/.clusterfuzzlite/project.yaml b/.clusterfuzzlite/project.yaml new file mode 100644 index 000000000..ed8819dd1 --- /dev/null +++ b/.clusterfuzzlite/project.yaml @@ -0,0 +1,15 @@ +# Copyright (c) 2023-2026, Nubificus LTD +# +# 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. + +language: go diff --git a/.github/linters/urunc-dict.txt b/.github/linters/urunc-dict.txt index 2eea9e643..b9b062e0c 100644 --- a/.github/linters/urunc-dict.txt +++ b/.github/linters/urunc-dict.txt @@ -490,3 +490,4 @@ anypb memfd errgrpc Inuth +clusterfuzzlite diff --git a/.github/workflows/fuzz_nightly.yml b/.github/workflows/fuzz_nightly.yml new file mode 100644 index 000000000..21a96bcd9 --- /dev/null +++ b/.github/workflows/fuzz_nightly.yml @@ -0,0 +1,36 @@ +name: urunc fuzzing (nightly) + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +permissions: + contents: read + actions: read + security-events: write + +jobs: + fuzz: + name: ClusterFuzzLite batch fuzzing + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@351661ca32ac09a36dc5ee2d536e3128f2a3c8ed # v2.22.0 + with: + egress-policy: audit + + - name: Build fuzz targets + uses: google/clusterfuzzlite/actions/build_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1 + with: + language: go + + - name: Run fuzz targets + uses: google/clusterfuzzlite/actions/run_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + language: go + mode: batch + fuzz-seconds: 1800 + output-sarif: true diff --git a/.github/workflows/fuzz_prune.yml b/.github/workflows/fuzz_prune.yml new file mode 100644 index 000000000..58c4cc40a --- /dev/null +++ b/.github/workflows/fuzz_prune.yml @@ -0,0 +1,34 @@ +name: urunc fuzzing (corpus pruning) + +on: + workflow_dispatch: + schedule: + - cron: '30 13 * * *' + +permissions: + contents: read + actions: read + +jobs: + prune: + name: ClusterFuzzLite corpus pruning + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@351661ca32ac09a36dc5ee2d536e3128f2a3c8ed # v2.22.0 + with: + egress-policy: audit + + - name: Build fuzz targets + uses: google/clusterfuzzlite/actions/build_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1 + with: + language: go + + - name: Prune the corpus + uses: google/clusterfuzzlite/actions/run_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + language: go + mode: prune + fuzz-seconds: 600