Skip to content

test(security): tests make the subprocess environment guard and the review target guard refuse unsafe input #2151

Closed

Description

@dan-petty

What happened

Two security guards have no test that makes them refuse their input. The coverage run of CI at f4d7066 shows the refusal lines as missed, and git grep at b170358 finds no test that names them.

  • build_subprocess_env refuses a caller override of LD_PRELOAD, LD_LIBRARY_PATH, DYLD_INSERT_LIBRARIES, DYLD_LIBRARY_PATH, BASH_ENV and ENV, and any key or value with a null byte. No test sends one of these overrides, so a change that removes the check passes the suite.
  • find_repo_files raises SecurityError for a target outside the repository root. It also skips a symlinked target file and a candidate that resolves outside the root. No test gives it such a target or candidate.
  • The second condition at review/targets.py:83 (not target_resolved.is_relative_to(root)) cannot be true, because line 79 already raised for that target.

What should happen

A test makes each guard refuse its input, and checks the error type and the message, or the empty result. The unreachable condition goes.

Evidence

At b170358:

  • src/devops_cli/core/process.py:182-194: the refused keys and the null-byte check. Lines 192 and 194 were not covered in CI at f4d7066 (.data coverage data of the 2026-10-24 coverage audit).
  • tests/test_subprocess_env_boundary.py:34-109: the four tests of build_subprocess_env send no refused key.
  • src/devops_cli/review/targets.py:51-54, :79-80 and :82-85: the outside-root error, the resolve check and the symlink skip. Lines 52-54, 80 and 83-85 were not covered.
  • git grep -n "find_repo_files" origin/main -- tests prints nothing.

Acceptance criteria

  • A test calls build_subprocess_env(env=...) with each of the six refused keys, in upper and lower case, and gets SecurityError with the message that names the key.
  • A test calls build_subprocess_env with a null byte in a key and in a value, and gets SecurityError.
  • A test calls find_repo_files with a target outside repo_root and gets SecurityError.
  • A test gives find_repo_files a symlinked target file and gets []. A test gives it a directory that holds a symlink to a file outside the root, and the result does not hold that file.
  • The unreachable second condition at review/targets.py:83 is deleted.
  • The tests build their trees under tmp_path, start no program and patch no devops_cli name (docs/TESTING.md, ADR 0007).
  • Each new test fails when its guard is removed from src/. The pull request shows this.
  • uv run devops ci passes.

Activity

  1. added
    source/agent
    type/test
    on Oct 24, 2026
  2. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

  3. added a commit that references this issue on Oct 25, 2026
    48cb34a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source/agenttype/test

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions