Repository navigation
84 lines (75 loc) · 3.04 KB
/
Copy pathcontract-audit.yml
File metadata and controls
84 lines (75 loc) · 3.04 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
name: Smart Contract Audit
on:
push:
branches: ["main"]
paths:
- "packages/contracts/**"
- "scripts/contract-audit.sh"
- ".github/workflows/contract-audit.yml"
pull_request:
paths:
- "packages/contracts/**"
- "scripts/contract-audit.sh"
- ".github/workflows/contract-audit.yml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
x402-audit:
name: x402 Heuristic Contract Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v4.2.2
- name: Make audit script executable
run: chmod +x scripts/contract-audit.sh
- name: Run pre-deploy contract audit
env:
X402_PAYMENT_PROOF: ${{ secrets.X402_PAYMENT_PROOF }}
CONTRACT_AUDIT_ADDRESSES: ${{ vars.CONTRACT_AUDIT_ADDRESSES }}
CONTRACT_AUDIT_API_URL: ${{ vars.CONTRACT_AUDIT_API_URL }}
run: ./scripts/contract-audit.sh
- name: Build contracts and calculate WASM hashes
run: |
cd packages/contracts
rustup target add wasm32-unknown-unknown
# Build only workspace-member contracts (excludes non-member dirs like rent_escrow)
# Use cargo metadata to enumerate workspace package names, then filter to those
# whose manifest path lives under contracts/.
cargo metadata --no-deps --format-version 1 \
| python3 -c "
import sys, json
meta = json.load(sys.stdin)
for pkg in meta['packages']:
if '/contracts/' in pkg['manifest_path'].replace('\\\\','/') and \
'/test_fixtures/' not in pkg['manifest_path'].replace('\\\\','/') and \
'/tests/' not in pkg['manifest_path'].replace('\\\\','/'):
print(pkg['name'])
" | while read pkg_name; do
echo "Building $pkg_name..."
cargo build --release --target wasm32-unknown-unknown -p "$pkg_name"
done
mkdir -p ../../wasm-hashes
echo "# Reproducible WASM Hashes" > ../../wasm-hashes/wasm-hashes.txt
echo "Generated on: $(date -u)" >> ../../wasm-hashes/wasm-hashes.txt
echo "" >> ../../wasm-hashes/wasm-hashes.txt
for wasm in target/wasm32-unknown-unknown/release/*.wasm; do
if [ -f "$wasm" ]; then
hash=$(sha256sum "$wasm" | awk '{print $1}')
name=$(basename "$wasm")
echo "$hash $name" >> ../../wasm-hashes/wasm-hashes.txt
fi
done
cat ../../wasm-hashes/wasm-hashes.txt
- name: Upload WASM Hashes Artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4
with:
name: contract-wasm-hashes
path: wasm-hashes/wasm-hashes.txt
- name: Upload audit reports
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v4
with:
name: contract-audit-reports
path: audit-report-*.json
if-no-files-found: ignore