-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deny preload for an image with secure boot enabled #2914
base: master
Are you sure you want to change the base?
Conversation
3d36582
to
a1650aa
Compare
Change-type: patch Signed-off-by: Ken Bannister <[email protected]>
a1650aa
to
a02df07
Compare
BalenaPartition.ROOTA, | ||
async (fs: typeof Fs): Promise<boolean> => { | ||
try { | ||
const promiseDir = promisify(fs.readdir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of using promisify
here, we can use the native promises api: https://nodejs.org/docs/latest-v20.x/api/fs.html#fspromisesreaddirpath-options to avoid having to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rcooke-warwick this is not the fs
namespace imported at the top level, but it's the virtual fs
"namespace" that balena-image-fs gives us.
That being said, since we recently added support for promises in balena-image-fs, @kb2ma should be able to just use v directly.
const promiseDir = promisify(fs.readdir); | |
const files = await fs.promises.readdir('/opt'); |
}, | ||
); | ||
// Next verify that config.json enables secureboot. | ||
if (isSecureBoot) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not relevant to this PR, but maybe elsewhere we can add a check to the CLI that detects if someone has tried to enable secureboot on a non signed image, and warn them that this won't work, to avoid any confusion / chance of them thinking they've deployed a secure device but haven't!
} | ||
|
||
// Find partition, by partition name on GPT or by filesystem label on MBR. | ||
async function findPartition( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since that's soooo similar to findBootPartitionByName()
of balena-config-json, how about avoiding the duplication by creating and exposing a more generic function like the one you did here?
We can then have findBootPartitionByName()
use this new findPartition()
by wiring in the names of interest for the partition.
Deny an attempt to preload an app into an image with secure boot enabled, and provide a message to the user. BalenaOS does not support this action.
Implementation includes a generic, callback-driven capability to explore a partition in
utils/explore-contents
module. Allows for the caller to determine success or failure.