Repository navigation
71 lines (59 loc) · 2.06 KB
/
Copy pathcontract-security.yml
File metadata and controls
71 lines (59 loc) · 2.06 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
name: Smart Contract Security Audit & Lint
on:
pull_request:
branches: [ "main", "dev" ]
paths:
- 'contracts/**'
- '.github/workflows/contract-security.yml'
permissions:
contents: read
jobs:
clippy:
name: Run Cargo Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: contracts
- name: Run Clippy
working-directory: ./contracts
run: cargo clippy --all-targets -- -D warnings -A clippy::inconsistent_digit_grouping
audit:
name: Run Cargo Audit
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Generate lockfile
working-directory: ./contracts
run: cargo generate-lockfile
- name: Verify Soroban host version
working-directory: ./contracts
shell: bash
run: |
host_version="$(cargo tree -i soroban-env-host --depth 0 | sed -n 's/^soroban-env-host v//p')"
if [ -z "$host_version" ] || [ "$(printf '%s\n22.1.1\n' "$host_version" | sort -V | head -n1)" != "22.1.1" ]; then
echo "soroban-env-host must resolve to 22.1.1 or newer; found: ${host_version:-unknown}"
exit 1
fi
- name: Verify Stellar XDR version
working-directory: ./contracts
shell: bash
run: |
xdr_version="$(cargo tree -i stellar-xdr --depth 0 | sed -n 's/^stellar-xdr v//p')"
if [ -z "$xdr_version" ] || [ "$(printf '%s\n21.2.0\n' "$xdr_version" | sort -V | head -n1)" != "21.2.0" ]; then
echo "stellar-xdr must resolve to 21.2.0 or newer; found: ${xdr_version:-unknown}"
exit 1
fi
- name: Run Cargo Audit
working-directory: ./contracts
run: cargo audit