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
2 changes: 1 addition & 1 deletion .github/workflows/branch-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
fi

- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
cli)
binary_component=cli
binary_name=openshell
features="bundled-z3"
features=""
has_image=false
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
ref: docs-website

- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ jobs:
sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${{ needs.compute-versions.outputs.cargo_version }}"'"/}' Cargo.toml

- name: Build ${{ matrix.target }}
run: mise x -- cargo build --release --target ${{ matrix.target }} -p openshell-cli --features bundled-z3
run: mise x -- cargo build --release --target ${{ matrix.target }} -p openshell-cli

- name: sccache stats
if: always()
Expand Down Expand Up @@ -980,7 +980,7 @@ jobs:
git push --force origin dev

- name: Create / update GitHub Release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
with:
name: OpenShell Development Build
prerelease: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ jobs:
sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${{ needs.compute-versions.outputs.cargo_version }}"'"/}' Cargo.toml

- name: Build ${{ matrix.target }}
run: mise x -- cargo build --release --target ${{ matrix.target }} -p openshell-cli --features bundled-z3
run: mise x -- cargo build --release --target ${{ matrix.target }} -p openshell-cli

- name: sccache stats
if: always()
Expand Down Expand Up @@ -1005,7 +1005,7 @@ jobs:
}

- name: Create GitHub Release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
with:
name: OpenShell ${{ env.RELEASE_TAG }}
prerelease: false
Expand Down Expand Up @@ -1052,7 +1052,7 @@ jobs:
ref: ${{ inputs.tag || github.ref }}

- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-vm-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ jobs:
}

- name: Create / update vm-runtime GitHub Release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
with:
name: OpenShell VM Runtime
prerelease: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
--display-name "$DISPLAY_NAME"

- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "24"

Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

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

4 changes: 0 additions & 4 deletions crates/openshell-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ openshell-bootstrap = { path = "../openshell-bootstrap" }
openshell-core = { path = "../openshell-core", default-features = false }
openshell-policy = { path = "../openshell-policy" }
openshell-providers = { path = "../openshell-providers" }
openshell-prover = { path = "../openshell-prover" }
openshell-tui = { path = "../openshell-tui" }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down Expand Up @@ -84,9 +83,6 @@ tracing-subscriber = { workspace = true }
[lints]
workspace = true

[features]
bundled-z3 = ["openshell-prover/bundled-z3"]

[dev-dependencies]
futures = { workspace = true }
rcgen = { version = "0.13", features = ["crypto", "pem"] }
Expand Down
47 changes: 0 additions & 47 deletions crates/openshell-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1743,30 +1743,6 @@ enum PolicyCommands {
#[arg(long)]
yes: bool,
},

/// Prove properties of a sandbox policy — or find counterexamples.
#[command(help_template = LEAF_HELP_TEMPLATE, next_help_heading = "FLAGS")]
Prove {
/// Path to `OpenShell` sandbox policy YAML.
#[arg(long, value_hint = ValueHint::FilePath)]
policy: String,

/// Path to credential descriptor YAML.
#[arg(long, value_hint = ValueHint::FilePath)]
credentials: String,

/// Path to capability registry directory (default: bundled).
#[arg(long, value_hint = ValueHint::DirPath)]
registry: Option<String>,

/// Path to accepted risks YAML.
#[arg(long, value_hint = ValueHint::FilePath)]
accepted_risks: Option<String>,

/// One-line-per-finding output (for demos and CI).
#[arg(long)]
compact: bool,
},
}

#[derive(Subcommand, Debug)]
Expand Down Expand Up @@ -2297,28 +2273,6 @@ async fn main() -> Result<()> {
// -----------------------------------------------------------
// Top-level policy (was `sandbox policy`)
// -----------------------------------------------------------
Some(Commands::Policy {
command:
Some(PolicyCommands::Prove {
policy,
credentials,
registry,
accepted_risks,
compact,
}),
}) => {
// Prove runs locally — no gateway needed.
let exit_code = openshell_prover::prove(
&policy,
&credentials,
registry.as_deref(),
accepted_risks.as_deref(),
compact,
)?;
if exit_code != 0 {
std::process::exit(exit_code);
}
}
Some(Commands::Policy {
command: Some(policy_cmd),
}) => {
Expand Down Expand Up @@ -2438,7 +2392,6 @@ async fn main() -> Result<()> {
}
run::gateway_setting_delete(&ctx.endpoint, "policy", yes, &tls).await?;
}
PolicyCommands::Prove { .. } => unreachable!(),
}
}

Expand Down
129 changes: 112 additions & 17 deletions crates/openshell-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::net::SocketAddr;
#[cfg(unix)]
use std::os::unix::fs::FileTypeExt;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str::FromStr;
use std::time::Duration;

Expand Down Expand Up @@ -163,22 +162,14 @@ pub fn detect_driver() -> Option<ComputeDriverKind> {
return Some(ComputeDriverKind::Podman);
}

// Docker: check if the CLI is available or a local Docker socket exists.
// Docker: check for a reachable local API socket.
if is_docker_available() {
return Some(ComputeDriverKind::Docker);
}

None
}

/// Check if a binary is available on the system PATH.
fn is_binary_available(name: &str) -> bool {
Command::new(name)
.arg("--version")
.output()
.is_ok_and(|output| output.status.success())
}

fn is_podman_available() -> bool {
podman_socket_candidates()
.iter()
Expand Down Expand Up @@ -228,13 +219,18 @@ fn podman_socket_candidates_from_env(
}

fn is_docker_available() -> bool {
is_binary_available("docker") || docker_socket_available()
detect_docker_socket().is_some()
}

fn docker_socket_available() -> bool {
docker_socket_candidates()
pub fn detect_docker_socket() -> Option<PathBuf> {
detect_docker_socket_from_candidates(&docker_socket_candidates())
}

fn detect_docker_socket_from_candidates(candidates: &[PathBuf]) -> Option<PathBuf> {
candidates
.iter()
.any(|path| is_unix_socket(path))
.find(|path| docker_socket_responds(path))
.cloned()
}

fn docker_socket_candidates() -> Vec<PathBuf> {
Expand Down Expand Up @@ -277,6 +273,15 @@ fn podman_socket_responds(path: &Path) -> bool {
})
}

#[cfg(unix)]
fn docker_socket_responds(path: &Path) -> bool {
unix_socket_http_ping(path, |response| {
http_response_is_success(response)
&& contains_ascii(response, b"Api-Version:")
&& !contains_ascii(response, b"Libpod-Api-Version:")
})
}

#[cfg(unix)]
fn unix_socket_http_ping(path: &Path, accepts_response: impl FnOnce(&[u8]) -> bool) -> bool {
const PROBE_TIMEOUT: Duration = Duration::from_secs(1);
Expand Down Expand Up @@ -350,6 +355,12 @@ fn podman_socket_responds(path: &Path) -> bool {
false
}

#[cfg(not(unix))]
fn docker_socket_responds(path: &Path) -> bool {
let _ = path;
false
}

/// Server configuration.
///
/// Built programmatically in [`crate::Config::new`] and the gateway CLI from
Expand Down Expand Up @@ -960,9 +971,9 @@ mod tests {
use super::{
ComputeDriverKind, Config, DEFAULT_SERVICE_ROUTING_DOMAIN, GatewayInterceptorBindingPolicy,
GatewayInterceptorConfig, GatewayInterceptorFailurePolicy, GatewayJwtConfig,
GatewayProviderProfileSourceConfig, detect_driver, docker_host_unix_socket_path,
is_unix_socket, normalize_compute_driver_name, podman_socket_candidates_from_env,
podman_socket_responds,
GatewayProviderProfileSourceConfig, detect_docker_socket_from_candidates, detect_driver,
docker_host_unix_socket_path, docker_socket_responds, is_unix_socket,
normalize_compute_driver_name, podman_socket_candidates_from_env, podman_socket_responds,
};
#[cfg(unix)]
use std::io::{Read as _, Write as _};
Expand Down Expand Up @@ -1239,6 +1250,90 @@ mod tests {
handle.join().expect("probe server exits");
}

#[cfg(unix)]
#[test]
fn docker_socket_probe_accepts_successful_ping_response() {
let temp_dir = tempfile::tempdir().expect("create temp dir");
let socket_path = temp_dir.path().join("docker.sock");
let listener = UnixListener::bind(&socket_path).expect("bind docker socket");

let handle = std::thread::spawn(move || {
let (mut stream, _) = listener.accept().expect("accept docker probe");
let mut request = [0_u8; 128];
let n = stream.read(&mut request).expect("read docker probe");
assert!(request[..n].starts_with(b"GET /_ping HTTP/1.1\r\n"));
stream
.write_all(
b"HTTP/1.1 200 OK\r\nApi-Version: 1.51\r\nDocker-Experimental: false\r\nContent-Length: 2\r\n\r\nOK",
)
.expect("write docker ping response");
});

assert!(docker_socket_responds(&socket_path));
handle.join().expect("probe server exits");
}

#[cfg(unix)]
#[test]
fn docker_socket_probe_rejects_podman_ping_response() {
let temp_dir = tempfile::tempdir().expect("create temp dir");
let socket_path = temp_dir.path().join("podman.sock");
let listener = UnixListener::bind(&socket_path).expect("bind podman socket");

let handle = std::thread::spawn(move || {
let (mut stream, _) = listener.accept().expect("accept docker probe");
let mut request = [0_u8; 128];
let n = stream.read(&mut request).expect("read docker probe");
assert!(request[..n].starts_with(b"GET /_ping HTTP/1.1\r\n"));
stream
.write_all(
b"HTTP/1.1 200 OK\r\nLibpod-Api-Version: 5.8.2\r\nContent-Length: 2\r\n\r\nOK",
)
.expect("write podman ping response");
});

assert!(!docker_socket_responds(&socket_path));
handle.join().expect("probe server exits");
}

#[cfg(unix)]
#[test]
fn docker_socket_probe_rejects_inactive_socket() {
let temp_dir = tempfile::tempdir().expect("create temp dir");
let socket_path = temp_dir.path().join("docker.sock");
let listener = UnixListener::bind(&socket_path).expect("bind docker socket");
drop(listener);

assert!(is_unix_socket(&socket_path));
assert!(!docker_socket_responds(&socket_path));
}

#[cfg(unix)]
#[test]
fn docker_socket_detection_returns_the_responsive_candidate() {
let temp_dir = tempfile::tempdir().expect("create temp dir");
let inactive_path = temp_dir.path().join("inactive.sock");
let inactive_listener = UnixListener::bind(&inactive_path).expect("bind inactive socket");
drop(inactive_listener);

let responsive_path = temp_dir.path().join("responsive.sock");
let listener = UnixListener::bind(&responsive_path).expect("bind responsive socket");
let handle = std::thread::spawn(move || {
let (mut stream, _) = listener.accept().expect("accept docker probe");
let mut request = [0_u8; 128];
let _ = stream.read(&mut request).expect("read docker probe");
stream
.write_all(b"HTTP/1.1 200 OK\r\nApi-Version: 1.51\r\nContent-Length: 2\r\n\r\nOK")
.expect("write docker ping response");
});

assert_eq!(
detect_docker_socket_from_candidates(&[inactive_path, responsive_path.clone(),]),
Some(responsive_path)
);
handle.join().expect("probe server exits");
}

#[test]
fn podman_socket_candidates_include_env_runtime_and_home_paths() {
let candidates = podman_socket_candidates_from_env(
Expand Down
6 changes: 6 additions & 0 deletions crates/openshell-driver-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The driver manages sandbox containers through the local Docker daemon with the
`bollard` client. It is intended for developer environments where Docker is
already available and running Kubernetes would be unnecessary.

The driver connects to `[openshell.drivers.docker].socket_path` when configured.
Otherwise, it uses the first standard local Docker socket that responds to an
API ping, which is the same selection mechanism used by gateway auto-detection.
An explicitly selected Docker driver falls back to `/var/run/docker.sock` when
no candidate responds.

## Runtime Model

The gateway runs as a host process. The Docker driver creates one container per
Expand Down
Loading
Loading