MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / measure_app_info

Method measure_app_info

dstack-util/src/system_setup.rs:1298–1346  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

1296 }
1297
1298 fn measure_app_info(&self) -> Result<AppInfo> {
1299 let compose_hash = sha256_file(self.shared.dir.app_compose_file())?;
1300 let truncated_compose_hash = truncate(&compose_hash, 20);
1301 let kms_enabled = self.shared.app_compose.kms_enabled();
1302 let key_provider = self.shared.app_compose.key_provider();
1303 let mut instance_info = self.shared.instance_info.clone();
1304
1305 if instance_info.app_id.is_empty() {
1306 instance_info.app_id = truncated_compose_hash.to_vec();
1307 }
1308 if instance_info.app_id.len() != 20 {
1309 bail!(
1310 "Invalid app id length: expected 20 bytes, got {}",
1311 instance_info.app_id.len()
1312 );
1313 }
1314
1315 let disk_reusable = !key_provider.is_none();
1316 if (!disk_reusable) || instance_info.instance_id_seed.is_empty() {
1317 instance_info.instance_id_seed = {
1318 let mut rand_id = vec![0u8; 20];
1319 getrandom::fill(&mut rand_id)?;
1320 rand_id
1321 };
1322 }
1323 let instance_id = if self.shared.app_compose.no_instance_id {
1324 vec![]
1325 } else {
1326 let mut id_path = instance_info.instance_id_seed.clone();
1327 id_path.extend_from_slice(&instance_info.app_id);
1328 sha256(&id_path)[..20].to_vec()
1329 };
1330 instance_info.instance_id = instance_id.clone();
1331 let app_id = if kms_enabled {
1332 instance_info.app_id.clone()
1333 } else {
1334 truncated_compose_hash.to_vec()
1335 };
1336
1337 emit_runtime_event("system-preparing", &[])?;
1338 emit_runtime_event("app-id", &app_id)?;
1339 emit_runtime_event("compose-hash", &compose_hash)?;
1340 emit_runtime_event("instance-id", &instance_id)?;
1341 emit_runtime_event("boot-mr-done", &[])?;
1342 Ok(AppInfo {
1343 instance_info,
1344 compose_hash,
1345 })
1346 }
1347
1348 fn verify_app(&self, app_info: &AppInfo, keys: &AppKeys) -> Result<()> {
1349 config_id_verifier::verify_mr_config_id(

Callers 1

setup_fsMethod · 0.80

Calls 12

sha256_fileFunction · 0.85
truncateFunction · 0.85
emit_runtime_eventFunction · 0.85
app_compose_fileMethod · 0.80
kms_enabledMethod · 0.80
key_providerMethod · 0.80
cloneMethod · 0.80
to_vecMethod · 0.80
is_noneMethod · 0.80
sha256Function · 0.70
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected