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
45 changes: 45 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Every update waits at least three days after its release before it is
# proposed, so a bad release that is pulled quickly never reaches a pull request.
version: 2
updates:
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
cooldown:
# One day more than the lockfile's three, so a proposed release is always
# old enough to be locked.
default-days: 4
commit-message:
prefix: "build"
include: "scope"
groups:
python-minor-and-patch:
patterns: ["*"]
update-types: ["minor", "patch"]

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
cooldown:
default-days: 3
commit-message:
prefix: "ci"
include: "scope"
groups:
actions:
patterns: ["*"]

- package-ecosystem: "docker"
directory: "/.github/tools"
schedule:
interval: "weekly"
day: "monday"
cooldown:
default-days: 3
commit-message:
prefix: "ci"
include: "scope"
3 changes: 3 additions & 0 deletions .github/tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pinned tools for the workflows, kept current by Dependabot's docker updates.
# Build one with: docker build --target <name> -t <name> .github/tools
FROM ghcr.io/gitleaks/gitleaks:v8.30.1@sha256:c00b6bd0aeb3071cbcb79009cb16a60dd9e0a7c60e2be9ab65d25e6bc8abbb7f AS gitleaks
163 changes: 163 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: CI

on:
push:
branches: [main]
pull_request:
schedule:
# Mondays: catches new advisories and breakage in a quiet repository.
- cron: "17 12 * * 1"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
UV_VERSION: "0.13.10"

jobs:
lint:
name: Lint and types
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version: ${{ env.UV_VERSION }}
python-version: "3.13"
- run: uv sync --locked
- run: uv run --no-sync ruff check --output-format github .
- run: uv run --no-sync ruff format --check .
- run: uv run --no-sync mypy

test:
name: Tests (Python ${{ matrix.python }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.11", "3.12", "3.13", "3.14"]
include:
- os: windows-latest
python: "3.13"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version: ${{ env.UV_VERSION }}
python-version: ${{ matrix.python }}
- run: uv sync --locked
# The live tests are deselected by default and no token is provided.
- run: uv run --no-sync pytest --cov --cov-report=term

build:
name: Build and install
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version: ${{ env.UV_VERSION }}
python-version: "3.11"
- run: uv sync --locked
- run: uv build
- run: uv run --no-sync twine check --strict dist/*
- name: Install the wheel with the oldest allowed dependencies
run: |
uv venv "$RUNNER_TEMP/wheel"
uv pip install --python "$RUNNER_TEMP/wheel" --resolution lowest-direct \
--requirement pyproject.toml
uv pip install --python "$RUNNER_TEMP/wheel" --no-deps dist/*.whl
uv pip check --python "$RUNNER_TEMP/wheel"
uv pip freeze --python "$RUNNER_TEMP/wheel" | grep -v '^vulnradar' \
> "$RUNNER_TEMP/oldest.txt"
cat "$RUNNER_TEMP/oldest.txt"
uv run --no-sync pip-audit --no-deps --disable-pip \
--requirement "$RUNNER_TEMP/oldest.txt"
cd "$RUNNER_TEMP"
# -W error: importing the package must not raise a deprecation warning.
wheel/bin/python -W error -c '
from pathlib import Path
import vulnradar
assert (Path(vulnradar.__file__).parent / "py.typed").is_file()
print(vulnradar.__version__)
'

audit:
name: Dependency audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version: ${{ env.UV_VERSION }}
python-version: "3.13"
- run: uv sync --locked
- name: Check the locked packages for known vulnerabilities
run: |
uv export --locked --all-groups --no-emit-project \
--format requirements-txt --output-file "$RUNNER_TEMP/requirements.txt" > /dev/null
uv run --no-sync pip-audit --require-hashes --disable-pip \
--requirement "$RUNNER_TEMP/requirements.txt"

outdated:
name: Outdated packages
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
version: ${{ env.UV_VERSION }}
python-version: "3.13"
- name: Report newer releases (older than three days)
run: |
set -o pipefail
{
echo '### Newer releases available'
echo '```'
uv lock --upgrade --dry-run 2>&1
echo '```'
} | tee -a "$GITHUB_STEP_SUMMARY"

secrets:
name: Secret scan
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- run: docker build --target gitleaks -t gitleaks .github/tools
- name: Scan the whole history
shell: bash
run: |
docker run --rm --user "$(id -u):$(id -g)" \
-e HOME=/tmp \
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0=/repo \
-v "$PWD:/repo:ro" -w /repo \
gitleaks git --redact --no-banner --no-color --exit-code 1 --log-opts=--all \
2>&1 | tee "$RUNNER_TEMP/gitleaks.log"
# gitleaks can exit 0 when git fails inside it, having scanned nothing.
grep -qE '[1-9][0-9]* commits scanned' "$RUNNER_TEMP/gitleaks.log"
40 changes: 40 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CodeQL

on:
push:
branches: [main]
pull_request:
schedule:
- cron: "43 12 * * 1"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: codeql-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
security-events: write # upload the results to code scanning
strategy:
fail-fast: false
matrix:
language: [python, actions]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: github/codeql-action/init@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
languages: ${{ matrix.language }}
build-mode: none
- uses: github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
category: /language:${{ matrix.language }}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ main.py
test.txt
test.py
.env
uv.lock

# Tool caches
.mypy_cache/
.pytest_cache/
.ruff_cache/
.coverage
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ dates on PyPI (UTC).

## Unreleased

### Added

- The package ships `py.typed`, so type checkers use its annotations.

### Changed

- 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 timestamp filled in when a reply has none is timezone-aware (UTC).
- The README now says that no published release works with the current API.

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include CHANGELOG.md
recursive-include tests *.py
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ VulnRadar scans web targets for security vulnerabilities, exposing findings cate
pip install vulnradar
```

Requires Python 3.10+.
The releases on PyPI require Python 3.10 or newer. The code on `main` requires Python 3.11 or
newer.

---

Expand Down Expand Up @@ -349,13 +350,27 @@ if discovery.total > 0:

## Contributing

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/my-feature`
3. Make your changes with full type hints
4. Run tests: `pytest`
5. Submit a pull request
Development uses [uv](https://docs.astral.sh/uv/). Fork the repository, create a branch, and
before opening a pull request run:

All contributions must pass lint and type checking.
```bash
uv sync
uv run ruff check .
uv run ruff format --check .
uv run mypy
uv run pytest
```

These tests never touch the network. The tests in `tests/live` call a real server, spend scan
quota and delete the scans they create. Run them only on purpose, with a key in
`VULNRADAR_TOKEN`:

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

`VULNRADAR_API_BASE` points them at another server and `VULNRADAR_TEST_URL` changes the scan
target. Until the rebuild is finished they are expected to fail.

---

Expand Down
Loading