-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (78 loc) · 3.27 KB
/
Copy pathfuzz.yml
File metadata and controls
84 lines (78 loc) · 3.27 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
# Nightly fuzzing of the internet-facing parsers.
#
# `go test ./...` only ever runs the SEED corpora of these targets - nothing in
# the repo actually fuzzes. This does, one target per job (Go permits only one
# -fuzz target per invocation), and caches the generated corpus so coverage
# compounds night over night instead of restarting from the seeds each time.
#
# None of these packages import the root package, so - unlike every job in
# ci.yml - this workflow needs no frontend/dist.
name: fuzz
on:
schedule:
- cron: "0 3 * * *"
workflow_dispatch:
inputs:
fuzztime:
description: "Duration per target (e.g. 5m, 30m)"
required: false
default: "5m"
permissions:
contents: read
jobs:
fuzz:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- { pkg: ./internal/control, target: FuzzReadMsg }
- { pkg: ./internal/link, target: FuzzParsePairingCode }
- { pkg: ./internal/mc, target: FuzzReadVarInt }
- { pkg: ./internal/mc, target: FuzzParseHandshake }
- { pkg: ./internal/mc, target: FuzzReadPacket }
- { pkg: ./internal/mc, target: FuzzParseLoginStart }
- { pkg: ./internal/mc, target: FuzzSnifferChunked }
- { pkg: ./internal/mc, target: FuzzServeOffline }
- { pkg: ./internal/relay, target: FuzzTapChunked }
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
cache-dependency-path: go.sum
# We manage the corpus cache below; setup-go's cache covers GOCACHE too
# and the two would fight over the same directory.
cache: false
# Go writes generated corpus entries under $GOCACHE/fuzz. Restoring them
# is what turns 8 nightly 5-minute runs into a corpus that grows, rather
# than 8 cold starts.
- name: resolve GOCACHE
id: gocache
run: echo "dir=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.gocache.outputs.dir }}/fuzz
key: fuzz-corpus-${{ matrix.target }}-${{ github.run_id }}
restore-keys: |
fuzz-corpus-${{ matrix.target }}-
# FUZZTIME comes from workflow_dispatch, i.e. from a human typing into a
# form: it goes through env, never interpolated into the shell command, or
# it would be a template-injection vector.
- name: fuzz ${{ matrix.target }}
env:
TARGET: ${{ matrix.target }}
PKG: ${{ matrix.pkg }}
FUZZTIME: ${{ inputs.fuzztime || '5m' }}
run: go test -run '^$' -fuzz "^${TARGET}$" -fuzztime "$FUZZTIME" "$PKG"
# A crasher is written to <pkg>/testdata/fuzz/<Target>/. It is a real bug
# and a permanent regression seed: commit it with the fix.
- if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: crasher-${{ matrix.target }}
path: ${{ matrix.pkg }}/testdata/fuzz/**
if-no-files-found: ignore