Skip to content

Commit a5092dd

Browse files
authored
Sync OSS release snapshot - Merge pull request #85 from NVIDIA/keshavp/oss-release-2026-06-16
Refresh the public SkillSpector tree from the internal OSS release branch release/oss-2026-06-16 at 94599d2baae5d532d83f630ddeeeead1f33c8cbb. This snapshot was generated by scripts/create-oss-release.sh, which removes internal-only files and produces a single orphan-branch tree for public publication. Changes: - Bump public package snapshot to 2.2.3. - Carry Python metadata and uv.lock support for >=3.12,<3.15, including Python 3.14. - Add native provider-backed LangChain chat model creation, including Anthropic support. - Resolve Anthropic API call failures caused by unsupported maximum/minimum parameters in structured-output tool schemas. - Add shared OpenAI-compatible chat model helper. - Add live provider test targets, docs, and provider endpoint tests. - Keep default unit and coverage targets scoped away from provider/integration tests. - Update LLM response text handling and provider unit coverage. Resolves #4, #34, #66, #76. Verification: - scripts/create-oss-release.sh release/oss-2026-06-16 - includes make test-unit: 621 passed, 12 skipped, 26 deselected - git diff --cached --check
2 parents e4cb70f + 77c55c6 commit a5092dd

19 files changed

Lines changed: 1153 additions & 79 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ venv.bak/
9797
tmp/
9898
temp/
9999
.skillspector/
100+
.provider-test-missing-keys
100101

101102
# API Keys (never commit!)
102103
.env.local

‎Makefile‎

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help install install-dev langgraph-dev test test-unit test-integration test-cov test-ci lint lint-fix format format-check clean build docker-build docker-smoke
1+
.PHONY: help install install-dev langgraph-dev test test-unit test-provider openai anthropic nv_build test-integration test-cov test-ci lint lint-fix format format-check clean build docker-build docker-smoke
22

33
# Prefer uv if available, else use pip (set when Makefile is parsed)
44
UV := $(shell command -v uv 2>/dev/null)
@@ -8,6 +8,24 @@ UV := $(shell command -v uv 2>/dev/null)
88
# make langgraph-dev LANGGRAPH_STUDIO_URL=https://your-studio.example
99
LANGGRAPH_STUDIO_URL = https://smith.langchain.com
1010

11+
PROVIDER_TEST_SELECTION := $(filter openai anthropic nv_build,$(MAKECMDGOALS))
12+
ifneq ($(PROVIDER_TEST_SELECTION),)
13+
PROVIDER_TEST_PROVIDERS := $(PROVIDER_TEST_SELECTION)
14+
PROVIDER_TEST_TARGETS :=
15+
ifneq ($(filter openai,$(PROVIDER_TEST_SELECTION)),)
16+
PROVIDER_TEST_TARGETS += tests/provider/test_provider_endpoint.py::test_openai_provider_makes_live_structured_request
17+
endif
18+
ifneq ($(filter anthropic,$(PROVIDER_TEST_SELECTION)),)
19+
PROVIDER_TEST_TARGETS += tests/provider/test_provider_endpoint.py::test_anthropic_provider_makes_live_structured_request
20+
endif
21+
ifneq ($(filter nv_build,$(PROVIDER_TEST_SELECTION)),)
22+
PROVIDER_TEST_TARGETS += tests/provider/test_provider_endpoint.py::test_nv_build_provider_makes_live_structured_request
23+
endif
24+
else
25+
PROVIDER_TEST_PROVIDERS := openai anthropic nv_build
26+
PROVIDER_TEST_TARGETS := tests/provider
27+
endif
28+
1129
# Default target. All targets assume the virtual env is already created and activated.
1230
help:
1331
@echo "Available targets (venv must be created and activated first):"
@@ -16,6 +34,7 @@ help:
1634
@echo " make langgraph-dev - Run LangGraph dev server (Studio at \$$LANGGRAPH_STUDIO_URL)"
1735
@echo " make test - Run unit + integration tests"
1836
@echo " make test-unit - Run unit tests only (no LLM calls)"
37+
@echo " make test-provider [openai|anthropic|nv_build] - Run live provider tests"
1938
@echo " make test-integration - Run integration tests only (invokes full graph, may call LLMs)"
2039
@echo " make test-cov - Run tests with coverage report"
2140
@echo " make lint - Run linters (ruff only)"
@@ -40,21 +59,51 @@ langgraph-dev:
4059
# Run unit + integration tests
4160
test: test-unit test-integration
4261

43-
# Run unit tests only (excludes integration marker)
62+
# Run unit tests only (excludes provider and integration markers)
4463
test-unit:
45-
pytest -m "not integration" tests/
64+
pytest -m "not integration and not provider" tests/
65+
66+
# Run live provider tests (requires provider-specific API keys)
67+
test-provider:
68+
@missing_keys=0; \
69+
if [ -n "$${PROVIDER_TEST_MISSING_KEYS_FILE:-}" ]; then \
70+
rm -f "$$PROVIDER_TEST_MISSING_KEYS_FILE"; \
71+
fi; \
72+
for provider in $(PROVIDER_TEST_PROVIDERS); do \
73+
case "$$provider" in \
74+
openai) env_name=OPENAI_API_KEY; label=OpenAI ;; \
75+
anthropic) env_name=ANTHROPIC_API_KEY; label=Anthropic ;; \
76+
nv_build) env_name=NVIDIA_INFERENCE_KEY; label="NV Build" ;; \
77+
esac; \
78+
eval "value=\$${$${env_name}:-}"; \
79+
if [ -z "$$value" ]; then \
80+
echo "WARNING: $$env_name is not set; $$label provider test will be skipped"; \
81+
missing_keys=1; \
82+
fi; \
83+
done; \
84+
pytest -m provider $(PROVIDER_TEST_TARGETS); \
85+
pytest_status=$$?; \
86+
if [ "$$pytest_status" -ne 0 ]; then \
87+
exit "$$pytest_status"; \
88+
fi; \
89+
if [ "$$missing_keys" -ne 0 ] && [ -n "$${PROVIDER_TEST_MISSING_KEYS_FILE:-}" ]; then \
90+
printf "missing provider keys\n" > "$$PROVIDER_TEST_MISSING_KEYS_FILE"; \
91+
fi
92+
93+
openai anthropic nv_build:
94+
@:
4695

4796
# Run integration tests only (invokes full graph, may call LLMs)
4897
test-integration:
4998
pytest -m integration tests/
5099

51100
# Run tests with coverage
52101
test-cov:
53-
pytest --cov=src/skillspector --cov-report=html --cov-report=term-missing tests/
102+
pytest -m "not integration and not provider" --cov=src/skillspector --cov-report=html --cov-report=term-missing tests/
54103

55104
# Run tests with coverage for CI (Cobertura XML + terminal)
56105
test-ci:
57-
pytest --cov=src/skillspector --cov-report=term-missing --cov-report=xml tests/
106+
pytest -m "not integration and not provider" --cov=src/skillspector --cov-report=term-missing --cov-report=xml tests/
58107

59108
# Run linters (fast: ruff only)
60109
lint:

‎docs/DEVELOPMENT.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,19 @@ Copy [.env.example](../.env.example) to `.env` in the project root and set value
267267
| `ANTHROPIC_API_KEY` | Credential for `SKILLSPECTOR_PROVIDER=anthropic`. | `sk-ant-...` |
268268
| `SKILLSPECTOR_MODEL` | Override the active provider's bundled default model (see [README.md](../README.md) for per-provider defaults). | `gpt-5.2` |
269269

270+
### Live provider tests
271+
272+
The manual `test-provider` CI job and local `make test-provider` target perform live requests against provider default endpoints. Missing provider keys print a `WARNING:` line before pytest runs and skip that provider. In CI, missing keys also make the manual job exit with the configured warning code so GitLab displays the job as passed with warnings; if a key is present but invalid, or the provider request fails, the corresponding test fails.
273+
274+
| Command | Required env var | Default URL | Optional model override |
275+
|---------|------------------|-------------|-------------------------|
276+
| `make test-provider openai` | `OPENAI_API_KEY` | `https://api.openai.com/v1` | `SKILLSPECTOR_OPENAI_TEST_MODEL` |
277+
| `make test-provider anthropic` | `ANTHROPIC_API_KEY` | `https://api.anthropic.com` | `SKILLSPECTOR_ANTHROPIC_TEST_MODEL` |
278+
| `make test-provider nv_build` | `NVIDIA_INFERENCE_KEY` | `https://integrate.api.nvidia.com/v1` | `SKILLSPECTOR_NV_BUILD_TEST_MODEL` |
279+
| `make test-provider` | Any/all of the provider keys above | All provider default URLs above | Any/all provider model overrides above |
280+
281+
Base URL env vars are not needed for live provider tests; the tests intentionally use provider defaults.
282+
270283
### Constants, token budgets, and LLM
271284

272285
- **Constants** ([constants.py](../src/skillspector/constants.py)): `_SKILLSPECTOR_DEFAULT_MODEL`, `MODEL_CONFIG` (per-node model selection), `MAX_INPUT_TOKENS_PCT` (0.75), `DEFAULT_CONTEXT_LENGTH` (128k fallback).

‎pyproject.toml‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "skillspector"
7-
version = "2.1.5"
7+
version = "2.2.3"
88
description = "SkillSpector: Security scanner for AI agent skills (Claude Code, Cursor, and similar). Scans skills for vulnerabilities, malicious patterns, and security risks before installation. Supports Git repos, URLs, zips, and local directories; runs static pattern checks and optional LLM semantic analysis; outputs terminal, JSON, and Markdown reports with risk scoring."
99
readme = "README.md"
1010
license = "Apache-2.0"
11-
requires-python = ">=3.12,<3.14"
11+
requires-python = ">=3.12,<3.15"
1212
keywords = [
1313
"security",
1414
"ai-agents",
@@ -25,6 +25,7 @@ classifiers = [
2525
"Programming Language :: Python :: 3",
2626
"Programming Language :: Python :: 3.12",
2727
"Programming Language :: Python :: 3.13",
28+
"Programming Language :: Python :: 3.14",
2829
"Topic :: Security",
2930
"Topic :: Software Development :: Quality Assurance",
3031
]
@@ -38,6 +39,7 @@ dependencies = [
3839
"openai>=2.25.0",
3940
"langgraph>=1.0.10",
4041
"langgraph-cli[inmem]>=0.4.14",
42+
"langchain-anthropic>=1.4.5",
4143
"langchain-core>=1.2.17",
4244
"langchain-openai>=1.1.10",
4345
"langsmith>=0.7.30",
@@ -97,5 +99,8 @@ source = ["src/skillspector"]
9799
[tool.pytest.ini_options]
98100
testpaths = ["tests"]
99101
asyncio_mode = "auto"
100-
markers = ["integration: end-to-end tests that invoke the full graph (may call LLMs)"]
101-
addopts = "-m 'not integration'"
102+
markers = [
103+
"integration: end-to-end tests that invoke the full graph (may call LLMs)",
104+
"provider: live OpenAI/Anthropic/NVIDIA Build provider endpoint tests",
105+
]
106+
addopts = "-m 'not integration and not provider'"

‎src/skillspector/llm_analyzer_base.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from dataclasses import dataclass, field
3333
from typing import Literal
3434

35+
from langchain_core.messages import BaseMessage
3536
from pydantic import BaseModel, Field
3637

3738
from skillspector.llm_utils import get_chat_model
@@ -191,6 +192,13 @@ def number_lines(content: str, start_line: int = 1) -> str:
191192
return "\n".join(f"L{start_line + i:0>{width}}: {line}" for i, line in enumerate(lines))
192193

193194

195+
def _message_text(response: object) -> str:
196+
"""Extract provider-normalized text from a LangChain chat response."""
197+
if not isinstance(response, BaseMessage):
198+
raise TypeError(f"Expected BaseMessage from chat model, got {type(response).__name__}")
199+
return str(response.text)
200+
201+
194202
BASE_ANALYSIS_PROMPT = """\
195203
{analyzer_prompt}
196204
@@ -355,7 +363,7 @@ def run_batches(
355363
if self._structured_llm:
356364
response = self._structured_llm.invoke(prompt)
357365
else:
358-
response = self._llm.invoke(prompt).content
366+
response = _message_text(self._llm.invoke(prompt))
359367
logger.debug("LLM response for %s", batch.file_label)
360368
parsed = self.parse_response(response, batch)
361369
results.append((batch, parsed))
@@ -390,7 +398,7 @@ async def _process(batch: Batch) -> tuple[Batch, list]:
390398
if self._structured_llm:
391399
response = await self._structured_llm.ainvoke(prompt)
392400
else:
393-
response = (await self._llm.ainvoke(prompt)).content
401+
response = _message_text(await self._llm.ainvoke(prompt))
394402
logger.debug("LLM response for %s", batch.file_label)
395403
return (batch, self.parse_response(response, batch))
396404

‎src/skillspector/llm_utils.py‎

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,33 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
"""Shared LLM utilities (OpenAI-compatible chat models).
16+
"""Shared LLM utilities.
1717
1818
Credentials are resolved in this order:
19-
1. The active NVIDIA provider (see :mod:`skillspector.providers`) —
20-
reads ``NVIDIA_INFERENCE_KEY`` and supplies the matching endpoint.
19+
1. The active SkillSpector provider (see :mod:`skillspector.providers`) —
20+
reads its own credential env var and supplies the matching client.
2121
2. ``OPENAI_API_KEY`` / ``OPENAI_BASE_URL`` (the langchain-openai
2222
defaults).
2323
2424
There is no SkillSpector-specific credential env var: setting
2525
``NVIDIA_INFERENCE_KEY`` configures whichever NVIDIA endpoint the
26-
deployment ships with, and any other OpenAI-compatible endpoint is
27-
configured via the standard ``OPENAI_*`` envs.
26+
deployment ships with, Anthropic reads ``ANTHROPIC_API_KEY``, and any
27+
other OpenAI-compatible endpoint is configured via the standard
28+
``OPENAI_*`` envs.
2829
"""
2930

3031
from __future__ import annotations
3132

32-
import os
33-
34-
from langchain_openai import ChatOpenAI
33+
from langchain_core.language_models.chat_models import BaseChatModel
34+
from langchain_core.messages import BaseMessage
3535

3636
from skillspector.constants import MODEL_CONFIG
3737
from skillspector.model_info import get_max_input_tokens, get_max_output_tokens
38-
from skillspector.providers import resolve_provider_credentials
38+
from skillspector.providers import (
39+
create_chat_model,
40+
raise_no_llm_api_key_configured,
41+
resolve_chat_model_credentials,
42+
)
3943

4044

4145
def _resolve_llm_credentials() -> tuple[str, str | None]:
@@ -47,21 +51,10 @@ def _resolve_llm_credentials() -> tuple[str, str | None]:
4751
Raises:
4852
ValueError: when no API key can be resolved from any source.
4953
"""
50-
creds = resolve_provider_credentials()
51-
if creds is not None:
52-
return creds
53-
54-
resolved_key = os.environ.get("OPENAI_API_KEY", "").strip()
55-
if not resolved_key:
56-
raise ValueError(
57-
"No LLM API key configured. Set the credential env var for the "
58-
"active provider, or set OPENAI_API_KEY (and optionally "
59-
"OPENAI_BASE_URL) to use a standard OpenAI-compatible endpoint. "
60-
"Use --no-llm to skip LLM analysis and run static checks only."
61-
)
62-
63-
resolved_base = os.environ.get("OPENAI_BASE_URL", "").strip() or None
64-
return resolved_key, resolved_base
54+
creds = resolve_chat_model_credentials()
55+
if creds is None:
56+
raise_no_llm_api_key_configured()
57+
return creds
6558

6659

6760
def is_llm_available() -> tuple[bool, str | None]:
@@ -78,26 +71,24 @@ def fetch_model_token_limits(model_label: str) -> tuple[int, int]:
7871
return get_max_input_tokens(model_label), get_max_output_tokens(model_label)
7972

8073

81-
def get_chat_model(model: str | None = None) -> ChatOpenAI:
82-
"""Return a :class:`ChatOpenAI` configured against the resolved endpoint.
74+
def get_chat_model(model: str | None = None) -> BaseChatModel:
75+
"""Return the active provider's native LangChain chat model.
8376
8477
Raises:
8578
ValueError: when no API key is configured (see ``is_llm_available``).
8679
"""
87-
resolved_key, resolved_base = _resolve_llm_credentials()
8880
model = model or MODEL_CONFIG["default"]
89-
90-
return ChatOpenAI(
81+
return create_chat_model(
9182
model=model,
92-
base_url=resolved_base,
93-
api_key=resolved_key,
9483
max_tokens=get_max_output_tokens(model),
9584
timeout=120,
9685
)
9786

9887

9988
def chat_completion(prompt: str, *, model: str | None = None) -> str:
100-
"""Request a single chat completion and return the assistant content."""
89+
"""Request a single chat completion and return the assistant text."""
10190
llm = get_chat_model(model=model)
10291
response = llm.invoke(prompt)
103-
return response.content or ""
92+
if not isinstance(response, BaseMessage):
93+
raise TypeError(f"Expected BaseMessage from chat model, got {type(response).__name__}")
94+
return str(response.text)

0 commit comments

Comments
 (0)