diff --git a/plugins/violin_guard/schemas.py b/plugins/violin_guard/schemas.py index c53207f..88e5a3e 100644 --- a/plugins/violin_guard/schemas.py +++ b/plugins/violin_guard/schemas.py @@ -3,11 +3,11 @@ from __future__ import annotations from typing import Any, Literal + from pydantic import BaseModel, ConfigDict, Field from . import state - # --------------------------------------------------------------------------- # Pydantic v2 Models # --------------------------------------------------------------------------- @@ -77,9 +77,7 @@ class RecordHypothesisArgsModel(BaseModel): " no-results/unavailable outcomes are allowed." ), ) - test_command: str = Field( - "", description="Exact syntax tested, including argument order" - ) + test_command: str = Field("", description="Exact syntax tested, including argument order") test_response: str = Field("", description="Exact decisive response or error") verification_status: str = "" rejection_reason: str = Field( @@ -112,8 +110,7 @@ class ExecArgsModel(BaseModel): background: bool = Field( False, description=( - "Run as a tracked background process; use status/cancel for lifecycle" - " management" + "Run as a tracked background process; use status/cancel for lifecycle management" ), ) @@ -297,9 +294,7 @@ class TargetArgsModel(BaseModel): eng_dir: str = Field( ..., description="engagement dir (required; target resolution is engagement-scoped)" ) - scope: str = Field( - "", description="explicit scope.yaml path (else $ENG_DIR/scope/scope.yaml)" - ) + scope: str = Field("", description="explicit scope.yaml path (else $ENG_DIR/scope/scope.yaml)") host: str = Field("", description="in-scope IP/CIDR to resolve") role: str = Field("", description="named role from scope.yaml targets.roles (e.g. web)") field: Literal["ip", "url", "host"] = Field("ip", description="what to print (default ip)") diff --git a/plugins/violin_guard/targets.py b/plugins/violin_guard/targets.py index 48228da..2cdf634 100644 --- a/plugins/violin_guard/targets.py +++ b/plugins/violin_guard/targets.py @@ -8,7 +8,6 @@ from __future__ import annotations import contextlib import re -import shlex from dataclasses import dataclass, field from pathlib import Path from typing import Any diff --git a/plugins/violin_guard/terminal_policy.py b/plugins/violin_guard/terminal_policy.py index d25be27..6c3a851 100644 --- a/plugins/violin_guard/terminal_policy.py +++ b/plugins/violin_guard/terminal_policy.py @@ -198,9 +198,7 @@ def _has_target_literal_in_segment(seg: CommandSegment) -> bool: words = seg.words executable = seg.executable skip_code = ( - executable in _SCRIPT_INTERPRETERS - and executable not in _SHELL_WRAPPERS - and "-c" in words + executable in _SCRIPT_INTERPRETERS and executable not in _SHELL_WRAPPERS and "-c" in words ) c_index = words.index("-c") if skip_code else -1 for index, word in enumerate(words): @@ -252,11 +250,7 @@ def _is_local_compilation_or_test(seg: CommandSegment) -> bool: "doctest", }: return True - return ( - "py_compile" in seg.raw_text - or "pytest" in lower_words - or "unittest" in lower_words - ) + return "py_compile" in seg.raw_text or "pytest" in lower_words or "unittest" in lower_words def _block_terminal_segment(seg: CommandSegment) -> str | None: diff --git a/tests/guard/test_bashlex_ast.py b/tests/guard/test_bashlex_ast.py index 916f031..7de695b 100644 --- a/tests/guard/test_bashlex_ast.py +++ b/tests/guard/test_bashlex_ast.py @@ -1,7 +1,5 @@ """Unit tests for bashlex AST parsing and terminal policy classification.""" -import pytest - from plugins.violin_guard import bash_ast, terminal_policy