Skip to content

Commit e5365da

Browse files
committed
fix: filter out apt-get/system commands from install (Basilica blocks syscalls), keep project-level installs
1 parent 477a433 commit e5365da

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/executor.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,24 @@ async fn run_shell(
7373
run_cmd(&["sh", "-c", shell_cmd], cwd, timeout, env).await
7474
}
7575

76+
/// Filter out system-level package commands that can't run in restricted containers.
77+
/// Keeps project-level install commands (npm install, pip install, yarn install, etc.)
78+
fn filter_install_command(cmd: &str) -> String {
79+
let system_prefixes = [
80+
"apt-get", "apt ", "dpkg", "yum ", "dnf ", "pacman ", "apk ", "snap ", "flatpak ",
81+
];
82+
83+
// Split on && and filter out system commands
84+
let parts: Vec<&str> = cmd.split("&&").collect();
85+
let filtered: Vec<&str> = parts
86+
.iter()
87+
.map(|p| p.trim())
88+
.filter(|p| !system_prefixes.iter().any(|prefix| p.starts_with(prefix)))
89+
.collect();
90+
91+
filtered.join(" && ")
92+
}
93+
7694
pub struct Executor {
7795
config: Arc<Config>,
7896
sessions: Arc<SessionManager>,
@@ -331,9 +349,20 @@ async fn run_task_pipeline(
331349
result.status = TaskStatus::InstallingDeps;
332350
if let Some(ref install_cmds) = task.workspace.install {
333351
for cmd in install_cmds {
334-
info!("[{}] Installing: {}", task.id, cmd);
352+
// Split chained commands and filter out system package commands
353+
// that can't run in a restricted container (apt-get, dpkg, etc.)
354+
let effective_cmd = filter_install_command(cmd);
355+
if effective_cmd.is_empty() {
356+
info!(
357+
"[{}] Skipping system install: {}",
358+
task.id,
359+
&cmd[..cmd.len().min(100)]
360+
);
361+
continue;
362+
}
363+
info!("[{}] Installing: {}", task.id, effective_cmd);
335364
let (_, stderr, exit) = run_shell(
336-
cmd,
365+
&effective_cmd,
337366
&repo_dir,
338367
Duration::from_secs(config.clone_timeout_secs),
339368
None,

0 commit comments

Comments
 (0)