diff --git a/.cargo/audit.toml b/.cargo/audit.toml new file mode 100644 index 0000000..352d558 --- /dev/null +++ b/.cargo/audit.toml @@ -0,0 +1,8 @@ +[advisories] +ignore = [ + # Advisory about a vulnerability in rsa, which we don't use, but comes via sqlx due + # to a bug in cargo. For context, see: + # https://github.com/launchbadge/sqlx/issues/2911 + # and https://github.com/rust-lang/cargo/issues/10801 + "RUSTSEC-2023-0071" +] diff --git a/controller/.sqlx/query-843923b9a0257cf80f1dff554e7dc8fdfc05f489328e8376513124dfb42996e3.json b/controller/.sqlx/query-843923b9a0257cf80f1dff554e7dc8fdfc05f489328e8376513124dfb42996e3.json new file mode 100644 index 0000000..043a176 --- /dev/null +++ b/controller/.sqlx/query-843923b9a0257cf80f1dff554e7dc8fdfc05f489328e8376513124dfb42996e3.json @@ -0,0 +1,46 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT * FROM users WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "name", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "time_deleted", + "type_info": "Timestamptz" + }, + { + "ordinal": 3, + "name": "time_created", + "type_info": "Timestamptz" + }, + { + "ordinal": 4, + "name": "time_modified", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + true, + false, + false + ] + }, + "hash": "843923b9a0257cf80f1dff554e7dc8fdfc05f489328e8376513124dfb42996e3" +} diff --git a/controller/Cargo.toml b/controller/Cargo.toml index 2167aaa..2c3af62 100644 --- a/controller/Cargo.toml +++ b/controller/Cargo.toml @@ -15,7 +15,9 @@ schemars.workspace = true serde.workspace = true slog-async.workspace = true slog.workspace = true -sqlx = { version = "0.8.3", features = ["postgres", "runtime-tokio", "tls-rustls", "time", "uuid"] } +sqlx = { version = "0.8.3", default-features = false, features = [ + "macros", "postgres", "runtime-tokio", "tls-rustls", "time", "uuid" + ] } tokio.workspace = true trace-request = { path = "../trace-request" } tracing-slog.workspace = true diff --git a/controller/src/bin/patagia-controller.rs b/controller/src/bin/patagia-controller.rs index 70ba4bc..a3a492c 100644 --- a/controller/src/bin/patagia-controller.rs +++ b/controller/src/bin/patagia-controller.rs @@ -30,12 +30,12 @@ struct Cli { )] log_stderr: bool, - #[arg( - long = "listen-address", - default_value = "0.0.0.0:9474", - env = "LISTEN_ADDRESS" - )] - listen_address: String, + #[arg( + long = "listen-address", + default_value = "0.0.0.0:9474", + env = "LISTEN_ADDRESS" + )] + listen_address: String, #[arg( long = "database-url", @@ -66,7 +66,11 @@ async fn main() -> Result<()> { let database_url = args.database_url.unwrap(); - tracing::info!(database_url, listen_address=args.listen_address, "Starting server"); + tracing::info!( + database_url, + listen_address = args.listen_address, + "Starting server" + ); let pg = PgPool::connect(&database_url).await?; diff --git a/controller/src/context.rs b/controller/src/context.rs index 53931cc..b99d559 100644 --- a/controller/src/context.rs +++ b/controller/src/context.rs @@ -5,9 +5,7 @@ pub struct ControllerContext { } impl ControllerContext { - pub fn new(pg_pool : PgPool) -> ControllerContext { - ControllerContext { - pg_pool - } + pub fn new(pg_pool: PgPool) -> ControllerContext { + ControllerContext { pg_pool } } } diff --git a/controller/src/user.rs b/controller/src/user.rs index 56d45a6..bc8fa1a 100644 --- a/controller/src/user.rs +++ b/controller/src/user.rs @@ -42,10 +42,11 @@ pub(crate) async fn get_user_by_id( .fetch_one(&pg) .await .map_err(|e| match e { - sqlx::Error::RowNotFound => HttpError::for_not_found(None, format!("User not found by id: {:?}", id)), - err => HttpError::for_internal_error( format!("Error: {}", err)) - } - )?; + sqlx::Error::RowNotFound => { + HttpError::for_not_found(None, format!("User not found by id: {:?}", id)) + } + err => HttpError::for_internal_error(format!("Error: {}", err)), + })?; let user = User { id: rec.id, diff --git a/justfile b/justfile index b894834..e081281 100644 --- a/justfile +++ b/justfile @@ -84,18 +84,13 @@ dev-postgres-clean: dev-postgres-psql: podman exec -it patagia-postgres psql -U patagia -[group('controller')] -[working-directory: 'controller'] -dev-controller-sqlx *ARGS: - sqlx {{ARGS}} - [group('controller')] [working-directory: 'controller'] dev-controller-db-migrate: - sqlx migrate run + cargo sqlx migrate run [group('controller')] [working-directory: 'controller'] dev-controller-db-reset: - sqlx db reset -y + cargo sqlx db reset -y