Skip to content

Commit

Permalink
WIP: Add Rust scaffolding
Browse files Browse the repository at this point in the history
This adds all the various configuration and tooling to have a
proxy written in Rust.
  • Loading branch information
legoktm committed Feb 9, 2024
1 parent e3c61d3 commit efc9a00
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 0 deletions.
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 @@ -21,3 +21,18 @@ jobs:
- name: Lint .desktop files
run: |
make lint-desktop
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"
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ lint-desktop: ## Lint .desktop files
# See: https://www.freedesktop.org/wiki/Software/desktop-file-utils/
find . -name *.desktop -type f -not -path '*/\.git/*' | xargs desktop-file-validate

.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 ##
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]

0 comments on commit efc9a00

Please sign in to comment.