Skip to content

Commit 6eeae48

Browse files
authored
Merge pull request #5 from mostafa/feat/ci-workflows
2 parents 0f00fcf + 40d6c99 commit 6eeae48

13 files changed

Lines changed: 957 additions & 24 deletions

File tree

‎.github/workflows/audit.yml‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Security Audit
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "Cargo.toml"
8+
- "Cargo.lock"
9+
- "go/ressrf/go.mod"
10+
- "go/ressrf/go.sum"
11+
pull_request:
12+
branches: [main]
13+
paths:
14+
- "Cargo.toml"
15+
- "Cargo.lock"
16+
- "go/ressrf/go.mod"
17+
- "go/ressrf/go.sum"
18+
schedule:
19+
- cron: "0 6 * * *" # Daily at 06:00 UTC
20+
21+
permissions: {}
22+
23+
concurrency:
24+
group: audit-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
cargo-audit:
29+
name: cargo audit
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: read # checkout
33+
steps:
34+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+
with:
36+
persist-credentials: false
37+
- run: rustup toolchain install stable --profile minimal
38+
- name: Install cargo-audit
39+
run: cargo install cargo-audit --locked
40+
- run: cargo audit
41+
42+
govulncheck:
43+
name: govulncheck
44+
runs-on: ubuntu-latest
45+
permissions:
46+
contents: read # checkout
47+
steps:
48+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
49+
with:
50+
persist-credentials: false
51+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v6.0.2
52+
with:
53+
go-version-file: go/ressrf/go.mod
54+
cache-dependency-path: go/ressrf/go.sum
55+
- name: Install govulncheck
56+
run: go install golang.org/x/vuln/cmd/govulncheck@latest
57+
- name: Run govulncheck
58+
working-directory: go/ressrf
59+
run: govulncheck ./...

‎.github/workflows/ci.yml‎

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths-ignore:
7+
- "**.md"
8+
- "docs/**"
9+
- "LICENSE"
10+
pull_request:
11+
branches: [main]
12+
paths-ignore:
13+
- "**.md"
14+
- "docs/**"
15+
- "LICENSE"
16+
17+
permissions: {}
18+
19+
concurrency:
20+
group: ci-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
env:
24+
CARGO_TERM_COLOR: always
25+
RUSTFLAGS: -Dwarnings
26+
27+
jobs:
28+
check:
29+
name: Check
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: read # checkout
33+
steps:
34+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+
with:
36+
persist-credentials: false
37+
- run: rustup toolchain install stable --profile minimal
38+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
39+
- run: cargo check --workspace --all-targets --all-features --locked
40+
41+
fmt:
42+
name: Format
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: read # checkout
46+
steps:
47+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
48+
with:
49+
persist-credentials: false
50+
- run: rustup toolchain install stable --profile minimal --component rustfmt
51+
- run: cargo fmt --all -- --check
52+
53+
clippy:
54+
name: Clippy
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: read # checkout
58+
steps:
59+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
60+
with:
61+
persist-credentials: false
62+
- run: rustup toolchain install stable --profile minimal --component clippy
63+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
64+
- run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
65+
66+
test-rust:
67+
name: Test Rust (${{ matrix.os }})
68+
runs-on: ${{ matrix.os }}
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
os: [ubuntu-latest, macos-latest, windows-latest]
73+
permissions:
74+
contents: read # checkout
75+
steps:
76+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
77+
with:
78+
persist-credentials: false
79+
- run: rustup toolchain install stable --profile minimal
80+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
81+
- run: cargo test --workspace --all-features --locked
82+
83+
build-wasm:
84+
name: Build WASM
85+
runs-on: ubuntu-latest
86+
permissions:
87+
contents: write # push updated core.wasm
88+
steps:
89+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
90+
with:
91+
ref: ${{ github.head_ref || github.ref_name }}
92+
persist-credentials: true # needed for git push in commit step
93+
- run: rustup toolchain install stable --profile minimal --target wasm32-wasip1
94+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
95+
- name: Install wasm-opt
96+
run: |
97+
curl -fsSL https://github.com/WebAssembly/binaryen/releases/download/version_129/binaryen-version_129-x86_64-linux.tar.gz \
98+
| sudo tar -xz -C /usr/local --strip-components=1
99+
- name: Install wasm-tools
100+
run: cargo install wasm-tools --locked
101+
- name: Rebuild core.wasm
102+
run: bash go/ressrf/build_wasm.sh
103+
- name: Commit if changed
104+
run: |
105+
if git diff --quiet go/ressrf/core.wasm; then
106+
echo "core.wasm is up to date"
107+
else
108+
git config user.name "github-actions[bot]"
109+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
110+
git add go/ressrf/core.wasm
111+
git commit -m "chore: rebuild core.wasm [ci]"
112+
git push
113+
fi
114+
115+
test-go:
116+
needs: [build-wasm]
117+
name: Test Go (${{ matrix.os }})
118+
runs-on: ${{ matrix.os }}
119+
strategy:
120+
fail-fast: false
121+
matrix:
122+
os: [ubuntu-latest, macos-latest, windows-latest]
123+
permissions:
124+
contents: read # checkout
125+
steps:
126+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
127+
with:
128+
ref: ${{ github.head_ref || github.ref_name }}
129+
persist-credentials: false
130+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v6.0.2
131+
with:
132+
go-version-file: go/ressrf/go.mod
133+
cache-dependency-path: go/ressrf/go.sum
134+
- name: Test
135+
working-directory: go/ressrf
136+
run: go test -count=1 -race ./...
137+
- name: Vet
138+
working-directory: go/ressrf
139+
run: go vet ./...
140+
141+
lint-go:
142+
needs: [build-wasm]
143+
name: Lint Go
144+
runs-on: ubuntu-latest
145+
permissions:
146+
contents: read # checkout
147+
steps:
148+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
149+
with:
150+
ref: ${{ github.head_ref || github.ref_name }}
151+
persist-credentials: false
152+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v6.0.2
153+
with:
154+
go-version-file: go/ressrf/go.mod
155+
cache-dependency-path: go/ressrf/go.sum
156+
- uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
157+
with:
158+
version: latest
159+
working-directory: go/ressrf

‎.github/workflows/fuzz.yml‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Fuzz
2+
3+
on:
4+
schedule:
5+
- cron: "0 3 * * 1" # Weekly on Monday at 03:00 UTC
6+
workflow_dispatch:
7+
inputs:
8+
duration:
9+
description: "Seconds per fuzz target"
10+
required: false
11+
default: "60"
12+
13+
permissions: {}
14+
15+
concurrency:
16+
group: fuzz-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
22+
jobs:
23+
fuzz:
24+
name: Fuzz (${{ matrix.target }})
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read # checkout
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
include:
32+
- target: fuzz_cidr
33+
max_len: 512
34+
- target: fuzz_policy
35+
max_len: 4096
36+
- target: fuzz_url_validator
37+
max_len: 2048
38+
steps:
39+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
40+
with:
41+
persist-credentials: false
42+
43+
- name: Install nightly toolchain
44+
run: |
45+
rustup toolchain install nightly --profile minimal --component llvm-tools-preview
46+
rustup default nightly
47+
48+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
49+
with:
50+
workspaces: fuzz -> target
51+
52+
- name: Install cargo-fuzz
53+
run: cargo install cargo-fuzz --locked
54+
55+
- name: Restore corpus cache
56+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
57+
with:
58+
path: fuzz/corpus/${{ matrix.target }}
59+
key: fuzz-corpus-${{ matrix.target }}-${{ github.sha }}
60+
restore-keys: |
61+
fuzz-corpus-${{ matrix.target }}-
62+
63+
- name: Run fuzzer
64+
working-directory: fuzz
65+
env:
66+
FUZZ_TARGET: ${{ matrix.target }}
67+
FUZZ_MAX_LEN: ${{ matrix.max_len }}
68+
FUZZ_DURATION: ${{ github.event.inputs.duration || '60' }}
69+
run: |
70+
mkdir -p "corpus/${FUZZ_TARGET}"
71+
cargo +nightly fuzz run "${FUZZ_TARGET}" \
72+
"corpus/${FUZZ_TARGET}" -- \
73+
-max_total_time="${FUZZ_DURATION}" \
74+
-timeout=10 \
75+
-max_len="${FUZZ_MAX_LEN}"
76+
77+
- name: Upload crash artifacts
78+
if: failure()
79+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
80+
with:
81+
name: fuzz-crashes-${{ matrix.target }}
82+
path: fuzz/artifacts/${{ matrix.target }}/
83+
retention-days: 30

‎.github/workflows/zizmor.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Zizmor
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- ".github/workflows/**"
8+
pull_request:
9+
branches: [main]
10+
paths:
11+
- ".github/workflows/**"
12+
13+
permissions: {}
14+
15+
concurrency:
16+
group: zizmor-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
zizmor:
21+
name: Workflow security lint
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read # checkout
25+
steps:
26+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
with:
28+
persist-credentials: false
29+
- name: Install zizmor
30+
run: pip install zizmor
31+
- name: Run zizmor
32+
run: zizmor --pedantic .github/workflows/

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ __pycache__/
2929
node/node_modules/
3030
node/dist/
3131

32-
# WASM build artifacts (built via go generate / npm run build)
32+
# WASM build artifacts
3333
*.wasm
34+
!go/ressrf/core.wasm

0 commit comments

Comments
 (0)