aKode 0.9.2: istruzioni dei permessi con la rete limitata ai registri

Con il proxy dei registri (profilo :workspace + features.network_proxy) le istruzioni
dei permessi dicono «Network access is limited to package registries (…). Other
connections, including ssh, are blocked inside the sandbox: run them with escalated
permissions, which requires approval.» (frase approvata dall'utente); l'elenco viene
dai domini configurati. Con rete piena o spenta il testo resta «enabled»/«restricted».
Test aggiunti; versione 0.9.2 e Novità nel README.

Prova reale: in un progetto fidato, «collegati in ssh a root@192.168.40.25 e dimmi
hostname e uptime» chiede subito l'escalation, l'approvazione compare nella TUI e ssh
funziona con le chiavi dell'utente.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-17 07:55:24 +01:00
parent 4ba28b130b
commit 8cc51099e2
38 changed files with 338 additions and 190 deletions

View File

@@ -39,6 +39,7 @@ pub(crate) enum PermissionsSnapshot {
impl PermissionsState {
#[allow(clippy::too_many_arguments)]
#[cfg_attr(not(test), allow(dead_code))]
pub(crate) fn new(
permission_profile: &PermissionProfile,
approval_policy: AskForApproval,
@@ -48,6 +49,33 @@ impl PermissionsState {
paths: Option<&FileSystemSandboxPolicyContext<'_>>,
exec_permission_approvals_enabled: bool,
request_permissions_tool_enabled: bool,
) -> Self {
Self::new_with_network_allowlist(
permission_profile,
approval_policy,
approval_context,
exec_policy,
cwd,
paths,
exec_permission_approvals_enabled,
request_permissions_tool_enabled,
&[],
)
}
/// aKode: like [`Self::new`], describing a network limited to `allowed_domains`
/// (the managed proxy allowlist) when it is not empty.
#[allow(clippy::too_many_arguments)]
pub(crate) fn new_with_network_allowlist(
permission_profile: &PermissionProfile,
approval_policy: AskForApproval,
approval_context: ApprovalPromptContext<'_>,
exec_policy: &Policy,
cwd: &Path,
paths: Option<&FileSystemSandboxPolicyContext<'_>>,
exec_permission_approvals_enabled: bool,
request_permissions_tool_enabled: bool,
allowed_domains: &[String],
) -> Self {
let build_instructions = |exec_policy| {
PermissionsInstructions::from_permission_profile(
@@ -60,6 +88,7 @@ impl PermissionsState {
exec_permission_approvals_enabled,
request_permissions_tool_enabled,
)
.with_limited_network(allowed_domains)
};
let instructions = build_instructions(exec_policy);
let instructions_without_approved_prefixes = build_instructions(&Policy::empty());

View File

@@ -279,7 +279,19 @@ impl Session {
let cwd = environment
.and_then(|environment| environment.cwd().to_abs_path().ok())
.unwrap_or_else(|| turn_context.cwd.clone());
world_state.add_section(PermissionsState::new(
// aKode: with the managed proxy, the network is limited to its allowlist.
let allowed_domains = match turn_context.network.as_ref() {
Some(network) if permission_profile.network_sandbox_policy().is_enabled() => {
network
.current_cfg()
.await
.ok()
.and_then(|cfg| cfg.allowed_domains())
.unwrap_or_default()
}
_ => Vec::new(),
};
world_state.add_section(PermissionsState::new_with_network_allowlist(
&permission_profile,
settings.approval_policy(),
approval_context,
@@ -294,6 +306,7 @@ impl Session {
.config
.features
.enabled(Feature::RequestPermissionsTool),
&allowed_domains,
));
} else {
world_state.add_section(CompactPermissionsState::new(