pub struct SecurityPolicy {
pub autonomy: AutonomyLevel,
pub workspace_dir: PathBuf,
pub workspace_only: bool,
pub blocked_commands: Vec<String>,
pub forbidden_paths: Vec<String>,
pub max_actions_per_hour: u32,
pub max_cost_per_day_cents: u32,
pub require_approval_for_medium_risk: bool,
pub block_high_risk_commands: bool,
pub tracker: ActionTracker,
pub forwarded_env: Vec<(String, String)>,
}Expand description
Security policy enforced on all tool executions
Fields§
§autonomy: AutonomyLevel§workspace_dir: PathBuf§workspace_only: bool§blocked_commands: Vec<String>§forbidden_paths: Vec<String>§max_actions_per_hour: u32§max_cost_per_day_cents: u32§require_approval_for_medium_risk: bool§block_high_risk_commands: bool§tracker: ActionTracker§forwarded_env: Vec<(String, String)>Extra environment variables forwarded to shell subprocesses.
Used for tool-specific credentials like GITHUB_TOKEN that agents
need at runtime (e.g. for gh CLI). Populated from the worker
process environment during policy construction.
Implementations§
Source§impl SecurityPolicy
impl SecurityPolicy
Sourcepub fn with_workspace_dir(workspace_dir: PathBuf) -> Self
pub fn with_workspace_dir(workspace_dir: PathBuf) -> Self
Create a SecurityPolicy with a specific workspace directory.
Use this instead of Default when a custom nenjo directory is configured
so that tool scoping and template variables resolve to the correct paths.
Sourcepub fn command_risk_level(&self, command: &str) -> CommandRiskLevel
pub fn command_risk_level(&self, command: &str) -> CommandRiskLevel
Classify command risk. Any high-risk segment marks the whole command high.
Sourcepub fn validate_command_execution(
&self,
command: &str,
approved: bool,
) -> Result<CommandRiskLevel, String>
pub fn validate_command_execution( &self, command: &str, approved: bool, ) -> Result<CommandRiskLevel, String>
Validate full command execution policy (allowlist + risk gate).
pub fn is_command_allowed(&self, command: &str) -> bool
Sourcepub fn is_path_allowed(&self, path: &str) -> bool
pub fn is_path_allowed(&self, path: &str) -> bool
Check if a file path is allowed (no path traversal, within workspace)
Sourcepub fn is_resolved_path_allowed(&self, resolved: &Path) -> bool
pub fn is_resolved_path_allowed(&self, resolved: &Path) -> bool
Validate that a resolved path is still inside the workspace.
Sourcepub fn record_action(&self) -> bool
pub fn record_action(&self) -> bool
Record an action and check if the rate limit has been exceeded.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Check if the rate limit would be exceeded without recording.
Sourcepub fn resolved_path_violation_message(&self, resolved: &Path) -> String
pub fn resolved_path_violation_message(&self, resolved: &Path) -> String
Return a human-readable error message when a resolved path escapes the workspace.
Trait Implementations§
Source§impl Clone for SecurityPolicy
impl Clone for SecurityPolicy
Source§impl Debug for SecurityPolicy
impl Debug for SecurityPolicy
Auto Trait Implementations§
impl !Freeze for SecurityPolicy
impl !RefUnwindSafe for SecurityPolicy
impl Forget for SecurityPolicy
impl Move for SecurityPolicy
impl Send for SecurityPolicy
impl Sync for SecurityPolicy
impl Unpin for SecurityPolicy
impl UnsafeUnpin for SecurityPolicy
impl UnwindSafe for SecurityPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more