-
Notifications
You must be signed in to change notification settings - Fork 4
189 lines (167 loc) · 6.8 KB
/
Copy pathfuzz.yml
File metadata and controls
189 lines (167 loc) · 6.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Fuzz
on:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:
permissions: {}
env:
CARGO_TERM_COLOR: always
jobs:
fuzz:
name: Fuzz (${{ matrix.target }})
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
issues: write
strategy:
fail-fast: false
matrix:
include:
- target: skill_frontmatter
budget: 300
- target: skill_extensions
budget: 300
- target: chunk_file
budget: 300
- target: config_toml
budget: 120
- target: plugin_manifest
budget: 300
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@4fd1da8b0805d2d2e936788875a7d65dbd677dc2 # nightly
- uses: taiki-e/install-action@82fc405565b9cf90abfe700ba43b4751ce2fe422 # cargo-fuzz
with:
tool: cargo-fuzz
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
workspaces: fuzz -> target
prefix-key: fuzz-${{ matrix.target }}
- name: Fuzz ${{ matrix.target }}
id: fuzz
working-directory: fuzz
run: cargo +nightly fuzz run ${{ matrix.target }} -- -max_total_time=${{ matrix.budget }}
- name: Minimize crash and file issue
if: failure() && steps.fuzz.outcome == 'failure'
working-directory: fuzz
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FUZZ_TARGET: ${{ matrix.target }}
run: |
crash="$(ls -t "artifacts/${FUZZ_TARGET}"/* 2>/dev/null | head -1)"
if [[ -z "$crash" ]]; then
echo "no crash artifact found under artifacts/${FUZZ_TARGET}/, skipping issue filing"
exit 0
fi
cargo +nightly fuzz tmin "$FUZZ_TARGET" "$crash" || true
title="fuzz: crash in ${FUZZ_TARGET}"
existing="$(gh issue list --repo "$GITHUB_REPOSITORY" --state open \
--search "${title} in:title" --json number,title \
--jq "[.[] | select(.title == \"${title}\")] | .[0].number" || true)"
if [[ -n "$existing" ]]; then
echo "open issue #$existing already tracks a crash in ${FUZZ_TARGET}, skipping duplicate"
exit 0
fi
body_file="$(mktemp)"
{
echo "## Fuzz crash"
echo ""
echo "Target: \`${FUZZ_TARGET}\`"
echo "Commit: ${GITHUB_SHA}"
echo "Workflow run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
echo ""
echo "The authoritative reproducer is attached to the workflow run above as the"
echo "\`fuzz-artifacts\` artifact, under \`${FUZZ_TARGET}/\`. A base64 copy of the"
echo "original (non-minimized) crash input is included below for quick inspection."
echo ""
echo '```'
base64 "$crash"
echo '```'
} > "$body_file"
gh issue create --repo "$GITHUB_REPOSITORY" \
--title "fuzz: crash in ${FUZZ_TARGET}" \
--label bug --label P1 \
--body-file "$body_file"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: always()
with:
name: fuzz-corpus-${{ matrix.target }}
path: fuzz/corpus/${{ matrix.target }}/
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: always()
with:
name: fuzz-artifacts-${{ matrix.target }}
path: fuzz/artifacts/${{ matrix.target }}/
if-no-files-found: ignore
coverage:
name: Coverage (${{ matrix.target }})
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
strategy:
fail-fast: false
matrix:
target:
- skill_frontmatter
- skill_extensions
- chunk_file
- config_toml
- plugin_manifest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@4fd1da8b0805d2d2e936788875a7d65dbd677dc2 # nightly
with:
components: llvm-tools-preview
- uses: taiki-e/install-action@afc483d62172accfff644fa56e82b4dab50727fc # cargo-fuzz, cargo-binutils
with:
tool: cargo-fuzz, cargo-binutils
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
workspaces: fuzz -> target
prefix-key: fuzz-coverage-${{ matrix.target }}
# Visibility only: replays the committed seed corpus (no libFuzzer mutation) through an
# instrumented binary to report which lines/branches the corpus reaches. Does not run
# crash-finding — that's the `fuzz` job above — and continue-on-error here means a
# tooling failure in this step must never fail the crash-finding `fuzz` job.
- name: Generate coverage profile
id: coverage
continue-on-error: true
working-directory: fuzz
run: cargo +nightly fuzz coverage ${{ matrix.target }}
# Uses `rust-cov` (the cargo-binutils-installed llvm-cov wrapper) directly rather than
# the `cargo cov --` subcommand: cargo-binutils 0.4.0's `cargo cov`/`cargo profdata`
# subcommand parsing panics unconditionally on a clap `ArgAction` incompatibility
# (`arg 'no-default-features's 'ArgAction' should be one of 'SetTrue', 'SetFalse'`),
# confirmed even on bare `cargo cov -- --help`. `rust-cov` itself is unaffected.
- name: Text coverage report
if: steps.coverage.outcome == 'success'
continue-on-error: true
working-directory: fuzz
run: |
triple="$(rustc -vV | sed -n 's/^host: //p')"
bin="target/${triple}/coverage/${triple}/release/${{ matrix.target }}"
rust-cov report \
--instr-profile="coverage/${{ matrix.target }}/coverage.profdata" \
"$bin" \
| tee "coverage-${{ matrix.target }}.txt"
- name: HTML coverage report
if: steps.coverage.outcome == 'success'
continue-on-error: true
working-directory: fuzz
run: |
triple="$(rustc -vV | sed -n 's/^host: //p')"
bin="target/${triple}/coverage/${triple}/release/${{ matrix.target }}"
rust-cov show \
--instr-profile="coverage/${{ matrix.target }}/coverage.profdata" \
"$bin" \
--format=html --output-dir="coverage-html-${{ matrix.target }}"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: always()
with:
name: fuzz-coverage-${{ matrix.target }}
path: |
fuzz/coverage-${{ matrix.target }}.txt
fuzz/coverage-html-${{ matrix.target }}/
if-no-files-found: ignore