Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rust scaffolding #1817

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[advisories]
# advisory IDs to ignore e.g. ["RUSTSEC-2019-0001", ...]
ignore = []

# Output Configuration
[output]
deny = ["warnings"]
quiet = false

# Target Configuration
[target]
arch = "x86_64" # Ignore advisories for CPU architectures other than this one
os = "linux" # Ignore advisories for operating systems other than this one
26 changes: 26 additions & 0 deletions .github/workflows/cargo-vet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Roughly based off of https://mozilla.github.io/cargo-vet/configuring-ci.html

name: cargo vet

on: [push, pull_request]

jobs:
cargo-vet:
name: Vet Dependencies
runs-on: ubuntu-latest
# Keep version in sync with rust-toolchain.toml
container: rust:1.74.1
env:
CARGO_VET_VERSION: 0.9.0
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v2
id: cache-vet
with:
path: /usr/local/cargo/bin/cargo-vet
key: cargo-vet-${{ env.CARGO_VET_VERSION }}
- name: Install the cargo-vet binary, if needed
if: ${{ steps.cache-vet.outputs.cache-hit != 'true' }}
run: cargo install --version ${{ env.CARGO_VET_VERSION }} cargo-vet
- name: Invoke cargo-vet
run: cargo vet --locked
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,18 @@ jobs:
poetry install
poetry update safety
make safety

rust:
runs-on: ubuntu-latest
# Keep version in sync with rust-toolchain.toml
container: rust:1.74.1
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
rustup component add rustfmt
rustup component add clippy
- name: Lint and test Rust code
run: |
make rust-lint
make rust-test
16 changes: 16 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Security (cron)
on:
schedule:
- cron: '0 3 * * *'

jobs:
rust-audit:
runs-on: ubuntu-latest
# Keep version in sync with rust-toolchain.toml
container: rust:1.74.1
steps:
- uses: actions/checkout@v3
- name: Check Rust dependencies
run: |
cargo install cargo-audit
cargo audit
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = [
"proxy"
]
resolver = "2"
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ safety: ## Run safety dependency checks on build dependencies
--ignore 62044 \
-r

.PHONY: rust-lint
rust-lint: ## Lint Rust code
cargo fmt --check
cargo clippy

.PHONY: rust-test
rust-test: ## Run Rust tests
cargo test

# Explanation of the below shell command should it ever break.
# 1. Set the field separator to ": ##" and any make targets that might appear between : and ##
# 2. Use sed-like syntax to remove the make targets
Expand Down
8 changes: 8 additions & 0 deletions proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "securedrop-proxy"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
5 changes: 5 additions & 0 deletions proxy/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![deny(clippy::all)]

fn main() {
println!("Hello, world!");
}
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.74.1"
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
max_width = 80
4 changes: 4 additions & 0 deletions supply-chain/audits.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# cargo-vet audits file

[audits]
26 changes: 26 additions & 0 deletions supply-chain/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# cargo-vet config file

[cargo-vet]
version = "0.9"

[imports.bytecode-alliance]
url = "https://raw.githubusercontent.com/bytecodealliance/wasmtime/main/supply-chain/audits.toml"

[imports.google]
url = "https://raw.githubusercontent.com/google/supply-chain/main/audits.toml"

[imports.isrg]
url = "https://raw.githubusercontent.com/divviup/libprio-rs/main/supply-chain/audits.toml"

[imports.mozilla]
url = "https://raw.githubusercontent.com/mozilla/supply-chain/main/audits.toml"

[imports.securedrop]
url = "https://raw.githubusercontent.com/freedomofpress/securedrop-supply-chain/main/audits.toml"

[imports.zcash]
url = "https://raw.githubusercontent.com/zcash/rust-ecosystem/main/supply-chain/audits.toml"

[policy.securedrop-proxy]
criteria = "safe-to-run"
14 changes: 14 additions & 0 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# cargo-vet imports lock

[audits.bytecode-alliance.audits]

[audits.google.audits]

[audits.isrg.audits]

[audits.mozilla.audits]

[audits.securedrop.audits]

[audits.zcash.audits]