Separate SYSTEM policy and verify thirteen policy guards on cloud Linux
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -152,7 +152,7 @@ impl RootScope {
|
||||
capabilities: &[String],
|
||||
global_log_units: Option<&[String]>,
|
||||
) -> bool {
|
||||
if job.execution_identity != "root" {
|
||||
if job.execution_identity != "root" || capabilities.iter().any(|c| c == "windows.base/1") {
|
||||
return false;
|
||||
}
|
||||
if !self.matches_target(job)
|
||||
@@ -279,13 +279,26 @@ fn load() -> Result<RootPolicy, Error> {
|
||||
}
|
||||
Ok(policy)
|
||||
}
|
||||
pub fn execution_permission(identity: &str) -> Option<&'static str> {
|
||||
match identity {
|
||||
"root" => Some("root:execute"),
|
||||
"system" => Some("system:execute"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn needs_helper(identity: &str) -> bool {
|
||||
execution_permission(identity).is_some()
|
||||
}
|
||||
pub async fn authorize(
|
||||
tx: &mut Transaction<'_, Postgres>,
|
||||
principal: &str,
|
||||
job: &JobPayload,
|
||||
) -> Result<(), Error> {
|
||||
if job.execution_identity != "root" {
|
||||
return Ok(());
|
||||
match job.execution_identity.as_str() {
|
||||
"system" => return crate::windows_policy::authorize(tx, principal, job).await,
|
||||
"agent_service" => return Ok(()),
|
||||
"root" => {}
|
||||
_ => return Err(Error(StatusCode::FORBIDDEN, "EXECUTION_IDENTITY_DENIED")),
|
||||
}
|
||||
for permission in required_permissions(job, false) {
|
||||
crate::permissions::require(tx, principal, permission).await?;
|
||||
@@ -375,6 +388,9 @@ mod tests {
|
||||
assert!(scope.permits("selected", &job, &caps, None));
|
||||
assert!(!scope.permits("automation", &job, &caps, None));
|
||||
assert!(!scope.permits("selected", &job, &caps[..4], None));
|
||||
let mut windows = caps;
|
||||
windows.push("windows.base/1".into());
|
||||
assert!(!scope.permits("selected", &job, &windows, None));
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user