Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "omg"
version = "0.2.0"
version = "0.2.1"
edition = "2024"
rust-version = "1.95.0"
description = "The Fastest Unified Package Manager for Arch Linux + All Language Runtimes"
Expand Down
5 changes: 5 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,9 @@ omg tool install ripgrep
# Install jq
omg tool install jq

# Install an exact published RubyGems version using the selected OMG Ruby or system Ruby
omg tool install gem:rake@13.3.1

# List installed tools
omg tool list

Expand Down Expand Up @@ -1224,6 +1227,8 @@ lifecycle scripts are disabled and registry signatures/provenance are audited;
pip accepts wheels only; Cargo requires the published lockfile; and Go uses the
public module proxy and checksum database.

Pinned RubyGems installs require an explicit clean decision from the live OMG API for the requested version and all resolved dependencies. OMG verifies each archive against the SHA-256 published by RubyGems and installs the reviewed files into a private gem home. Gems with native build extensions or RubyGems plugins are currently rejected.

Registry-backed managers accept registry package names only. npm GitHub
shorthands, Git URLs, tarball URLs, and local package paths are rejected so a
package name cannot silently select a less verified source. Go module paths are
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions scripts/check-qemu-controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ done
# https://security-tracker.debian.org/tracker/source-package/libslirp
version=$(dpkg-query -W -f='${Version}' libslirp0)
[[ -n "$version" && "$version" != *$'\n'* ]] || exit 3
printf 'libslirp0=%s minimum=4.9.5-1\n' "$version"
if ! dpkg --compare-versions "$version" ge '4.9.5-1'; then
printf 'libslirp0=%s minimum=4.9.7-1\n' "$version"
if ! dpkg --compare-versions "$version" ge '4.9.7-1'; then
printf 'error: libslirp0 is below the patched controller floor\n' >&2
exit 3
fi
24 changes: 16 additions & 8 deletions scripts/install-qemu-libslirp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@
import subprocess
import tempfile

# Debian's signed sid Packages indexes and matching downloads, 2026-10-03.
# https://security-tracker.debian.org/tracker/CVE-2026-95507
# https://security-tracker.debian.org/tracker/CVE-2026-95508
VERSION = "4.9.5-1"
# Debian's signed sid Packages indexes and matching downloads, 2026-12-04.
# https://security-tracker.debian.org/tracker/source-package/libslirp
# Snapshot file IDs locate the archived bytes. The signed index supplies the SHA-256.
VERSION = "4.9.7-1"
PINS = {
"amd64": {"size": 71872, "sha256": "3fad48bcc3830a8d236678042e246121cfac26931311874d0a69f862dd82e5d3"},
"arm64": {"size": 62600, "sha256": "ae1f711bc86fc0336773f67a1df9f5372c9596016181b4130c6fdf36efe159bb"},
"amd64": {
"size": 73912,
"sha256": "0f681317e59fb84aa69bc0246a5b4e5cd4c83ef685657c7a0ce93dc850cfb79e",
"snapshot": "2bced765b5df987cd3cbc3e6f57b77fc9ac85657"
},
"arm64": {
"size": 64904,
"sha256": "bad25e3be87ccd920859bc8485726109db9385868e861c7af54ebb83675f4066",
"snapshot": "5518ed511caafc7dadd0b88852f39d75b34cede6"
}
}


Expand Down Expand Up @@ -45,7 +53,7 @@ def install(qemu_package):
raise ValueError("Unsupported controller architecture")
pin = PINS[architecture]
filename = f"libslirp0_{VERSION}_{architecture}.deb"
url = "https://deb.debian.org/debian/pool/main/libs/libslirp/" + filename
url = "https://snapshot.debian.org/file/" + pin["snapshot"]
with tempfile.TemporaryDirectory(prefix="omg-libslirp-") as directory:
path = Path(directory) / filename
subprocess.run(["curl", "--fail", "--show-error", "--silent", "--location",
Expand All @@ -69,7 +77,7 @@ def install(qemu_package):
library = ctypes.CDLL(matches[0])
library.slirp_version_string.restype = ctypes.c_char_p
runtime = library.slirp_version_string().decode("ascii")
if runtime != "4.9.5":
if runtime != VERSION.split("-", 1)[0]:
raise ValueError("Loaded libslirp version mismatch")
print(json.dumps({"url": url, "sha256": pin["sha256"], "size": pin["size"],
"package": fields, "installed": installed, "library": matches[0],
Expand Down
10 changes: 5 additions & 5 deletions scripts/test_qemu_controller_floor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@


class QemuControllerFloorTests(unittest.TestCase):
def run_gate(self, query_status=0, comparator_status=0, version='1:10.0.13+ds-0+deb13u1', package='qemu-system-x86', slirp_version='4.9.5-1'):
def run_gate(self, query_status=0, comparator_status=0, version='1:10.0.13+ds-0+deb13u1', package='qemu-system-x86', slirp_version='4.9.7-1'):
gate = (ROOT / 'scripts/check-qemu-controller.sh').read_text(encoding='utf-8')
prefix = '''dpkg-query() { if [[ "$3" == libslirp0 ]]; then printf '%s' "$SLIRP_VERSION"; else printf '%s' "$FIXTURE_VERSION"; fi; return "$QUERY_STATUS"; }
dpkg() { [[ "$1" == --compare-versions && "$3" == ge && ( "$4" == '1:10.0.13+ds-0+deb13u1' || "$4" == '4.9.5-1' ) ]] || return 99; return "$COMPARATOR_STATUS"; }
dpkg() { [[ "$1" == --compare-versions && "$3" == ge && ( "$4" == '1:10.0.13+ds-0+deb13u1' || "$4" == '4.9.7-1' ) ]] || return 99; return "$COMPARATOR_STATUS"; }
'''
return subprocess.run([BASH, '-c', prefix + gate, '_', package],
env=dict(os.environ, FIXTURE_VERSION=version, QUERY_STATUS=str(query_status),
Expand All @@ -22,8 +22,8 @@ def run_gate(self, query_status=0, comparator_status=0, version='1:10.0.13+ds-0+
def test_rejects_affected_libslirp_with_real_debian_version_comparison(self):
gate = (ROOT / 'scripts/check-qemu-controller.sh').read_text(encoding='utf-8')
prefix = 'dpkg-query() { if [[ "$3" == libslirp0 ]]; then printf "%s" "$SLIRP_VERSION"; else printf "1:10.0.13+ds-0+deb13u1"; fi; }\n'
for version, accepted in [('4.8.0-1+deb13u1', False), ('4.9.4-1', False),
('4.9.5-1', True), ('4.9.5-2', True)]:
for version, accepted in [('4.8.0-1+deb13u1', False), ('4.9.5-1', False), ('4.9.6-1', False),
('4.9.7-1', True), ('4.9.7-2', True)]:
with self.subTest(version=version):
result = subprocess.run([BASH, '-c', prefix + gate, '_', 'qemu-system-x86'],
env=dict(os.environ, SLIRP_VERSION=version), capture_output=True, text=True, timeout=10)
Expand All @@ -46,7 +46,7 @@ def test_rejects_missing_old_or_invalid_package_evidence(self):
def test_real_debian_version_ordering(self):
gate = (ROOT / 'scripts/check-qemu-controller.sh').read_text(encoding='utf-8')
prefix = '''dpkg-query() {
if [[ "$3" == libslirp0 ]]; then printf "4.9.5-1";
if [[ "$3" == libslirp0 ]]; then printf "4.9.7-1";
elif [[ "$3" == "$FIXTURE_PACKAGE" ]]; then printf "%s" "$FIXTURE_VERSION";
else printf "1:10.0.13+ds-0+deb13u1"; fi;
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/test_qemu_libslirp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class LibslirpPackageTests(unittest.TestCase):
def archive(self, directory, **changes):
fields = {"Package": "libslirp0", "Source": "libslirp", "Version": "4.9.5-1",
fields = {"Package": "libslirp0", "Source": "libslirp", "Version": "4.9.7-1",
"Architecture": "amd64", "Maintainer": "Fixture <fixture@example.invalid>",
"Description": "Synthetic package identity fixture"}
fields.update(changes)
Expand All @@ -34,7 +34,7 @@ def test_accepts_actual_debian_archive_identity(self):
archive, pin = self.archive(directory)
fields = installer.verify_package(archive, "amd64", pin)
self.assertEqual(fields, {"Package": "libslirp0", "Source": "libslirp",
"Version": "4.9.5-1", "Architecture": "amd64"})
"Version": "4.9.7-1", "Architecture": "amd64"})

def test_rejects_coherent_wrong_package_source_version_or_architecture(self):
for changes in ({"Package": "another-package"}, {"Source": "another-source"},
Expand Down
4 changes: 2 additions & 2 deletions src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ pub enum EnvCommands {

#[derive(Subcommand, Debug)]
pub enum ToolCommands {
/// Install a dev tool from any source (Pacman, Cargo, NPM, Pip, Go)
/// Install a dev tool from any source (Pacman, Cargo, NPM, Pip, Go, RubyGems)
Install {
/// Tool name (e.g. ripgrep, jq, tldr)
/// Tool name or pinned RubyGem (e.g. ripgrep, gem:rake@13.3.1)
name: String,
},
/// List installed tools
Expand Down
45 changes: 41 additions & 4 deletions src/cli/tool.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod gem;

use crate::cli::{CliContext, LocalCommandRunner, ToolCommands};
use anyhow::{Context, Result};
use console::user_attended;
Expand Down Expand Up @@ -81,6 +83,7 @@ fn validate_managed_package(manager: &str, package: &str) -> Result<()> {
};
let valid = match manager {
"npm" => crate::core::security::npm::NpmSpec::parse(package).is_ok(),
"gem" => gem::parse_request(package).is_ok(),
"cargo" => crate::runtimes::cargo_tool::validate_request(package).is_ok(),
"pip" => crate::runtimes::pip_tool::validate_request(package).is_ok(),
"pacman" => !package.contains('/') && !package.contains('@') && registry_name(package),
Expand Down Expand Up @@ -757,7 +760,7 @@ fn installed_tool_names_in(tools_dir: &Path) -> Result<Vec<String>> {
}
}

for manager in ["cargo", "npm", "pip", "go"] {
for manager in ["cargo", "npm", "pip", "go", "gem"] {
let manager_dir = tools_dir.join(manager);
let entries = match fs::read_dir(&manager_dir) {
Ok(entries) => entries,
Expand Down Expand Up @@ -844,6 +847,16 @@ pub async fn install(name: &str) -> Result<()> {
Go,
}

if let Some(request) = name.strip_prefix("gem:") {
return gem::install_request(
request,
get_dirs(),
std::sync::Arc::new(crate::core::security::vulnerability::VulnerabilityScanner::new()),
crate::runtimes::security::RuntimeSecurity::default(),
)
.await;
}

// SECURITY: Validate tool name
crate::core::security::validate_package_name(name)?;

Expand Down Expand Up @@ -1047,6 +1060,15 @@ fn install_managed_blocking(
runtime_security,
)?);
}
"gem" => {
tool_admission = Some(gem::install(
pkg,
&staging_dir,
tools_dir,
runtime_security,
advisories.as_ref(),
)?);
}
"cargo" | "go" | "pip" => {
let install = match manager {
"cargo" => crate::runtimes::cargo_tool::install_reviewed,
Expand All @@ -1063,7 +1085,7 @@ fn install_managed_blocking(
)?);
}
_ => anyhow::bail!(
"Unknown package manager '{manager}'. Supported: npm, cargo, pip, go, pacman"
"Unknown package manager '{manager}'. Supported: npm, cargo, pip, go, gem, pacman"
),
}
if let Some(admission) = &npm_admission {
Expand Down Expand Up @@ -1360,7 +1382,7 @@ pub async fn remove(name: &str) -> Result<()> {
}
} else {
candidates.extend(
["cargo", "npm", "pip", "go"]
["cargo", "npm", "pip", "go", "gem"]
.into_iter()
.map(|manager| (manager, tools_dir.join(manager).join(name))),
);
Expand Down Expand Up @@ -1924,7 +1946,11 @@ with zipfile.ZipFile(sys.argv[1], 'w') as archive:
}

#[cfg(unix)]
fn prepare_managed_registry_fixture(tools: &Path, runtime: &str, programs: &[(&str, &Path)]) {
pub(super) fn prepare_managed_registry_fixture(
tools: &Path,
runtime: &str,
programs: &[(&str, &Path)],
) {
use std::os::unix::fs::PermissionsExt as _;
let versions = tools.parent().unwrap().join("versions").join(runtime);
let version = versions.join("1.78.0");
Expand Down Expand Up @@ -1986,6 +2012,17 @@ with zipfile.ZipFile(sys.argv[1], 'w') as archive:
.unwrap();
}

#[tokio::test]
async fn sources_without_gem_coverage_cannot_authorize_gems() {
use crate::core::security::vulnerability::VulnerabilitySource as _;
assert!(
TestNpmAdvisories::default()
.require_clean_gems(&[("fixture".into(), "1".into())])
.await
.is_err()
);
}

#[derive(Default)]
struct TestNpmAdvisories {
findings: Vec<crate::core::security::scan::Vulnerability>,
Expand Down
Loading
Loading