vulnotes 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.
- vulnotes-0.1.0/.github/workflows/ci.yml +22 -0
- vulnotes-0.1.0/.github/workflows/publish.yml +21 -0
- vulnotes-0.1.0/.gitignore +12 -0
- vulnotes-0.1.0/LICENSE +21 -0
- vulnotes-0.1.0/PKG-INFO +166 -0
- vulnotes-0.1.0/README.md +115 -0
- vulnotes-0.1.0/examples/export_report.py +33 -0
- vulnotes-0.1.0/examples/import_scanner_findings.py +46 -0
- vulnotes-0.1.0/pyproject.toml +53 -0
- vulnotes-0.1.0/src/vulnotes/__init__.py +42 -0
- vulnotes-0.1.0/src/vulnotes/_utils.py +65 -0
- vulnotes-0.1.0/src/vulnotes/_version.py +1 -0
- vulnotes-0.1.0/src/vulnotes/client.py +228 -0
- vulnotes-0.1.0/src/vulnotes/exceptions.py +122 -0
- vulnotes-0.1.0/src/vulnotes/resources/__init__.py +31 -0
- vulnotes-0.1.0/src/vulnotes/resources/_base.py +67 -0
- vulnotes-0.1.0/src/vulnotes/resources/ai.py +110 -0
- vulnotes-0.1.0/src/vulnotes/resources/api_keys.py +17 -0
- vulnotes-0.1.0/src/vulnotes/resources/attachments.py +75 -0
- vulnotes-0.1.0/src/vulnotes/resources/comments.py +98 -0
- vulnotes-0.1.0/src/vulnotes/resources/companies.py +77 -0
- vulnotes-0.1.0/src/vulnotes/resources/findings.py +62 -0
- vulnotes-0.1.0/src/vulnotes/resources/images.py +85 -0
- vulnotes-0.1.0/src/vulnotes/resources/notes.py +71 -0
- vulnotes-0.1.0/src/vulnotes/resources/planning.py +210 -0
- vulnotes-0.1.0/src/vulnotes/resources/report_templates.py +52 -0
- vulnotes-0.1.0/src/vulnotes/resources/reports.py +293 -0
- vulnotes-0.1.0/src/vulnotes/resources/snapshots.py +35 -0
- vulnotes-0.1.0/src/vulnotes/resources/vulnerabilities.py +82 -0
- vulnotes-0.1.0/src/vulnotes/resources/vulnerability_templates.py +132 -0
- vulnotes-0.1.0/tests/conftest.py +71 -0
- vulnotes-0.1.0/tests/integration/test_live.py +440 -0
- vulnotes-0.1.0/tests/test_client.py +57 -0
- vulnotes-0.1.0/tests/test_errors.py +62 -0
- vulnotes-0.1.0/tests/test_pagination.py +52 -0
- vulnotes-0.1.0/tests/test_resources.py +203 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v5
|
|
17
|
+
- uses: actions/setup-python@v6
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- run: pip install -e ".[dev]"
|
|
21
|
+
- run: ruff check .
|
|
22
|
+
- run: pytest -q
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
id-token: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v5
|
|
16
|
+
- uses: actions/setup-python@v6
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- run: pip install build
|
|
20
|
+
- run: python -m build
|
|
21
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
vulnotes-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vulnotes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
vulnotes-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vulnotes
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the Vulnotes API
|
|
5
|
+
Project-URL: Homepage, https://vulnotes.com
|
|
6
|
+
Project-URL: Documentation, https://docs.vulnotes.com
|
|
7
|
+
Project-URL: Repository, https://github.com/vulnotes/vulnotes-python-sdk
|
|
8
|
+
Author: Vulnotes
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 Vulnotes
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Keywords: api,pentest,reporting,sdk,vulnerability,vulnotes
|
|
32
|
+
Classifier: Development Status :: 4 - Beta
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: Intended Audience :: Information Technology
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
43
|
+
Classifier: Topic :: Security
|
|
44
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
45
|
+
Requires-Python: >=3.9
|
|
46
|
+
Requires-Dist: requests>=2.28
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
49
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
|
|
52
|
+
# vulnotes-python-sdk
|
|
53
|
+
|
|
54
|
+
Python client for the [Vulnotes](https://vulnotes.com) REST API.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install vulnotes
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Needs Python 3.9 or later. The only dependency is `requests`.
|
|
61
|
+
|
|
62
|
+
## Getting started
|
|
63
|
+
|
|
64
|
+
Create an API key in Vulnotes under Settings > API Keys, then:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from vulnotes import VulnotesClient
|
|
68
|
+
|
|
69
|
+
client = VulnotesClient("https://acme.vulnotes.app", api_key="vuln_sk_...")
|
|
70
|
+
|
|
71
|
+
report = client.reports.create("External pentest Q3", language="EN")
|
|
72
|
+
|
|
73
|
+
client.findings.add(report["_id"], {
|
|
74
|
+
"title": "SQL Injection in /login",
|
|
75
|
+
"severity": "Critical",
|
|
76
|
+
"cvss": {"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"},
|
|
77
|
+
"data": {"EN": {"title": "SQL Injection in /login", "description": "..."}},
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If `VULNOTES_URL` and `VULNOTES_API_KEY` are set in the environment you can just do `VulnotesClient()`.
|
|
82
|
+
|
|
83
|
+
Methods return plain dicts and lists matching the API's JSON. File exports return bytes. If you're wondering what a key is allowed to do, `client.api_keys.me()` tells you.
|
|
84
|
+
|
|
85
|
+
## What's covered
|
|
86
|
+
|
|
87
|
+
Everything reachable with an API key: reports and findings, companies, the vulnerability library, vulnerability templates, report templates, snapshots and review comments, notes, image/attachment uploads, exports (PDF, DOCX, XLSX, ZIP, JSON), the planning calendar, and the AI endpoints. Full endpoint reference: [docs.vulnotes.com](https://docs.vulnotes.com).
|
|
88
|
+
|
|
89
|
+
Anything not wrapped yet can still be called directly:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
client.request("GET", f"/reports/{report_id}/snapshots")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## A few common tasks
|
|
96
|
+
|
|
97
|
+
Iterating without dealing with pages:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
for report in client.reports.iter():
|
|
101
|
+
print(report["title"])
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Feeding scanner results into a report:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
for issue in results:
|
|
108
|
+
client.findings.add(report_id, {
|
|
109
|
+
"title": issue["name"],
|
|
110
|
+
"severity": issue["severity"],
|
|
111
|
+
"affectedSystems": issue["hosts"],
|
|
112
|
+
"data": {"EN": {"title": issue["name"], "description": issue["detail"]}},
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Downloading exports:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
client.reports.export_xlsx(report_id, finding_fields=["title", "severity"], path="findings.xlsx")
|
|
120
|
+
client.reports.archived_pdf(report_id, path="final.pdf") # PDF stored when the report was completed
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Uploading evidence:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
client.images.upload("screenshot.png", report_id=report_id)
|
|
127
|
+
client.attachments.upload("nmap-scan.xml", report_id=report_id)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Dates can be passed as ISO strings or as `datetime.date`/`datetime.datetime`.
|
|
131
|
+
|
|
132
|
+
## Errors
|
|
133
|
+
|
|
134
|
+
Everything raised by the SDK inherits from `vulnotes.VulnotesError`. HTTP errors map to subclasses (`NotFoundError`, `PermissionDeniedError`, `RateLimitError`, ...) with `status_code`, `message` and the parsed body attached.
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from vulnotes import NotFoundError
|
|
138
|
+
|
|
139
|
+
try:
|
|
140
|
+
client.reports.get(report_id)
|
|
141
|
+
except NotFoundError:
|
|
142
|
+
# doesn't exist, or the key's owner can't see it
|
|
143
|
+
...
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
A key that lacks the permission an endpoint needs gets a `PermissionDeniedError` naming it. Reports outside the owner's visibility raise `NotFoundError`, not 403; that's intentional on the server side.
|
|
147
|
+
|
|
148
|
+
Idempotent requests are retried automatically on connection errors and 429/502/503/504. Tune with `max_retries`, `timeout` and `verify_ssl` on the client.
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
pip install -e ".[dev]"
|
|
154
|
+
pytest # offline, no instance needed
|
|
155
|
+
ruff check .
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
There's also an integration suite that runs against a real instance. It creates its own fixtures and removes them, but point it at a disposable instance anyway:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
VULNOTES_TEST_URL=https://dev.example VULNOTES_TEST_API_KEY=vuln_sk_... pytest tests/integration
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|
vulnotes-0.1.0/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# vulnotes-python-sdk
|
|
2
|
+
|
|
3
|
+
Python client for the [Vulnotes](https://vulnotes.com) REST API.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install vulnotes
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Needs Python 3.9 or later. The only dependency is `requests`.
|
|
10
|
+
|
|
11
|
+
## Getting started
|
|
12
|
+
|
|
13
|
+
Create an API key in Vulnotes under Settings > API Keys, then:
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from vulnotes import VulnotesClient
|
|
17
|
+
|
|
18
|
+
client = VulnotesClient("https://acme.vulnotes.app", api_key="vuln_sk_...")
|
|
19
|
+
|
|
20
|
+
report = client.reports.create("External pentest Q3", language="EN")
|
|
21
|
+
|
|
22
|
+
client.findings.add(report["_id"], {
|
|
23
|
+
"title": "SQL Injection in /login",
|
|
24
|
+
"severity": "Critical",
|
|
25
|
+
"cvss": {"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"},
|
|
26
|
+
"data": {"EN": {"title": "SQL Injection in /login", "description": "..."}},
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If `VULNOTES_URL` and `VULNOTES_API_KEY` are set in the environment you can just do `VulnotesClient()`.
|
|
31
|
+
|
|
32
|
+
Methods return plain dicts and lists matching the API's JSON. File exports return bytes. If you're wondering what a key is allowed to do, `client.api_keys.me()` tells you.
|
|
33
|
+
|
|
34
|
+
## What's covered
|
|
35
|
+
|
|
36
|
+
Everything reachable with an API key: reports and findings, companies, the vulnerability library, vulnerability templates, report templates, snapshots and review comments, notes, image/attachment uploads, exports (PDF, DOCX, XLSX, ZIP, JSON), the planning calendar, and the AI endpoints. Full endpoint reference: [docs.vulnotes.com](https://docs.vulnotes.com).
|
|
37
|
+
|
|
38
|
+
Anything not wrapped yet can still be called directly:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
client.request("GET", f"/reports/{report_id}/snapshots")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## A few common tasks
|
|
45
|
+
|
|
46
|
+
Iterating without dealing with pages:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
for report in client.reports.iter():
|
|
50
|
+
print(report["title"])
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Feeding scanner results into a report:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
for issue in results:
|
|
57
|
+
client.findings.add(report_id, {
|
|
58
|
+
"title": issue["name"],
|
|
59
|
+
"severity": issue["severity"],
|
|
60
|
+
"affectedSystems": issue["hosts"],
|
|
61
|
+
"data": {"EN": {"title": issue["name"], "description": issue["detail"]}},
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Downloading exports:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
client.reports.export_xlsx(report_id, finding_fields=["title", "severity"], path="findings.xlsx")
|
|
69
|
+
client.reports.archived_pdf(report_id, path="final.pdf") # PDF stored when the report was completed
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Uploading evidence:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
client.images.upload("screenshot.png", report_id=report_id)
|
|
76
|
+
client.attachments.upload("nmap-scan.xml", report_id=report_id)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Dates can be passed as ISO strings or as `datetime.date`/`datetime.datetime`.
|
|
80
|
+
|
|
81
|
+
## Errors
|
|
82
|
+
|
|
83
|
+
Everything raised by the SDK inherits from `vulnotes.VulnotesError`. HTTP errors map to subclasses (`NotFoundError`, `PermissionDeniedError`, `RateLimitError`, ...) with `status_code`, `message` and the parsed body attached.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from vulnotes import NotFoundError
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
client.reports.get(report_id)
|
|
90
|
+
except NotFoundError:
|
|
91
|
+
# doesn't exist, or the key's owner can't see it
|
|
92
|
+
...
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
A key that lacks the permission an endpoint needs gets a `PermissionDeniedError` naming it. Reports outside the owner's visibility raise `NotFoundError`, not 403; that's intentional on the server side.
|
|
96
|
+
|
|
97
|
+
Idempotent requests are retried automatically on connection errors and 429/502/503/504. Tune with `max_retries`, `timeout` and `verify_ssl` on the client.
|
|
98
|
+
|
|
99
|
+
## Development
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pip install -e ".[dev]"
|
|
103
|
+
pytest # offline, no instance needed
|
|
104
|
+
ruff check .
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
There's also an integration suite that runs against a real instance. It creates its own fixtures and removes them, but point it at a disposable instance anyway:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
VULNOTES_TEST_URL=https://dev.example VULNOTES_TEST_API_KEY=vuln_sk_... pytest tests/integration
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Export a report as JSON and PDF.
|
|
2
|
+
|
|
3
|
+
Usage: python export_report.py <report_id>
|
|
4
|
+
Set VULNOTES_URL and VULNOTES_API_KEY first (the key needs ro:reports).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
from vulnotes import NotFoundError, VulnotesClient
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main(report_id: str) -> None:
|
|
14
|
+
client = VulnotesClient()
|
|
15
|
+
|
|
16
|
+
export = client.reports.export_json(report_id)
|
|
17
|
+
with open(f"report-{report_id}.json", "w") as fh:
|
|
18
|
+
json.dump(export, fh, indent=2)
|
|
19
|
+
print(f"Wrote report-{report_id}.json")
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
# PDF archived when the report was marked completed (pixel-perfect)
|
|
23
|
+
client.reports.archived_pdf(report_id, path=f"report-{report_id}.pdf")
|
|
24
|
+
except NotFoundError:
|
|
25
|
+
# Not completed yet: fall back to server-side rendering
|
|
26
|
+
client.reports.export_pdf(report_id, path=f"report-{report_id}.pdf")
|
|
27
|
+
print(f"Wrote report-{report_id}.pdf")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if __name__ == "__main__":
|
|
31
|
+
if len(sys.argv) != 2:
|
|
32
|
+
sys.exit(__doc__)
|
|
33
|
+
main(sys.argv[1])
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Create a report and push scanner findings into it.
|
|
2
|
+
|
|
3
|
+
Set VULNOTES_URL and VULNOTES_API_KEY before running (the key needs
|
|
4
|
+
rw:reports and, to link a company, ro:clients).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from vulnotes import VulnotesClient
|
|
8
|
+
|
|
9
|
+
# Pretend output of a scanner
|
|
10
|
+
SCANNER_RESULTS = [
|
|
11
|
+
{
|
|
12
|
+
"name": "Outdated OpenSSH (9.0p1)",
|
|
13
|
+
"severity": "Medium",
|
|
14
|
+
"hosts": ["203.0.113.10"],
|
|
15
|
+
"detail": "The SSH service reports an outdated version with known CVEs.",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "TLS certificate expired",
|
|
19
|
+
"severity": "Low",
|
|
20
|
+
"hosts": ["203.0.113.12"],
|
|
21
|
+
"detail": "The certificate served on port 443 expired 42 days ago.",
|
|
22
|
+
},
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def main() -> None:
|
|
27
|
+
client = VulnotesClient()
|
|
28
|
+
|
|
29
|
+
report = client.reports.create("Perimeter scan import", language="EN")
|
|
30
|
+
print(f"Created report {report['_id']}")
|
|
31
|
+
|
|
32
|
+
for issue in SCANNER_RESULTS:
|
|
33
|
+
finding = client.findings.add(
|
|
34
|
+
report["_id"],
|
|
35
|
+
{
|
|
36
|
+
"title": issue["name"],
|
|
37
|
+
"severity": issue["severity"],
|
|
38
|
+
"affectedSystems": issue["hosts"],
|
|
39
|
+
"data": {"EN": {"title": issue["name"], "description": issue["detail"]}},
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
print(f" added finding {finding['id']}: {issue['name']}")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
main()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vulnotes"
|
|
7
|
+
description = "Official Python SDK for the Vulnotes API"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = { file = "LICENSE" }
|
|
10
|
+
authors = [{ name = "Vulnotes" }]
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
dependencies = ["requests>=2.28"]
|
|
13
|
+
dynamic = ["version"]
|
|
14
|
+
keywords = ["vulnotes", "pentest", "vulnerability", "reporting", "api", "sdk"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Information Technology",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Topic :: Security",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://vulnotes.com"
|
|
33
|
+
Documentation = "https://docs.vulnotes.com"
|
|
34
|
+
Repository = "https://github.com/vulnotes/vulnotes-python-sdk"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = ["pytest>=7", "ruff>=0.4"]
|
|
38
|
+
|
|
39
|
+
[tool.hatch.version]
|
|
40
|
+
path = "src/vulnotes/_version.py"
|
|
41
|
+
|
|
42
|
+
[tool.hatch.build.targets.wheel]
|
|
43
|
+
packages = ["src/vulnotes"]
|
|
44
|
+
|
|
45
|
+
[tool.pytest.ini_options]
|
|
46
|
+
testpaths = ["tests"]
|
|
47
|
+
|
|
48
|
+
[tool.ruff]
|
|
49
|
+
line-length = 100
|
|
50
|
+
target-version = "py39"
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint]
|
|
53
|
+
select = ["E", "F", "W", "I", "UP", "B"]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Official Python SDK for the Vulnotes API.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
>>> from vulnotes import VulnotesClient
|
|
5
|
+
>>> client = VulnotesClient("https://acme.vulnotes.app", api_key="...")
|
|
6
|
+
>>> report = client.reports.create("External pentest Q3")
|
|
7
|
+
>>> client.findings.add(report["_id"], {"title": "Open SSH port"})
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from ._version import __version__
|
|
11
|
+
from .client import VulnotesClient
|
|
12
|
+
from .exceptions import (
|
|
13
|
+
APIConnectionError,
|
|
14
|
+
APIStatusError,
|
|
15
|
+
APITimeoutError,
|
|
16
|
+
AuthenticationError,
|
|
17
|
+
BadRequestError,
|
|
18
|
+
ConflictError,
|
|
19
|
+
NotFoundError,
|
|
20
|
+
PermissionDeniedError,
|
|
21
|
+
RateLimitError,
|
|
22
|
+
ServerError,
|
|
23
|
+
UnprocessableEntityError,
|
|
24
|
+
VulnotesError,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"__version__",
|
|
29
|
+
"VulnotesClient",
|
|
30
|
+
"VulnotesError",
|
|
31
|
+
"APIConnectionError",
|
|
32
|
+
"APITimeoutError",
|
|
33
|
+
"APIStatusError",
|
|
34
|
+
"BadRequestError",
|
|
35
|
+
"AuthenticationError",
|
|
36
|
+
"PermissionDeniedError",
|
|
37
|
+
"NotFoundError",
|
|
38
|
+
"ConflictError",
|
|
39
|
+
"UnprocessableEntityError",
|
|
40
|
+
"RateLimitError",
|
|
41
|
+
"ServerError",
|
|
42
|
+
]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Internal helpers shared by the resource modules."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime as _dt
|
|
6
|
+
import io
|
|
7
|
+
import mimetypes
|
|
8
|
+
import os
|
|
9
|
+
from typing import Any, Union
|
|
10
|
+
|
|
11
|
+
# A file argument may be a filesystem path, raw bytes, an open file object,
|
|
12
|
+
# or a (filename, fileobj_or_bytes) / (filename, fileobj_or_bytes, content_type) tuple.
|
|
13
|
+
FileTypes = Union[str, "os.PathLike[str]", bytes, io.IOBase, tuple]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def omit_none(mapping: dict[str, Any]) -> dict[str, Any]:
|
|
17
|
+
"""Drop keys whose value is ``None`` (the API treats absent fields as unchanged)."""
|
|
18
|
+
return {k: v for k, v in mapping.items() if v is not None}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def iso(value: str | _dt.date | _dt.datetime | None) -> str | None:
|
|
22
|
+
"""Convert a date/datetime to an ISO-8601 string; pass strings and None through."""
|
|
23
|
+
if value is None or isinstance(value, str):
|
|
24
|
+
return value
|
|
25
|
+
if isinstance(value, _dt.datetime):
|
|
26
|
+
return value.isoformat()
|
|
27
|
+
if isinstance(value, _dt.date):
|
|
28
|
+
return value.isoformat()
|
|
29
|
+
raise TypeError(f"expected str, date or datetime, got {type(value).__name__}")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _with_content_type(filename: str, payload: Any) -> tuple:
|
|
33
|
+
"""Attach a guessed Content-Type so server-side upload filters (which
|
|
34
|
+
check the part's MIME type, not the filename) accept the file."""
|
|
35
|
+
content_type = mimetypes.guess_type(filename)[0]
|
|
36
|
+
if content_type:
|
|
37
|
+
return (filename, payload, content_type)
|
|
38
|
+
return (filename, payload)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def prepare_file(file: FileTypes, default_name: str = "upload") -> tuple:
|
|
42
|
+
"""Normalize a user-supplied file argument into a (filename, payload[, type]) tuple
|
|
43
|
+
suitable for the ``files=`` parameter of requests."""
|
|
44
|
+
if isinstance(file, tuple):
|
|
45
|
+
if len(file) == 2:
|
|
46
|
+
return _with_content_type(file[0], file[1])
|
|
47
|
+
return file # already (filename, fileobj, content_type)
|
|
48
|
+
if isinstance(file, bytes):
|
|
49
|
+
return _with_content_type(default_name, file)
|
|
50
|
+
if isinstance(file, (str, os.PathLike)):
|
|
51
|
+
path = os.fspath(file)
|
|
52
|
+
return _with_content_type(os.path.basename(path), open(path, "rb"))
|
|
53
|
+
# file-like object
|
|
54
|
+
name = getattr(file, "name", None)
|
|
55
|
+
if isinstance(name, str) and name and not name.startswith("<"):
|
|
56
|
+
return _with_content_type(os.path.basename(name), file)
|
|
57
|
+
return _with_content_type(default_name, file)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def write_bytes(content: bytes, path: str | os.PathLike[str]) -> str:
|
|
61
|
+
"""Write binary content to *path* and return the path as a string."""
|
|
62
|
+
path = os.fspath(path)
|
|
63
|
+
with open(path, "wb") as fh:
|
|
64
|
+
fh.write(content)
|
|
65
|
+
return path
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|