Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
as before. The signal handler no longer tears anything down itself: it
raises, so an `nft` or `systemctl` call in flight finishes unwinding before
the undo starts.
- `ttp status` printed its Tor AppArmor, Required VPN and diagnostic lines with
the prefix as raw Rich markup, `[bold cyan]\[TTP][/bold cyan] …`, because
those lines turned markup off to show their values literally. Markup stays on
now, and only the values are escaped, so a profile name or a message
containing brackets still prints as it is.

### Tests

Expand Down
5 changes: 5 additions & 0 deletions docs/web/release-notes/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
as before. The signal handler no longer tears anything down itself: it
raises, so an `nft` or `systemctl` call in flight finishes unwinding before
the undo starts.
- `ttp status` printed its Tor AppArmor, Required VPN and diagnostic lines with
the prefix as raw Rich markup, `[bold cyan]\[TTP][/bold cyan] …`, because
those lines turned markup off to show their values literally. Markup stays on
now, and only the values are escaped, so a profile name or a message
containing brackets still prints as it is.

### Tests

Expand Down
23 changes: 23 additions & 0 deletions tests/test_cli_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,29 @@ def test_status_reports_actual_confinement_separately(confinement):
assert f"Tor AppArmor: {confinement}; profile: ttp-tor" in result.output


def test_status_renders_the_apparmor_line_and_shows_its_values_literally():
"""The prefix is markup; the observed values are not (a profile name is not ours)."""
with (
patch(
"ttp.state.read_lock",
return_value={
"timestamp": "2026-11-10T12:00:00",
"apparmor": {"required": True, "profile": "[red]ttp-tor"},
"tor_uid": 103,
},
),
patch(
"ttp.apparmor.observe",
return_value={"state": "enforced", "profile": "[red]ttp-tor", "reason": "apparmor.test"},
),
):
result = runner.invoke(app, ["status"])
assert result.exit_code == 0, result.output
assert "[TTP] Tor AppArmor: enforced;" in result.output
assert "profile: [red]ttp-tor" in result.output
assert "[bold cyan]" not in result.output and "[/bold cyan]" not in result.output


@patch("ttp.state.read_lock", return_value=None)
def test_status_inactive(mock_read):
"""status with no session -> shows INACTIVE."""
Expand Down
4 changes: 3 additions & 1 deletion tests/test_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,9 @@ def test_status_displays_vpn_guard_without_claiming_remote_liveness(monkeypatch,
result = CliRunner().invoke(app, ["status"])
assert result.exit_code == 0
if phase == "running":
assert "Required VPN: unknown" in result.output and "verified: True" in result.output
assert "[TTP] Required VPN: unknown; kernel guard verified: True" in result.output
assert "[bold cyan]" not in result.output
assert "[TTP] vpn.test: Unavailable" in result.output
assert "vpn.test" in result.output
else:
assert "restore-only" in result.output
Expand Down
10 changes: 6 additions & 4 deletions ttp/commands/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess

import typer
from rich.markup import escape
from rich.progress import Progress, SpinnerColumn, TextColumn

from ttp import state
Expand Down Expand Up @@ -92,13 +93,14 @@ def status_command(json_output: bool = typer.Option(False, "--json", help="Print
if "apparmor" in report:
confinement = report["apparmor"]
console.print(
f"{_PREFIX} Tor AppArmor: {confinement['state']}; profile: {confinement['profile']} (local process evidence)",
markup=False,
f"{_PREFIX} Tor AppArmor: {escape(str(confinement['state']))}; "
f"profile: {escape(str(confinement['profile']))} (local process evidence)"
)
if "vpn" in report:
vpn = report["vpn"]
console.print(
f"{_PREFIX} Required VPN: {vpn['state']}; kernel guard verified: {vpn['guard_verified']}", markup=False
f"{_PREFIX} Required VPN: {escape(str(vpn['state']))}; "
f"kernel guard verified: {escape(str(vpn['guard_verified']))}"
)
console.print(f"{_PREFIX} Tor verification: {verification['state']} (recorded measurement)")
if "age_seconds" in verification:
Expand All @@ -114,7 +116,7 @@ def status_command(json_output: bool = typer.Option(False, "--json", help="Print
f"{_PREFIX} Notifications: {report['notifications']['state']} (acceptance is not proof of display or reading)"
)
for diagnostic in report["diagnostics"]:
console.print(f"{_PREFIX} {diagnostic['reason']}: {diagnostic['message']}", markup=False)
console.print(f"{_PREFIX} {escape(str(diagnostic['reason']))}: {escape(str(diagnostic['message']))}")
# Successful status collection is distinct from the health it describes.


Expand Down