Skip to content

Commit b66d681

Browse files
committed
fix plugin smoke schema mismatches
1 parent d958f58 commit b66d681

7 files changed

Lines changed: 39 additions & 8 deletions

File tree

docs/plugins/generated.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,7 +2404,7 @@ List system cron.d entries and optionally one user's crontab.
24042404

24052405
| Parameter | Required | Type | Default | Description |
24062406
|---|---:|---|---|---|
2407-
| `user` | no | `boolean` | `False` | Use systemctl --user instead of the system manager. |
2407+
| `user` | no | `string` | `False` | User account whose crontab should be listed. |
24082408
| `sudo` | no | `boolean` | `False` | Run the remote operation through sudo -n when supported. |
24092409

24102410
Result fields:
@@ -8746,7 +8746,7 @@ Set an SELinux boolean.
87468746
| Parameter | Required | Type | Default | Description |
87478747
|---|---:|---|---|---|
87488748
| `name` | yes | `string` | | Package, user or group name. |
8749-
| `value` | yes | `string` | | Desired parameter value. |
8749+
| `value` | yes | `string` | | Desired SELinux boolean value. |
87508750
| `persist` | no | `boolean` | `False` | Persist the change across reboots. |
87518751
| `sudo` | no | `boolean` | `False` | Run the remote operation through sudo -n when supported. |
87528752

examples/runbooks/runbooks/49-secret.check.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ tasks:
1818
use: secret.redact_assert
1919
with:
2020
text: password=secret
21-
value: 1
21+
value: '1'
2222
- id: secret_scan_output
2323
use: secret.scan_output
2424
with:
2525
text: password=secret
26-
value: 1
26+
value: '1'
2727
- id: secret_scan_preview
2828
use: secret.scan_preview
2929
with:
3030
text: password=secret
31-
value: 1
31+
value: '1'

examples/runbooks/runbooks/56-sysctl.check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tasks:
1818
use: sysctl.assert
1919
with:
2020
name: nginx
21-
value: 1
21+
value: '1'
2222
- id: sysctl_dropin
2323
use: sysctl.dropin
2424
with:
@@ -40,7 +40,7 @@ tasks:
4040
use: sysctl.persist
4141
with:
4242
name: nginx
43-
value: 1
43+
value: '1'
4444
- id: sysctl_reload
4545
use: sysctl.reload
4646
with:

examples/runbooks/runbooks/58-systemctl.check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tasks:
1818
use: systemctl.daemon_reload
1919
with:
2020
sudo: true
21-
user: deploy
21+
user: true
2222
- id: systemctl_disable
2323
use: systemctl.disable
2424
with:

src/automax/plugins/cron.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class CronListPlugin(BasePlugin):
100100
name = "cron.list"
101101
description = "List system cron.d entries and optionally one user's crontab."
102102
optional_params = ("user", "sudo")
103+
parameter_schema = {"user": {"type": "string", "description": "User account whose crontab should be listed."}}
103104
opens_remote_session = True
104105
supports_check_mode = True
105106

src/automax/plugins/security_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class SelinuxBooleanPlugin(BasePlugin):
6868
description = "Set an SELinux boolean."
6969
required_params = ("name", "value")
7070
optional_params = ("persist", "sudo")
71+
parameter_schema = {"value": {"types": ("boolean", "string"), "description": "Desired SELinux boolean value."}}
7172
opens_remote_session = True
7273

7374
def execute(self, params: Dict[str, Any], context: ExecutionContext) -> PluginResult:

tests/test_documentation_and_regressions.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,35 @@ def test_plugin_smoke_runbooks_match_auditd_search_user_schema():
681681
assert search_substeps
682682
assert all(isinstance((substep.get("with") or {}).get("user"), str) for substep in search_substeps)
683683

684+
685+
def test_plugin_smoke_runbooks_validate_against_builtin_schemas():
686+
from automax.plugins.registry import build_builtin_registry
687+
688+
registry = build_builtin_registry()
689+
failures = []
690+
for runbook_path in sorted(Path("examples/runbooks/runbooks").glob("*.check.yaml")):
691+
data = yaml.safe_load(runbook_path.read_text(encoding="utf-8"))
692+
for task in data.get("tasks", []):
693+
for step in task.get("steps", []):
694+
for substep in step.get("substeps", []):
695+
plugin_name = substep.get("use")
696+
params = substep.get("with") or {}
697+
try:
698+
registry.get(plugin_name).validate(params)
699+
except Exception as exc: # pragma: no cover - assertion reports all offenders
700+
failures.append(f"{runbook_path}:{substep.get('id')}:{plugin_name}: {exc}")
701+
702+
assert failures == []
703+
704+
705+
def test_plugin_specific_user_and_boolean_value_schemas_do_not_use_global_fallbacks():
706+
from automax.plugins.registry import build_builtin_registry
707+
708+
registry = build_builtin_registry()
709+
registry.get("cron.list").validate({"user": "deploy", "sudo": True})
710+
registry.get("selinux.boolean").validate({"name": "httpd_can_network_connect", "value": True, "persist": True})
711+
712+
684713
def test_docs_show_sudo_password_env_for_runs_and_capability_installs():
685714
docs = "\n".join(
686715
path.read_text(encoding="utf-8")

0 commit comments

Comments
 (0)