Skip to content

Commit

Permalink
fix: bake gpg keys in (#3318)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Dec 4, 2024
1 parent 62b3e7e commit dfd8bd7
Show file tree
Hide file tree
Showing 10 changed files with 535 additions and 30 deletions.
386 changes: 386 additions & 0 deletions src/assets/gpg/node.asc

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions src/assets/gpg/swift.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2

mQINBGGJWe0BEADGVbVhCEWnCMdAoxCaUaCPNomG5wdzw+sgx8FvqCFiGqYq/qzN
ckaydk+XWfiDT/Vo/NjMYnUJ0+gdSua1X0IUGqQlATYhKSGTHqgab4nwDCym0nFl
SBHPDgmMTNO57dHSGYduPjuisuhq7i0pybyn/oXuHAW5SIlz7bfpaz2jzFDY4xEP
TXImllHOmTxBsDdwv2J+H158w1NSHJoHeXpPIse3VHlcwJVNeGYMiDx4Qw9TfaL5
fI7GgjbcELCXw/pGjbiz/JFX7Fzm4snesnqwIG3TN4kH3BdKRNMFnyN3zNZxQTaZ
LNCr3NCzhmmWTjeX5VSu6C+W8wuYRAThqJ42HpPR78zgv6pMnHgdhqquqAfL/Oid
XlISbQ4bSdc1y8xkLb86pzwzrLV3LmHjJ3NAi9U1QXygW0ikTgbB9LPzaTSGVU+y
0PMQ6JrRfSvyt5G7RmVzqm1ro8fkmeZBjNUf7GXCldn9linbhKzh/IvvPTYeNhIK
T99giWSChvZyR950vE5a4WEYKV3taJRLCqXHH1d7FKC080pvPR9VsqWB/thQ48Vr
dPleEa6O9IFMDudpOfsXTnHtnO7wKssN9RtxpotRukIhLGWxjHED3Rrt93T+IMQz
kpKz+Tcz/koM8SuAcYX15N/jeW8BzgA6Y6ODI/OSAMBzMQUYME5S7F7xOwARAQAB
tEZTd2lmdCBBdXRvbWF0aWMgU2lnbmluZyBLZXkgIzQgPHN3aWZ0LWluZnJhc3Ry
dWN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JrLiGuLwH170KgeMYpWffNLtUNH1oCkh1lj8jQARAQAB
tEVTd2lmdCA2LnggUmVsZWFzZSBTaWduaW5nIEtleSA8c3dpZnQtaW5mcmFzdHJ1
Y3R1cmVAZm9ydW1zLnN3aWZ0Lm9yZz6JAj0EEwEKACcFAmbolYECGwMFCQPCZwAF
CwkIBwMFFQoJCAsFFgIDAQACHgECF4AACgkQ74CoZrR6mB/DIhAAnSHnGfRpr/0A
98dWa2uM2tt4oGT1+SN+va544/vu6CAc9jhvS871GvHe25B5HL5S6MDF3dim3oQe
zIGaIx3DUhbb0/JLeayL3NfhbCed5DX0W1XIQtksjYuHnvBRD+zrhcTQKqumR+LU
NVOh6l4o2Ko+aAYc8mIm+HufryRKJSWup1ZnExEdcZZEzyY4kT0H1fxAIWWU3NI1
LDtq1O0Wl5CTUHU7mI/h2eWrxFDg4SmfV9dv4uBXyvxherHEhImJXceQ4ZkxvYGF
amXjlNzIr8c6y/IE8Q775nkfG5+4Gt+bGIJqxeSzfc4wq+txMa85TtRpgSthgqFi
+yQx5qghs3y8Pqj3kDatJB41oQZ221WbBRc2uvFDMWUaOtJ/pRymCN54FUwxUm6U
aM4VTWbGw0es1QRO+Px25Thoh8a5a3Fu0s9fa1sDJOUYSc7vfyRUfqNOVv5g8rnS
sPTmOGGjrjxWHA0oL7B5hxCR+/jBhw+6mLu18qwGI7YpgyZYSzowPY+LrMm/J973
SyUtlCb2o42WhDR9FsX0AGvLhZpxy4Q7br7Pa2RXwmWEaxZik0iQ2Sg4pEvL5tVd
aFIUvVsFlayfXSBCZVjH0uyh0Vkk1ERZpSmxkRWgzp5MRIfkP5eh9009uhEUmxHV
Yih/un915S6ObH32x1IbJfi0cGK1NUA=
=sWSN
-----END PGP PUBLIC KEY BLOCK-----
3 changes: 3 additions & 0 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ pub static MISE_BIN_NAME: Lazy<&str> = Lazy::new(|| filename(&ARGV0));
pub static MISE_LOG_FILE: Lazy<Option<PathBuf>> = Lazy::new(|| var_path("MISE_LOG_FILE"));
pub static MISE_LOG_FILE_LEVEL: Lazy<Option<LevelFilter>> = Lazy::new(log_file_level);

pub static HTTP_PROXY: Lazy<Option<String>> =
Lazy::new(|| var("https_proxy").or_else(|_| var("http_proxy")).ok());

pub static __USAGE: Lazy<Option<String>> = Lazy::new(|| var("__USAGE").ok());

// true if running inside a shim
Expand Down
8 changes: 4 additions & 4 deletions src/git.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::env;
use crate::env;
use std::fmt::Debug;
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -260,11 +260,11 @@ impl Git {
}
}

fn get_fetch_options() -> Result<git2::FetchOptions<'static>> {
fn get_fetch_options() -> Result<FetchOptions<'static>> {
let mut fetch_options = FetchOptions::new();
if let Ok(proxy_url) = env::var("https_proxy").or_else(|_| env::var("http_proxy")) {
if let Some(proxy_url) = env::HTTP_PROXY.as_ref() {
let mut proxy_options = ProxyOptions::new();
proxy_options.url(&proxy_url);
proxy_options.url(proxy_url);
fetch_options.proxy_options(proxy_options);
}
Ok(fetch_options)
Expand Down
20 changes: 20 additions & 0 deletions src/gpg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use crate::cmd::CmdLineRunner;
use crate::install_context::InstallContext;
use crate::Result;

pub fn add_keys_node(ctx: &InstallContext) -> Result<()> {
add_keys(ctx, include_str!("assets/gpg/node.asc"))
}

pub fn add_keys_swift(ctx: &InstallContext) -> Result<()> {
add_keys(ctx, include_str!("assets/gpg/swift.asc"))
}

fn add_keys(ctx: &InstallContext, keys: &str) -> Result<()> {
CmdLineRunner::new("gpg")
.arg("--quiet")
.arg("--import")
.stdin_string(keys)
.with_pr(ctx.pr.as_ref())
.execute()
}
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ mod fake_asdf;
mod file;
mod git;
pub(crate) mod github;
mod gpg;
mod hash;
mod hook_env;
mod hooks;
Expand Down Expand Up @@ -70,6 +71,7 @@ mod versions_host;
mod watch_files;

pub(crate) use crate::exit::exit;
pub(crate) use crate::result::Result;
pub(crate) use crate::toolset::install_state;
use crate::ui::multi_progress_report::MultiProgressReport;

Expand Down
18 changes: 2 additions & 16 deletions src/plugins/core/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::http::{HTTP, HTTP_FETCH};
use crate::install_context::InstallContext;
use crate::toolset::ToolVersion;
use crate::ui::progress_report::SingleReport;
use crate::{env, file, hash, http, plugins};
use crate::{env, file, gpg, hash, http, plugins};
use eyre::{bail, ensure, Result};
use serde_derive::Deserialize;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -205,21 +205,7 @@ impl NodePlugin {
let sig_file = shasums_file.with_extension("asc");
let sig_url = format!("{}.sig", self.shasums_url(v)?);
HTTP.download_file(sig_url, &sig_file, Some(ctx.pr.as_ref()))?;
CmdLineRunner::new("gpg")
.arg("--keyserver")
.arg("hkps://keys.openpgp.org")
.arg("--recv-keys")
.arg("--quiet")
.arg("C0D6248439F1D5604AAFFB4021D900FFDB233756") // Antoine du Hamel
.arg("DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7") // Juan José Arboleda
.arg("CC68F5A3106FF448322E48ED27F5E38D5B0A215F") // Marco Ippolito
.arg("8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600") // Michaël Zasso
.arg("890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4") // Rafael Gonzaga
.arg("C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C") // Richard Lau
.arg("108F52B48DB57BB0CC439B2997B01419BD92F80A") // Ruy Adorno
.arg("A363A499291CBBC940DD62E41F10027AF002F8B0") // Ulises Gascón
.with_pr(ctx.pr.as_ref())
.execute()?;
gpg::add_keys_node(ctx)?;
CmdLineRunner::new("gpg")
.arg("--quiet")
.arg("--trust-model")
Expand Down
12 changes: 2 additions & 10 deletions src/plugins/core/swift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::http::HTTP;
use crate::install_context::InstallContext;
use crate::toolset::ToolVersion;
use crate::ui::progress_report::SingleReport;
use crate::{env, file, github, plugins};
use crate::{env, file, github, gpg, plugins};
use eyre::Result;
use std::path::{Path, PathBuf};
use tempfile::tempdir_in;
Expand Down Expand Up @@ -109,15 +109,7 @@ impl SwiftPlugin {
.println("gpg not found, skipping verification".to_string());
return Ok(());
}
self.gpg(ctx)
.arg("--quiet")
.arg("--keyserver")
.arg("hkp://keyserver.ubuntu.com")
.arg("--recv-keys")
.arg("E813 C892 820A 6FA1 3755 B268 F167 DF1A CF9C E069")
.arg("A62A E125 BBBF BB96 A6E0 42EC 925C C1CC ED3D 1561")
.arg("52BB 7E3D E28A 71BE 22EC 05FF EF80 A866 B47A 981F")
.execute()?;
gpg::add_keys_swift(ctx)?;
let sig_path = PathBuf::from(format!("{}.sig", tarball_path.to_string_lossy()));
HTTP.download_file(format!("{}.sig", url(tv)), &sig_path, Some(ctx.pr.as_ref()))?;
self.gpg(ctx)
Expand Down
4 changes: 4 additions & 0 deletions tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ run a command inside of development docker container

- **Usage**: `docs:setup`

## `fetch-gpg-keys`

- **Usage**: `fetch-gpg-keys`

## `filetask`

- **Usage**: `filetask [-f --force] [-u --user <user>] [file] [arg_with_default]`
Expand Down
22 changes: 22 additions & 0 deletions xtasks/fetch-gpg-keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euxo pipefail

NODE_FINGERPRINTS=(
"C0D6248439F1D5604AAFFB4021D900FFDB233756" # Antoine du Hamel
"DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7" # Juan José Arboleda
"CC68F5A3106FF448322E48ED27F5E38D5B0A215F" # Marco Ippolito
"8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600" # Michaël Zasso
"890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4" # Rafael Gonzaga
"C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C" # Richard Lau
"108F52B48DB57BB0CC439B2997B01419BD92F80A" # Ruy Adorno
"A363A499291CBBC940DD62E41F10027AF002F8B0" # Ulises Gascón
)

rm -rf src/assets/gpg
mkdir -p src/assets/gpg
for fingerprint in "${NODE_FINGERPRINTS[@]}"; do
curl -fLSs "https://keys.openpgp.org/vks/v1/by-fingerprint/$fingerprint" >> "src/assets/gpg/node.asc"
done
curl -fLSs "https://swift.org/keys/automatic-signing-key-4.asc" >> src/assets/gpg/swift.asc
curl -fLSs "https://swift.org/keys/release-key-swift-5.x.asc" >> src/assets/gpg/swift.asc
curl -fLSs "https://swift.org/keys/release-key-swift-6.x.asc" >> src/assets/gpg/swift.asc

0 comments on commit dfd8bd7

Please sign in to comment.