oysterav 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oyst_cli/__init__.py +1 -0
- oyst_cli/commands/__init__.py +0 -0
- oyst_cli/commands/audit_cmd.py +30 -0
- oyst_cli/commands/auth_cmd.py +60 -0
- oyst_cli/commands/config_cmd.py +63 -0
- oyst_cli/commands/desktop_cmd.py +141 -0
- oyst_cli/commands/doctor.py +42 -0
- oyst_cli/commands/install_helper_cmd.py +48 -0
- oyst_cli/commands/job_cmd.py +45 -0
- oyst_cli/commands/maintenance.py +72 -0
- oyst_cli/commands/news_cmd.py +127 -0
- oyst_cli/commands/pack_install_cmd.py +47 -0
- oyst_cli/commands/packs/__init__.py +31 -0
- oyst_cli/commands/packs/clamav_cmd.py +126 -0
- oyst_cli/commands/packs/clamonacc_cmd.py +144 -0
- oyst_cli/commands/packs/fail2ban_cmd.py +107 -0
- oyst_cli/commands/packs/firewall_cmd.py +314 -0
- oyst_cli/commands/packs/firewall_cmd_firewalld.py +161 -0
- oyst_cli/commands/packs/firewall_cmd_manage.py +79 -0
- oyst_cli/commands/packs/lynis_cmd.py +107 -0
- oyst_cli/commands/packs/maldet_cmd.py +158 -0
- oyst_cli/commands/packs/rkhunter_cmd.py +143 -0
- oyst_cli/commands/packs/signatures_cmd.py +135 -0
- oyst_cli/commands/quarantine.py +211 -0
- oyst_cli/commands/runtime_cmd.py +194 -0
- oyst_cli/commands/scan.py +104 -0
- oyst_cli/commands/schedule_cmd.py +361 -0
- oyst_cli/commands/services_cmd.py +40 -0
- oyst_cli/commands/setup_cmd.py +225 -0
- oyst_cli/commands/status.py +223 -0
- oyst_cli/commands/terminal_cmd.py +89 -0
- oyst_cli/commands/updates_cmd.py +74 -0
- oyst_cli/commands/version_cmd.py +43 -0
- oyst_cli/commands/virusevent_cmd.py +61 -0
- oyst_cli/confirm.py +18 -0
- oyst_cli/main.py +188 -0
- oyst_cli/options.py +23 -0
- oyst_cli/output.py +39 -0
- oyst_cli/progress.py +70 -0
- oyst_core/__init__.py +25 -0
- oyst_core/app_release.py +214 -0
- oyst_core/audit.py +159 -0
- oyst_core/client.py +176 -0
- oyst_core/client_api.py +338 -0
- oyst_core/client_api_shield.py +207 -0
- oyst_core/config.py +76 -0
- oyst_core/config_access.py +331 -0
- oyst_core/config_io.py +184 -0
- oyst_core/config_models.py +231 -0
- oyst_core/desktop_icons.py +186 -0
- oyst_core/desktop_util.py +215 -0
- oyst_core/doctor_cache.py +40 -0
- oyst_core/events.py +53 -0
- oyst_core/events_history.py +227 -0
- oyst_core/events_jobs.py +190 -0
- oyst_core/finding_status.py +40 -0
- oyst_core/health.py +216 -0
- oyst_core/history_actions.py +213 -0
- oyst_core/history_export.py +175 -0
- oyst_core/logging_util.py +30 -0
- oyst_core/maintenance.py +85 -0
- oyst_core/models.py +130 -0
- oyst_core/orchestrator.py +268 -0
- oyst_core/orchestrator_helpers.py +206 -0
- oyst_core/orchestrator_scan_concert.py +102 -0
- oyst_core/pack_install.py +283 -0
- oyst_core/pack_jobs.py +80 -0
- oyst_core/pack_sources.py +194 -0
- oyst_core/packs/__init__.py +1 -0
- oyst_core/packs/base.py +149 -0
- oyst_core/packs/chkrootkit.py +101 -0
- oyst_core/packs/clamav.py +280 -0
- oyst_core/packs/clamd_ensure.py +297 -0
- oyst_core/packs/clamd_onaccess.py +277 -0
- oyst_core/packs/clamonacc.py +244 -0
- oyst_core/packs/fail2ban.py +177 -0
- oyst_core/packs/fangfrisch.py +156 -0
- oyst_core/packs/firewall.py +181 -0
- oyst_core/packs/firewall_batch.py +116 -0
- oyst_core/packs/firewall_ensure.py +101 -0
- oyst_core/packs/firewall_ops.py +398 -0
- oyst_core/packs/firewall_select.py +74 -0
- oyst_core/packs/firewall_ufw_read.py +214 -0
- oyst_core/packs/freshclam.py +119 -0
- oyst_core/packs/lynis.py +182 -0
- oyst_core/packs/maldet.py +259 -0
- oyst_core/packs/maldet_parse.py +200 -0
- oyst_core/packs/rkhunter.py +151 -0
- oyst_core/packs/rkhunter_disable_tests.py +99 -0
- oyst_core/packs/rkhunter_overlay.py +208 -0
- oyst_core/packs/rkhunter_resolve.py +69 -0
- oyst_core/packs/rkhunter_resolve_plan.py +194 -0
- oyst_core/packs/rkhunter_resolve_preview.py +73 -0
- oyst_core/packs/unhide.py +90 -0
- oyst_core/privilege/__init__.py +46 -0
- oyst_core/privilege/plan.py +51 -0
- oyst_core/privilege/preflight.py +38 -0
- oyst_core/privilege/priority.py +107 -0
- oyst_core/privilege/recipes.py +291 -0
- oyst_core/privilege/recipes_firewall.py +61 -0
- oyst_core/privilege/recipes_update.py +134 -0
- oyst_core/privilege/run.py +74 -0
- oyst_core/privileged/__init__.py +6 -0
- oyst_core/privileged/auth_grant.py +330 -0
- oyst_core/privileged/auth_grant_expire.py +139 -0
- oyst_core/privileged/auth_grant_scope.py +67 -0
- oyst_core/privileged/elevate_cli.py +217 -0
- oyst_core/privileged/helper.py +146 -0
- oyst_core/privileged/helper_clamd.py +302 -0
- oyst_core/privileged/helper_clamd_unit.py +208 -0
- oyst_core/privileged/helper_concert.py +63 -0
- oyst_core/privileged/helper_fail2ban.py +122 -0
- oyst_core/privileged/helper_firewall.py +172 -0
- oyst_core/privileged/helper_firewall_batch.py +175 -0
- oyst_core/privileged/helper_fw_enable.py +110 -0
- oyst_core/privileged/helper_fw_lifecycle.py +326 -0
- oyst_core/privileged/helper_install_script.py +144 -0
- oyst_core/privileged/helper_scan_concert.py +159 -0
- oyst_core/privileged/helper_sealed_scanner.py +114 -0
- oyst_core/privileged/helper_services.py +143 -0
- oyst_core/privileged/helper_setup_concert.py +170 -0
- oyst_core/privileged/helper_setup_harden.py +185 -0
- oyst_core/privileged/helper_update_concert.py +85 -0
- oyst_core/privileged/helper_validate.py +317 -0
- oyst_core/privileged/install_privileged_helper.py +310 -0
- oyst_core/privileged/oyst_helper.py +206 -0
- oyst_core/privileged/polkit_policy.py +178 -0
- oyst_core/privileged/runner.py +235 -0
- oyst_core/privileged/safe_write.py +28 -0
- oyst_core/privileged/scanner_exec.py +86 -0
- oyst_core/privileged/systemctl_route.py +22 -0
- oyst_core/privileged/validators.py +201 -0
- oyst_core/quarantine.py +338 -0
- oyst_core/quarantine_guards.py +62 -0
- oyst_core/registry.py +57 -0
- oyst_core/rpc_auth.py +93 -0
- oyst_core/rpc_errors.py +30 -0
- oyst_core/rpc_handlers/__init__.py +147 -0
- oyst_core/rpc_handlers/config_schedule.py +58 -0
- oyst_core/rpc_handlers/data.py +185 -0
- oyst_core/rpc_handlers/jobs.py +70 -0
- oyst_core/rpc_handlers/shield_fw.py +263 -0
- oyst_core/rpc_handlers/status_pack.py +87 -0
- oyst_core/rpc_handlers/system.py +264 -0
- oyst_core/rpc_io.py +92 -0
- oyst_core/runtime/__init__.py +17 -0
- oyst_core/runtime/bootstrap.py +320 -0
- oyst_core/runtime/bundles/__init__.py +1 -0
- oyst_core/runtime/bundles/clamav.py +102 -0
- oyst_core/runtime/bundles/fangfrisch_bundle.py +72 -0
- oyst_core/runtime/bundles/lynis_bundle.py +141 -0
- oyst_core/runtime/bundles/rootkit_bundles.py +218 -0
- oyst_core/runtime/bundles/scanners.py +23 -0
- oyst_core/runtime/checksums.json +6 -0
- oyst_core/runtime/checksums.py +38 -0
- oyst_core/runtime/download.py +61 -0
- oyst_core/runtime/manifest.py +128 -0
- oyst_core/runtime/progress.py +27 -0
- oyst_core/runtime/resolver.py +102 -0
- oyst_core/runtime_full_bootstrap.py +96 -0
- oyst_core/scan_excludes.py +50 -0
- oyst_core/schedule_linger.py +122 -0
- oyst_core/schedule_time.py +76 -0
- oyst_core/schedule_units.py +387 -0
- oyst_core/schedule_util.py +58 -0
- oyst_core/schedule_validate.py +37 -0
- oyst_core/security_news.py +58 -0
- oyst_core/security_news_fetch.py +320 -0
- oyst_core/security_news_parse.py +172 -0
- oyst_core/security_news_sources.py +161 -0
- oyst_core/serve.py +182 -0
- oyst_core/services.py +267 -0
- oyst_core/setup_concert.py +275 -0
- oyst_core/setup_harden.py +326 -0
- oyst_core/setup_harden_fw.py +172 -0
- oyst_core/setup_workflow.py +271 -0
- oyst_core/terminal_log.py +342 -0
- oyst_core/ui_theme.py +53 -0
- oyst_core/updates.py +283 -0
- oyst_core/updates_query.py +154 -0
- oyst_core/virusevent.py +226 -0
- oysterav/__init__.py +3 -0
- oysterav/gui/__init__.py +5 -0
- oysterav/gui/app.py +346 -0
- oysterav/gui/dashboard_helpers.py +396 -0
- oysterav/gui/finding_present.py +240 -0
- oysterav/gui/rpc_actions.py +284 -0
- oysterav/gui/rpc_actions_shield.py +263 -0
- oysterav/gui/scan_helpers.py +160 -0
- oysterav/gui/theme/__init__.py +69 -0
- oysterav/gui/theme/css.py +309 -0
- oysterav/gui/theme/manager.py +66 -0
- oysterav/gui/theme/palettes.py +274 -0
- oysterav/gui/tray.py +356 -0
- oysterav/gui/widgets/__init__.py +17 -0
- oysterav/gui/widgets/bulk_checklist.py +86 -0
- oysterav/gui/widgets/clamonacc_ui.py +395 -0
- oysterav/gui/widgets/common.py +387 -0
- oysterav/gui/widgets/dashboard.py +313 -0
- oysterav/gui/widgets/finding_actions_ui.py +215 -0
- oysterav/gui/widgets/finding_list.py +247 -0
- oysterav/gui/widgets/packs.py +239 -0
- oysterav/gui/widgets/packs_display.py +91 -0
- oysterav/gui/widgets/packs_install_all.py +208 -0
- oysterav/gui/widgets/packs_install_ui.py +221 -0
- oysterav/gui/widgets/privilege_confirm.py +47 -0
- oysterav/gui/widgets/progress_button.py +52 -0
- oysterav/gui/widgets/quarantine.py +331 -0
- oysterav/gui/widgets/reports.py +393 -0
- oysterav/gui/widgets/reports_actions.py +376 -0
- oysterav/gui/widgets/reports_format.py +52 -0
- oysterav/gui/widgets/runtime_ui.py +152 -0
- oysterav/gui/widgets/scan.py +359 -0
- oysterav/gui/widgets/scan_const.py +43 -0
- oysterav/gui/widgets/scan_job_ui.py +328 -0
- oysterav/gui/widgets/scan_path_ui.py +137 -0
- oysterav/gui/widgets/scan_result_dialog.py +122 -0
- oysterav/gui/widgets/schedule_ui.py +209 -0
- oysterav/gui/widgets/services_ui.py +345 -0
- oysterav/gui/widgets/settings.py +388 -0
- oysterav/gui/widgets/settings_const.py +58 -0
- oysterav/gui/widgets/settings_general_ui.py +351 -0
- oysterav/gui/widgets/settings_host_audit_ui.py +74 -0
- oysterav/gui/widgets/settings_maintenance_ui.py +283 -0
- oysterav/gui/widgets/settings_maintenance_update.py +96 -0
- oysterav/gui/widgets/settings_schedule_apply.py +287 -0
- oysterav/gui/widgets/settings_schedule_build.py +163 -0
- oysterav/gui/widgets/settings_schedule_ui.py +11 -0
- oysterav/gui/widgets/settings_terminal_ui.py +280 -0
- oysterav/gui/widgets/setup_wizard.py +357 -0
- oysterav/gui/widgets/setup_wizard_actions.py +299 -0
- oysterav/gui/widgets/setup_wizard_auto.py +191 -0
- oysterav/gui/widgets/setup_wizard_firewall.py +196 -0
- oysterav/gui/widgets/setup_wizard_harden.py +106 -0
- oysterav/gui/widgets/setup_wizard_harden_page.py +155 -0
- oysterav/gui/widgets/setup_wizard_pages.py +259 -0
- oysterav/gui/widgets/setup_wizard_text.py +107 -0
- oysterav/gui/widgets/shield.py +360 -0
- oysterav/gui/widgets/shield_fail2ban_ui.py +65 -0
- oysterav/gui/widgets/shield_firewall_add_dialog.py +156 -0
- oysterav/gui/widgets/shield_firewall_dialogs.py +229 -0
- oysterav/gui/widgets/shield_firewall_rules_ui.py +202 -0
- oysterav/gui/widgets/shield_firewall_ui.py +302 -0
- oysterav/gui/widgets/status_bar.py +254 -0
- oysterav/main.py +26 -0
- oysterav-0.2.2.dist-info/METADATA +213 -0
- oysterav-0.2.2.dist-info/RECORD +250 -0
- oysterav-0.2.2.dist-info/WHEEL +4 -0
- oysterav-0.2.2.dist-info/entry_points.txt +3 -0
- oysterav-0.2.2.dist-info/licenses/LICENSE +674 -0
oyst_cli/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""oyst-cli command implementations."""
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Security audit log commands."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.output import emit
|
|
8
|
+
from oyst_core.audit import SecurityAudit
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@click.group("audit")
|
|
12
|
+
def audit_group() -> None:
|
|
13
|
+
"""Security audit trail for privileged operations."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@audit_group.command("list")
|
|
17
|
+
@click.option("--limit", default=50, type=int, show_default=True)
|
|
18
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
19
|
+
def audit_list_cmd(limit: int, json_mode: bool) -> None:
|
|
20
|
+
"""List recent security audit entries."""
|
|
21
|
+
rows = SecurityAudit().list_entries(limit=limit)
|
|
22
|
+
if json_mode:
|
|
23
|
+
emit(rows, json_mode=True)
|
|
24
|
+
return
|
|
25
|
+
if not rows:
|
|
26
|
+
click.echo("No audit entries.")
|
|
27
|
+
return
|
|
28
|
+
for row in rows:
|
|
29
|
+
ok = "ok" if row.get("success") else "FAIL"
|
|
30
|
+
click.echo(f"{row.get('ts', '')} [{ok}] {row.get('kind', '')}: {row.get('action', '')}")
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""CLI: polkit passwordless grants for service lifecycle."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.confirm import require_confirm
|
|
8
|
+
from oyst_cli.output import emit
|
|
9
|
+
from oyst_core.privileged.auth_grant import (
|
|
10
|
+
auth_status,
|
|
11
|
+
grant_service_lifecycle,
|
|
12
|
+
revoke_service_lifecycle,
|
|
13
|
+
)
|
|
14
|
+
from oyst_core.privileged.install_privileged_helper import helper_status
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.group("auth")
|
|
18
|
+
def auth_group() -> None:
|
|
19
|
+
"""Polkit authorization grants for oysterAV privileged helpers."""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@auth_group.command("status")
|
|
23
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
24
|
+
def auth_status_cmd(json_mode: bool) -> None:
|
|
25
|
+
"""Show helper install state and service-lifecycle passwordless grant."""
|
|
26
|
+
payload = {
|
|
27
|
+
"helper": helper_status(),
|
|
28
|
+
"service_lifecycle": auth_status(),
|
|
29
|
+
}
|
|
30
|
+
emit(payload, json_mode=json_mode)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@auth_group.command("grant-service-lifecycle")
|
|
34
|
+
@click.option(
|
|
35
|
+
"--user",
|
|
36
|
+
"username",
|
|
37
|
+
default=None,
|
|
38
|
+
help="Unix username to grant (default: current user). Requires root.",
|
|
39
|
+
)
|
|
40
|
+
@click.option("--confirm", is_flag=True)
|
|
41
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
42
|
+
def auth_grant_cmd(username: str | None, confirm: bool, json_mode: bool) -> None:
|
|
43
|
+
"""Allow service start/stop without password (polkit rules.d; requires root)."""
|
|
44
|
+
require_confirm(confirm, message="--confirm required to grant passwordless service lifecycle")
|
|
45
|
+
result = grant_service_lifecycle(username)
|
|
46
|
+
emit(result, json_mode=json_mode)
|
|
47
|
+
if not result.get("ok"):
|
|
48
|
+
raise SystemExit(2)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@auth_group.command("revoke-service-lifecycle")
|
|
52
|
+
@click.option("--confirm", is_flag=True)
|
|
53
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
54
|
+
def auth_revoke_cmd(confirm: bool, json_mode: bool) -> None:
|
|
55
|
+
"""Remove passwordless service-lifecycle grant (requires root)."""
|
|
56
|
+
require_confirm(confirm, message="--confirm required to revoke passwordless service lifecycle")
|
|
57
|
+
result = revoke_service_lifecycle()
|
|
58
|
+
emit(result, json_mode=json_mode)
|
|
59
|
+
if not result.get("ok"):
|
|
60
|
+
raise SystemExit(2)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Config commands."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.options import json_option
|
|
8
|
+
from oyst_cli.output import emit
|
|
9
|
+
from oyst_core.config import config_path, get_config_value, load_config, set_config_value
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@click.group("config")
|
|
13
|
+
def config_group() -> None:
|
|
14
|
+
"""Configuration management."""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@config_group.command("path")
|
|
18
|
+
@json_option
|
|
19
|
+
def config_path_cmd(json_mode: bool) -> None:
|
|
20
|
+
path = str(config_path())
|
|
21
|
+
if json_mode:
|
|
22
|
+
emit({"path": path}, json_mode=True)
|
|
23
|
+
else:
|
|
24
|
+
click.echo(path)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@config_group.command("get")
|
|
28
|
+
@click.argument("key", required=False, default=None)
|
|
29
|
+
@json_option
|
|
30
|
+
def config_get(key: str | None, json_mode: bool) -> None:
|
|
31
|
+
"""Get a config value, or dump all config when KEY is omitted."""
|
|
32
|
+
if key is None:
|
|
33
|
+
payload = load_config().model_dump()
|
|
34
|
+
emit(payload, json_mode=json_mode)
|
|
35
|
+
return
|
|
36
|
+
val = get_config_value(key)
|
|
37
|
+
if val is None:
|
|
38
|
+
raise click.ClickException(f"unknown key: {key}")
|
|
39
|
+
if json_mode:
|
|
40
|
+
emit({key: val}, json_mode=True)
|
|
41
|
+
else:
|
|
42
|
+
click.echo(val)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@config_group.command("set")
|
|
46
|
+
@click.argument("key")
|
|
47
|
+
@click.argument("value")
|
|
48
|
+
@json_option
|
|
49
|
+
def config_set(key: str, value: str, json_mode: bool) -> None:
|
|
50
|
+
"""Set a config value.
|
|
51
|
+
|
|
52
|
+
ui.run_at_startup / ui.start_minimized also update the XDG autostart file
|
|
53
|
+
(same path as desktop install-autostart).
|
|
54
|
+
"""
|
|
55
|
+
try:
|
|
56
|
+
set_config_value(key, value)
|
|
57
|
+
except KeyError as exc:
|
|
58
|
+
raise click.ClickException(str(exc)) from exc
|
|
59
|
+
payload = {"ok": True, "key": key, "value": value}
|
|
60
|
+
if json_mode:
|
|
61
|
+
emit(payload, json_mode=True)
|
|
62
|
+
else:
|
|
63
|
+
click.echo(f"Set {key}={value}")
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""Desktop integration CLI (autostart / icons / launcher / tray status)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.output import emit
|
|
8
|
+
from oyst_core.desktop_icons import (
|
|
9
|
+
ensure_desktop_integration,
|
|
10
|
+
install_user_icons,
|
|
11
|
+
install_user_launcher,
|
|
12
|
+
remove_user_launcher,
|
|
13
|
+
)
|
|
14
|
+
from oyst_core.desktop_util import (
|
|
15
|
+
autostart_status,
|
|
16
|
+
install_autostart,
|
|
17
|
+
remove_autostart,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@click.group("desktop")
|
|
22
|
+
def desktop_group() -> None:
|
|
23
|
+
"""GUI desktop integration (icons, launcher, autostart, tray probe)."""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@desktop_group.command("status")
|
|
27
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
28
|
+
def desktop_status(json_mode: bool) -> None:
|
|
29
|
+
"""Show UI config, icons/launcher, autostart file, and tray availability."""
|
|
30
|
+
data = autostart_status()
|
|
31
|
+
if json_mode:
|
|
32
|
+
emit(data, json_mode=True)
|
|
33
|
+
return
|
|
34
|
+
click.echo(f"Run at startup: {data.get('run_at_startup')}")
|
|
35
|
+
click.echo(f"Start minimized: {data.get('start_minimized')}")
|
|
36
|
+
click.echo(f"Minimize to tray: {data.get('minimize_to_tray')}")
|
|
37
|
+
click.echo(f"Icon name: {data.get('icon_name')}")
|
|
38
|
+
click.echo(f"User icons installed: {data.get('user_icons_installed')}")
|
|
39
|
+
click.echo(f"Launcher: {data.get('launcher_path')}")
|
|
40
|
+
click.echo(f"Launcher present: {data.get('launcher_present')}")
|
|
41
|
+
click.echo(f"Autostart file: {data.get('autostart_path')}")
|
|
42
|
+
click.echo(f"Autostart present: {data.get('autostart_present')}")
|
|
43
|
+
click.echo(f"Exec: {data.get('exec')}")
|
|
44
|
+
click.echo(f"Flatpak: {data.get('flatpak')}")
|
|
45
|
+
tray_raw = data.get("tray")
|
|
46
|
+
tray = tray_raw if isinstance(tray_raw, dict) else {}
|
|
47
|
+
if tray.get("available"):
|
|
48
|
+
click.echo(f"Tray library: {tray.get('library')} {tray.get('version')}")
|
|
49
|
+
else:
|
|
50
|
+
click.echo(f"Tray library: missing — {tray.get('hint', '')}")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@desktop_group.command("install")
|
|
54
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
55
|
+
def desktop_install(json_mode: bool) -> None:
|
|
56
|
+
"""Install user icons (hicolor) and applications-menu launcher."""
|
|
57
|
+
result = ensure_desktop_integration()
|
|
58
|
+
if json_mode:
|
|
59
|
+
emit(result, json_mode=True)
|
|
60
|
+
return
|
|
61
|
+
click.echo(str(result.get("message", "ok")))
|
|
62
|
+
icons = result.get("icons") if isinstance(result.get("icons"), dict) else {}
|
|
63
|
+
launcher = result.get("launcher") if isinstance(result.get("launcher"), dict) else {}
|
|
64
|
+
if icons.get("path"):
|
|
65
|
+
click.echo(f"Icons: {icons['path']}")
|
|
66
|
+
if launcher.get("path"):
|
|
67
|
+
click.echo(f"Launcher: {launcher['path']}")
|
|
68
|
+
if not result.get("ok"):
|
|
69
|
+
raise SystemExit(2)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@desktop_group.command("install-icons")
|
|
73
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
74
|
+
def desktop_install_icons(json_mode: bool) -> None:
|
|
75
|
+
"""Install oysterav theme icons into ~/.local/share/icons/hicolor."""
|
|
76
|
+
result = install_user_icons()
|
|
77
|
+
if json_mode:
|
|
78
|
+
emit(result, json_mode=True)
|
|
79
|
+
return
|
|
80
|
+
click.echo(str(result.get("message", "ok")))
|
|
81
|
+
if not result.get("ok"):
|
|
82
|
+
raise SystemExit(2)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@desktop_group.command("install-launcher")
|
|
86
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
87
|
+
def desktop_install_launcher(json_mode: bool) -> None:
|
|
88
|
+
"""Install ~/.local/share/applications launcher (.desktop)."""
|
|
89
|
+
result = install_user_launcher()
|
|
90
|
+
if json_mode:
|
|
91
|
+
emit(result, json_mode=True)
|
|
92
|
+
return
|
|
93
|
+
click.echo(str(result.get("message", "ok")))
|
|
94
|
+
if not result.get("ok"):
|
|
95
|
+
raise SystemExit(2)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@desktop_group.command("remove-launcher")
|
|
99
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
100
|
+
def desktop_remove_launcher(json_mode: bool) -> None:
|
|
101
|
+
"""Remove the user applications-menu launcher (does not remove icons)."""
|
|
102
|
+
result = remove_user_launcher()
|
|
103
|
+
if json_mode:
|
|
104
|
+
emit(result, json_mode=True)
|
|
105
|
+
return
|
|
106
|
+
click.echo(str(result.get("message", "ok")))
|
|
107
|
+
if not result.get("ok"):
|
|
108
|
+
raise SystemExit(2)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@desktop_group.command("install-autostart")
|
|
112
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
113
|
+
@click.option(
|
|
114
|
+
"--minimized/--no-minimized",
|
|
115
|
+
default=None,
|
|
116
|
+
help="Override ui.start_minimized for the Exec line",
|
|
117
|
+
)
|
|
118
|
+
def desktop_install_autostart(json_mode: bool, minimized: bool | None) -> None:
|
|
119
|
+
"""Install XDG autostart desktop entry (same file as config set ui.run_at_startup)."""
|
|
120
|
+
result = install_autostart(minimized=minimized)
|
|
121
|
+
if json_mode:
|
|
122
|
+
emit(result, json_mode=True)
|
|
123
|
+
return
|
|
124
|
+
click.echo(str(result.get("message", "ok")))
|
|
125
|
+
if result.get("exec"):
|
|
126
|
+
click.echo(f"Exec: {result['exec']}")
|
|
127
|
+
if not result.get("ok"):
|
|
128
|
+
raise SystemExit(2)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@desktop_group.command("remove-autostart")
|
|
132
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
133
|
+
def desktop_remove_autostart(json_mode: bool) -> None:
|
|
134
|
+
"""Remove XDG autostart desktop entry and disable ui.run_at_startup."""
|
|
135
|
+
result = remove_autostart()
|
|
136
|
+
if json_mode:
|
|
137
|
+
emit(result, json_mode=True)
|
|
138
|
+
return
|
|
139
|
+
click.echo(str(result.get("message", "ok")))
|
|
140
|
+
if not result.get("ok"):
|
|
141
|
+
raise SystemExit(2)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Doctor command."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.options import json_option
|
|
8
|
+
from oyst_cli.output import emit
|
|
9
|
+
from oyst_core.models import PackTier
|
|
10
|
+
from oyst_core.registry import get_registry
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.command(
|
|
14
|
+
"doctor",
|
|
15
|
+
epilog="""
|
|
16
|
+
Examples:
|
|
17
|
+
oyst-cli doctor --json
|
|
18
|
+
oyst-cli doctor
|
|
19
|
+
""",
|
|
20
|
+
)
|
|
21
|
+
@json_option
|
|
22
|
+
def doctor_cmd(json_mode: bool) -> None:
|
|
23
|
+
"""Check all packs; print install hints per distro."""
|
|
24
|
+
registry = get_registry()
|
|
25
|
+
results = []
|
|
26
|
+
for pack in registry.all():
|
|
27
|
+
status = pack.doctor()
|
|
28
|
+
results.append(status.model_dump())
|
|
29
|
+
if not json_mode:
|
|
30
|
+
tier = status.tier.value.upper()
|
|
31
|
+
mark = "OK" if status.installed and status.version_ok else "MISSING"
|
|
32
|
+
ver = status.version or "-"
|
|
33
|
+
click.echo(f"[{tier:12}] {status.name:12} {mark:7} {ver}")
|
|
34
|
+
if status.message:
|
|
35
|
+
click.echo(f" {status.message}")
|
|
36
|
+
if not status.installed:
|
|
37
|
+
click.echo(f" install: {status.install_hint}")
|
|
38
|
+
if json_mode:
|
|
39
|
+
emit(results, json_mode=True)
|
|
40
|
+
missing_required = [r for r in results if r["tier"] == PackTier.REQUIRED and not r["installed"]]
|
|
41
|
+
if missing_required:
|
|
42
|
+
raise SystemExit(5)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Install privileged helper and polkit policy."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.output import emit
|
|
8
|
+
from oyst_core.privileged.install_privileged_helper import helper_status, install_privileged_helper
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@click.command("install-privileged-helper")
|
|
12
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
13
|
+
@click.option(
|
|
14
|
+
"--dev",
|
|
15
|
+
is_flag=True,
|
|
16
|
+
help="Git checkout / uv dev install: embed user site root (not for production)",
|
|
17
|
+
)
|
|
18
|
+
def install_helper_cmd(json_mode: bool, dev: bool) -> None:
|
|
19
|
+
"""Install oyst-helper and polkit policy for GUI-driven privileged operations."""
|
|
20
|
+
result = install_privileged_helper(dev_mode=dev)
|
|
21
|
+
if json_mode:
|
|
22
|
+
emit(result, json_mode=True)
|
|
23
|
+
else:
|
|
24
|
+
click.echo(result.get("message", ""))
|
|
25
|
+
if result.get("helper_path"):
|
|
26
|
+
click.echo(f"Helper: {result['helper_path']}")
|
|
27
|
+
if result.get("polkit_path"):
|
|
28
|
+
click.echo(f"Policy: {result['polkit_path']}")
|
|
29
|
+
if not result.get("ok"):
|
|
30
|
+
raise SystemExit(2)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@click.command("helper-status")
|
|
34
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
35
|
+
def helper_status_cmd(json_mode: bool) -> None:
|
|
36
|
+
"""Show whether oyst-helper is installed and polkit actions are current."""
|
|
37
|
+
result = helper_status()
|
|
38
|
+
if json_mode:
|
|
39
|
+
emit(result, json_mode=True)
|
|
40
|
+
elif result.get("installed") and result.get("policy_current"):
|
|
41
|
+
click.echo(f"installed (policy v{result.get('policy_version')})")
|
|
42
|
+
elif result.get("installed"):
|
|
43
|
+
click.echo(
|
|
44
|
+
f"installed but policy outdated — re-run: "
|
|
45
|
+
f"sudo oyst-cli install-privileged-helper (v{result.get('policy_version')})"
|
|
46
|
+
)
|
|
47
|
+
else:
|
|
48
|
+
click.echo("not installed")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Job control commands (cancel / clear active scan lock)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.output import emit
|
|
8
|
+
from oyst_core.orchestrator import JobOrchestrator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@click.group("job")
|
|
12
|
+
def job_group() -> None:
|
|
13
|
+
"""Background / active job control."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@job_group.command("cancel")
|
|
17
|
+
@click.option("--job-id", default=None, help="Optional job id (defaults to active job).")
|
|
18
|
+
@click.option(
|
|
19
|
+
"--force",
|
|
20
|
+
is_flag=True,
|
|
21
|
+
help="Force-clear the job lock (use when no scan is actually running).",
|
|
22
|
+
)
|
|
23
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
24
|
+
def job_cancel_cmd(job_id: str | None, force: bool, json_mode: bool) -> None:
|
|
25
|
+
"""Request cancel of the active scan job (cooperative between packs)."""
|
|
26
|
+
result = JobOrchestrator().cancel_job(job_id, force=force)
|
|
27
|
+
emit(result, json_mode=json_mode)
|
|
28
|
+
if not result.get("ok"):
|
|
29
|
+
raise SystemExit(2)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@job_group.command("clear")
|
|
33
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
34
|
+
def job_clear_cmd(json_mode: bool) -> None:
|
|
35
|
+
"""Force-clear a stuck job lock (zombie 'scan in progress' banner)."""
|
|
36
|
+
result = JobOrchestrator().clear_job()
|
|
37
|
+
emit(result, json_mode=json_mode)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@job_group.command("status")
|
|
41
|
+
@click.option("--json", "json_mode", is_flag=True)
|
|
42
|
+
def job_status_cmd(json_mode: bool) -> None:
|
|
43
|
+
"""Show live progress for the active scan job (if any)."""
|
|
44
|
+
result = JobOrchestrator().job_status()
|
|
45
|
+
emit(result, json_mode=json_mode)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""Maintenance workflows."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.options import json_option
|
|
8
|
+
from oyst_cli.output import emit
|
|
9
|
+
from oyst_core.maintenance import run_bootstrap, run_post_update
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _exit_for_steps(steps: list[dict[str, object]]) -> None:
|
|
13
|
+
"""Exit 5 if required packs missing; 2 if any non-skipped step failed."""
|
|
14
|
+
missing_required = [
|
|
15
|
+
s for s in steps if str(s.get("step", "")).startswith("doctor-") and not s.get("ok")
|
|
16
|
+
]
|
|
17
|
+
if missing_required:
|
|
18
|
+
raise SystemExit(5)
|
|
19
|
+
failed = [s for s in steps if not s.get("ok") and not s.get("skipped")]
|
|
20
|
+
if failed:
|
|
21
|
+
raise SystemExit(2)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _print_steps(label: str, steps: list[dict[str, object]]) -> None:
|
|
25
|
+
click.echo(f"{label}: {sum(1 for s in steps if s.get('ok'))}/{len(steps)} steps OK")
|
|
26
|
+
for step in steps:
|
|
27
|
+
name = step.get("step", "?")
|
|
28
|
+
if step.get("skipped"):
|
|
29
|
+
click.echo(f" {name}: skipped")
|
|
30
|
+
elif step.get("ok"):
|
|
31
|
+
click.echo(f" {name}: OK")
|
|
32
|
+
else:
|
|
33
|
+
click.echo(f" {name}: FAILED — {step.get('message', '')}")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@click.group("maintenance")
|
|
37
|
+
def maintenance_group() -> None:
|
|
38
|
+
"""First-run and post-update maintenance."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@maintenance_group.command(
|
|
42
|
+
"bootstrap",
|
|
43
|
+
epilog="""
|
|
44
|
+
Examples:
|
|
45
|
+
oyst-cli maintenance bootstrap --json
|
|
46
|
+
oyst-cli maintenance bootstrap --skip-lynis
|
|
47
|
+
""",
|
|
48
|
+
)
|
|
49
|
+
@click.option("--skip-lynis", is_flag=True, help="Skip Lynis audit (requires root)")
|
|
50
|
+
@json_option
|
|
51
|
+
def bootstrap(skip_lynis: bool, json_mode: bool) -> None:
|
|
52
|
+
"""Signatures/baseline only. First-run: setup run; full runtime: runtime bootstrap."""
|
|
53
|
+
steps = run_bootstrap(skip_lynis=skip_lynis)
|
|
54
|
+
if json_mode:
|
|
55
|
+
emit({"bootstrap": steps}, json_mode=True)
|
|
56
|
+
else:
|
|
57
|
+
_print_steps("Bootstrap", steps)
|
|
58
|
+
click.echo("Never run propupd on a suspect system.")
|
|
59
|
+
_exit_for_steps(steps)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@maintenance_group.command("post-update")
|
|
63
|
+
@json_option
|
|
64
|
+
def post_update(json_mode: bool) -> None:
|
|
65
|
+
"""After OS updates: refresh signatures and rkhunter baseline."""
|
|
66
|
+
steps = run_post_update()
|
|
67
|
+
if json_mode:
|
|
68
|
+
emit({"post_update": steps}, json_mode=True)
|
|
69
|
+
else:
|
|
70
|
+
_print_steps("Post-update", steps)
|
|
71
|
+
click.echo("Consider: oyst-cli scan --profile integrity")
|
|
72
|
+
_exit_for_steps(steps)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""Security news CLI (selectable advisory feeds)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.options import json_option
|
|
8
|
+
from oyst_cli.output import emit
|
|
9
|
+
from oyst_core.security_news import NEWS_SOURCES, list_security_news, normalize_source_ids
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _parse_sources_option(raw: str | None) -> list[str] | None:
|
|
13
|
+
if raw is None or not raw.strip():
|
|
14
|
+
return None
|
|
15
|
+
return normalize_source_ids([s.strip() for s in raw.split(",") if s.strip()])
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@click.group("news")
|
|
19
|
+
def news_group() -> None:
|
|
20
|
+
"""Security advisory headlines (selectable distro / OSS feeds)."""
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@news_group.command("list")
|
|
24
|
+
@json_option
|
|
25
|
+
@click.option("--refresh", is_flag=True, help="Force fetch even if cache is fresh")
|
|
26
|
+
@click.option(
|
|
27
|
+
"--sources",
|
|
28
|
+
default=None,
|
|
29
|
+
help=(
|
|
30
|
+
"Comma-separated source ids "
|
|
31
|
+
f"({', '.join(NEWS_SOURCES)}); default: config ui.security_news_sources"
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
@click.option(
|
|
35
|
+
"--max-age-days",
|
|
36
|
+
type=click.Choice(["7", "14", "30"], case_sensitive=False),
|
|
37
|
+
default=None,
|
|
38
|
+
help=(
|
|
39
|
+
"Only include advisories newer than N days (default: config ui.security_news_max_age_days)"
|
|
40
|
+
),
|
|
41
|
+
)
|
|
42
|
+
def news_list_cmd(
|
|
43
|
+
json_mode: bool,
|
|
44
|
+
refresh: bool,
|
|
45
|
+
sources: str | None,
|
|
46
|
+
max_age_days: str | None,
|
|
47
|
+
) -> None:
|
|
48
|
+
"""List cached or freshly fetched security headlines."""
|
|
49
|
+
selected = _parse_sources_option(sources)
|
|
50
|
+
age = int(max_age_days) if max_age_days is not None else None
|
|
51
|
+
data = list_security_news(force_refresh=refresh, sources=selected, max_age_days=age)
|
|
52
|
+
if json_mode:
|
|
53
|
+
emit(data, json_mode=True)
|
|
54
|
+
return
|
|
55
|
+
items = data.get("items") if isinstance(data.get("items"), list) else []
|
|
56
|
+
fetched = data.get("fetched_at", "—")
|
|
57
|
+
click.echo(f"Fetched: {fetched}")
|
|
58
|
+
used = data.get("sources")
|
|
59
|
+
if isinstance(used, list) and used:
|
|
60
|
+
click.echo(f"Sources: {', '.join(str(s) for s in used)}")
|
|
61
|
+
window = data.get("max_age_days")
|
|
62
|
+
if window is not None:
|
|
63
|
+
click.echo(f"Freshness: last {window} day(s)")
|
|
64
|
+
if data.get("stale"):
|
|
65
|
+
click.echo("Cache: stale (showing last good fetch)")
|
|
66
|
+
elif data.get("from_cache"):
|
|
67
|
+
click.echo("Cache: fresh")
|
|
68
|
+
else:
|
|
69
|
+
click.echo("Cache: updated")
|
|
70
|
+
if not items:
|
|
71
|
+
click.echo("No headlines available.")
|
|
72
|
+
return
|
|
73
|
+
for item in items:
|
|
74
|
+
if not isinstance(item, dict):
|
|
75
|
+
continue
|
|
76
|
+
source = item.get("source", "?")
|
|
77
|
+
title = item.get("title", "")
|
|
78
|
+
link = item.get("link", "")
|
|
79
|
+
label = str(item.get("severity_label") or "unknown")
|
|
80
|
+
if label != "unknown":
|
|
81
|
+
click.echo(f"[{source}] ({label}) {title}")
|
|
82
|
+
else:
|
|
83
|
+
click.echo(f"[{source}] {title}")
|
|
84
|
+
if link:
|
|
85
|
+
click.echo(f" {link}")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@news_group.command("refresh")
|
|
89
|
+
@json_option
|
|
90
|
+
@click.option(
|
|
91
|
+
"--sources",
|
|
92
|
+
default=None,
|
|
93
|
+
help=(
|
|
94
|
+
"Comma-separated source ids "
|
|
95
|
+
f"({', '.join(NEWS_SOURCES)}); default: config ui.security_news_sources"
|
|
96
|
+
),
|
|
97
|
+
)
|
|
98
|
+
@click.option(
|
|
99
|
+
"--max-age-days",
|
|
100
|
+
type=click.Choice(["7", "14", "30"], case_sensitive=False),
|
|
101
|
+
default=None,
|
|
102
|
+
help=(
|
|
103
|
+
"Only include advisories newer than N days (default: config ui.security_news_max_age_days)"
|
|
104
|
+
),
|
|
105
|
+
)
|
|
106
|
+
def news_refresh_cmd(
|
|
107
|
+
json_mode: bool,
|
|
108
|
+
sources: str | None,
|
|
109
|
+
max_age_days: str | None,
|
|
110
|
+
) -> None:
|
|
111
|
+
"""Force-refresh advisory feeds and update the cache."""
|
|
112
|
+
selected = _parse_sources_option(sources)
|
|
113
|
+
age = int(max_age_days) if max_age_days is not None else None
|
|
114
|
+
data = list_security_news(force_refresh=True, sources=selected, max_age_days=age)
|
|
115
|
+
errors_raw = data.get("errors")
|
|
116
|
+
errors = errors_raw if isinstance(errors_raw, list) else []
|
|
117
|
+
items_raw = data.get("items")
|
|
118
|
+
items = items_raw if isinstance(items_raw, list) else []
|
|
119
|
+
if json_mode:
|
|
120
|
+
emit(data, json_mode=True)
|
|
121
|
+
else:
|
|
122
|
+
click.echo(f"Refreshed {len(items)} headline(s).")
|
|
123
|
+
for err in errors:
|
|
124
|
+
if isinstance(err, dict):
|
|
125
|
+
click.echo(f" warn {err.get('source')}: {err.get('error')}", err=True)
|
|
126
|
+
if errors and not items:
|
|
127
|
+
raise SystemExit(2)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Pack install CLI commands."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from oyst_cli.options import json_option, progress_option
|
|
8
|
+
from oyst_cli.output import emit
|
|
9
|
+
from oyst_cli.progress import resolve_cli_progress
|
|
10
|
+
from oyst_core.pack_install import install_pack, list_packs
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.group("packs")
|
|
14
|
+
def packs_group() -> None:
|
|
15
|
+
"""Security pack management."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@packs_group.command(
|
|
19
|
+
"install",
|
|
20
|
+
epilog="""
|
|
21
|
+
Examples:
|
|
22
|
+
oyst-cli packs install clamav --confirm-aur --json
|
|
23
|
+
oyst-cli packs install lynis --progress
|
|
24
|
+
""",
|
|
25
|
+
)
|
|
26
|
+
@click.argument("name")
|
|
27
|
+
@click.option("--confirm-aur", is_flag=True, help="Confirm AUR install without prompting")
|
|
28
|
+
@json_option
|
|
29
|
+
@progress_option
|
|
30
|
+
def packs_install(name: str, confirm_aur: bool, json_mode: bool, show_progress: bool) -> None:
|
|
31
|
+
"""Install a pack (full mode → private runtime; lite → distro packages)."""
|
|
32
|
+
on_progress = resolve_cli_progress(show_progress=show_progress, json_mode=json_mode)
|
|
33
|
+
result = install_pack(name, confirm_aur=confirm_aur, on_progress=on_progress)
|
|
34
|
+
emit(result.model_dump(), json_mode=json_mode)
|
|
35
|
+
if result.ok:
|
|
36
|
+
raise SystemExit(0)
|
|
37
|
+
if result.mode in ("manual", "aur_confirm"):
|
|
38
|
+
raise SystemExit(4)
|
|
39
|
+
raise SystemExit(2)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@packs_group.command("list")
|
|
43
|
+
@json_option
|
|
44
|
+
def packs_list(json_mode: bool) -> None:
|
|
45
|
+
"""List all packs with install status."""
|
|
46
|
+
packs = list_packs()
|
|
47
|
+
emit(packs, json_mode=json_mode)
|