Skip to content
Open
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
21 changes: 21 additions & 0 deletions src/skillspector/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import json
import os
import shutil
import sys
from enum import StrEnum
from pathlib import Path
from typing import Annotated
Expand All @@ -38,6 +39,26 @@

logger = get_logger(__name__)


def _ensure_utf8_streams() -> None:
"""Reconfigure stdout/stderr to UTF-8 so Unicode report output does not crash.

On Windows the default console encoding (e.g. cp1252) cannot encode the
box-drawing characters and icons used in the terminal report, which raises
UnicodeEncodeError. Reconfiguring with errors="replace" makes output robust
across platforms without crashing.
"""
for stream in (sys.stdout, sys.stderr):
reconfigure = getattr(stream, "reconfigure", None)
if reconfigure is not None:
try:
reconfigure(encoding="utf-8", errors="replace")
except (ValueError, OSError):
logger.debug("Could not reconfigure %s to UTF-8", stream)


_ensure_utf8_streams()

app = typer.Typer(
name="skillspector",
help="Security scanner for AI agent skills (LangGraph). Detect vulnerabilities before installation.",
Expand Down
2 changes: 1 addition & 1 deletion src/skillspector/nodes/build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _walk_skill_files(skill_dir: Path) -> list[str]:
continue
try:
rel = item.relative_to(skill_dir)
paths.append(str(rel))
paths.append(rel.as_posix())
except ValueError:
logger.debug("Skipping path (not under skill_dir): %s", item)
continue
Expand Down
2 changes: 1 addition & 1 deletion tests/nodes/analyzers/test_semantic_developer_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def _build_file_cache(skill_dir: Path) -> dict[str, str]:
for item in sorted(skill_dir.rglob("*")):
if not item.is_file():
continue
rel = str(item.relative_to(skill_dir))
rel = item.relative_to(skill_dir).as_posix()
try:
cache[rel] = item.read_text(encoding="utf-8", errors="replace")
except OSError:
Expand Down
2 changes: 1 addition & 1 deletion tests/nodes/analyzers/test_semantic_security_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _build_file_cache(skill_dir: Path) -> dict[str, str]:
for item in sorted(skill_dir.rglob("*")):
if not item.is_file():
continue
rel = str(item.relative_to(skill_dir))
rel = item.relative_to(skill_dir).as_posix()
try:
cache[rel] = item.read_text(encoding="utf-8", errors="replace")
except OSError:
Expand Down
2 changes: 1 addition & 1 deletion tests/nodes/test_semantic_quality_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _build_file_cache(skill_dir: Path) -> dict[str, str]:
for item in sorted(skill_dir.rglob("*")):
if not item.is_file():
continue
rel = str(item.relative_to(skill_dir))
rel = item.relative_to(skill_dir).as_posix()
try:
cache[rel] = item.read_text(encoding="utf-8", errors="replace")
except OSError:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mcp_least_privilege.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _make_state(fixture_name: str) -> dict:
continue
if item.name.startswith(".") and not item.name.startswith(".claude"):
continue
rel = str(item.relative_to(fixture_dir))
rel = item.relative_to(fixture_dir).as_posix()
components.append(rel)
components.sort()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_mcp_tool_poisoning.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _make_state(
continue
if item.name.startswith(".") and not item.name.startswith(".claude"):
continue
rel = str(item.relative_to(fixture_dir))
rel = item.relative_to(fixture_dir).as_posix()
components.append(rel)
components.sort()

Expand Down