Skip to content

Commit 7f56316

Browse files
Merge pull request #20 from joshrotenberg/feat/security-audit-workflow
feat: add security audit workflow and fix crates.io README display
2 parents a1d0fd0 + 185a3a8 commit 7f56316

File tree

5 files changed

+105
-2
lines changed

5 files changed

+105
-2
lines changed

.github/workflows/security.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Security Audit
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- '**/Cargo.toml'
8+
- '**/Cargo.lock'
9+
- '.github/workflows/security.yml'
10+
pull_request:
11+
paths:
12+
- '**/Cargo.toml'
13+
- '**/Cargo.lock'
14+
- '.github/workflows/security.yml'
15+
schedule:
16+
- cron: '0 0 * * *' # Daily at midnight UTC
17+
18+
env:
19+
CARGO_TERM_COLOR: always
20+
21+
jobs:
22+
security-audit:
23+
name: Security Audit
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Install Rust
30+
uses: dtolnay/rust-toolchain@stable
31+
32+
- name: Cache cargo registry
33+
uses: Swatinem/rust-cache@v2
34+
with:
35+
cache-on-failure: true
36+
37+
- name: Install cargo-audit
38+
uses: taiki-e/install-action@v2
39+
with:
40+
tool: cargo-audit
41+
42+
- name: Run security audit
43+
run: cargo audit --deny warnings
44+
45+
- name: Run audit and generate SARIF
46+
run: cargo audit --json | python3 -c "
47+
import sys, json
48+
sarif = {
49+
'version': '2.1.0',
50+
'runs': [{
51+
'tool': {'driver': {'name': 'cargo-audit', 'informationUri': 'https://rustsec.org/'}},
52+
'results': []
53+
}]
54+
}
55+
try:
56+
data = json.load(sys.stdin)
57+
for vuln in data.get('vulnerabilities', {}).get('list', []):
58+
sarif['runs'][0]['results'].append({
59+
'ruleId': vuln['advisory']['id'],
60+
'level': 'error' if vuln['advisory'].get('cvss') and float(vuln['advisory']['cvss'].split('/')[0].split(':')[-1]) >= 7 else 'warning',
61+
'message': {'text': vuln['advisory']['title']},
62+
'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'Cargo.lock'}}}]
63+
})
64+
except: pass
65+
print(json.dumps(sarif))
66+
" > audit.sarif || echo '{"version":"2.1.0","runs":[{"tool":{"driver":{"name":"cargo-audit"}},"results":[]}]}' > audit.sarif
67+
68+
- name: Upload audit results to GitHub Security
69+
if: always()
70+
uses: github/codeql-action/upload-sarif@v3
71+
with:
72+
sarif_file: audit.sarif
73+
category: dependency-audit
74+
75+
cargo-deny:
76+
name: Dependency Check
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
82+
- name: Run cargo-deny
83+
uses: EmbarkStudios/cargo-deny-action@v2
84+
with:
85+
command: check
86+
arguments: --all-features
87+
continue-on-error: true # Don't fail until deny.toml is configured
88+
89+
dependency-review:
90+
name: Dependency Review
91+
runs-on: ubuntu-latest
92+
if: github.event_name == 'pull_request'
93+
steps:
94+
- name: Checkout code
95+
uses: actions/checkout@v4
96+
97+
- name: Dependency Review
98+
uses: actions/dependency-review-action@v4
99+
with:
100+
fail-on-severity: high
101+
deny-licenses: GPL-3.0, AGPL-3.0

crates/redis-cloud/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ documentation.workspace = true
1010
description = "Redis Cloud REST API client library"
1111
keywords = ["redis", "cloud", "api", "rest", "client"]
1212
categories = ["api-bindings", "database"]
13-
readme = "README.md"
13+
readme = "../../README.md"
1414

1515
[dependencies]
1616
async-trait = { workspace = true }

crates/redis-common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ homepage.workspace = true
99
description = "Shared utilities for Redis CLI tools"
1010
keywords = ["redis", "cli", "common", "utilities"]
1111
categories = ["command-line-utilities", "api-bindings"]
12+
readme = "../../README.md"
1213

1314
[dependencies]
1415
anyhow = { workspace = true }

crates/redis-enterprise/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ documentation.workspace = true
1010
description = "Redis Enterprise REST API client library"
1111
keywords = ["redis", "enterprise", "api", "rest", "client"]
1212
categories = ["api-bindings", "database"]
13-
readme = "README.md"
13+
readme = "../../README.md"
1414

1515
[dependencies]
1616
async-trait = { workspace = true }

crates/redisctl/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ homepage.workspace = true
99
description = "Unified CLI for Redis Cloud and Enterprise"
1010
keywords = ["redis", "cli", "cloud", "enterprise", "database"]
1111
categories = ["command-line-utilities", "api-bindings"]
12+
readme = "../../README.md"
1213

1314
[[bin]]
1415
name = "redisctl"

0 commit comments

Comments
 (0)