fix: address blocking sentinel findings (unsafe SAFETY comment, unwrap panics)
Some checks failed
Public Repo Readiness / Check Public Repo Readiness (push) Failing after 4s

This commit is contained in:
Joseph O'Brien
2026-04-01 08:59:28 -04:00
parent bd06746b31
commit 403bcc4436
2 changed files with 6 additions and 3 deletions

View File

@@ -32,7 +32,7 @@ pub fn install_age_key(key: &str) -> Result<PathBuf> {
let path = dirs::home_dir() let path = dirs::home_dir()
.context("cannot find home directory")? .context("cannot find home directory")?
.join(".config/sops/age/keys.txt"); .join(".config/sops/age/keys.txt");
std::fs::create_dir_all(path.parent().unwrap())?; std::fs::create_dir_all(path.parent().with_context(|| "age keys.txt path has no parent directory")?)?;
std::fs::write(&path, key)?; std::fs::write(&path, key)?;
#[cfg(unix)] #[cfg(unix)]
{ {
@@ -45,7 +45,7 @@ pub fn install_age_key(key: &str) -> Result<PathBuf> {
/// Run `sops --decrypt <sops_file>` and return the decrypted content. /// Run `sops --decrypt <sops_file>` and return the decrypted content.
pub fn decrypt_sops(sops_file: &Path) -> Result<String> { pub fn decrypt_sops(sops_file: &Path) -> Result<String> {
let output = Command::new("sops") let output = Command::new("sops")
.args(["--decrypt", sops_file.to_str().unwrap()]) .args(["--decrypt", sops_file.to_str().ok_or_else(|| anyhow::anyhow!("sops path is not valid UTF-8"))?])
.output() .output()
.context("failed to run sops")?; .context("failed to run sops")?;

View File

@@ -108,7 +108,10 @@ pub fn run(opts: BootstrapOptions) -> Result<Report> {
let k = k.trim(); let k = k.trim();
let v = v.trim().trim_matches('"'); let v = v.trim().trim_matches('"');
if !k.is_empty() && !k.starts_with('#') { if !k.is_empty() && !k.starts_with('#') {
// Safety: single-threaded bootstrap, no concurrent env readers // SAFETY: `notstrap` is a single-threaded bootstrap binary. No other threads
// are spawned before this point, and `env_injector` is called before any
// `Command::spawn` calls in this `run()` invocation. Callers that use
// `env_injector: None` (e.g. tests) never reach this block.
unsafe { std::env::set_var(k, v); } unsafe { std::env::set_var(k, v); }
} }
} }