Skip to content

fix: Replace unsafe FFI with safe nix wrapper and add apt-get failure logging#689

Closed
Copilot wants to merge 2 commits intofeature/security-vulnerability-managementfrom
copilot/sub-pr-688
Closed

fix: Replace unsafe FFI with safe nix wrapper and add apt-get failure logging#689
Copilot wants to merge 2 commits intofeature/security-vulnerability-managementfrom
copilot/sub-pr-688

Conversation

Copy link

Copilot AI commented Jan 29, 2026

Addresses two security module code review findings: unsafe FFI call for privilege checking and silent apt-get update failures.

Changes

  • scheduler.rs: Replace unsafe { libc::geteuid() == 0 } with nix::unistd::geteuid().is_root()

    • Add platform guards (#[cfg(unix)] / #[cfg(not(unix))])
    • Add nix crate dependency with user feature
  • patcher.rs: Log apt-get update failures instead of silent suppression

    • Warn on non-zero exit status with stderr output
    • Warn on command execution failures
    • Add log::warn import
  • License headers: Convert /** to /* in all security modules to fix Rust E0753 doc comment conflicts

  • Dependencies: Align rusqlite to workspace version, add Serialize/Deserialize to PatchStrategy and ScheduleFrequency enums

// Before (unsafe)
fn is_root() -> bool {
    unsafe { libc::geteuid() == 0 }
}

// After (safe)
#[cfg(unix)]
fn is_root() -> bool {
    geteuid().is_root()
}
// Before (silent failure)
let _ = Command::new("apt-get").args(["update", "-qq"]).output();

// After (logged failure)
match Command::new("apt-get").args(["update", "-qq"]).output() {
    Ok(output) if !output.status.success() => {
        warn!("apt-get update failed with status: {}. Package cache may be stale.", output.status);
    }
    Err(e) => warn!("Failed to execute apt-get update: {}. Package cache may be stale.", e),
    _ => {}
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ging

Co-authored-by: mikejmorgan-ai <73376634+mikejmorgan-ai@users.noreply.github.com>
@sonarqubecloud
Copy link

Copilot AI changed the title [WIP] Add security vulnerability management module fix: Replace unsafe FFI with safe nix wrapper and add apt-get failure logging Jan 29, 2026
Copilot AI requested a review from mikejmorgan-ai January 29, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants