Repository navigation
113 lines (103 loc) · 3.75 KB
/
Copy pathfuzz.yml
File metadata and controls
113 lines (103 loc) · 3.75 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
name: Fuzz
# Swift's -sanitize=fuzzer is Linux-only, so this runs in a Swift Linux
# container; IncomingLink needs only Foundation.
on:
schedule:
# Nightly, offset from the hour and from Thaw's run.
- cron: "43 3 * * *"
workflow_dispatch:
inputs:
duration:
description: Seconds to fuzz for
required: false
type: string
default: "300"
pull_request:
paths:
- "Tests/Fuzzing/**"
- "Sources/Floe/App/IncomingLink.swift"
- ".github/workflows/fuzz.yml"
push:
branches:
- development
paths:
- "Tests/Fuzzing/**"
- "Sources/Floe/App/IncomingLink.swift"
- ".github/workflows/fuzz.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
fuzz:
if: github.repository == 'thaw-app/Floe'
name: IncomingLink
runs-on: ubuntu-latest
timeout-minutes: 30
container:
image: swift@sha256:dd349c6dfc3cd3040910a84ab3e5bd5d08efdd547e5fb9f77b765abed16fe5ff # 6.2-noble
# Steps inside a container default to `sh -e {0}`, which rejects
# `set -o pipefail`.
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The corpus was saved under Fuzzing/ before it moved, and a cache is tied to its path.
# Remove these two steps once a nightly run has saved it under Tests/Fuzzing.
- name: Restore corpus saved before the move
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: Fuzzing/Corpus/IncomingLink
key: fuzz-corpus-incominglink-${{ github.run_id }}
restore-keys: |
fuzz-corpus-incominglink-
# Each night starts from the coverage the previous nights reached.
- name: Restore corpus
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: Tests/Fuzzing/Corpus/IncomingLink
key: fuzz-corpus-incominglink-${{ github.run_id }}
restore-keys: |
fuzz-corpus-incominglink-
- name: Add the corpus saved before the move
run: |
set -euo pipefail
if [ -d Fuzzing/Corpus/IncomingLink ]; then
mkdir -p Tests/Fuzzing/Corpus/IncomingLink
# Inputs are named by their content, so one in both is the same input.
cp -R Fuzzing/Corpus/IncomingLink/. Tests/Fuzzing/Corpus/IncomingLink/
rm -rf Fuzzing
fi
- name: Build fuzzer
run: |
set -euo pipefail
# Calls swiftc directly: SwiftPM links with --defsym main=<Module>_main, which
# -parse-as-library never emits.
mkdir -p Tests/Fuzzing/.build/release
swiftc -parse-as-library -O -sanitize=fuzzer,address \
-o Tests/Fuzzing/.build/release/FuzzIncomingLink \
Tests/Fuzzing/Sources/FuzzIncomingLink/*.swift
- name: Fuzz
env:
DURATION: ${{ inputs.duration || '300' }}
run: |
set -euo pipefail
mkdir -p Tests/Fuzzing/Corpus/IncomingLink artifacts
./Tests/Fuzzing/.build/release/FuzzIncomingLink \
-max_total_time="$DURATION" \
-print_final_stats=1 \
-artifact_prefix=artifacts/ \
Tests/Fuzzing/Corpus/IncomingLink
# A reproducer is the input needed to turn a finding into a regression test.
- name: Upload reproducers
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: fuzz-reproducers
path: artifacts/
if-no-files-found: ignore
retention-days: 30