From ae3de25663e5bf47ab71be5f1480d328602fe429 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Wed, 8 Jun 2022 21:35:22 +0000 Subject: [PATCH] kata-security-coordinator::fakeimpl: construct unique bundle id's Fake bundle id's are now "fake.X" where X is the CPtr for the package contents' CNode (which is known unique). While here fix some whitespace bogons. Change-Id: I84c586e11f56c416d9bad667cae8e4cecba5dca2 GitOrigin-RevId: 0cec9e3308d9f3fe019af666dea583f92b3735b4 --- .../src/fakeimpl/mod.rs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/fakeimpl/mod.rs b/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/fakeimpl/mod.rs index e296c88..e00abf3 100644 --- a/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/fakeimpl/mod.rs +++ b/apps/system/components/SecurityCoordinator/kata-security-coordinator/src/fakeimpl/mod.rs @@ -1,6 +1,7 @@ //! Kata OS security coordinator fake support extern crate alloc; +use alloc::fmt; use alloc::string::{String, ToString}; use hashbrown::HashMap; use kata_memory_interface::ObjDescBundle; @@ -22,16 +23,16 @@ impl BundleData { pkg_size: size, manifest: String::from( "# Comments like this - [Manifest] - BundleId=com.google.cerebra.hw.HelloWorld + [Manifest] + BundleId=com.google.cerebra.hw.HelloWorld - [Binaries] - App=HelloWorldBin - Model=NeuralNetworkName + [Binaries] + App=HelloWorldBin + Model=NeuralNetworkName - [Storage] - Required=1 - ", + [Storage] + Required=1 + ", ), keys: HashMap::with_capacity(2), } @@ -78,7 +79,9 @@ pub type KataSecurityCoordinatorInterface = FakeSecurityCoordinator; impl SecurityCoordinatorInterface for FakeSecurityCoordinator { fn install(&mut self, pkg_contents: &ObjDescBundle) -> Result { - let bundle_id = "fubar".to_string(); // XXX + // TODO(sleffler): get bundle_id from the manifest; for now use the + // cnode's CPtr since it is unique wrt all installed packages + let bundle_id = fmt::format(format_args!("fake.{}", pkg_contents.cnode)); if self.bundles.contains_key(&bundle_id) { return Err(SecurityRequestError::SreDeleteFirst); }