mirror of
https://github.com/edera-dev/sprout.git
synced 2026-02-04 18:30:17 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
656fde2044 | ||
|
|
5740c14e31 | ||
|
c295de4951
|
|||
|
|
95e0360721 | ||
|
|
1370e1b39b |
6
.github/workflows/ci-actions.yml
vendored
6
.github/workflows/ci-actions.yml
vendored
@@ -25,17 +25,17 @@ jobs:
|
|||||||
actions: read # Needed to analyze action metadata.
|
actions: read # Needed to analyze action metadata.
|
||||||
steps:
|
steps:
|
||||||
- name: harden runner
|
- name: harden runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: setup uv
|
- name: setup uv
|
||||||
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
|
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
|
||||||
|
|
||||||
- name: zizmor
|
- name: zizmor
|
||||||
run: uvx zizmor --pedantic --format sarif . > results.sarif
|
run: uvx zizmor --pedantic --format sarif . > results.sarif
|
||||||
|
|||||||
12
.github/workflows/ci-code.yml
vendored
12
.github/workflows/ci-code.yml
vendored
@@ -21,12 +21,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: harden runner
|
- name: harden runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -51,12 +51,12 @@ jobs:
|
|||||||
name: 'build ${{ matrix.arch }}'
|
name: 'build ${{ matrix.arch }}'
|
||||||
steps:
|
steps:
|
||||||
- name: harden runner
|
- name: harden runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -80,12 +80,12 @@ jobs:
|
|||||||
name: 'clippy ${{ matrix.arch }}'
|
name: 'clippy ${{ matrix.arch }}'
|
||||||
steps:
|
steps:
|
||||||
- name: harden runner
|
- name: harden runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/codeql.yml
vendored
4
.github/workflows/codeql.yml
vendored
@@ -37,12 +37,12 @@ jobs:
|
|||||||
build-mode: none
|
build-mode: none
|
||||||
steps:
|
steps:
|
||||||
- name: harden runner
|
- name: harden runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
|
|||||||
6
.github/workflows/publish.yml
vendored
6
.github/workflows/publish.yml
vendored
@@ -25,12 +25,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: harden runner
|
- name: harden runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ jobs:
|
|||||||
path: target/assemble/*
|
path: target/assemble/*
|
||||||
|
|
||||||
- name: 'attest artifacts'
|
- name: 'attest artifacts'
|
||||||
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
|
uses: actions/attest-build-provenance@00014ed6ed5efc5b1ab7f7f34a39eb55d41aa4f8 # v3.1.0
|
||||||
with:
|
with:
|
||||||
subject-name: artifacts.zip
|
subject-name: artifacts.zip
|
||||||
subject-digest: "sha256:${{ steps.upload.outputs.artifact-digest }}"
|
subject-digest: "sha256:${{ steps.upload.outputs.artifact-digest }}"
|
||||||
|
|||||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@@ -25,12 +25,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: harden runner
|
- name: harden runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
run: ./hack/assemble.sh
|
run: ./hack/assemble.sh
|
||||||
|
|
||||||
- name: 'attest release artifacts'
|
- name: 'attest release artifacts'
|
||||||
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
|
uses: actions/attest-build-provenance@00014ed6ed5efc5b1ab7f7f34a39eb55d41aa4f8 # v3.1.0
|
||||||
with:
|
with:
|
||||||
subject-path: target/assemble/*
|
subject-path: target/assemble/*
|
||||||
|
|
||||||
|
|||||||
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -270,9 +270,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.9.10+spec-1.1.0"
|
version = "0.9.11+spec-1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0825052159284a1a8b4d6c0c86cbc801f2da5afd2b225fa548c72f2e74002f48"
|
checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde_core",
|
||||||
"serde_spanned",
|
"serde_spanned",
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ version = "1.3.0"
|
|||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[workspace.dependencies.toml]
|
[workspace.dependencies.toml]
|
||||||
version = "0.9.10"
|
version = "0.9.11"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["serde", "parse"]
|
features = ["serde", "parse"]
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub fn chainload(context: Rc<SproutContext>, configuration: &ChainloadConfigurat
|
|||||||
// Resolve the path to the image to chainload.
|
// Resolve the path to the image to chainload.
|
||||||
let resolved = eficore::path::resolve_path(
|
let resolved = eficore::path::resolve_path(
|
||||||
Some(context.root().loaded_image_path()?),
|
Some(context.root().loaded_image_path()?),
|
||||||
&context.stamp(&configuration.path),
|
context.stamp(&configuration.path),
|
||||||
)
|
)
|
||||||
.context("unable to resolve chainload path")?;
|
.context("unable to resolve chainload path")?;
|
||||||
|
|
||||||
@@ -38,8 +38,7 @@ pub fn chainload(context: Rc<SproutContext>, configuration: &ChainloadConfigurat
|
|||||||
.context("unable to open loaded image protocol")?;
|
.context("unable to open loaded image protocol")?;
|
||||||
|
|
||||||
// Stamp and combine the options to pass to the image.
|
// Stamp and combine the options to pass to the image.
|
||||||
let options =
|
let options = utils::combine_options(context.stamp_iter(configuration.options.iter()));
|
||||||
utils::combine_options(configuration.options.iter().map(|item| context.stamp(item)));
|
|
||||||
|
|
||||||
// Pass the load options to the image.
|
// Pass the load options to the image.
|
||||||
// If no options are provided, the resulting string will be empty.
|
// If no options are provided, the resulting string will be empty.
|
||||||
@@ -50,6 +49,7 @@ pub fn chainload(context: Rc<SproutContext>, configuration: &ChainloadConfigurat
|
|||||||
.context("unable to convert chainloader options to CString16")?,
|
.context("unable to convert chainloader options to CString16")?,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Ensure the chainloader options limit is not exceeded.
|
||||||
if options.num_bytes() > u32::MAX as usize {
|
if options.num_bytes() > u32::MAX as usize {
|
||||||
bail!("chainloader options too large");
|
bail!("chainloader options too large");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,20 +20,11 @@ use uefi::Guid;
|
|||||||
/// Builds a configuration string for the Xen EFI stub using the specified `configuration`.
|
/// Builds a configuration string for the Xen EFI stub using the specified `configuration`.
|
||||||
fn build_xen_config(context: Rc<SproutContext>, configuration: &EderaConfiguration) -> String {
|
fn build_xen_config(context: Rc<SproutContext>, configuration: &EderaConfiguration) -> String {
|
||||||
// Stamp xen options and combine them.
|
// Stamp xen options and combine them.
|
||||||
let xen_options = utils::combine_options(
|
let xen_options = utils::combine_options(context.stamp_iter(configuration.xen_options.iter()));
|
||||||
configuration
|
|
||||||
.xen_options
|
|
||||||
.iter()
|
|
||||||
.map(|item| context.stamp(item)),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Stamp kernel options and combine them.
|
// Stamp kernel options and combine them.
|
||||||
let kernel_options = utils::combine_options(
|
let kernel_options =
|
||||||
configuration
|
utils::combine_options(context.stamp_iter(configuration.kernel_options.iter()));
|
||||||
.kernel_options
|
|
||||||
.iter()
|
|
||||||
.map(|item| context.stamp(item)),
|
|
||||||
);
|
|
||||||
|
|
||||||
// xen config file format is ini-like
|
// xen config file format is ini-like
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -269,6 +269,15 @@ impl SproutContext {
|
|||||||
Self::stamp_values(&self.all_values(), text.as_ref()).1
|
Self::stamp_values(&self.all_values(), text.as_ref()).1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stamps all the items from the iterator `input` with all the values in this [SproutContext]
|
||||||
|
/// and it's parents. This calls [self.stamp] on each item.
|
||||||
|
pub fn stamp_iter(
|
||||||
|
&self,
|
||||||
|
input: impl Iterator<Item = impl AsRef<str>>,
|
||||||
|
) -> impl Iterator<Item = String> {
|
||||||
|
input.map(|item| self.stamp(item))
|
||||||
|
}
|
||||||
|
|
||||||
/// Unloads a [SproutContext] back into an owned context. This
|
/// Unloads a [SproutContext] back into an owned context. This
|
||||||
/// may not succeed if something else is holding onto the value.
|
/// may not succeed if something else is holding onto the value.
|
||||||
pub fn unload(self: Rc<SproutContext>) -> Option<SproutContext> {
|
pub fn unload(self: Rc<SproutContext>) -> Option<SproutContext> {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ fn load_driver(context: Rc<SproutContext>, driver: &DriverDeclaration) -> Result
|
|||||||
// Resolve the path to the driver image.
|
// Resolve the path to the driver image.
|
||||||
let resolved = eficore::path::resolve_path(
|
let resolved = eficore::path::resolve_path(
|
||||||
Some(context.root().loaded_image_path()?),
|
Some(context.root().loaded_image_path()?),
|
||||||
&context.stamp(&driver.path),
|
context.stamp(&driver.path),
|
||||||
)
|
)
|
||||||
.context("unable to resolve path to driver")?;
|
.context("unable to resolve path to driver")?;
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,10 @@ pub fn generate(
|
|||||||
|
|
||||||
// Stamp the entry title and actions from the template.
|
// Stamp the entry title and actions from the template.
|
||||||
let mut entry = list.entry.clone();
|
let mut entry = list.entry.clone();
|
||||||
entry.actions = entry
|
|
||||||
.actions
|
// Stamp all the actions this entry references.
|
||||||
.into_iter()
|
entry.actions = context.stamp_iter(entry.actions.into_iter()).collect();
|
||||||
.map(|action| context.stamp(action))
|
|
||||||
.collect();
|
|
||||||
// Push the entry into the list with the new context.
|
// Push the entry into the list with the new context.
|
||||||
entries.push(BootableEntry::new(
|
entries.push(BootableEntry::new(
|
||||||
index.to_string(),
|
index.to_string(),
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ fn cstring16_contains_char(string: &CString16, c: char) -> bool {
|
|||||||
|
|
||||||
/// Parses the input `path` as a [DevicePath].
|
/// Parses the input `path` as a [DevicePath].
|
||||||
/// Uses the [DevicePathFromText] protocol exclusively, and will fail if it cannot acquire the protocol.
|
/// Uses the [DevicePathFromText] protocol exclusively, and will fail if it cannot acquire the protocol.
|
||||||
pub fn text_to_device_path(path: &str) -> Result<PoolDevicePath> {
|
pub fn text_to_device_path(path: impl AsRef<str>) -> Result<PoolDevicePath> {
|
||||||
let path = CString16::try_from(path).context("unable to convert path to CString16")?;
|
let path = CString16::try_from(path.as_ref()).context("unable to convert path to CString16")?;
|
||||||
let device_path_from_text = uefi::boot::open_protocol_exclusive::<DevicePathFromText>(
|
let device_path_from_text = uefi::boot::open_protocol_exclusive::<DevicePathFromText>(
|
||||||
uefi::boot::get_handle_for_protocol::<DevicePathFromText>()
|
uefi::boot::get_handle_for_protocol::<DevicePathFromText>()
|
||||||
.context("no device path from text protocol")?,
|
.context("no device path from text protocol")?,
|
||||||
@@ -113,8 +113,13 @@ pub fn device_path_subpath(path: &DevicePath) -> Result<String> {
|
|||||||
/// Resolve a path specified by `input` to its various components.
|
/// Resolve a path specified by `input` to its various components.
|
||||||
/// Uses `default_root_path` as the base root if one is not specified in the path.
|
/// Uses `default_root_path` as the base root if one is not specified in the path.
|
||||||
/// Returns [ResolvedPath] which contains the resolved components.
|
/// Returns [ResolvedPath] which contains the resolved components.
|
||||||
pub fn resolve_path(default_root_path: Option<&DevicePath>, input: &str) -> Result<ResolvedPath> {
|
pub fn resolve_path(
|
||||||
let mut path = text_to_device_path(input).context("unable to convert text to path")?;
|
default_root_path: Option<&DevicePath>,
|
||||||
|
input: impl ToString,
|
||||||
|
) -> Result<ResolvedPath> {
|
||||||
|
let mut input = input.to_string();
|
||||||
|
|
||||||
|
let mut path = text_to_device_path(&input).context("unable to convert text to path")?;
|
||||||
let path_has_device = path
|
let path_has_device = path
|
||||||
.node_iter()
|
.node_iter()
|
||||||
.next()
|
.next()
|
||||||
@@ -125,7 +130,6 @@ pub fn resolve_path(default_root_path: Option<&DevicePath>, input: &str) -> Resu
|
|||||||
.map(|it| it.to_string().contains('('))
|
.map(|it| it.to_string().contains('('))
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
if !path_has_device {
|
if !path_has_device {
|
||||||
let mut input = input.to_string();
|
|
||||||
if !input.starts_with('\\') {
|
if !input.starts_with('\\') {
|
||||||
input.insert(0, '\\');
|
input.insert(0, '\\');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ impl<'a> ShimInput<'a> {
|
|||||||
let path = path
|
let path = path
|
||||||
.to_string(DisplayOnly(false), AllowShortcuts(false))
|
.to_string(DisplayOnly(false), AllowShortcuts(false))
|
||||||
.context("unable to convert device path to string")?;
|
.context("unable to convert device path to string")?;
|
||||||
let path = crate::path::resolve_path(None, &path.to_string())
|
let path = crate::path::resolve_path(None, path.to_string())
|
||||||
.context("unable to resolve path")?;
|
.context("unable to resolve path")?;
|
||||||
// Read the file path.
|
// Read the file path.
|
||||||
let data = path.read_file()?;
|
let data = path.read_file()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user