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
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release

# Runs only when someone publishes a GitHub release. PyPI trusts this workflow
# (trusted publishing), so there is no token to store.
on:
release:
types: [published]

permissions:
contents: read

concurrency:
group: release-${{ github.event.release.tag_name }}
cancel-in-progress: false

env:
UV_VERSION: "0.13.10"

jobs:
build:
name: Check and build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version: ${{ env.UV_VERSION }}
python-version: "3.13"
enable-cache: false
- name: Check that the release is on main and carries its version
shell: bash
env:
TAG: ${{ github.event.release.tag_name }}
run: |
git merge-base --is-ancestor "$GITHUB_SHA" origin/main ||
{ echo "::error::the tagged commit is not on main"; exit 1; }
version=$(uv version --short)
[ "$TAG" = "v$version" ] ||
{ echo "::error::tag $TAG does not match version $version"; exit 1; }
grep -qE "^## ${version//./[.]}( |$)" CHANGELOG.md ||
{ echo "::error::CHANGELOG.md has no section for $version"; exit 1; }
- run: uv sync --locked
- run: uv run --no-sync ruff check .
- run: uv run --no-sync mypy
- run: uv run --no-sync pytest
- run: uv build
- run: uv run --no-sync twine check --strict dist/*
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
if-no-files-found: error

publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: pypi
url: https://pypi.org/p/vulnradar
permissions:
id-token: write # proves to PyPI which workflow is publishing
steps:
# Nothing from the repository runs in this job, which can publish.
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
154 changes: 49 additions & 105 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,118 +7,62 @@ dates on PyPI (UTC).

## Unreleased

### Added
## 3.0.0b1

- The package ships `py.typed`, so type checkers use its annotations.
- `VULNRADAR_TOKEN` and `VULNRADAR_API_BASE` are used when `api_key` or
`base_url` is not given.
- `NetworkError`, `RequestTimeoutError`, `UnexpectedResponseError` and
`RateLimitKind`. `RateLimitInfo` is exported.
- Errors carry `code`, `request_id`, `retry_after` and `body`, and a
`RateLimitError` says which limit was reached in `kind`.
- `client.scans` starts scans and crawls, reports their progress, waits for them
and cancels them, with `ScanJob`, `ScanStatus`, `ScanState` and `ScanOptions`.
- `ScanFailedError` and `ScanTimeoutError`. An error raised while waiting names
the scan in `scan_id`.
- Scan options: `public`, `capture_screenshot`, `port_scan` and `team_ids`.
- `Scanner` lists the scanner names.
- Results keep the server's whole reply in `raw`, and have `public_id`,
`incomplete` and `tags`. Findings have their category, evidence, fix steps,
`suppressed` and `remediation_status` among other details.
- History can be searched, paged and iterated, and scans changed, deleted all at
once or downloaded as reports: `history.iterate()`, `update()`,
`delete_all()` and `report()`, with `ScanSettings`, `Report` and
`ReportFormat`.
- `client.me()` returns the `Account` behind the key, and
`metadata.plan_limits()` the published plan limits.
- Bulk and signed-in scans (`scans.bulk()`, `scans.authenticated()`), AI review
(`scans.verify()`, `verify_batch()`, `history.summary()`), subdomain search
(`discovery.subdomains()`, `subdomain_progress()`), `reputation()`,
`demo_scan()` and `verify_webhook()`.
- `incomplete` holds `authenticated-session` when a login was lost.
- `NoResultError` for a stored scan that is still running or failed, raised by
`history.get()` and `history.report()`. A `Report` says what the scan did not
check in `incomplete`.
A rebuild for version 3 of the API. No earlier release works with the current service.
It has been tested against the server's source code, not yet against a live server.

### Changed
### Upgrading from 2.0.0b2

- The client calls the v3 API. `scan()` and `scan_crawl()` wait for the
background scan to finish, for 960 seconds unless `timeout` says otherwise.
- Scanner names are checked before a scan is sent.
- `ScanResult.duration` is now `duration_ms`, in milliseconds, and
`scanned_at` is `None` when the server gives no time.
- `CrawlResult` is a `ScanResult` with `pages`, `pages_discovered`,
`pages_scanned`, `pages_skipped` and `pages_unreachable`.
- `CrawlPage.duration` is now `duration_ms`, and `ScanResult`, `Finding` and
`CrawlPage` take different constructor arguments.
- `incomplete` also holds `page-checks` when checks failed to run, and
`crawl-pages-not-scanned` when a crawl left pages out, for servers that do not
say so themselves.
- Summary counts that are not numbers are an error.
- `history.list()` takes keyword arguments and returns `total`, `matched`,
`limit`, `offset` and `truncated` beside the scans.
- `HistoryScan.id` is the text id, `duration` is `duration_ms`, `tags` are
names, `scanned_at` may be `None`, and `summary` and `findings_count` are
`None` without a result. `notes` is gone: the list does not send it.
- `history.get()` returns a `CrawlResult` for a crawl.
- `FindingTypesResult` has `categories` instead of `version`, and
`FindingType` has `description`, cannot be changed and compares all its fields.
- `VersionInfo.latest` and `engine` may be `None`, `status` is `unknown` when
missing, and it also has `release_url`, `api` and `raw`.
- `HistoryList` and `FindingTypesResult` have no default values, and a delete
reply must say `true` or `false`.
- An unfamiliar severity is `Severity.UNKNOWN`, not `info`.
- Targets without a scheme, with punycode or underscore host names, or using any
scheme the server knows are no longer rejected.
- `retries` counts the attempts after the first, with a default of 2, and only
reads are retried.
- `discover_urls()` adds `https://` to an address without a scheme.
- A web page in reply raises `UnexpectedResponseError`, not
`AuthenticationError`.
- A reply without the fields a result needs raises `UnexpectedResponseError`
instead of giving an empty result.
- Rate limit figures the server did not send are `None`, not zero.
- A missing or unusable key, address or number raises `ValueError` when the
client is created. `base_url` must include the API path.
- `history.get()` and `history.delete()` raise `ValueError` for an id holding
anything but letters, digits, `_` and `-`.
- `timeout` may be a fraction of a second.
- Python 3.11 or newer is required.
- `requests` 2.33.0 or newer is required, which leaves out PYSEC-2026-2275.
- `Severity` is a `StrEnum`: `str()` and f-strings now give the value, such as
`high`.
- `__version__` is read from the installed package, and is `unknown` when the
source is used without being installed.
- The README now says that no published release works with the current API.

### Removed

- `Finding.type`, which the server never sends, and `Finding.remediation`; use
`fix_steps` and `remediation_status`.
- `CrawlInfo`, `CrawlResult.crawl` and `CrawlPage.response_headers`.
- `vulnradar.utils.parse_rate_limit_headers`, and the `VERSION_URL` and
`RATE_LIMIT_*_HEADER` constants.

### Fixed

- `vulnradar.__version__` reports the same version as the package metadata.
- Network failures, unreadable replies and odd rate limit headers raise SDK
errors instead of other exceptions.
- The version address keeps the path prefix of a self-hosted `base_url`.
- `history.get()` sets `scan_history_id`, and a cut-short crawl read from
history is marked incomplete.
- `history.list()` reads the server's replies, and finding types are no longer
equal just because one field matches.
- `scan()` and `scan_crawl()` wait for the background scan to finish, for 960 seconds
unless `timeout` says otherwise, and take options such as `public` and `team_ids`.
- `ScanResult.duration` is `duration_ms` in milliseconds, and `scanned_at` may be `None`.
- `Finding.type` and `Finding.remediation` are gone: use `fix_steps` and
`remediation_status`. An unfamiliar severity is `Severity.UNKNOWN`, not `info`.
- `CrawlResult` is a `ScanResult` with `pages`, `pages_discovered`, `pages_scanned`,
`pages_skipped` and `pages_unreachable`. `CrawlInfo`, `CrawlResult.crawl` and
`CrawlPage.response_headers` are gone; `CrawlPage.duration` is `duration_ms`.
- `history.list()` takes keyword arguments and returns `total`, `matched`, `limit`,
`offset` and `truncated`. `HistoryScan.id` is the text id, `tags` are names,
`summary` and `findings_count` are `None` without a result, and `notes` is gone.
- `history.get()` returns a `CrawlResult` for a crawl.
- `FindingTypesResult` has `categories` instead of `version`. `FindingType` cannot be
changed and compares all its fields.
- `VersionInfo.latest` and `engine` may be `None`.
- `retries` counts the attempts after the first (default 2), and only reads are retried.
- Failures raise errors where an empty or partial result came back before: unreadable
replies, a web page (`UnexpectedResponseError`), a missing key or bad setting
(`ValueError`), and a scan id with characters an address could be changed by.
- `base_url` must include the API path. `Severity` is a `StrEnum`.
- Result classes take different constructor arguments, and rate limit figures the
server did not send are `None`.
- `vulnradar.utils.parse_rate_limit_headers` and the `VERSION_URL` and
`RATE_LIMIT_*_HEADER` constants are gone.

### Added

- `client.scans` to start, follow, wait for and cancel scans and crawls, to queue many
(`bulk()`), to scan while signed in (`authenticated()`) and to have findings
reviewed by the server's AI.
- History search, paging and `iterate()`, `update()`, `delete_all()`, `report()` and
`summary()`.
- `client.me()`, `reputation()`, `demo_scan()`, `discovery.subdomains()`,
`metadata.plan_limits()` and `verify_webhook()`.
- `incomplete` on results names what was not checked, including cases older servers
do not report themselves.
- Errors for network failures, unreadable replies, failed and unfinished scans, with
the server's code, request id, `Retry-After` and which rate limit was reached.
- `VULNRADAR_TOKEN` and `VULNRADAR_API_BASE`, `py.typed`, and the whole server reply
in `raw`.

### Security

- A request that starts or deletes something is never sent twice.
- `base_url` must use `https`, except for this computer, and a plain `http`
request never goes through a proxy.
- Redirects are not followed.
- The key is not shown when the client's settings are printed, and a `.netrc`
entry cannot replace it.
- A scan id cannot change the address of a request.
- A request that starts, changes or deletes something is sent once.
- The key goes only to the configured address: `https` except for this computer, no
redirects, no proxy for plain `http`, and no `.netrc` override. It does not appear in
printed settings or network errors.
- `requests` 2.33.0 or newer, which leaves out PYSEC-2026-2275.

## 2.0.0b2 - 2026-03-16

Expand Down
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing

## Setup and checks

Development uses [uv](https://docs.astral.sh/uv/) and Python 3.11 or newer. Create a
branch, and before opening a pull request run:

```bash
uv sync
uv run ruff check .
uv run ruff format --check .
uv run mypy
uv run pytest
```

Commits follow [Conventional Commits](https://www.conventionalcommits.org/). Add a line
to `CHANGELOG.md` for anything a user would notice.

## How the code is laid out

| Path | What it holds |
|---|---|
| `vulnradar/client.py` | The `VulnRadar` class, the entry point |
| `vulnradar/services/` | One class per group of API calls |
| `vulnradar/models/` | Replies turned into objects |
| `vulnradar/http.py` | The only code that sends requests: key, retries, errors |
| `vulnradar/replies.py` | Turns an unreadable reply into an error |
| `vulnradar/webhooks.py` | Webhook signature check |
| `tests/` | Offline tests; `tests/samples.py` holds server replies |

Two rules matter more than the rest:

- A scan that is unfinished, failed or only partly checked must never look clean. Raise,
or name what is missing in `incomplete`.
- A request that starts, changes or deletes something is sent once, and the key goes only
to the configured address.

The server's source is [VulnRadar/vulnradar.dev](https://github.com/VulnRadar/vulnradar.dev).
Write test replies from its routes, not from what the SDK expects.

## Live tests

`tests/live` calls a real server, spends scan quota and deletes the scans it creates.
Run it only on purpose, against a site you may scan, with a key in `VULNRADAR_TOKEN`:

```bash
uv run pytest -m live
```

`VULNRADAR_API_BASE` points it at another server and `VULNRADAR_TEST_URL` changes the
target. Crawls need several scans of quota.

## Releasing

Once, before the first release:

- In the repository settings, give the `pypi` environment a required reviewer and allow
deployments from tags matching `v*` only, and add a tag ruleset so that only
maintainers can create such tags. This is required: the checks in the workflow come from
the tagged commit, so only these settings stop someone with write access from releasing
other code.
- On PyPI, an owner of the `vulnradar` project adds a trusted publisher: GitHub owner
`VulnRadar`, repository `Python-SDK`, workflow `release.yml`, environment `pypi`.

For each release:

1. In one pull request, set `version` in `pyproject.toml`, run `uv lock`, and give the
version its section in `CHANGELOG.md`.
2. Run the live tests.
3. After merging, publish a GitHub release from `main`. The tag is `v` plus the version,
the title is the same, and the body is that changelog section. Mark betas as
pre-releases.

```bash
gh release create v3.0.0b1 --target main --title v3.0.0b1 --notes-file notes.md --prerelease
```

Publishing the release builds, checks and uploads the package.

To roll back, yank the version on PyPI (the files stay, but `pip` stops choosing it) and
release a fixed one. A version number cannot be used twice.
Loading