Skip to content

Commit 0828504

Browse files
authored
chore(deps): pin @stoplight/spectral-cli to v6.15.0 (#199)
1 parent 16ed232 commit 0828504

File tree

7 files changed

+33
-21
lines changed

7 files changed

+33
-21
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jentic-openapi-validator-spectral/README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# jentic-openapi-validator-spectral
22

3-
A [Spectral](https://github.com/stoplightio/spectral) validator backend for the Jentic OpenAPI Tools ecosystem. This package provides OpenAPI document validation using Stoplight's Spectral CLI with comprehensive error reporting and flexible configuration options.
3+
A [Spectral](https://github.com/stoplightio/spectral) validator backend for the Jentic OpenAPI Tools ecosystem. This
4+
package provides OpenAPI document validation using Stoplight's Spectral CLI with comprehensive error reporting and
5+
flexible configuration options.
46

57
## Features
68

@@ -17,6 +19,7 @@ pip install jentic-openapi-validator-spectral
1719
```
1820

1921
**Prerequisites:**
22+
2023
- Node.js and npm (for Spectral CLI)
2124
- Python 3.11+
2225

@@ -69,7 +72,7 @@ print(f"Document is valid: {result.valid}")
6972
validator = SpectralValidatorBackend(spectral_path="/usr/local/bin/spectral")
7073

7174
# Use specific version via npx
72-
validator = SpectralValidatorBackend(spectral_path="npx --yes @stoplight/spectral-cli@^6.15.0")
75+
validator = SpectralValidatorBackend(spectral_path="npx --yes @stoplight/spectral-cli@6.15.0")
7376
```
7477

7578
### Custom Rulesets
@@ -140,13 +143,15 @@ validator = SpectralValidatorBackend(
140143
```
141144

142145
**Security Benefits:**
146+
143147
- Prevents path traversal attacks (`../../etc/passwd`)
144148
- Restricts access to allowed directories only (when `allowed_base_dir` is set)
145149
- Validates file extensions (`.yaml`, `.yml`, `.json`) - **always enforced**, even when `allowed_base_dir=None`
146150
- Checks symlinks don't escape boundaries (when `allowed_base_dir` is set)
147151
- Validates both document and ruleset paths
148152

149-
**Note:** File extension validation (`.yaml`, `.yml`, `.json`) is always performed for filesystem paths, regardless of whether `allowed_base_dir` is set. When `allowed_base_dir=None`, only the base directory containment check is skipped.
153+
**Note:** File extension validation (`.yaml`, `.yml`, `.json`) is always performed for filesystem paths, regardless of
154+
whether `allowed_base_dir` is set. When `allowed_base_dir=None`, only the base directory containment check is skipped.
150155

151156
## Advanced Usage
152157

@@ -196,7 +201,7 @@ Create a custom Spectral ruleset file:
196201

197202
```yaml
198203
# custom-rules.yaml
199-
extends: ["spectral:oas"]
204+
extends: [ "spectral:oas" ]
200205

201206
rules:
202207
info-contact: error
@@ -225,7 +230,8 @@ result = validator.validate("file:///path/to/openapi.yaml")
225230

226231
### Integration Tests
227232

228-
The integration tests require Spectral CLI to be available. They will be automatically skipped if Spectral is not installed.
233+
The integration tests require Spectral CLI to be available. They will be automatically skipped if Spectral is not
234+
installed.
229235

230236
**Run the integration test:**
231237

@@ -240,29 +246,35 @@ uv run --package jentic-openapi-validator-spectral pytest packages/jentic-openap
240246
```python
241247
class SpectralValidatorBackend(BaseValidatorBackend):
242248
def __init__(
243-
self,
244-
spectral_path: str = "npx --yes @stoplight/spectral-cli@^6.15.0",
245-
ruleset_path: str | None = None,
246-
timeout: float = 600.0,
247-
allowed_base_dir: str | Path | None = None,
249+
self,
250+
spectral_path: str = "npx --yes @stoplight/spectral-cli@6.15.0",
251+
ruleset_path: str | None = None,
252+
timeout: float = 600.0,
253+
allowed_base_dir: str | Path | None = None,
248254
) -> None
249255
```
250256

251257
**Parameters:**
258+
252259
- `spectral_path`: Path to Spectral CLI executable
253260
- `ruleset_path`: Path to a custom ruleset file (optional)
254261
- `timeout`: Maximum execution time in seconds
255-
- `allowed_base_dir`: Optional base directory for path security validation. When set, all document and ruleset paths are validated to be within this directory, providing defense against path traversal attacks. When `None` (default), only file extension validation is performed (no base directory containment check). Recommended for web services or untrusted input (optional)
262+
- `allowed_base_dir`: Optional base directory for path security validation. When set, all document and ruleset paths are
263+
validated to be within this directory, providing defense against path traversal attacks. When `None` (default), only
264+
file extension validation is performed (no base directory containment check). Recommended for web services or
265+
untrusted input (optional)
256266

257267
**Methods:**
258268

259269
- `accepts() -> list[Literal["uri", "dict"]]`: Returns supported document format identifiers
260270
- `validate(document: str | dict) -> ValidationResult`: Validates an OpenAPI document
261271

262272
**Exceptions:**
273+
263274
- `FileNotFoundError`: Custom ruleset file doesn't exist
264275
- `RuntimeError`: Spectral execution fails
265276
- `SubprocessExecutionError`: Spectral times out or fails to start
266277
- `TypeError`: Unsupported document type
267-
- `PathTraversalError`: Document or ruleset path attempts to escape allowed_base_dir (only when `allowed_base_dir` is set)
278+
- `PathTraversalError`: Document or ruleset path attempts to escape allowed_base_dir (only when `allowed_base_dir` is
279+
set)
268280
- `InvalidExtensionError`: Document or ruleset path has disallowed file extension (always checked for filesystem paths)

packages/jentic-openapi-validator-spectral/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"description": "OpenAPI validator using Spectral for jentic-openapi-tools",
55
"private": true,
66
"dependencies": {
7-
"@stoplight/spectral-cli": "^6.15.0"
7+
"@stoplight/spectral-cli": "6.15.0"
88
}
99
}

packages/jentic-openapi-validator-spectral/src/jentic/apitools/openapi/validator/backends/spectral/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
class SpectralValidatorBackend(BaseValidatorBackend):
3333
def __init__(
3434
self,
35-
spectral_path: str = "npx --yes @stoplight/spectral-cli@^6.15.0",
35+
spectral_path: str = "npx --yes @stoplight/spectral-cli@6.15.0",
3636
ruleset_path: str | None = None,
3737
timeout: float = 600.0,
3838
allowed_base_dir: str | Path | None = None,
@@ -41,7 +41,7 @@ def __init__(
4141
Initialize the SpectralValidatorBackend.
4242
4343
Args:
44-
spectral_path: Path to the spectral CLI executable (default: "npx --yes @stoplight/spectral-cli@^6.15.0").
44+
spectral_path: Path to the spectral CLI executable (default: "npx --yes @stoplight/spectral-cli@6.15.0").
4545
Uses shell-safe parsing to handle quoted arguments properly.
4646
ruleset_path: Path to a custom ruleset file. If None, uses bundled default ruleset.
4747
timeout: Maximum time in seconds to wait for Spectral CLI execution (default: 600.0)

packages/jentic-openapi-validator-spectral/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def pytest_runtest_setup(item):
8080
if item.get_closest_marker("requires_spectral_cli"):
8181
try:
8282
result = subprocess.run(
83-
["npx", "--yes", "@stoplight/spectral-cli@^6.15.0", "--version"],
83+
["npx", "--yes", "@stoplight/spectral-cli@6.15.0", "--version"],
8484
capture_output=True,
8585
timeout=10,
8686
)

packages/jentic-openapi-validator-spectral/tests/test_spectral_validate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class TestSpectralValidatorUnit:
5050
def test_initialization_with_defaults(self):
5151
"""Test SpectralValidator initialization with default values."""
5252
validator = SpectralValidatorBackend()
53-
assert validator.spectral_path == "npx --yes @stoplight/spectral-cli@^6.15.0"
53+
assert validator.spectral_path == "npx --yes @stoplight/spectral-cli@6.15.0"
5454
assert validator.ruleset_path is None
5555
assert validator.timeout == 600.0
5656

@@ -68,7 +68,7 @@ def test_initialization_with_custom_timeout(self):
6868
"""Test SpectralValidator with custom timeout."""
6969
validator = SpectralValidatorBackend(timeout=60.0)
7070
assert validator.timeout == 60.0
71-
assert validator.spectral_path == "npx --yes @stoplight/spectral-cli@^6.15.0" # default
71+
assert validator.spectral_path == "npx --yes @stoplight/spectral-cli@6.15.0" # default
7272
assert validator.ruleset_path is None # default
7373

7474
def test_initialization_with_all_custom_parameters(self, custom_ruleset_path):

packages/jentic-openapi-validator/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def spectral_cli_available() -> bool:
164164
"""Check if Spectral CLI is available on the system."""
165165
try:
166166
result = subprocess.run(
167-
["npx", "--yes", "@stoplight/spectral-cli@^6.15.0", "--version"],
167+
["npx", "--yes", "@stoplight/spectral-cli@6.15.0", "--version"],
168168
capture_output=True,
169169
timeout=10,
170170
)
@@ -188,7 +188,7 @@ def pytest_runtest_setup(item):
188188
if item.get_closest_marker("requires_spectral_cli"):
189189
try:
190190
result = subprocess.run(
191-
["npx", "--yes", "@stoplight/spectral-cli@^6.15.0", "--version"],
191+
["npx", "--yes", "@stoplight/spectral-cli@6.15.0", "--version"],
192192
capture_output=True,
193193
timeout=10,
194194
)

0 commit comments

Comments
 (0)