Skip to content
Open
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
5 changes: 5 additions & 0 deletions crates/openshell-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,11 @@ pub struct GatewayAuditConfig {
/// sets. Bytes values are never recorded.
#[serde(default)]
pub capture_setting_values: bool,
/// Record the command arguments of `ExecSandbox` and
/// `ExecSandboxInteractive` calls. Environment variables and standard
/// input are never recorded.
#[serde(default)]
pub capture_exec_command: bool,
}

/// mTLS user authentication for gateway users.
Expand Down
9 changes: 7 additions & 2 deletions crates/openshell-server/src/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2129,10 +2129,15 @@ service_name = "openshell-gateway-dev"

#[test]
fn gateway_audit_capture_is_opt_in() {
let tmp = write_tmp("[openshell.gateway.audit]\ncapture_setting_values = true\n");
let tmp = write_tmp(
"[openshell.gateway.audit]\ncapture_setting_values = true\ncapture_exec_command = true\n",
);
let audit = load(tmp.path()).unwrap().openshell.gateway.audit.unwrap();
assert!(audit.capture_setting_values);
assert!(!GatewayAuditConfig::default().capture_setting_values);
assert!(audit.capture_exec_command);
let defaults = GatewayAuditConfig::default();
assert!(!defaults.capture_setting_values);
assert!(!defaults.capture_exec_command);
}

#[test]
Expand Down
20 changes: 18 additions & 2 deletions crates/openshell-server/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ impl OpenShell for OpenShellService {
&self,
request: Request<ExecSandboxRequest>,
) -> Result<Response<Self::ExecSandboxStream>, Status> {
mutation_audit::record_exec_targets(request.get_ref());
mutation_replay::run(&self.state, request).await
}

Expand Down Expand Up @@ -619,7 +620,18 @@ impl OpenShell for OpenShellService {
&self,
request: Request<CreateSshSessionRequest>,
) -> Result<Response<CreateSshSessionResponse>, Status> {
sandbox::handle_create_ssh_session(&self.state, request).await
let targets = {
let request = request.get_ref();
mutation_audit::scoped(
request.workspace_scope.as_ref(),
[mutation_audit::requested("sandbox", &request.sandbox)],
)
};
mutation_audit::audited(
targets,
sandbox::handle_create_ssh_session(&self.state, request),
)
.await
}

async fn expose_service(
Expand Down Expand Up @@ -674,7 +686,11 @@ impl OpenShell for OpenShellService {
&self,
request: Request<RevokeSshSessionRequest>,
) -> Result<Response<RevokeSshSessionResponse>, Status> {
sandbox::handle_revoke_ssh_session(&self.state, request).await
mutation_audit::audited(
Vec::new(),
sandbox::handle_revoke_ssh_session(&self.state, request),
)
.await
}

// --- Providers ---
Expand Down
Loading
Loading