fix: verify the metadata database certificate with sslmode=verify-full (#235)
Part of https://codefloe.com/rpkgs/bincraft/issues/225. Stacked on #234. Every connection to the metadata database used `sslmode = 'require'`, which encrypts but does not authenticate the server, so anyone able to impersonate `r-binaries.devxy.io:15432` would receive `PGPASS`. ## Changes - `.crow/build-all-versions.yaml`, `process-updates.yaml`, `prune-stale-flat-binaries.yaml`, `reindex.yaml`, `weekly-rebuild-reindex.yaml`: `metadata_db_sslmode = 'verify-full'` in every bincraft call. - `local/*.R`: the same for bincraft calls; scripts that call `DBI::dbConnect()` directly also pass `sslrootcert = bincraft::postgres_sslrootcert("verify-full")`, because libpq looks for `~/.postgresql/root.crt` rather than the system trust store. - `README.md`: note that the endpoint serves a Let's Encrypt certificate and how to verify it. - air reformatted three `=` assignments to `<-` in `local/missing-cran-packages-db.R` and `local/packages-without-any-binary.R` while the hook ran on those files. ## Ordering: merge last 1. devxy/k8s-talos#417 must be live: today the server presents an in-cluster certificate from a private CA, which `verify-full` rejects. 2. https://codefloe.com/rpkgs/bincraft/pulls/226 must be released: `local/install-bincraft.R` installs the latest tag, and older releases neither pass a root certificate nor export `postgres_sslrootcert()`. 3. #234 must be merged. Merging early fails every database connection in CI, and since #234 per-minor reindex failures fail the pipeline. Reviewed-on: #235
This commit is contained in:
parent
8a7942d7d7
commit
5c4cca6cce
16 changed files with 40 additions and 28 deletions
|
|
@ -47,7 +47,7 @@ db <- list(
|
|||
metadata_db_port = 15432L,
|
||||
metadata_db_user = "rpkgs",
|
||||
metadata_db_password = Sys.getenv("PGPASS"),
|
||||
metadata_db_sslmode = "require"
|
||||
metadata_db_sslmode = "verify-full"
|
||||
)
|
||||
|
||||
read_index <- function(index_url) {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "rpkgs",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
# Scope the skip to the R minor this pass is running under. `single_builds`
|
||||
# records `r_version` per attempt, but querying without it made a non-primary
|
||||
|
|
@ -250,7 +251,7 @@ mapply(
|
|||
metadata_db_table = "single_builds",
|
||||
metadata_db_user = "rpkgs",
|
||||
metadata_db_password = Sys.getenv("PGPASS"),
|
||||
metadata_db_sslmode = "require",
|
||||
metadata_db_sslmode = "verify-full",
|
||||
metadata_db_port = 15432,
|
||||
archive = TRUE,
|
||||
patches = "local/patches",
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ if ("--dry-run" %in% args) {
|
|||
metadata_db_name = "build_metadata",
|
||||
metadata_db_user = "rpkgs",
|
||||
metadata_db_password = Sys.getenv("PGPASS"),
|
||||
metadata_db_sslmode = "require",
|
||||
metadata_db_sslmode = "verify-full",
|
||||
metadata_db_port = 15432
|
||||
),
|
||||
s3_endpoint = "https://s3.eu-central-003.backblazeb2.com",
|
||||
|
|
@ -61,7 +61,7 @@ if ("--dry-run" %in% args) {
|
|||
metadata_db_table = "single_builds",
|
||||
metadata_db_user = "rpkgs",
|
||||
metadata_db_password = Sys.getenv("PGPASS"),
|
||||
metadata_db_sslmode = "require",
|
||||
metadata_db_sslmode = "verify-full",
|
||||
metadata_db_port = 15432,
|
||||
archive = TRUE,
|
||||
patches = "local/patches",
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ for (ver in versions) {
|
|||
metadata_db_table = "single_builds",
|
||||
metadata_db_user = "rpkgs",
|
||||
metadata_db_password = Sys.getenv("PGPASS"),
|
||||
metadata_db_sslmode = "require",
|
||||
metadata_db_sslmode = "verify-full",
|
||||
metadata_db_port = 15432
|
||||
)
|
||||
if (sensitive) touched_minor <- TRUE else touched_generic <- TRUE
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "rpkgs",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
on.exit(DBI::dbDisconnect(con), add = TRUE)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "r_binaries",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
|
||||
pkgs_db <- query_metadata_table() |>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432L,
|
||||
user = "rpkgs",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
on.exit(try(DBI::dbDisconnect(con), silent = TRUE), add = TRUE)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "r_binaries",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
|
||||
`%nin%` <- Negate(`%in%`)
|
||||
|
|
@ -45,12 +46,12 @@ data <- dbGetQuery(
|
|||
"SELECT name FROM single_builds WHERE platform = $1 AND arch = $2 and removed = FALSE;",
|
||||
params = list(platform, arch)
|
||||
)
|
||||
removed_pkgs = get_removed_cran_packages(lubridate::interval(
|
||||
removed_pkgs <- get_removed_cran_packages(lubridate::interval(
|
||||
lubridate::today(),
|
||||
lubridate::today() - 2
|
||||
))$name
|
||||
pkgs_db <- unique(data$name)
|
||||
pkgs_db = setdiff(pkgs_db, removed_pkgs)
|
||||
pkgs_db <- setdiff(pkgs_db, removed_pkgs)
|
||||
|
||||
pkgs <- setdiff(cran_pkgs, pkgs_db)
|
||||
formatted_pkgs <- gsub(
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "rpkgs",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
|
||||
cran_archive <- tools::CRAN_archive_db()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "r_binaries",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
|
||||
cran_pkgs <- tools::CRAN_package_db() |>
|
||||
|
|
@ -27,7 +28,7 @@ pkgs <- data |>
|
|||
distinct(name) |>
|
||||
pull(name)
|
||||
|
||||
pkgs = setdiff(cran_pkgs, pkgs)
|
||||
pkgs <- setdiff(cran_pkgs, pkgs)
|
||||
# Format, remove line breaks, and print as a single line
|
||||
formatted_pkgs <- gsub(
|
||||
'"',
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "rpkgs",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
on.exit(DBI::dbDisconnect(con), add = TRUE)
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "rpkgs",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
on.exit(DBI::dbDisconnect(con), add = TRUE)
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ if (length(explicit) > 0L) {
|
|||
port = 15432L,
|
||||
user = "rpkgs",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
on.exit(try(DBI::dbDisconnect(con), silent = TRUE), add = TRUE)
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ for (i in seq_along(mine)) {
|
|||
metadata_db_table = "single_builds",
|
||||
metadata_db_user = "rpkgs",
|
||||
metadata_db_password = Sys.getenv("PGPASS"),
|
||||
metadata_db_sslmode = "require",
|
||||
metadata_db_sslmode = "verify-full",
|
||||
metadata_db_port = 15432,
|
||||
archive = TRUE,
|
||||
upload = TRUE,
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ for (minor in r_minors) {
|
|||
metadata_db_port = 15432L,
|
||||
metadata_db_user = "rpkgs",
|
||||
metadata_db_password = Sys.getenv("PGPASS"),
|
||||
metadata_db_sslmode = "require"
|
||||
metadata_db_sslmode = "verify-full"
|
||||
)
|
||||
TRUE
|
||||
},
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ con <- DBI::dbConnect(
|
|||
port = 15432,
|
||||
user = "rpkgs",
|
||||
password = Sys.getenv("PGPASS"),
|
||||
sslmode = "require"
|
||||
sslmode = "verify-full",
|
||||
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
|
||||
)
|
||||
|
||||
errored_pkgs <- DBI::dbGetQuery(
|
||||
|
|
|
|||
Loading…
Reference in a new issue