MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / require_target

Method require_target

libatomic/src/daemon/sandbox_grants.rs:509–541  ·  view source on GitHub ↗

Refuse unless the request is for the grant's repository (and names no host workspace) and `named` — the view the request names, if any — is the grant's.

(
        &self,
        handle: &RepoHandle,
        repository: &RepositoryRef,
        named: Option<&ViewRef>,
    )

Source from the content-addressed store, hash-verified

507 /// host workspace) and `named` — the view the request names, if any — is
508 /// the grant's.
509 pub fn require_target(
510 &self,
511 handle: &RepoHandle,
512 repository: &RepositoryRef,
513 named: Option<&ViewRef>,
514 ) -> Result<(), Status> {
515 if repository.workspace_id.is_some() {
516 return Err(domain_status(
517 ErrorCode::Forbidden,
518 "a sandbox request may not name a host workspace",
519 ));
520 }
521 if handle.repository_id() != self.grant.repository_id {
522 return Err(domain_status(
523 ErrorCode::Forbidden,
524 "this sandbox's grant is for another repository",
525 ));
526 }
527 if let Some(named) = named {
528 let by_name = named.name.as_deref().is_some_and(|n| n != self.grant.view);
529 let by_id = !named.view_id.is_empty() && named.view_id != view_ref_id(&self.grant.view);
530 if by_name || by_id {
531 return Err(domain_status(
532 ErrorCode::Forbidden,
533 format!(
534 "that view is not this sandbox's (view '{}')",
535 self.grant.view
536 ),
537 ));
538 }
539 }
540 Ok(())
541 }
542
543 /// Check the grant again — after time spent waiting for the repository,
544 /// it may have expired or been revoked.

Callers 9

data_viewFunction · 0.80
reserve_turn_implFunction · 0.80
append_envelopes_implFunction · 0.80
prepare_checkpoint_implFunction · 0.80
update_turn_implFunction · 0.80
get_turn_implFunction · 0.80

Calls 4

domain_statusFunction · 0.85
view_ref_idFunction · 0.85
repository_idMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected