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

Update dependencies #140

Merged
merged 3 commits into from
Oct 18, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,266 changes: 757 additions & 509 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:alpine3.14
FROM rust:alpine3.18
ENV RUSTFLAGS="-C target-feature=-crt-static"
WORKDIR /usr/src/rebuilderd
RUN apk add --no-cache musl-dev openssl-dev shared-mime-info sqlite-dev xz-dev zstd-dev
Expand All @@ -10,7 +10,7 @@ RUN --mount=type=cache,target=/var/cache/buildkit \
cp -v /var/cache/buildkit/target/release/rebuilderd \
/var/cache/buildkit/target/release/rebuildctl /

FROM alpine:3.14
FROM alpine:3.18
RUN apk add --no-cache libgcc openssl shared-mime-info sqlite-libs xz zstd-libs
COPY --from=0 \
/rebuilderd /rebuildctl \
Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ reqwest = { version="0.11.11", features=["blocking", "json"] }
chrono = { version = "0.4.19", features=["serde"] }
colored = "2.0.0"
dirs-next = "2.0.0"
toml = "0.5.9"
toml = "0.8"
url = "2.2.2"
4 changes: 2 additions & 2 deletions common/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl AuthConfig {

fn read_cookie_from_config<P: AsRef<Path>>(path: P) -> Result<Option<String>> {
debug!("Attempting reading cookie from config: {:?}", path.as_ref());
if let Ok(buf) = fs::read(path.as_ref()) {
let config = toml::from_slice::<Config>(&buf)?;
if let Ok(buf) = fs::read_to_string(path.as_ref()) {
let config = toml::from_str::<Config>(&buf)?;
debug!("Found cookie in config {:?}", path.as_ref());
Ok(config.auth.cookie)
} else {
Expand Down
4 changes: 2 additions & 2 deletions common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ fn config_path() -> Result<PathBuf> {
}

fn load_from<P: AsRef<Path>>(path: P) -> Result<Option<ConfigFile>> {
if let Ok(buf) = fs::read(path.as_ref()) {
if let Ok(buf) = fs::read_to_string(path.as_ref()) {
debug!("loading config file {:?}", path.as_ref());
let config = toml::from_slice(&buf)
let config = toml::from_str(&buf)
.context("Failed to load config")?;
Ok(Some(config))
} else {
Expand Down
4 changes: 2 additions & 2 deletions daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ diesel = { version = "1.4.8", features = ["sqlite", "r2d2", "chrono"] }
diesel_migrations = { version = "1.4.0", features = ["sqlite"] }
dirs-next = "2.0.0"
dotenv = "0.15.0"
env_logger = "0.9.0"
env_logger = "0.10"
log = "0.4.17"
rand = "0.8.5"
rebuilderd-common = { version= "=0.19.0", path="../common" }
serde = { version="1.0.137", features=["derive"] }
serde_json = "1.0.81"
structopt = "0.3.26"
toml = "0.5.9"
toml = "0.8"

# https://crates.io/crates/deb-version
2 changes: 1 addition & 1 deletion daemon/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub async fn list_pkgs(
// Set Last-Modified header to the most recent build package time
// If If-Modified-Since header is set, compare it to the latest built time.
if let Some(latest_built_at) = models::Package::most_recent_built_at(connection.as_ref())? {
let latest_built_at = DateTime::from_utc(latest_built_at, Utc);
let latest_built_at = DateTime::from_naive_utc_and_offset(latest_built_at, Utc);
if let Some(duration) = modified_since_duration(&req, latest_built_at) {
if duration.num_seconds() >= 0 {
return Ok(not_modified());
Expand Down
4 changes: 2 additions & 2 deletions daemon/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ pub fn from_struct(config: ConfigFile, auth_cookie: String) -> Result<Config> {

pub fn load(path: Option<&Path>) -> Result<Config> {
let config = if let Some(path) = path {
let buf = fs::read(path)
let buf = fs::read_to_string(path)
.context("Failed to read config file")?;
toml::from_slice(&buf)?
toml::from_str(&buf)?
} else {
ConfigFile::default()
};
Expand Down
2 changes: 1 addition & 1 deletion tools/src/pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::process::{Command, Stdio};
pub fn write(buf: &[u8]) -> Result<()> {
if atty::is(atty::Stream::Stdout) && env::var_os("NOPAGER").is_none() {
let mut cmd = Command::new("less")
.args(&["-R"])
.args(["-R"])
.stdin(Stdio::piped())
.spawn()
.context("Failed to spawn pager")?;
Expand Down
8 changes: 4 additions & 4 deletions worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ assets = [
[dependencies]
rebuilderd-common = { version= "=0.19.0", path="../common" }
structopt = "0.3.26"
env_logger = "0.9.0"
base64 = "0.13.0"
toml = "0.5.9"
env_logger = "0.10.0"
data-encoding = "2"
toml = "0.8"
serde = { version="1.0.137", features=["derive"] }
serde_json = "1.0.81"
reqwest = { version="0.11.11", features = ["stream"] }
Expand All @@ -31,6 +31,6 @@ url = "2.2.2"
tokio = { version="1.19.2", features=["macros", "rt-multi-thread", "fs", "io-util", "process", "io-std", "time"] }
futures-util = "0.3.21"
futures = "0.3.21"
nix = "0.25"
nix = { version = "0.27", features = ["process", "signal"] }
in-toto = "0.3"
async-trait = "0.1.56"
4 changes: 2 additions & 2 deletions worker/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:alpine3.14
FROM rust:alpine3.18
ENV RUSTFLAGS="-C target-feature=-crt-static"
WORKDIR /usr/src/rebuilderd
RUN apk add --no-cache musl-dev openssl-dev pkgconfig
Expand All @@ -9,7 +9,7 @@ RUN --mount=type=cache,target=/var/cache/buildkit \
cargo build --release --locked -p rebuilderd-worker && \
cp -v /var/cache/buildkit/alpine/target/release/rebuilderd-worker /

FROM alpine:3.14
FROM alpine:3.18
RUN apk add --no-cache libgcc openssl
COPY --from=0 /rebuilderd-worker /usr/local/bin/
ENV REBUILDERD_WORKER_BACKEND=alpine=/usr/local/libexec/rebuilderd/rebuilder-alpine.sh
Expand Down
9 changes: 5 additions & 4 deletions worker/src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use data_encoding::BASE64;
use in_toto::crypto::{KeyType, PrivateKey, SignatureScheme};
use rebuilderd_common::api::Client;
use rebuilderd_common::config::ConfigFile;
use rebuilderd_common::errors::*;
use std::fs;
use std::path::Path;
use std::fs::OpenOptions;
use std::os::unix::fs::OpenOptionsExt;
use std::fs;
use std::io::ErrorKind;
use std::io::prelude::*;
use std::os::unix::fs::OpenOptionsExt;
use std::path::Path;

pub struct Profile {
pub pubkey: String,
Expand Down Expand Up @@ -58,7 +59,7 @@ fn load_key<P: AsRef<Path>>(path: P) -> Result<Profile> {
};

let pk = privkey.public();
let pubkey = base64::encode(pk.as_bytes());
let pubkey = BASE64.encode(pk.as_bytes());

Ok(Profile {
pubkey,
Expand Down
4 changes: 2 additions & 2 deletions worker/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ pub fn load(args: &Args) -> Result<ConfigFile> {

let mut conf = if let Some(path) = path {
info!("Loading configuration from {:?}", path);
let buf = fs::read(&path)
let buf = fs::read_to_string(&path)
.with_context(|| anyhow!("Failed to open {:?}", path))?;
toml::from_slice::<ConfigFile>(&buf)?
toml::from_str::<ConfigFile>(&buf)?
} else {
info!("Using default configuration");
ConfigFile::default()
Expand Down
8 changes: 4 additions & 4 deletions worker/src/rebuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,17 @@ mod tests {
#[tokio::test]
async fn compare_large_files_equal() {
let dir = tempfile::tempdir().unwrap();
fs::write(dir.path().join("a"), &[0u8; 4096 * 100]).unwrap();
fs::write(dir.path().join("b"), &[0u8; 4096 * 100]).unwrap();
fs::write(dir.path().join("a"), [0u8; 4096 * 100]).unwrap();
fs::write(dir.path().join("b"), [0u8; 4096 * 100]).unwrap();
let equal = compare_files(&dir.path().join("a"), &dir.path().join("b")).await.unwrap();
assert!(equal);
}

#[tokio::test]
async fn compare_large_files_not_equal() {
let dir = tempfile::tempdir().unwrap();
fs::write(dir.path().join("a"), &[0u8; 4096 * 100]).unwrap();
fs::write(dir.path().join("b"), &[1u8; 4096 * 100]).unwrap();
fs::write(dir.path().join("a"), [0u8; 4096 * 100]).unwrap();
fs::write(dir.path().join("b"), [1u8; 4096 * 100]).unwrap();
let equal = compare_files(&dir.path().join("a"), &dir.path().join("b")).await.unwrap();
assert!(!equal);
}
Expand Down