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

Method submit_attestation

libatomic/src/daemon/services_sandbox.rs:866–960  ·  view source on GitHub ↗

`SubmitAttestation`: a remote sandbox's session-end attestation — the signed audit node its agent created — plus the session state file it verifies under, saved in the repository (CB-12B). The gate that decides whether a managed change may cross a publication boundary needs two things this sandbox holds and no other transport carries: a same-session attestation over the change, and the session MA

(
        &self,
        request: Request<SubmitAttestationRequest>,
    )

Source from the content-addressed store, hash-verified

864 /// owner may resolve DID keys later — signature policy is not the
865 /// transport's to decide).
866 async fn submit_attestation(
867 &self,
868 request: Request<SubmitAttestationRequest>,
869 ) -> Result<Response<SubmitAttestationResponse>, Status> {
870 let caller = self.state.sandbox_caller(&request)?;
871 let request = request.into_inner();
872 let repository = repository_ref(&request.repository)?;
873 let handle = self.state.resolve(&repository)?;
874 self.state.log_rpc("SubmitAttestation", Some(&handle));
875 let view = data_view(
876 caller.as_ref(),
877 &handle,
878 &repository,
879 request.target.as_ref(),
880 "attestation.write",
881 )?;
882 let session_id = request.session_id;
883 if session_id.is_empty() {
884 return Err(invalid("session_id is required"));
885 }
886 let bytes = wire::attestation_from(request.attestation.as_ref()).map_err(invalid)?;
887 let attestation = match atomic_core::change::attestation::Attestation::deserialize(&bytes) {
888 Ok((attestation, _)) => attestation,
889 Err(e) => {
890 return Ok(Response::new(SubmitAttestationResponse {
891 outcome: Some(submit_attestation_response::Outcome::Refused(
892 wire::rejection_error_info(&SubmitRejection::Malformed(e.to_string())),
893 )),
894 meta: response_meta(&request.meta),
895 }))
896 }
897 };
898 if attestation.session_id != session_id {
899 return Err(invalid("the attestation names another session"));
900 }
901 if let Some(caller) = &caller {
902 let owns = self
903 .state
904 .sandbox_grants()
905 .owns_session(&caller.grant, &session_id)
906 .map_err(|e| e.status())?;
907 if !owns {
908 return Err(domain_status(
909 ErrorCode::Forbidden,
910 format!(
911 "session '{}' is not this sandbox's (view '{}')",
912 session_id,
913 caller.view()
914 ),
915 ));
916 }
917 }
918 let meta = request.meta.clone();
919 let session_json = request.session_json;
920 let gate_handle = handle.clone();
921 let _gate = gate_handle.exclusive().await;
922 if let Some(caller) = &caller {
923 caller.revalidate(&self.state)?;

Callers

nothing calls this directly

Calls 15

repository_refFunction · 0.85
data_viewFunction · 0.85
attestation_fromFunction · 0.85
rejection_error_infoFunction · 0.85
response_metaFunction · 0.85
domain_statusFunction · 0.85
check_viewFunction · 0.85
SubmittedClass · 0.85
sandbox_callerMethod · 0.80
log_rpcMethod · 0.80
as_refMethod · 0.80
owns_sessionMethod · 0.80

Tested by

no test coverage detected