Repository: comtrya/comtrya (language: rust)

Issue:
Bug: wrongly configured actions are simply ignored, no error shown
**Description**
After being told that you can escalate privileges for a command by using a flag instead of `sudo` as command I initially assumed `privileged: true` would be the way to do so as I couldn't find anything about it in the documentation.

When running `apply` that specific action was just skipped. Turns out it's `sudo: true` instead.

It seems that actions that cannot be parsed or are invalid for some reason are just ignored and no error is given.

**Steps to reproduce**
```
  - action: command.run
    command: cp
    privileged: true
    args:
      - -f
      - manifests/tools/zsh/files/zshenv
      - /etc/zsh/
```

**Expected behaviour**
Getting an error message

**Environment**
- Manjaro
- Version: 0.8.3



Discussion / hints:
I was pretty sure it was `priviledged.` We should probably rename it to `privileged.` Sudo works, but some systems don't have sudo. Windows systems. Or systems that use `doas.`
windows can have sudo:

- https://smalltech.com.au/blog/sudo-for-windows
- https://github.com/lukesampson/psutils/blob/master/sudo.ps1
- https://morioh.com/p/268fc8bd0027
This is probably due to my report of #278
Mostly just to do a more generic name since sudo doesnt translate well to all platforms and there are alaternatives to sudo. Doas being an example that is rather popular in the BSD community and has caught on in some areas of Liunux. Renaming the property to 'privileged' other than 'sudo' would make it more generic instead of tying the concept of privileged escalation to a name of a specific tool for doing that in the context of comtrya.

Fix patch:
diff --git a/lib/src/actions/mod.rs b/lib/src/actions/mod.rs
index d132ef01..09b4e825 100644
--- a/lib/src/actions/mod.rs
+++ b/lib/src/actions/mod.rs
@@ -33,6 +33,7 @@ use user::add::UserAdd;
 use self::user::add_group::UserAddGroup;
 
 #[derive(JsonSchema, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
+#[serde(deny_unknown_fields)]
 pub struct ConditionalVariantAction<T> {
     #[serde(flatten)]
     pub action: T,
@@ -98,7 +99,7 @@ where
 }
 
 #[derive(JsonSchema, Clone, Debug, Serialize, Deserialize)]
-#[serde(tag = "action")]
+#[serde(deny_unknown_fields, tag = "action")]
 pub enum Actions {
     #[serde(rename = "command.run", alias = "cmd.run")]
     CommandRun(ConditionalVariantAction<RunCommand>),
diff --git a/lib/src/manifests/load.rs b/lib/src/manifests/load.rs
index cba86862..86056613 100644
--- a/lib/src/manifests/load.rs
+++ b/lib/src/manifests/load.rs
@@ -92,9 +92,9 @@ pub fn load(manifest_path: PathBuf, contexts: &Contexts) -> HashMap<String, Mani
                     .and_then(OsStr::to_str)
                 {
                     Some("yaml") | Some("yml") => {
-                        serde_yaml::from_str(template.deref()).map_err(anyhow::Error::from)
+                        serde_yaml::from_str::<Manifest>(template.deref()).map_err(anyhow::Error::from)
                     }
-                    Some("toml") => toml::from_str(template.deref()).map_err(anyhow::Error::from),
+                    Some("toml") => toml::from_str::<Manifest>(template.deref()).map_err(anyhow::Error::from),
                     _ => {
                         error!("Unrecognized file extension for manifest");
                         span.exit();
diff --git a/lib/src/manifests/mod.rs b/lib/src/manifests/mod.rs
index 4f78c268..753bd1e7 100644
--- a/lib/src/manifests/mod.rs
+++ b/lib/src/manifests/mod.rs
@@ -11,6 +11,7 @@ use std::path::{Path, PathBuf};
 use tracing::error;
 
 #[derive(JsonSchema, Clone, Debug, Default, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
 pub struct Manifest {
     #[serde(default)]
     pub r#where: Option<String>,


Test patch: