[AUTO-UAT-8] ShellSafetyService default block_level is MEDIUM — spec requires HIGH (blocks only HIGH/CRITICAL by default) #8106

Closed
opened 2026-04-13 03:34:00 +00:00 by HAL9000 · 2 comments
Owner

Metadata

  • Commit message: fix(tui): set ShellSafetyService default block_level to HIGH per spec
  • Branch: fix/tui-shell-safety-default-block-level

Summary

The ShellSafetyService in src/cleveragents/tui/shell_safety/safety_service.py defaults to block_level=ShellDangerLevel.MEDIUM, which causes it to block MEDIUM, HIGH, and CRITICAL commands automatically. The v3.7.0 specification states: "Shell danger detection blocks HIGH/CRITICAL commands by default." The default should be ShellDangerLevel.HIGH, not ShellDangerLevel.MEDIUM.

Background and Context

The v3.7.0 milestone (M8: TUI Implementation) specifies shell safety behavior as:

"Shell Safety: ShellDangerLevel enum (LOW/MEDIUM/HIGH/CRITICAL) with configurable block_level"
"Shell danger detection blocks HIGH/CRITICAL commands by default"

This means the default block_level should be HIGH, so that only HIGH and CRITICAL commands are blocked automatically, while LOW and MEDIUM commands are allowed through (possibly with a warning callback).

Expected Behavior

With block_level=HIGH (3):

  • LOW (1) < 3 → allowed
  • MEDIUM (2) < 3 → allowed ✓ (per spec: only HIGH/CRITICAL blocked by default)
  • HIGH (3) < 3 → blocked
  • CRITICAL (4) < 3 → blocked

Acceptance Criteria

  • ShellSafetyService default block_level is ShellDangerLevel.HIGH
  • MEDIUM-level commands are not blocked by default (only warned, if a callback is set)
  • HIGH and CRITICAL commands are blocked by default
  • All BDD scenarios and unit tests reflect the corrected default
  • nox passes with no errors and coverage ≥ 97%

Current Behavior (Actual)

ShellSafetyService.__init__ defaults to block_level=ShellDangerLevel.MEDIUM:

def __init__(
    self,
    *,
    detector: DangerousPatternDetector | None = None,
    block_level: ShellDangerLevel = ShellDangerLevel.MEDIUM,  # ← WRONG
    ...

The blocking logic is: allowed = warning.danger_level < self._block_level

With block_level=MEDIUM (2):

  • LOW (1) < 2 → allowed
  • MEDIUM (2) < 2 → blocked ✗ (should be allowed per spec)
  • HIGH (3) < 2 → blocked
  • CRITICAL (4) < 2 → blocked

This means MEDIUM-level commands (e.g., sudo rm, wget | sh, chmod 777) are blocked by default, which is more restrictive than the spec requires.

Evidence

File: src/cleveragents/tui/shell_safety/safety_service.py

def __init__(
    self,
    *,
    detector: DangerousPatternDetector | None = None,
    block_level: ShellDangerLevel = ShellDangerLevel.MEDIUM,  # Line ~55
    warn_callback: Callable[[DangerousCommandWarning], bool] | None = None,
    extra_patterns: list[DangerousPattern] | None = None,
) -> None:

BDD test also encodes the wrong default (features/steps/tui_shell_danger_detection_steps.py):

@then("the service block_level should be MEDIUM")
def step_service_block_level(context: Context) -> None:
    assert context.service.block_level == ShellDangerLevel.MEDIUM, ...

The BDD test tui_shell_danger_detection.feature scenario "ShellSafetyService exposes block_level property" asserts block_level should be MEDIUM — this test itself is wrong per the spec and needs to be updated to assert HIGH.

Duplicate Check

  • Issue #5901 (MainScreen class missing) — different topic, not a duplicate
  • Issue #5938 (TuiMaterializer not implemented) — different topic, not a duplicate
  • No existing open issue found for this specific block_level default value discrepancy

Subtasks

  • Change ShellSafetyService.__init__ default block_level from ShellDangerLevel.MEDIUM to ShellDangerLevel.HIGH
  • Update BDD scenario "ShellSafetyService exposes block_level property" in features/tui_shell_danger_detection.feature to assert HIGH
  • Update corresponding step definition in features/steps/tui_shell_danger_detection_steps.py
  • Verify all other shell safety tests still pass with the new default
  • Run nox (all default sessions), fix any errors
  • Verify coverage ≥97% via nox -s coverage_report

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Supervisor: UAT Test Pool | Agent: uat-test-worker | Session: [AUTO-UAT-8]

## Metadata - **Commit message**: `fix(tui): set ShellSafetyService default block_level to HIGH per spec` - **Branch**: `fix/tui-shell-safety-default-block-level` ## Summary The `ShellSafetyService` in `src/cleveragents/tui/shell_safety/safety_service.py` defaults to `block_level=ShellDangerLevel.MEDIUM`, which causes it to block MEDIUM, HIGH, and CRITICAL commands automatically. The v3.7.0 specification states: "Shell danger detection blocks HIGH/CRITICAL commands by default." The default should be `ShellDangerLevel.HIGH`, not `ShellDangerLevel.MEDIUM`. ## Background and Context The v3.7.0 milestone (M8: TUI Implementation) specifies shell safety behavior as: > "Shell Safety: ShellDangerLevel enum (LOW/MEDIUM/HIGH/CRITICAL) with configurable block_level" > "Shell danger detection blocks HIGH/CRITICAL commands by default" This means the default `block_level` should be `HIGH`, so that only HIGH and CRITICAL commands are blocked automatically, while LOW and MEDIUM commands are allowed through (possibly with a warning callback). ## Expected Behavior With `block_level=HIGH (3)`: - LOW (1) < 3 → **allowed** ✓ - MEDIUM (2) < 3 → **allowed** ✓ (per spec: only HIGH/CRITICAL blocked by default) - HIGH (3) < 3 → **blocked** ✓ - CRITICAL (4) < 3 → **blocked** ✓ ## Acceptance Criteria - `ShellSafetyService` default `block_level` is `ShellDangerLevel.HIGH` - MEDIUM-level commands are **not** blocked by default (only warned, if a callback is set) - HIGH and CRITICAL commands are blocked by default - All BDD scenarios and unit tests reflect the corrected default - `nox` passes with no errors and coverage ≥ 97% ## Current Behavior (Actual) `ShellSafetyService.__init__` defaults to `block_level=ShellDangerLevel.MEDIUM`: ```python def __init__( self, *, detector: DangerousPatternDetector | None = None, block_level: ShellDangerLevel = ShellDangerLevel.MEDIUM, # ← WRONG ... ``` The blocking logic is: `allowed = warning.danger_level < self._block_level` With `block_level=MEDIUM (2)`: - LOW (1) < 2 → **allowed** ✓ - MEDIUM (2) < 2 → **blocked** ✗ (should be allowed per spec) - HIGH (3) < 2 → **blocked** ✓ - CRITICAL (4) < 2 → **blocked** ✓ This means MEDIUM-level commands (e.g., `sudo rm`, `wget | sh`, `chmod 777`) are blocked by default, which is more restrictive than the spec requires. ## Evidence **File:** `src/cleveragents/tui/shell_safety/safety_service.py` ```python def __init__( self, *, detector: DangerousPatternDetector | None = None, block_level: ShellDangerLevel = ShellDangerLevel.MEDIUM, # Line ~55 warn_callback: Callable[[DangerousCommandWarning], bool] | None = None, extra_patterns: list[DangerousPattern] | None = None, ) -> None: ``` **BDD test also encodes the wrong default** (`features/steps/tui_shell_danger_detection_steps.py`): ```python @then("the service block_level should be MEDIUM") def step_service_block_level(context: Context) -> None: assert context.service.block_level == ShellDangerLevel.MEDIUM, ... ``` The BDD test `tui_shell_danger_detection.feature` scenario "ShellSafetyService exposes block_level property" asserts `block_level should be MEDIUM` — this test itself is wrong per the spec and needs to be updated to assert `HIGH`. ## Duplicate Check - Issue #5901 (MainScreen class missing) — different topic, not a duplicate - Issue #5938 (TuiMaterializer not implemented) — different topic, not a duplicate - No existing open issue found for this specific `block_level` default value discrepancy ## Subtasks - [ ] Change `ShellSafetyService.__init__` default `block_level` from `ShellDangerLevel.MEDIUM` to `ShellDangerLevel.HIGH` - [ ] Update BDD scenario "ShellSafetyService exposes block_level property" in `features/tui_shell_danger_detection.feature` to assert `HIGH` - [ ] Update corresponding step definition in `features/steps/tui_shell_danger_detection_steps.py` - [ ] Verify all other shell safety tests still pass with the new default - [ ] Run `nox` (all default sessions), fix any errors - [ ] Verify coverage ≥97% via `nox -s coverage_report` ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Supervisor: UAT Test Pool | Agent: uat-test-worker | Session: [AUTO-UAT-8]
Author
Owner

Verified — ShellSafetyService defaulting to MEDIUM instead of HIGH is a security spec violation. The spec explicitly requires HIGH as the default block level. This is a Must Have fix — incorrect safety defaults could allow dangerous operations. Assign to v3.5.0 (Autonomy Hardening). Verified.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — ShellSafetyService defaulting to MEDIUM instead of HIGH is a security spec violation. The spec explicitly requires HIGH as the default block level. This is a **Must Have** fix — incorrect safety defaults could allow dangerous operations. Assign to v3.5.0 (Autonomy Hardening). Verified. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Owner

superseded by next cycle

superseded by next cycle
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8106
No description provided.