agent-lint-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_lint_cli-0.1.0/.gitignore +210 -0
- agent_lint_cli-0.1.0/.vscode/launch.json +14 -0
- agent_lint_cli-0.1.0/PKG-INFO +66 -0
- agent_lint_cli-0.1.0/README.md +37 -0
- agent_lint_cli-0.1.0/pyproject.toml +53 -0
- agent_lint_cli-0.1.0/src/agent_lint/__init__.py +3 -0
- agent_lint_cli-0.1.0/src/agent_lint/cli.py +71 -0
- agent_lint_cli-0.1.0/src/agent_lint/core/__init__.py +0 -0
- agent_lint_cli-0.1.0/src/agent_lint/core/checks.py +75 -0
- agent_lint_cli-0.1.0/src/agent_lint/core/reporter.py +220 -0
- agent_lint_cli-0.1.0/src/agent_lint/core/validator.py +55 -0
- agent_lint_cli-0.1.0/src/agent_lint/observability/__init__.py +1 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/__init__.py +0 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/a2a/__init__.py +1 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/__init__.py +0 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/__init__.py +0 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/performance.py +82 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/quality.py +93 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/schema.py +111 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/security/__init__.py +0 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/security/patterns.py +69 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/security/permissions.py +54 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/security/ratelimit.py +41 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/security/secrets.py +64 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/checks/security/validation.py +58 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/client.py +101 -0
- agent_lint_cli-0.1.0/src/agent_lint/protocols/mcp/validator.py +94 -0
- agent_lint_cli-0.1.0/tests/__init__.py +0 -0
- agent_lint_cli-0.1.0/tests/conftest.py +104 -0
- agent_lint_cli-0.1.0/tests/test_checks.py +288 -0
- agent_lint_cli-0.1.0/tests/test_cli.py +30 -0
- agent_lint_cli-0.1.0/tests/test_integration.py +227 -0
- agent_lint_cli-0.1.0/tests/test_reporter.py +81 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Claude
|
|
2
|
+
Claude.md
|
|
3
|
+
|
|
4
|
+
# Byte-compiled / optimized / DLL files
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[codz]
|
|
7
|
+
*$py.class
|
|
8
|
+
|
|
9
|
+
# C extensions
|
|
10
|
+
*.so
|
|
11
|
+
|
|
12
|
+
# Distribution / packaging
|
|
13
|
+
.Python
|
|
14
|
+
build/
|
|
15
|
+
develop-eggs/
|
|
16
|
+
dist/
|
|
17
|
+
downloads/
|
|
18
|
+
eggs/
|
|
19
|
+
.eggs/
|
|
20
|
+
lib/
|
|
21
|
+
lib64/
|
|
22
|
+
parts/
|
|
23
|
+
sdist/
|
|
24
|
+
var/
|
|
25
|
+
wheels/
|
|
26
|
+
share/python-wheels/
|
|
27
|
+
*.egg-info/
|
|
28
|
+
.installed.cfg
|
|
29
|
+
*.egg
|
|
30
|
+
MANIFEST
|
|
31
|
+
|
|
32
|
+
# PyInstaller
|
|
33
|
+
# Usually these files are written by a python script from a template
|
|
34
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
35
|
+
*.manifest
|
|
36
|
+
*.spec
|
|
37
|
+
|
|
38
|
+
# Installer logs
|
|
39
|
+
pip-log.txt
|
|
40
|
+
pip-delete-this-directory.txt
|
|
41
|
+
|
|
42
|
+
# Unit test / coverage reports
|
|
43
|
+
htmlcov/
|
|
44
|
+
.tox/
|
|
45
|
+
.nox/
|
|
46
|
+
.coverage
|
|
47
|
+
.coverage.*
|
|
48
|
+
.cache
|
|
49
|
+
nosetests.xml
|
|
50
|
+
coverage.xml
|
|
51
|
+
*.cover
|
|
52
|
+
*.py.cover
|
|
53
|
+
.hypothesis/
|
|
54
|
+
.pytest_cache/
|
|
55
|
+
cover/
|
|
56
|
+
|
|
57
|
+
# Translations
|
|
58
|
+
*.mo
|
|
59
|
+
*.pot
|
|
60
|
+
|
|
61
|
+
# Django stuff:
|
|
62
|
+
*.log
|
|
63
|
+
local_settings.py
|
|
64
|
+
db.sqlite3
|
|
65
|
+
db.sqlite3-journal
|
|
66
|
+
|
|
67
|
+
# Flask stuff:
|
|
68
|
+
instance/
|
|
69
|
+
.webassets-cache
|
|
70
|
+
|
|
71
|
+
# Scrapy stuff:
|
|
72
|
+
.scrapy
|
|
73
|
+
|
|
74
|
+
# Sphinx documentation
|
|
75
|
+
docs/_build/
|
|
76
|
+
|
|
77
|
+
# PyBuilder
|
|
78
|
+
.pybuilder/
|
|
79
|
+
target/
|
|
80
|
+
|
|
81
|
+
# Jupyter Notebook
|
|
82
|
+
.ipynb_checkpoints
|
|
83
|
+
|
|
84
|
+
# IPython
|
|
85
|
+
profile_default/
|
|
86
|
+
ipython_config.py
|
|
87
|
+
|
|
88
|
+
# pyenv
|
|
89
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
90
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
91
|
+
# .python-version
|
|
92
|
+
|
|
93
|
+
# pipenv
|
|
94
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
95
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
96
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
97
|
+
# install all needed dependencies.
|
|
98
|
+
#Pipfile.lock
|
|
99
|
+
|
|
100
|
+
# UV
|
|
101
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
102
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
103
|
+
# commonly ignored for libraries.
|
|
104
|
+
#uv.lock
|
|
105
|
+
|
|
106
|
+
# poetry
|
|
107
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
108
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
109
|
+
# commonly ignored for libraries.
|
|
110
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
111
|
+
#poetry.lock
|
|
112
|
+
#poetry.toml
|
|
113
|
+
|
|
114
|
+
# pdm
|
|
115
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
116
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
117
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
118
|
+
#pdm.lock
|
|
119
|
+
#pdm.toml
|
|
120
|
+
.pdm-python
|
|
121
|
+
.pdm-build/
|
|
122
|
+
|
|
123
|
+
# pixi
|
|
124
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
125
|
+
#pixi.lock
|
|
126
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
127
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
128
|
+
.pixi
|
|
129
|
+
|
|
130
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
131
|
+
__pypackages__/
|
|
132
|
+
|
|
133
|
+
# Celery stuff
|
|
134
|
+
celerybeat-schedule
|
|
135
|
+
celerybeat.pid
|
|
136
|
+
|
|
137
|
+
# SageMath parsed files
|
|
138
|
+
*.sage.py
|
|
139
|
+
|
|
140
|
+
# Environments
|
|
141
|
+
.env
|
|
142
|
+
.envrc
|
|
143
|
+
.venv
|
|
144
|
+
env/
|
|
145
|
+
venv/
|
|
146
|
+
ENV/
|
|
147
|
+
env.bak/
|
|
148
|
+
venv.bak/
|
|
149
|
+
|
|
150
|
+
# Spyder project settings
|
|
151
|
+
.spyderproject
|
|
152
|
+
.spyproject
|
|
153
|
+
|
|
154
|
+
# Rope project settings
|
|
155
|
+
.ropeproject
|
|
156
|
+
|
|
157
|
+
# mkdocs documentation
|
|
158
|
+
/site
|
|
159
|
+
|
|
160
|
+
# mypy
|
|
161
|
+
.mypy_cache/
|
|
162
|
+
.dmypy.json
|
|
163
|
+
dmypy.json
|
|
164
|
+
|
|
165
|
+
# Pyre type checker
|
|
166
|
+
.pyre/
|
|
167
|
+
|
|
168
|
+
# pytype static type analyzer
|
|
169
|
+
.pytype/
|
|
170
|
+
|
|
171
|
+
# Cython debug symbols
|
|
172
|
+
cython_debug/
|
|
173
|
+
|
|
174
|
+
# PyCharm
|
|
175
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
176
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
177
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
178
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
179
|
+
#.idea/
|
|
180
|
+
|
|
181
|
+
# Abstra
|
|
182
|
+
# Abstra is an AI-powered process automation framework.
|
|
183
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
184
|
+
# Learn more at https://abstra.io/docs
|
|
185
|
+
.abstra/
|
|
186
|
+
|
|
187
|
+
# Visual Studio Code
|
|
188
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
189
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
190
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
191
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
192
|
+
# .vscode/
|
|
193
|
+
|
|
194
|
+
# Ruff stuff:
|
|
195
|
+
.ruff_cache/
|
|
196
|
+
|
|
197
|
+
# PyPI configuration file
|
|
198
|
+
.pypirc
|
|
199
|
+
|
|
200
|
+
# Cursor
|
|
201
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
202
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
203
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
204
|
+
.cursorignore
|
|
205
|
+
.cursorindexingignore
|
|
206
|
+
|
|
207
|
+
# Marimo
|
|
208
|
+
marimo/_static/
|
|
209
|
+
marimo/_lsp/
|
|
210
|
+
__marimo__/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"name": "agent-lint validate",
|
|
6
|
+
"type": "debugpy",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"module": "agent_lint.cli",
|
|
9
|
+
"args": ["validate", "http://localhost:8080"],
|
|
10
|
+
"console": "integratedTerminal",
|
|
11
|
+
"justMyCode": true
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-lint-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Quality and security platform for AI agents. Validate MCP servers, scan for vulnerabilities, ship reliable agents.
|
|
5
|
+
Project-URL: Homepage, https://github.com/agent-lint/agent-lint
|
|
6
|
+
Project-URL: Issues, https://github.com/agent-lint/agent-lint/issues
|
|
7
|
+
Author: agent-lint contributors
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Keywords: agents,ai,lint,mcp,security,validation
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Security
|
|
18
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: click>=8.0
|
|
21
|
+
Requires-Dist: httpx>=0.27
|
|
22
|
+
Requires-Dist: pydantic>=2.0
|
|
23
|
+
Requires-Dist: rich>=13.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: respx>=0.22; extra == 'dev'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# agent-lint
|
|
31
|
+
|
|
32
|
+
Quality and security platform for AI agents. Validate MCP servers, scan for vulnerabilities, ship reliable agents.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install agent-lint
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
agent-lint validate https://my-mcp-server.com
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Options
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
--format, -f Output format: console, json, sarif (default: console)
|
|
50
|
+
--fail-under Fail if score below threshold (0-100)
|
|
51
|
+
--fail-on-security Fail if any security issues found
|
|
52
|
+
--security-level strict, standard, or permissive (default: standard)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### CI/CD Integration
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Exit non-zero on security issues
|
|
59
|
+
agent-lint validate https://my-server.com --fail-on-security
|
|
60
|
+
|
|
61
|
+
# Require minimum score
|
|
62
|
+
agent-lint validate https://my-server.com --fail-under 80
|
|
63
|
+
|
|
64
|
+
# SARIF output for GitHub Security tab
|
|
65
|
+
agent-lint validate https://my-server.com -f sarif > results.sarif
|
|
66
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# agent-lint
|
|
2
|
+
|
|
3
|
+
Quality and security platform for AI agents. Validate MCP servers, scan for vulnerabilities, ship reliable agents.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install agent-lint
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
agent-lint validate https://my-mcp-server.com
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Options
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
--format, -f Output format: console, json, sarif (default: console)
|
|
21
|
+
--fail-under Fail if score below threshold (0-100)
|
|
22
|
+
--fail-on-security Fail if any security issues found
|
|
23
|
+
--security-level strict, standard, or permissive (default: standard)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### CI/CD Integration
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Exit non-zero on security issues
|
|
30
|
+
agent-lint validate https://my-server.com --fail-on-security
|
|
31
|
+
|
|
32
|
+
# Require minimum score
|
|
33
|
+
agent-lint validate https://my-server.com --fail-under 80
|
|
34
|
+
|
|
35
|
+
# SARIF output for GitHub Security tab
|
|
36
|
+
agent-lint validate https://my-server.com -f sarif > results.sarif
|
|
37
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agent-lint-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Quality and security platform for AI agents. Validate MCP servers, scan for vulnerabilities, ship reliable agents."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "agent-lint contributors" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["mcp", "ai", "agents", "security", "validation", "lint"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
25
|
+
"Topic :: Security",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"click>=8.0",
|
|
29
|
+
"httpx>=0.27",
|
|
30
|
+
"pydantic>=2.0",
|
|
31
|
+
"rich>=13.0",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
dev = [
|
|
36
|
+
"pytest>=8.0",
|
|
37
|
+
"pytest-asyncio>=0.23",
|
|
38
|
+
"respx>=0.22",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.scripts]
|
|
42
|
+
agent-lint = "agent_lint.cli:cli"
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://github.com/agent-lint/agent-lint"
|
|
46
|
+
Issues = "https://github.com/agent-lint/agent-lint/issues"
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/agent_lint"]
|
|
50
|
+
|
|
51
|
+
[tool.pytest.ini_options]
|
|
52
|
+
asyncio_mode = "auto"
|
|
53
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""CLI entry point for agent-lint."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
|
|
9
|
+
from agent_lint import __version__
|
|
10
|
+
from agent_lint.core.reporter import ConsoleReporter, JsonReporter, SarifReporter
|
|
11
|
+
from agent_lint.protocols.mcp.validator import MCPValidator
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@click.group()
|
|
15
|
+
@click.version_option(version=__version__)
|
|
16
|
+
def cli() -> None:
|
|
17
|
+
"""agent-lint: Quality and security tools for AI agents."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@cli.command()
|
|
21
|
+
@click.argument("url")
|
|
22
|
+
@click.option(
|
|
23
|
+
"--format", "-f",
|
|
24
|
+
"output_format",
|
|
25
|
+
type=click.Choice(["console", "json", "sarif"]),
|
|
26
|
+
default="console",
|
|
27
|
+
help="Output format",
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--fail-under",
|
|
31
|
+
type=int,
|
|
32
|
+
default=0,
|
|
33
|
+
help="Fail if overall score is below this threshold (0-100)",
|
|
34
|
+
)
|
|
35
|
+
@click.option(
|
|
36
|
+
"--fail-on-security",
|
|
37
|
+
is_flag=True,
|
|
38
|
+
help="Exit with error if any security issues are found",
|
|
39
|
+
)
|
|
40
|
+
@click.option(
|
|
41
|
+
"--security-level",
|
|
42
|
+
type=click.Choice(["strict", "standard", "permissive", "none"]),
|
|
43
|
+
default="standard",
|
|
44
|
+
help="Security check strictness level",
|
|
45
|
+
)
|
|
46
|
+
def validate(
|
|
47
|
+
url: str,
|
|
48
|
+
output_format: str,
|
|
49
|
+
fail_under: int,
|
|
50
|
+
fail_on_security: bool,
|
|
51
|
+
security_level: str,
|
|
52
|
+
) -> None:
|
|
53
|
+
"""Validate an MCP server for quality and security issues."""
|
|
54
|
+
validator = MCPValidator(security_level=security_level)
|
|
55
|
+
report = asyncio.run(validator.validate(url))
|
|
56
|
+
|
|
57
|
+
reporters = {
|
|
58
|
+
"console": ConsoleReporter(),
|
|
59
|
+
"json": JsonReporter(),
|
|
60
|
+
"sarif": SarifReporter(),
|
|
61
|
+
}
|
|
62
|
+
reporters[output_format].output(report)
|
|
63
|
+
|
|
64
|
+
if fail_on_security and report.has_security_issues:
|
|
65
|
+
raise SystemExit(1)
|
|
66
|
+
if report.score < fail_under:
|
|
67
|
+
raise SystemExit(1)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
cli()
|
|
File without changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Core check result types and validation report."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from enum import Enum
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Severity(Enum):
|
|
10
|
+
CRITICAL = "critical"
|
|
11
|
+
HIGH = "high"
|
|
12
|
+
MEDIUM = "medium"
|
|
13
|
+
LOW = "low"
|
|
14
|
+
INFO = "info"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass
|
|
18
|
+
class CheckResult:
|
|
19
|
+
name: str
|
|
20
|
+
passed: bool
|
|
21
|
+
message: str
|
|
22
|
+
severity: Severity
|
|
23
|
+
category: str # "security", "quality", "performance", "schema"
|
|
24
|
+
recommendation: str | None = None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass
|
|
28
|
+
class ValidationReport:
|
|
29
|
+
"""Aggregated results from all validation checks."""
|
|
30
|
+
|
|
31
|
+
server_url: str
|
|
32
|
+
results: list[CheckResult] = field(default_factory=list)
|
|
33
|
+
|
|
34
|
+
def add(self, result: CheckResult) -> None:
|
|
35
|
+
self.results.append(result)
|
|
36
|
+
|
|
37
|
+
def add_all(self, results: list[CheckResult]) -> None:
|
|
38
|
+
self.results.extend(results)
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def passed(self) -> list[CheckResult]:
|
|
42
|
+
return [r for r in self.results if r.passed]
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def failed(self) -> list[CheckResult]:
|
|
46
|
+
return [r for r in self.results if not r.passed]
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def has_security_issues(self) -> bool:
|
|
50
|
+
return any(r.category == "security" and not r.passed for r in self.results)
|
|
51
|
+
|
|
52
|
+
def _category_score(self, category: str) -> int:
|
|
53
|
+
"""Score for a category as percentage of passed checks (0-100)."""
|
|
54
|
+
cat_results = [r for r in self.results if r.category == category]
|
|
55
|
+
if not cat_results:
|
|
56
|
+
return 100
|
|
57
|
+
passed = sum(1 for r in cat_results if r.passed)
|
|
58
|
+
return int(passed / len(cat_results) * 100)
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def security_score(self) -> int:
|
|
62
|
+
return self._category_score("security")
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def quality_score(self) -> int:
|
|
66
|
+
return self._category_score("quality")
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def score(self) -> int:
|
|
70
|
+
"""Overall score: weighted average of all categories."""
|
|
71
|
+
categories = {r.category for r in self.results}
|
|
72
|
+
if not categories:
|
|
73
|
+
return 100
|
|
74
|
+
scores = [self._category_score(c) for c in categories]
|
|
75
|
+
return int(sum(scores) / len(scores))
|