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
3 changes: 2 additions & 1 deletion .claude/agents/principal-engineer-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ When reviewing code or diffs:
6. When suggesting a change, show the concrete fix — don't just describe it.
7. If something is good, say so briefly. Positive signal is useful too.
8. When behavior, commands, or development workflows change, consult the `sync-agent-infra` maintenance map and verify that related skills were updated. Apply its full consistency checklist when the changes add, remove, or rename skills or crates; change workflow relationships or skill coverage; modify issue or PR templates; or change agent cross-references. Report missing companion updates or drift as a warning.
9. When the task includes a prior review feedback ledger, treat trusted resolved
9. For pull request reviews, determine whether the changes affect Windows support. Changes to Windows or MSVC CI and `mise` tasks, Windows lock-file platform entries, the MXC driver, or `cfg(windows)` implementations and tests require the `test:windows` label. Report that requirement explicitly to the caller so the PR workflow can apply the label; label routing is review metadata, not a code-review finding.
10. When the task includes a prior review feedback ledger, treat trusted resolved
or explicitly waived findings as durable across later revisions. Do not
re-raise the same finding with different wording unless the new diff
materially invalidates the prior rationale or reintroduces the defect. If
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-e2e-kind/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ inputs:
mise-version:
description: mise release to install
required: false
default: v2026.4.25
default: v2026.9.9

runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-e2e-podman/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
mise-version:
description: mise release to install
required: false
default: v2026.4.25
default: v2026.9.9
podman-major:
description: Expected Podman major version
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-e2e-vm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
mise-version:
description: mise release to install
required: false
default: v2026.4.25
default: v2026.9.9
rust-cache-key:
description: Shared key for Rust test artifacts
required: false
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-mise/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
version:
description: mise release to install
required: false
default: v2026.4.25
default: v2026.9.9

runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-kubernetes-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ on:
description: "mise version to install on the bare Kubernetes e2e runner"
required: false
type: string
default: "v2026.4.25"
default: "v2026.9.9"
gateway-artifact:
description: "Optional prebuilt gateway artifact used to compose a local test image"
required: false
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ These pipelines connect skills into end-to-end workflows. Individual skill files
| `crates/openshell-isolation-interface/` | Isolation backend interface | RFC 0012 `IsolationBackend` trait and types; the supervisor-facing runtime contract |
| `crates/openshell-sandbox-backend/` | OpenShell sandbox backend | `OpenShellRuntimeBackend` and the authenticated OpenShell Sandbox Protocol shared with `openshell-sandbox` |
| `crates/openshell-policy/` | Policy engine | Filesystem, network, and process constraints |
| `crates/openshell-policy-schema/` | Authored policy schema | Dependency-light YAML/JSON representation, bounded parsing, and pure authored-language semantics |
| `crates/openshell-bootstrap/` | Gateway metadata | Gateway registration metadata, auth token storage, mTLS bundle storage |
| `crates/openshell-gateway-interceptors/` | Gateway interceptors | Intercepts and transforms configured gRPC requests at the gateway routing boundary |
| `crates/openshell-ocsf/` | OCSF logging | OCSF v1.8.0 event types, builders, shorthand/JSONL formatters, tracing layers |
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ These are the primary `mise` tasks for day-to-day development:
| Path | Purpose |
| --------------- | --------------------------------------------- |
| `crates/` | Rust crates |
| `crates/openshell-policy-schema/` | Canonical authored policy DTOs and bounded YAML/JSON parser |
| `python/` | Python SDK and bindings |
| `sdk/go/` | Go SDK (types, gRPC clients, converters) |
| `sdk/typescript/` | TypeScript SDK (Connect client and generated protobuf bindings) |
Expand Down
15 changes: 14 additions & 1 deletion Cargo.lock

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

19 changes: 19 additions & 0 deletions architecture/security-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ For the field-by-field YAML reference, use
Filesystem and process policy are startup-time controls. Network policy is
dynamic and can be hot-reloaded when the new policy validates successfully.

### Authored policy boundary

`openshell-policy-schema` is the sole owner of the authored YAML and JSON
representation. It preserves authored distinctions such as an absent
`filesystem_policy` versus an explicitly empty object, rejects duplicate keys,
and applies parser budgets while noyalib constructs the document. It also owns
pure language semantics such as access presets, MCP revision vocabulary,
effective ports and rule names, protocol classification, and lexical policy
path normalization.

Consumers project that syntax into purpose-specific models. `openshell-policy`
owns protobuf conversion, composition, merge behavior, raw-protobuf checks, and
validation that depends on runtime components. The existing prover retains its
risk model but uses the same fail-closed parser as the runtime. The parser
requires `version: 1` and rejects managed annotations and every unknown field
before any consumer-specific projection runs. There is no permissive parsing
profile: unsupported policy fields always invalidate the document. Middleware `config`, query and persisted-query names, and recursive MCP
parameter names are open user-data maps rather than schema extensions.

Before applying Landlock, the supervisor enriches baseline filesystem paths that
the runtime needs. Missing baseline paths are skipped so one absent runtime path
does not weaken the whole ruleset. When GPU devices are present, GPU baseline
Expand Down
1 change: 1 addition & 0 deletions crates/openshell-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ nix = { workspace = true }

[dev-dependencies]
futures = { workspace = true }
openshell-server = { path = "../openshell-server", features = ["test-support"] }
rcgen = { workspace = true }
reqwest = { workspace = true }
serde_json = { workspace = true }
Expand Down
39 changes: 36 additions & 3 deletions crates/openshell-cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1477,19 +1477,52 @@ pub async fn sandbox_sync_command(
Ok(())
}

pub async fn sandbox_get(
server: &str,
name: &str,
policy_only: bool,
output: &str,
workspace: &str,
tls: &TlsOptions,
) -> Result<()> {
let mut stdout = Vec::new();
sandbox_get_to_writer(
server,
name,
policy_only,
output,
workspace,
tls,
&mut stdout,
)
.await?;
if !stdout.is_empty() {
std::io::stdout()
.lock()
.write_all(&stdout)
.into_diagnostic()?;
}
Ok(())
}

/// Fetch a sandbox by name.
///
/// Policy always comes from [`GetSandboxConfig`] (effective active policy, sandbox
/// or global). With `policy_only`, prints only that YAML to stdout; otherwise
/// prints sandbox metadata and the same policy with formatted YAML.
pub async fn sandbox_get(
#[doc(hidden)]
pub async fn sandbox_get_to_writer<W>(
server: &str,
name: &str,
policy_only: bool,
output: &str,
workspace: &str,
tls: &TlsOptions,
) -> Result<()> {
stdout: &mut W,
) -> Result<()>
where
W: Write + Send,
{
let mut client = grpc_client(server, tls).await?;

let response = client
Expand Down Expand Up @@ -1524,7 +1557,7 @@ pub async fn sandbox_get(
};
let yaml_str = openshell_policy::serialize_sandbox_policy(policy)
.wrap_err("failed to serialize policy to YAML")?;
print!("{yaml_str}");
stdout.write_all(yaml_str.as_bytes()).into_diagnostic()?;
return Ok(());
}

Expand Down
138 changes: 138 additions & 0 deletions crates/openshell-cli/tests/policy_only_process_identity_integration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

mod helpers;

use helpers::{build_ca, build_client_cert, build_server_cert};
use openshell_cli::run;
use openshell_cli::tls::{TlsOptions, grpc_client};
use openshell_core::proto::open_shell_server::OpenShellServer;
use openshell_core::proto::{CreateSandboxRequest, SandboxSpec};
use openshell_server::test_support::{authenticate_as_dev_user, gateway_service_with_driver};
use tempfile::TempDir;
use tokio::net::TcpListener;
use tokio_stream::wrappers::TcpListenerStream;
use tonic::transport::{Certificate as TlsCertificate, Identity, Server, ServerTlsConfig};

struct TestServer {
endpoint: String,
tls: TlsOptions,
_dir: TempDir,
}

async fn run_server() -> TestServer {
let (ca, ca_key) = build_ca();
let (server_cert, server_key) = build_server_cert(&ca, &ca_key);
let (client_cert, client_key) = build_client_cert(&ca, &ca_key);
let ca_cert = ca.pem();

let tls_config = ServerTlsConfig::new()
.identity(Identity::from_pem(server_cert, server_key))
.client_ca_root(TlsCertificate::from_pem(ca_cert.clone()));
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let addr = listener.local_addr().unwrap();
let service = gateway_service_with_driver("docker").await;

tokio::spawn(async move {
Server::builder()
.tls_config(tls_config)
.unwrap()
.add_service(OpenShellServer::with_interceptor(
service,
authenticate_as_dev_user,
))
.serve_with_incoming(TcpListenerStream::new(listener))
.await
.unwrap();
});

let dir = tempfile::tempdir().unwrap();
let ca_path = dir.path().join("ca.crt");
let cert_path = dir.path().join("tls.crt");
let key_path = dir.path().join("tls.key");
std::fs::write(&ca_path, ca_cert).unwrap();
std::fs::write(&cert_path, client_cert).unwrap();
std::fs::write(&key_path, client_key).unwrap();

TestServer {
endpoint: format!("https://localhost:{}", addr.port()),
tls: TlsOptions::new(Some(ca_path), Some(cert_path), Some(key_path)),
_dir: dir,
}
}

#[tokio::test]
async fn policy_only_preserves_all_process_identity_combinations_through_gateway() {
let server = run_server().await;
let cases = [
("neither", "process: {}", None),
(
"user-only",
"process:\n run_as_user: \"1500\"",
Some(("1500", "")),
),
(
"group-only",
"process:\n run_as_group: \"1600\"",
Some(("", "1600")),
),
(
"both",
"process:\n run_as_user: \"1500\"\n run_as_group: \"1600\"",
Some(("1500", "1600")),
),
];

for (name, process_yaml, expected) in cases {
let authored = format!("version: 1\n{process_yaml}\n");
let policy = openshell_policy::parse_sandbox_policy(&authored)
.unwrap_or_else(|error| panic!("{name}: authored policy should parse: {error}"));

let mut client = grpc_client(&server.endpoint, &server.tls).await.unwrap();
client
.create_sandbox(CreateSandboxRequest {
name: name.to_string(),
spec: Some(SandboxSpec {
policy: Some(policy),
..Default::default()
}),
workspace_scope: Some(openshell_core::proto::workspace_selector("default")),
..Default::default()
})
.await
.unwrap_or_else(|error| panic!("{name}: gateway create should succeed: {error}"));

let mut output = Vec::new();
run::sandbox_get_to_writer(
&server.endpoint,
name,
true,
"table",
"default",
&server.tls,
&mut output,
)
.await
.unwrap_or_else(|error| panic!("{name}: --policy-only should succeed: {error}"));

let output = String::from_utf8(output).unwrap();
let exported = openshell_policy::parse_sandbox_policy(&output)
.unwrap_or_else(|error| panic!("{name}: exported YAML should parse: {error}"));
match expected {
None => {
assert!(
exported.process.is_none(),
"{name}: empty process must be omitted"
);
assert!(!output.contains("process:"), "{name}: {output}");
}
Some((user, group)) => {
let process = exported
.process
.expect("partial process should be retained");
assert_eq!(process.run_as_user, user, "{name}: {output}");
assert_eq!(process.run_as_group, group, "{name}: {output}");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl OpenShell for TestOpenShell {
);
Ok(Response::new(GetSandboxConfigResponse {
policy: Some(SandboxPolicy {
version: 9,
version: 1,
network_policies: [
(
"user_api".to_string(),
Expand Down Expand Up @@ -464,7 +464,7 @@ impl OpenShell for TestOpenShell {
assert!(!req.global);

let policy = SandboxPolicy {
version: 7,
version: 1,
network_policies: std::iter::once((
"api".to_string(),
NetworkPolicyRule {
Expand Down
1 change: 1 addition & 0 deletions crates/openshell-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repository.workspace = true
[dependencies]
async-trait = "0.1"
openshell-extension-core = { path = "../openshell-extension-core" }
openshell-policy-schema = { path = "../openshell-policy-schema" }
glob = { workspace = true }
prost = { workspace = true }
prost-types = { workspace = true }
Expand Down
Loading
Loading