Skip to content

Commit

Permalink
Bootstrap Rust project for noble-migration scripts
Browse files Browse the repository at this point in the history
Establish a folder where we can build Rust binaries that will
be shipped in the securedrop-config deb. That package is now
architecture-dependent and only built for amd64.

We are using Rust because a statically compiled binary is going
to be the most robust option during a system upgrade when Python
itself is being removed and installed (not to mention all the other
Rust benefits).
  • Loading branch information
legoktm committed Nov 21, 2024
1 parent f006815 commit 105a171
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]

members = [
"noble-migration",
"redwood",
]

Expand Down
6 changes: 4 additions & 2 deletions builder/build-debs-securedrop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ set -euxo pipefail

# Make a copy of the source tree since we do destructive operations on it
cp -R /src/securedrop /srv/securedrop
cp -R /src/redwood /srv/redwood
cp /src/Cargo.lock /srv/redwood/
mkdir /srv/rust
cp -R /src/noble-migration /srv/rust/noble-migration
cp -R /src/redwood /srv/rust/redwood
cp /src/Cargo.{toml,lock} /srv/rust/
cd /srv/securedrop/

# Control the version of setuptools used in the default construction of virtual environments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ip_info:
### Used by the install_local_deb_pkgs role ###
local_deb_packages:
- "securedrop-keyring_0.2.2+{{ securedrop_version }}+{{ securedrop_target_distribution }}_all.deb"
- "securedrop-config_{{ securedrop_version }}+{{ securedrop_target_distribution }}_all.deb"
- "securedrop-config_{{ securedrop_version }}+{{ securedrop_target_distribution }}_amd64.deb"
- "securedrop-ossec-agent_3.6.0+{{ securedrop_version }}+{{ securedrop_target_distribution }}_all.deb"
- "{{ securedrop_app_code_deb }}.deb"
- "ossec-agent_3.6.0+{{ securedrop_target_distribution }}_amd64.deb"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ip_info:
### Used by the install_local_deb_pkgs role ###
local_deb_packages:
- "securedrop-keyring_0.2.2+{{ securedrop_version }}+{{ securedrop_target_distribution }}_all.deb"
- "securedrop-config_{{ securedrop_version }}+{{ securedrop_target_distribution }}_all.deb"
- "securedrop-config_{{ securedrop_version }}+{{ securedrop_target_distribution }}_amd64.deb"
- "securedrop-ossec-server_3.6.0+{{ securedrop_version }}+{{ securedrop_target_distribution }}_all.deb"
- ossec-server_3.6.0+{{ securedrop_target_distribution }}_amd64.deb

Expand Down
6 changes: 6 additions & 0 deletions noble-migration/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "noble-migration"
version = "0.1.0"
edition = "2021"

[dependencies]
3 changes: 3 additions & 0 deletions noble-migration/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
4 changes: 2 additions & 2 deletions securedrop/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Depends: ${dist:Depends}, ${misc:Depends}, ${python3:Depends}, ${apparmor:Depend
Description: SecureDrop application code, dependencies, Apache configuration, systemd services, and AppArmor profiles. This package will put the AppArmor profiles in enforce mode.

Package: securedrop-config
Architecture: all
Depends: unattended-upgrades, update-notifier-common
Architecture: amd64
Depends: ${shlibs:Depends}, unattended-upgrades, update-notifier-common
Description: Establishes baseline system state for running SecureDrop.
Configures apt repositories.

Expand Down
9 changes: 7 additions & 2 deletions securedrop/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ override_dh_installdeb:
echo -n "" > ${CURDIR}/debian/securedrop-keyring/DEBIAN/conffiles

override_dh_auto_install:
# Build securedrop-config Rust code
cd /srv/rust/noble-migration && cargo build --release --locked && \
cd /srv/securedrop && \
mkdir -p ./debian/securedrop-config/usr/bin && \
mv /srv/rust/target/release/noble-migration ./debian/securedrop-config/usr/bin/noble-migration
# Build redwood wheel
python3 /srv/redwood/build-wheel.py --release --redwood /srv/redwood --target /srv/redwood/target
python3 /srv/rust/redwood/build-wheel.py --release --redwood /srv/rust/redwood --target /srv/rust/target
# Set up virtualenv and install dependencies
/usr/bin/python3 -m venv ./debian/securedrop-app-code/opt/venvs/securedrop-app-code
./debian/securedrop-app-code/opt/venvs/securedrop-app-code/bin/pip install $(PIP_ARGS) \
pip==24.2
./debian/securedrop-app-code/opt/venvs/securedrop-app-code/bin/pip install $(PIP_ARGS) \
-r requirements/python3/requirements.txt
./debian/securedrop-app-code/opt/venvs/securedrop-app-code/bin/pip install $(PIP_ARGS) \
/srv/redwood/redwood-*.whl
/srv/rust/redwood/redwood-*.whl
# Update paths to point to install destination
find ./debian/securedrop-app-code/ -type f -exec sed -i "s#$(shell pwd)/debian/securedrop-app-code##" {} \;
# Generage wsgi.load for apache
Expand Down
3 changes: 3 additions & 0 deletions supply-chain/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ notes = "Haiku OS-only"
criteria = []
notes = "WASM-only"

[policy.noble-migration]
criteria = "safe-to-run"

[policy.redox_syscall]
criteria = []
notes = "Redox OS-only"
Expand Down

0 comments on commit 105a171

Please sign in to comment.