style: rustfmt after merging the release branches
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,10 +33,12 @@ fn every_registered_path_has_an_authorization_contract() {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn human_read_endpoints_reject_anonymous_and_outpost_tokens() {
|
async fn human_read_endpoints_reject_anonymous_and_outpost_tokens() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state =
|
let mut state = crate::state::HubState::bootstrap(
|
||||||
crate::state::HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
dir.path().to_str().unwrap(),
|
||||||
.await
|
"synthetic-vault-passphrase",
|
||||||
.unwrap();
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
state.sessions = crate::admin::SessionGate::fixture(state.db.clone());
|
state.sessions = crate::admin::SessionGate::fixture(state.db.clone());
|
||||||
state.admin.token = Some("synthetic-admin".into());
|
state.admin.token = Some("synthetic-admin".into());
|
||||||
let outpost = uuid::Uuid::new_v4();
|
let outpost = uuid::Uuid::new_v4();
|
||||||
@@ -54,9 +56,13 @@ async fn human_read_endpoints_reject_anonymous_and_outpost_tokens() {
|
|||||||
let path = fields[1].replace(":id", "00000000-0000-0000-0000-000000000001");
|
let path = fields[1].replace(":id", "00000000-0000-0000-0000-000000000001");
|
||||||
for token in [None, Some("synthetic-outpost")] {
|
for token in [None, Some("synthetic-outpost")] {
|
||||||
source += 1;
|
source += 1;
|
||||||
let mut request = Request::builder().uri(&path).extension(ConnectInfo(
|
let mut request =
|
||||||
SocketAddr::from(([10, 0, (source >> 8) as u8, source as u8], 9000)),
|
Request::builder()
|
||||||
));
|
.uri(&path)
|
||||||
|
.extension(ConnectInfo(SocketAddr::from((
|
||||||
|
[10, 0, (source >> 8) as u8, source as u8],
|
||||||
|
9000,
|
||||||
|
))));
|
||||||
if let Some(token) = token {
|
if let Some(token) = token {
|
||||||
request = request
|
request = request
|
||||||
.header(header::AUTHORIZATION, format!("Bearer {token}"))
|
.header(header::AUTHORIZATION, format!("Bearer {token}"))
|
||||||
@@ -79,10 +85,12 @@ async fn human_read_endpoints_reject_anonymous_and_outpost_tokens() {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn local_proxy_never_enables_auth_when_credentials_are_absent() {
|
async fn local_proxy_never_enables_auth_when_credentials_are_absent() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state =
|
let mut state = crate::state::HubState::bootstrap(
|
||||||
crate::state::HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
dir.path().to_str().unwrap(),
|
||||||
.await
|
"synthetic-vault-passphrase",
|
||||||
.unwrap();
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
state.admin = crate::admin::AdminGate {
|
state.admin = crate::admin::AdminGate {
|
||||||
token: None,
|
token: None,
|
||||||
local_development: false,
|
local_development: false,
|
||||||
|
|||||||
@@ -422,10 +422,7 @@ pub fn router(state: HubState) -> Router {
|
|||||||
.route("/api-doc/openapi.json", get(openapi_document))
|
.route("/api-doc/openapi.json", get(openapi_document))
|
||||||
.with_state(state);
|
.with_state(state);
|
||||||
|
|
||||||
let hsts = matches!(
|
let hsts = matches!(std::env::var("TESSERA_HSTS").as_deref(), Ok("1" | "true"));
|
||||||
std::env::var("TESSERA_HSTS").as_deref(),
|
|
||||||
Ok("1" | "true")
|
|
||||||
);
|
|
||||||
api.fallback(spa_fallback)
|
api.fallback(spa_fallback)
|
||||||
.layer(TraceLayer::new_for_http().make_span_with(request_span))
|
.layer(TraceLayer::new_for_http().make_span_with(request_span))
|
||||||
.layer(axum::middleware::from_fn(move |request, next| {
|
.layer(axum::middleware::from_fn(move |request, next| {
|
||||||
@@ -460,7 +457,10 @@ async fn security_headers(
|
|||||||
header::X_CONTENT_TYPE_OPTIONS,
|
header::X_CONTENT_TYPE_OPTIONS,
|
||||||
HeaderValue::from_static("nosniff"),
|
HeaderValue::from_static("nosniff"),
|
||||||
);
|
);
|
||||||
headers.insert(header::REFERRER_POLICY, HeaderValue::from_static("no-referrer"));
|
headers.insert(
|
||||||
|
header::REFERRER_POLICY,
|
||||||
|
HeaderValue::from_static("no-referrer"),
|
||||||
|
);
|
||||||
headers.insert(header::X_FRAME_OPTIONS, HeaderValue::from_static("DENY"));
|
headers.insert(header::X_FRAME_OPTIONS, HeaderValue::from_static("DENY"));
|
||||||
if hsts {
|
if hsts {
|
||||||
headers.insert(
|
headers.insert(
|
||||||
@@ -1635,23 +1635,30 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn unauthenticated_floods_write_one_denial_row_per_source() {
|
async fn unauthenticated_floods_write_one_denial_row_per_source() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state = HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
let mut state =
|
||||||
.await
|
HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
||||||
.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
||||||
let app = router(state);
|
let app = router(state);
|
||||||
let human = |ip: &str| {
|
let human = |ip: &str| {
|
||||||
Request::get("/api/v1/orbits")
|
Request::get("/api/v1/orbits")
|
||||||
.extension(ConnectInfo(format!("{ip}:9000").parse::<SocketAddr>().unwrap()))
|
.extension(ConnectInfo(
|
||||||
|
format!("{ip}:9000").parse::<SocketAddr>().unwrap(),
|
||||||
|
))
|
||||||
.body(Body::empty())
|
.body(Body::empty())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
let outpost = |ip: &str| {
|
let outpost = |ip: &str| {
|
||||||
Request::post("/api/v1/wormhole/upload/init")
|
Request::post("/api/v1/wormhole/upload/init")
|
||||||
.extension(ConnectInfo(format!("{ip}:9000").parse::<SocketAddr>().unwrap()))
|
.extension(ConnectInfo(
|
||||||
|
format!("{ip}:9000").parse::<SocketAddr>().unwrap(),
|
||||||
|
))
|
||||||
.header(header::CONTENT_TYPE, "application/json")
|
.header(header::CONTENT_TYPE, "application/json")
|
||||||
.header("x-tessera-upload-token", "wrong")
|
.header("x-tessera-upload-token", "wrong")
|
||||||
.body(Body::from(r#"{"orbit_id":"00000000-0000-0000-0000-000000000000","total_bytes":1}"#))
|
.body(Body::from(
|
||||||
|
r#"{"orbit_id":"00000000-0000-0000-0000-000000000000","total_bytes":1}"#,
|
||||||
|
))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
for _ in 0..25 {
|
for _ in 0..25 {
|
||||||
@@ -1674,21 +1681,28 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn wrong_admin_tokens_are_throttled_per_source() {
|
async fn wrong_admin_tokens_are_throttled_per_source() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state = HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
let mut state =
|
||||||
.await
|
HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
||||||
.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
||||||
let app = router(state);
|
let app = router(state);
|
||||||
let req = |ip: &str, token: &str| {
|
let req = |ip: &str, token: &str| {
|
||||||
Request::get("/api/v1/orbits")
|
Request::get("/api/v1/orbits")
|
||||||
.extension(ConnectInfo(format!("{ip}:9000").parse::<SocketAddr>().unwrap()))
|
.extension(ConnectInfo(
|
||||||
|
format!("{ip}:9000").parse::<SocketAddr>().unwrap(),
|
||||||
|
))
|
||||||
.header("x-tessera-admin-token", token)
|
.header("x-tessera-admin-token", token)
|
||||||
.body(Body::empty())
|
.body(Body::empty())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
let mut limited = false;
|
let mut limited = false;
|
||||||
for _ in 0..20 {
|
for _ in 0..20 {
|
||||||
let r = app.clone().oneshot(req("203.0.113.20", "wrong")).await.unwrap();
|
let r = app
|
||||||
|
.clone()
|
||||||
|
.oneshot(req("203.0.113.20", "wrong"))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
limited |= r.status() == StatusCode::TOO_MANY_REQUESTS;
|
limited |= r.status() == StatusCode::TOO_MANY_REQUESTS;
|
||||||
}
|
}
|
||||||
assert!(limited);
|
assert!(limited);
|
||||||
@@ -1699,18 +1713,25 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn reconstitute_targets_stay_inside_the_exports_directory_for_every_caller() {
|
async fn reconstitute_targets_stay_inside_the_exports_directory_for_every_caller() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state = HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
let mut state =
|
||||||
.await
|
HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
||||||
.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
||||||
let app = router(state);
|
let app = router(state);
|
||||||
let attempt = |path: &str| {
|
let attempt = |path: &str| {
|
||||||
Request::post("/api/v1/reconstitute")
|
Request::post("/api/v1/reconstitute")
|
||||||
.extension(ConnectInfo("203.0.113.30:9000".parse::<SocketAddr>().unwrap()))
|
.extension(ConnectInfo(
|
||||||
.header(header::AUTHORIZATION, "Bearer synthetic-admin-token-of-32-chars!")
|
"203.0.113.30:9000".parse::<SocketAddr>().unwrap(),
|
||||||
|
))
|
||||||
|
.header(
|
||||||
|
header::AUTHORIZATION,
|
||||||
|
"Bearer synthetic-admin-token-of-32-chars!",
|
||||||
|
)
|
||||||
.header(header::CONTENT_TYPE, "application/json")
|
.header(header::CONTENT_TYPE, "application/json")
|
||||||
.body(Body::from(
|
.body(Body::from(
|
||||||
serde_json::json!({"snapshot_id": Uuid::new_v4(), "target_path": path}).to_string(),
|
serde_json::json!({"snapshot_id": Uuid::new_v4(), "target_path": path})
|
||||||
|
.to_string(),
|
||||||
))
|
))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
@@ -1749,14 +1770,18 @@ mod tests {
|
|||||||
let sink = Sink::default();
|
let sink = Sink::default();
|
||||||
let subscriber = tracing_subscriber::fmt().with_writer(sink.clone()).finish();
|
let subscriber = tracing_subscriber::fmt().with_writer(sink.clone()).finish();
|
||||||
tracing::subscriber::with_default(subscriber, || {
|
tracing::subscriber::with_default(subscriber, || {
|
||||||
let request = Request::get("/api/v1/auth/oidc/callback?code=secret-code&state=secret-state")
|
let request =
|
||||||
.body(Body::empty())
|
Request::get("/api/v1/auth/oidc/callback?code=secret-code&state=secret-state")
|
||||||
.unwrap();
|
.body(Body::empty())
|
||||||
|
.unwrap();
|
||||||
request_span(&request).in_scope(|| tracing::info!("handled"));
|
request_span(&request).in_scope(|| tracing::info!("handled"));
|
||||||
});
|
});
|
||||||
let logged = String::from_utf8(sink.0.lock().unwrap().clone()).unwrap();
|
let logged = String::from_utf8(sink.0.lock().unwrap().clone()).unwrap();
|
||||||
assert!(logged.contains("/api/v1/auth/oidc/callback"), "{logged}");
|
assert!(logged.contains("/api/v1/auth/oidc/callback"), "{logged}");
|
||||||
assert!(!logged.contains("secret-code") && !logged.contains("secret-state"), "{logged}");
|
assert!(
|
||||||
|
!logged.contains("secret-code") && !logged.contains("secret-state"),
|
||||||
|
"{logged}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1774,14 +1799,16 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn the_api_description_is_not_served_to_anonymous_callers() {
|
async fn the_api_description_is_not_served_to_anonymous_callers() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state = HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
let mut state =
|
||||||
.await
|
HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
||||||
.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
||||||
let app = router(state);
|
let app = router(state);
|
||||||
let request = |token: Option<&str>| {
|
let request = |token: Option<&str>| {
|
||||||
let mut r = Request::get("/api-doc/openapi.json")
|
let mut r = Request::get("/api-doc/openapi.json").extension(ConnectInfo(
|
||||||
.extension(ConnectInfo("203.0.113.50:9000".parse::<SocketAddr>().unwrap()));
|
"203.0.113.50:9000".parse::<SocketAddr>().unwrap(),
|
||||||
|
));
|
||||||
if let Some(token) = token {
|
if let Some(token) = token {
|
||||||
r = r.header(header::AUTHORIZATION, format!("Bearer {token}"));
|
r = r.header(header::AUTHORIZATION, format!("Bearer {token}"));
|
||||||
}
|
}
|
||||||
@@ -1805,7 +1832,9 @@ mod tests {
|
|||||||
let app = router(state);
|
let app = router(state);
|
||||||
let get = |uri: &str| {
|
let get = |uri: &str| {
|
||||||
Request::get(uri)
|
Request::get(uri)
|
||||||
.extension(ConnectInfo("203.0.113.40:9000".parse::<SocketAddr>().unwrap()))
|
.extension(ConnectInfo(
|
||||||
|
"203.0.113.40:9000".parse::<SocketAddr>().unwrap(),
|
||||||
|
))
|
||||||
.body(Body::empty())
|
.body(Body::empty())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
@@ -1834,9 +1863,10 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn a_failed_denial_audit_write_still_answers_401() {
|
async fn a_failed_denial_audit_write_still_answers_401() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state = HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
let mut state =
|
||||||
.await
|
HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
||||||
.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
state.admin.token = Some("synthetic-admin-token-of-32-chars!".into());
|
||||||
let app = router(state);
|
let app = router(state);
|
||||||
rusqlite::Connection::open(dir.path().join("tessera.db"))
|
rusqlite::Connection::open(dir.path().join("tessera.db"))
|
||||||
@@ -1844,7 +1874,9 @@ mod tests {
|
|||||||
.execute_batch("DROP TABLE audit_events")
|
.execute_batch("DROP TABLE audit_events")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let human = Request::get("/api/v1/orbits")
|
let human = Request::get("/api/v1/orbits")
|
||||||
.extension(ConnectInfo("203.0.113.9:9000".parse::<SocketAddr>().unwrap()))
|
.extension(ConnectInfo(
|
||||||
|
"203.0.113.9:9000".parse::<SocketAddr>().unwrap(),
|
||||||
|
))
|
||||||
.body(Body::empty())
|
.body(Body::empty())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -1852,10 +1884,14 @@ mod tests {
|
|||||||
StatusCode::UNAUTHORIZED
|
StatusCode::UNAUTHORIZED
|
||||||
);
|
);
|
||||||
let outpost = Request::post("/api/v1/wormhole/upload/init")
|
let outpost = Request::post("/api/v1/wormhole/upload/init")
|
||||||
.extension(ConnectInfo("203.0.113.10:9000".parse::<SocketAddr>().unwrap()))
|
.extension(ConnectInfo(
|
||||||
|
"203.0.113.10:9000".parse::<SocketAddr>().unwrap(),
|
||||||
|
))
|
||||||
.header(header::CONTENT_TYPE, "application/json")
|
.header(header::CONTENT_TYPE, "application/json")
|
||||||
.header("x-tessera-upload-token", "wrong")
|
.header("x-tessera-upload-token", "wrong")
|
||||||
.body(Body::from(r#"{"orbit_id":"00000000-0000-0000-0000-000000000000","total_bytes":1}"#))
|
.body(Body::from(
|
||||||
|
r#"{"orbit_id":"00000000-0000-0000-0000-000000000000","total_bytes":1}"#,
|
||||||
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.oneshot(outpost).await.unwrap().status(),
|
app.oneshot(outpost).await.unwrap().status(),
|
||||||
@@ -1866,9 +1902,10 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn legacy_uploads_are_owned_by_the_assigned_outpost() {
|
async fn legacy_uploads_are_owned_by_the_assigned_outpost() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state = HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
let mut state =
|
||||||
.await
|
HubState::bootstrap(dir.path().to_str().unwrap(), "synthetic-vault-passphrase")
|
||||||
.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
state.accept_plain_upload = true;
|
state.accept_plain_upload = true;
|
||||||
state.admin.token = Some("synthetic-admin".into());
|
state.admin.token = Some("synthetic-admin".into());
|
||||||
let a = Uuid::new_v4();
|
let a = Uuid::new_v4();
|
||||||
|
|||||||
@@ -369,9 +369,10 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn operator_session_requires_csrf_and_expires_without_disabling_cli() {
|
async fn operator_session_requires_csrf_and_expires_without_disabling_cli() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state = HubState::bootstrap(dir.path().to_str().unwrap(), "fixture-vault-passphrase")
|
let mut state =
|
||||||
.await
|
HubState::bootstrap(dir.path().to_str().unwrap(), "fixture-vault-passphrase")
|
||||||
.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
state.sessions = SessionGate::fixture(state.db.clone());
|
state.sessions = SessionGate::fixture(state.db.clone());
|
||||||
state.admin.token = Some("fixture-api-token".into());
|
state.admin.token = Some("fixture-api-token".into());
|
||||||
let app = crate::api::router(state.clone());
|
let app = crate::api::router(state.clone());
|
||||||
@@ -507,9 +508,10 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn me_reports_the_caller_and_rejects_anonymous() {
|
async fn me_reports_the_caller_and_rejects_anonymous() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
let mut state = HubState::bootstrap(dir.path().to_str().unwrap(), "fixture-vault-passphrase")
|
let mut state =
|
||||||
.await
|
HubState::bootstrap(dir.path().to_str().unwrap(), "fixture-vault-passphrase")
|
||||||
.unwrap();
|
.await
|
||||||
|
.unwrap();
|
||||||
state.sessions = SessionGate::fixture(state.db.clone());
|
state.sessions = SessionGate::fixture(state.db.clone());
|
||||||
let app = crate::api::router(state);
|
let app = crate::api::router(state);
|
||||||
let peer = || ConnectInfo("127.0.0.1:1234".parse::<SocketAddr>().unwrap());
|
let peer = || ConnectInfo("127.0.0.1:1234".parse::<SocketAddr>().unwrap());
|
||||||
|
|||||||
@@ -86,7 +86,10 @@ mod tests {
|
|||||||
db.conn
|
db.conn
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.execute("UPDATE audit_events SET at = ?1 WHERE id <= 2", params![now - 100 * 86_400])
|
.execute(
|
||||||
|
"UPDATE audit_events SET at = ?1 WHERE id <= 2",
|
||||||
|
params![now - 100 * 86_400],
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(db.prune_audit_events(now - 90 * 86_400).unwrap(), 2);
|
assert_eq!(db.prune_audit_events(now - 90 * 86_400).unwrap(), 2);
|
||||||
let left: i64 = db
|
let left: i64 = db
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ const DEFAULT_AUDIT_RETENTION_DAYS: i64 = 90;
|
|||||||
/// `TESSERA_AUDIT_RETENTION_DAYS`: how long structured audit events are kept.
|
/// `TESSERA_AUDIT_RETENTION_DAYS`: how long structured audit events are kept.
|
||||||
/// Unset means 90 days; `0` keeps them forever.
|
/// Unset means 90 days; `0` keeps them forever.
|
||||||
pub fn audit_retention_from_env() -> Result<Option<i64>> {
|
pub fn audit_retention_from_env() -> Result<Option<i64>> {
|
||||||
parse_audit_retention(std::env::var("TESSERA_AUDIT_RETENTION_DAYS").ok().as_deref())
|
parse_audit_retention(
|
||||||
|
std::env::var("TESSERA_AUDIT_RETENTION_DAYS")
|
||||||
|
.ok()
|
||||||
|
.as_deref(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_audit_retention(value: Option<&str>) -> Result<Option<i64>> {
|
fn parse_audit_retention(value: Option<&str>) -> Result<Option<i64>> {
|
||||||
@@ -48,7 +52,9 @@ fn parse_audit_retention(value: Option<&str>) -> Result<Option<i64>> {
|
|||||||
.parse()
|
.parse()
|
||||||
.ok()
|
.ok()
|
||||||
.filter(|days| (0..=36_500).contains(days))
|
.filter(|days| (0..=36_500).contains(days))
|
||||||
.context("TESSERA_AUDIT_RETENTION_DAYS must be a whole number of days (0 keeps everything)")?;
|
.context(
|
||||||
|
"TESSERA_AUDIT_RETENTION_DAYS must be a whole number of days (0 keeps everything)",
|
||||||
|
)?;
|
||||||
Ok((days > 0).then_some(days))
|
Ok((days > 0).then_some(days))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -409,7 +409,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn pg_dump_keeps_the_url_out_of_argv() {
|
fn pg_dump_keeps_the_url_out_of_argv() {
|
||||||
let target =
|
let target =
|
||||||
parse_postgres_url("postgres://migrator:s%3Acret@example.invalid:5433/billing").unwrap();
|
parse_postgres_url("postgres://migrator:s%3Acret@example.invalid:5433/billing")
|
||||||
|
.unwrap();
|
||||||
assert_eq!(target.password, "s:cret");
|
assert_eq!(target.password, "s:cret");
|
||||||
let args = dump_args("custom").unwrap();
|
let args = dump_args("custom").unwrap();
|
||||||
let pgpass = write_pgpass(&target, false).unwrap();
|
let pgpass = write_pgpass(&target, false).unwrap();
|
||||||
|
|||||||
@@ -90,7 +90,9 @@ impl Vault {
|
|||||||
restrict_dir(&root.join("keys"))?;
|
restrict_dir(&root.join("keys"))?;
|
||||||
// Not refused: that would lock existing deployments out of their own backups.
|
// Not refused: that would lock existing deployments out of their own backups.
|
||||||
if passphrase == "dev-vault-key" {
|
if passphrase == "dev-vault-key" {
|
||||||
tracing::warn!("this vault uses the published dev passphrase; rotate it to a private one");
|
tracing::warn!(
|
||||||
|
"this vault uses the published dev passphrase; rotate it to a private one"
|
||||||
|
);
|
||||||
} else if passphrase.chars().count() < MIN_PASSPHRASE_CHARS {
|
} else if passphrase.chars().count() < MIN_PASSPHRASE_CHARS {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
"the vault passphrase is shorter than {MIN_PASSPHRASE_CHARS} characters; a new vault would refuse it"
|
"the vault passphrase is shorter than {MIN_PASSPHRASE_CHARS} characters; a new vault would refuse it"
|
||||||
|
|||||||
Reference in New Issue
Block a user