Implement bounded Windows Event Log jobs and verify contracts on cloud Linux
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -71,10 +71,45 @@ pub fn supported(job: &JobPayload) -> bool {
|
||||
interpreter == "powershell" && powershell().is_ok()
|
||||
}
|
||||
Action::RefreshInventory { scope } => scope == "windows.base",
|
||||
Action::QueryLogs { .. } => crate::event_log::for_job(job).is_ok(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Each prepared operation retains its own typed binding; no non-script action
|
||||
/// can fall through to inventory or borrow the PowerShell execution profile.
|
||||
pub enum PreparedAction {
|
||||
Script(Script),
|
||||
Inventory,
|
||||
EventLog(crate::event_log_job::Prepared),
|
||||
}
|
||||
impl PreparedAction {
|
||||
pub fn prepare(
|
||||
job: &JobPayload,
|
||||
directory: &Path,
|
||||
grant: uuid::Uuid,
|
||||
request: &rmm_agent_core::auth::Request,
|
||||
boot: uuid::Uuid,
|
||||
) -> Result<Self> {
|
||||
ensure!(supported(job), "UNSUPPORTED_CAPABILITY");
|
||||
match &job.action {
|
||||
Action::RunScript { .. } => Ok(Self::Script(Script::prepare(job, directory, grant)?)),
|
||||
Action::RefreshInventory { scope } if scope == "windows.base" => Ok(Self::Inventory),
|
||||
Action::QueryLogs { .. } => Ok(Self::EventLog(
|
||||
crate::event_log_job::Prepared::prepare(job, directory, request, grant, boot)?,
|
||||
)),
|
||||
_ => anyhow::bail!("UNSUPPORTED_CAPABILITY"),
|
||||
}
|
||||
}
|
||||
pub fn run(self, job: &JobPayload, cancel: &AtomicBool) -> Result<Outcome> {
|
||||
match self {
|
||||
Self::Script(script) => script.run(job, cancel),
|
||||
Self::Inventory => inventory(job),
|
||||
Self::EventLog(log) => log.run(job, cancel),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Script {
|
||||
executable: PathBuf,
|
||||
path: PathBuf,
|
||||
|
||||
Reference in New Issue
Block a user