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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ SKILLSPECTOR_COMPAT_BASE_URL=
# authentication session and do not need an API key here.

# SkillSpector config
# Defaults: openai uses gpt-5.4; anthropic uses claude-opus-4-6 and
# claude-sonnet-4-6 for meta_analyzer. Sol and Claude 5.5 remain opt-in pending
# live scanner acceptance (see README).
SKILLSPECTOR_MODEL= # leave empty to use the active provider's bundled default (see README); set to override (e.g. gpt-5.2)
# SKILLSPECTOR_MODEL_REGISTRY=./model_registry.yaml # optional override; defaults to each provider's bundled YAML in src/skillspector/providers/
SKILLSPECTOR_LOG_LEVEL=WARNING # options: DEBUG|INFO|WARNING|ERROR
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ inference gateways.

| Provider (`SKILLSPECTOR_PROVIDER`) | Credential env var | Endpoint | Default model |
| ---------- | ---- | ---- | ---- |
| `openai` | `OPENAI_API_KEY` (+ optional `OPENAI_BASE_URL`) | api.openai.com (or any OpenAI-compatible URL) | `gpt-6.1-sol` |
| `anthropic` | `ANTHROPIC_API_KEY` | api.anthropic.com | `claude-opus-5-5` (`meta_analyzer`: `claude-sonnet-5-5`) |
| `openai` | `OPENAI_API_KEY` (+ optional `OPENAI_BASE_URL`) | api.openai.com (or any OpenAI-compatible URL) | `gpt-5.4` |
| `anthropic` | `ANTHROPIC_API_KEY` | api.anthropic.com | `claude-opus-4-6` (`meta_analyzer`: `claude-sonnet-4-6`) |
| `anthropic_proxy` | `ANTHROPIC_PROXY_API_KEY` + `ANTHROPIC_PROXY_ENDPOINT_URL` | Any Vertex-style raw-predict proxy | `claude-sonnet-4-6` |
| `bedrock` | `AWS_PROFILE` (optional) + `AWS_REGION` — SigV4 via boto3 | AWS Bedrock Runtime | `us.anthropic.claude-sonnet-4-6` |
| `nv_build` | `NVIDIA_INFERENCE_KEY` | build.nvidia.com | `z-ai/glm-5.3` |
Expand All @@ -300,6 +300,13 @@ inference gateways.
| `gemini_cli` | _(none — uses local CLI auth)_ | local `gemini` binary | local Gemini runtime fallback, or `SKILLSPECTOR_MODEL` |
| `opencode_cli` | _(none — uses local CLI auth)_ | local `opencode` 1.18.33 binary | local OpenCode runtime fallback, or `SKILLSPECTOR_MODEL` |

`gpt-6.1-sol`, `claude-opus-5-5`, and `claude-sonnet-5-5` remain opt-in through
`SKILLSPECTOR_MODEL` or per-slot overrides. Promoting them to defaults requires
live scanner acceptance covering benign input, credential disclosure, prompt
injection, refusals, and incomplete responses.
Record findings, completion status, latency, and usage, and compare against
previous defaults where accessible.

For NVIDIA Build's `z-ai/glm-5.3`, SkillSpector requests `high` reasoning effort.
Set `SKILLSPECTOR_REASONING_EFFORT` to override it with `low`, `high`, or `max`.
The bundled 128,000-token context and 32,000-token output budgets are conservative
Expand Down Expand Up @@ -732,11 +739,11 @@ Issues (2)
| `GOOGLE_CLOUD_LOCATION` | Google Cloud location for the `gemini` provider endpoint (e.g. `global`, `us`, `eu`, `us-central1`). Defaults to `global`. | Optional (used when `SKILLSPECTOR_PROVIDER=gemini`) |
| `GOOGLE_APPLICATION_CREDENTIALS` | Optional path to ADC credential/config file (e.g. Workload or Workforce Identity Federation config; exported service account keys are discouraged). For local development, use `gcloud auth application-default login`; for GKE, use Workload Identity. | Optional (used when `SKILLSPECTOR_PROVIDER=gemini`) |
| `NVIDIA_INFERENCE_KEY` | Credential for the `nv_build` provider (build.nvidia.com). | Required for LLM analysis when `SKILLSPECTOR_PROVIDER=nv_build` |
| `OPENAI_API_KEY` | Credential for the OpenAI provider (`SKILLSPECTOR_PROVIDER=openai`). Also serves as the tier-2 fallback in the credential waterfall when the active provider returns no credentials; the fallback then uses the `openai` default model (`gpt-6.1-sol`) for any slot without a model override. Claude Opus or Sonnet 5.5 gateway IDs are not supported through the fallback, because it keeps the active provider's structured-output method; select `SKILLSPECTOR_PROVIDER=openai` for them. | Required for LLM analysis when `SKILLSPECTOR_PROVIDER=openai` |
| `OPENAI_API_KEY` | Credential for the OpenAI provider (`SKILLSPECTOR_PROVIDER=openai`). Also serves as the tier-2 fallback in the credential waterfall when the active provider returns no credentials; the fallback then uses the `openai` default model (`gpt-5.4`) for any slot without a model override. Claude Opus or Sonnet 5.5 gateway IDs are not supported through the fallback, because it keeps the active provider's structured-output method; select `SKILLSPECTOR_PROVIDER=openai` for them. | Required for LLM analysis when `SKILLSPECTOR_PROVIDER=openai` |
| `OPENAI_BASE_URL` | Override the OpenAI endpoint (e.g. point at Ollama). | Optional |
| `SKILLSPECTOR_REASONING_EFFORT` | Optional provider- and model-dependent reasoning-effort setting. Non-empty values are trimmed and passed through unchanged. When unset or blank, SkillSpector sends `high` for `nv_build` with `z-ai/glm-5.3`; other provider/model combinations keep their endpoint defaults (`medium` for `gpt-6.1-sol` and `claude-opus-5-5`, `high` for `claude-sonnet-5-5`). The value applies to every model slot, so the `anthropic` `meta_analyzer` default receives the same effort as the analyzers. `gpt-6.1-sol` accepts only `low`, `medium`, `high`, `xhigh`, or `max`; any other value stops a scan before analysis (exit code 2). | Optional |
| `SKILLSPECTOR_REASONING_EFFORT` | Optional provider- and model-dependent reasoning-effort setting. Non-empty values are trimmed and passed through unchanged. When unset or blank, SkillSpector sends `high` for `nv_build` with `z-ai/glm-5.3`; other provider/model combinations keep their endpoint defaults. The value applies to every model slot, so the `anthropic` `meta_analyzer` default receives the same effort as the analyzers. `gpt-6.1-sol` accepts only `low`, `medium`, `high`, `xhigh`, or `max`; any other value stops a scan before analysis (exit code 2). | Optional |
| `SKILLSPECTOR_OUTPUT_LANGUAGE` | Short, single-line language label (letters, numbers, spaces, `_`, or `-`; maximum 64 characters) for human-readable LLM finding text such as messages, explanations, and remediation. Rule IDs, severity values, paths, code, and other machine-readable values remain unchanged. Unset, blank, or invalid values preserve the default output language. | Optional |
| `SKILLSPECTOR_TEMPERATURE` | Optional sampling temperature from `0` to `1` for hosted providers. Unset or blank preserves the provider default. Lower values can reduce run-to-run variation but do not guarantee identical output. `gpt-6.1-sol` rejects every explicit temperature, including `1`. `claude-opus-5-5` and `claude-sonnet-5-5` accept only `1.0` on the native Anthropic endpoint ([API compatibility rule](https://platform.claude.com/docs/en/api/messages/create)); gateways, proxies, and Bedrock still reject every explicit value for these models. Unsupported settings on active LLM slots stop a scan before analysis (exit code 2). Static scans (`--no-llm`) skip provider initialization and control validation. A Bedrock application-inference-profile ARN hides the model name, so declare `sampling: rejected` for it in the model registry. With the previous `gpt-5.4` and `claude-opus-4-6` defaults a temperature was accepted; unset it, or pin the older model with `SKILLSPECTOR_MODEL`. | Optional |
| `SKILLSPECTOR_TEMPERATURE` | Optional sampling temperature from `0` to `1` for hosted providers. Unset or blank preserves the provider default. Lower values can reduce run-to-run variation but do not guarantee identical output. `gpt-6.1-sol` rejects every explicit temperature, including `1`. `claude-opus-5-5` and `claude-sonnet-5-5` accept only `1.0` on the native Anthropic endpoint ([API compatibility rule](https://platform.claude.com/docs/en/api/messages/create)); gateways, proxies, and Bedrock still reject every explicit value for these models. Unsupported settings on active LLM slots stop a scan before analysis (exit code 2). Static scans (`--no-llm`) skip provider initialization and control validation. A Bedrock application-inference-profile ARN hides the model name, so declare `sampling: rejected` for it in the model registry. | Optional |
| `SKILLSPECTOR_SEED` | Optional integer sampling seed for OpenAI-compatible and Azure OpenAI providers. Other hosted providers and CLI providers do not receive it. Provider support remains model-dependent; `gpt-6.1-sol` receives it, but OpenAI treats `seed` as best-effort, so output can still differ between runs. | Optional |
| `SKILLSPECTOR_COMPACT_PROMPTS` | Opt-in compact line numbering in LLM prompts: numbered lines render as `L1:`, `L2:` instead of zero-padded `L01:`, `L02:`. Accepted truthy values are `1`, `true`, and `yes` (case-insensitive; surrounding whitespace is trimmed). Unset or any other value keeps the default zero-padded format. | Optional |
| `ANTHROPIC_API_KEY` | Credential for the Anthropic provider (`SKILLSPECTOR_PROVIDER=anthropic`). | Required for LLM analysis when `SKILLSPECTOR_PROVIDER=anthropic` |
Expand Down
2 changes: 1 addition & 1 deletion docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ make install-dev
- **`SKILLSPECTOR_PROVIDER`**: Selects the active LLM provider — `openai`, `anthropic`, `anthropic_proxy`, `bedrock`, `nv_build`, `ollama`, `azure_openai`, `openai_compatible`, `claude_cli`, `gemini_cli`, or `opencode_cli`. Defaults to `nv_build` when unset.
- **Provider credential**: depends on the active provider. Hosted providers use the matching variables in [.env.example](../.env.example); Ollama and CLI providers do not require an API key. See [providers/](../src/skillspector/providers/).
- **`OPENAI_BASE_URL`**: Override the OpenAI endpoint (e.g. point at Ollama).
- **`SKILLSPECTOR_MODEL`**: Override default model; see [constants.py](../src/skillspector/constants.py).
- **`SKILLSPECTOR_MODEL`**: Override default model; see [constants.py](../src/skillspector/constants.py). OpenAI retains `gpt-5.4`; Anthropic retains `claude-opus-4-6` with `claude-sonnet-4-6` for `meta_analyzer`. Sol and Claude 5.5 remain opt-in pending the [live scanner acceptance described in the README](../README.md#llm-analysis).
- **`SKILLSPECTOR_TEMPERATURE`**: Optional hosted-provider sampling temperature from `0` to `1`. `gpt-6.1-sol` rejects every explicit value. `claude-opus-5-5` and `claude-sonnet-5-5` accept only `1.0` on the native Anthropic endpoint; other routes reject every explicit value. Unsupported settings on active LLM slots stop the scan before analysis. Static scans skip provider initialization and control validation.
- **`SKILLSPECTOR_SEED`**: Optional integer seed for OpenAI-compatible and Azure OpenAI providers.

Expand Down
5 changes: 4 additions & 1 deletion src/skillspector/mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from skillspector.llm_utils import is_llm_available
from skillspector.logging_config import get_logger
from skillspector.nodes.analyzers import ANALYZER_MODULES
from skillspector.nodes.report import redact_llm_error
from skillspector.semantic_runtime import llm_runtime_available, semantic_runtime_accounting
from skillspector.suppression import effective_findings

Expand Down Expand Up @@ -142,7 +143,7 @@ async def run_scan(
):
raise ValueError("this MCP transport requires an unauthenticated HTTPS target")

llm_preflight_available, _ = is_llm_available() if use_llm else (False, None)
llm_preflight_available, llm_preflight_error = is_llm_available() if use_llm else (False, None)
llm_enabled = use_llm and llm_preflight_available

state: dict[str, Any] = {
Expand All @@ -152,6 +153,8 @@ async def run_scan(
"use_llm": llm_enabled,
"llm_requested": use_llm,
}
if use_llm and not llm_preflight_available:
state["llm_preflight_error"] = redact_llm_error(llm_preflight_error)
if yara_rules_dir:
state["yara_rules_dir"] = yara_rules_dir

Expand Down
21 changes: 19 additions & 2 deletions src/skillspector/nodes/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

from skillspector import __version__ as skillspector_version
from skillspector.dependency_sources import redact_text
from skillspector.inference_usage import sanitize_inference_usage
from skillspector.inference_usage import looks_like_credential, sanitize_inference_usage
from skillspector.inspection_ledger import (
MAX_FINDING_OUTPUT_RECORDS,
RULE_SET_SCOPE,
Expand Down Expand Up @@ -127,6 +127,18 @@ def _clean_text(value: str | None) -> str | None:
return _CONTROL_RE.sub("", _ANSI_RE.sub("", value))


def redact_llm_error(value: object) -> str | None:
"""Keep actionable provider error text without report-visible credentials."""
if not isinstance(value, str) or not value.strip():
return None
cleaned = redact_text(_clean_text(value) or "")
return re.sub(
r"(?i)(?:(?:authorization\s*:\s*)?(?:bearer|basic)\s+)?[A-Za-z0-9_+/.-]+={0,2}",
lambda match: "***" if looks_like_credential(match.group(0)) else match.group(0),
cleaned,
)


def _sanitize_finding(finding: Finding) -> Finding:
"""Clean finding text and recursively redact credentials from evidence."""

Expand Down Expand Up @@ -1265,6 +1277,7 @@ def _build_metadata(
if use_llm
else (False, None)
)
llm_error = redact_llm_error(llm_error)
attempted, succeeded, call_log_degraded = _llm_runtime_status(use_llm, llm_call_log)
# meta_analyzer's own record, independent of whether a DIFFERENT
# LLM-backed node (a semantic_* analyzer) lost coverage to a dropped
Expand Down Expand Up @@ -1339,9 +1352,10 @@ def _build_metadata(
meta["llm_calls_attempted"] = attempted
meta["llm_calls_succeeded"] = succeeded
if unavailable_before_execution:
detail = f" Reason: {llm_error}" if llm_error else ""
meta["llm_error"] = (
"LLM analysis was requested but unavailable during preflight; "
"results reflect static analysis only."
f"results reflect static analysis only.{detail}"
)
elif call_log_degraded:
meta["llm_degraded"] = True
Expand Down Expand Up @@ -1808,6 +1822,9 @@ def report(state: SkillspectorState) -> dict[str, object]:
remaining = transitive_remaining_seconds(state)
if not llm_requested:
provider_available, provider_error = False, None
elif not use_llm and "llm_preflight_error" in state:
provider_available = False
provider_error = redact_llm_error(state.get("llm_preflight_error"))
elif remaining is not None and remaining <= 0:
provider_available = any(successful_llm_record(record) for record in llm_call_log)
provider_error = (
Expand Down
6 changes: 3 additions & 3 deletions src/skillspector/providers/anthropic/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Reads ``ANTHROPIC_API_KEY`` for credentials and honors ``ANTHROPIC_BASE_URL``
as an explicit endpoint override (e.g. a local proxy); when unset, requests
go to api.anthropic.com. Constructs ``langchain_anthropic.ChatAnthropic``
directly. It defaults to Opus 5.5 for analyzers and Sonnet 5.5 for
directly. It defaults to Opus 4.6 for analyzers and Sonnet 4.6 for
``meta_analyzer`` (cheaper for the high-volume filter pass).

Set ``ANTHROPIC_AUTH_SCHEME=bearer`` when the endpoint expects
Expand Down Expand Up @@ -73,9 +73,9 @@ def _client_params(self) -> dict[str, Any]:
class AnthropicProvider:
"""Anthropic credentials + bundled-YAML metadata provider."""

DEFAULT_MODEL = "claude-opus-5-5"
DEFAULT_MODEL = "claude-opus-4-6"
SLOT_DEFAULTS: dict[str, str] = {
"meta_analyzer": "claude-sonnet-5-5",
"meta_analyzer": "claude-sonnet-4-6",
}

def resolve_credentials(self) -> tuple[str, str | None] | None:
Expand Down
2 changes: 1 addition & 1 deletion src/skillspector/providers/openai/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _resolve_openai_project_headers() -> dict[str, str] | None:
class OpenAIProvider:
"""Stock OpenAI credentials + bundled-YAML metadata provider."""

DEFAULT_MODEL = "gpt-6.1-sol"
DEFAULT_MODEL = "gpt-5.4"
SLOT_DEFAULTS: dict[str, str] = {}

def resolve_credentials(self) -> tuple[str, str | None] | None:
Expand Down
3 changes: 3 additions & 0 deletions src/skillspector/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ class SkillspectorState(TypedDict, total=False):
# Report generation uses this to distinguish unavailable requested analysis from an
# explicit static-only scan while analyzers continue to honor use_llm.
llm_requested: bool
# Sanitized reason captured when caller preflight disables requested execution.
# Presence (including None) preserves that result without probing a new provider context.
llm_preflight_error: str | None
# Explicit caller scope, recorded in public coverage accounting.
exclude_patterns: list[str]
# Monotonic provenance flag: content rooted beneath a hidden/local-only
Expand Down
50 changes: 50 additions & 0 deletions tests/nodes/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2756,3 +2756,53 @@ def test_report_active_findings_are_sanitized_and_exclude_suppressed() -> None:
assert result["active_findings"][0].finding_id == kept.finding_id
assert result["active_findings"][0].message == "destructive command"
assert kept.message == "destructive\x1b[31m command"


@pytest.mark.parametrize("reason", [None, "SKILLSPECTOR_TEMPERATURE is unsupported; unset it"])
def test_report_retains_preflight_reason_without_reprobing(
monkeypatch: pytest.MonkeyPatch, reason: str | None
) -> None:
"""A captured unavailable result remains authoritative if provider context changes."""

def unexpected_probe(**_: object) -> tuple[bool, str | None]:
raise AssertionError("preflight-disabled reports must not probe the provider again")

monkeypatch.setattr("skillspector.nodes.report.is_llm_available", unexpected_probe)
state: SkillspectorState = {
"filtered_findings": [],
"output_format": "json",
"use_llm": False,
"llm_requested": True,
"llm_preflight_error": reason,
}

metadata = json.loads(report(state)["report_body"])["metadata"]

assert "unavailable during preflight" in metadata["llm_error"]
assert "static analysis only" in metadata["llm_error"]
if reason:
assert reason in metadata["llm_error"]
assert metadata["llm_available"] is False


def test_report_active_runtime_error_takes_priority_over_stale_preflight_reason(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""An executing scan reports the current call failure rather than old configuration detail."""
monkeypatch.setattr("skillspector.nodes.report.is_llm_available", lambda **_: (True, None))
state: SkillspectorState = {
"filtered_findings": [],
"output_format": "json",
"use_llm": True,
"llm_requested": True,
"llm_preflight_error": "stale preflight reason",
"llm_call_log": [
{"node": "meta_analyzer", "ok": False, "error": "active provider runtime failure"}
],
}

metadata = json.loads(report(state)["report_body"])["metadata"]

assert "active provider runtime failure" in metadata["llm_error"]
assert "stale preflight reason" not in metadata["llm_error"]
assert metadata["llm_degraded"] is True
Loading
Loading