urlscope 0.1.3rc1__tar.gz → 0.2.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.
- urlscope-0.2.0/.githooks/commit-msg +8 -0
- urlscope-0.2.0/.githooks/pre-commit +5 -0
- urlscope-0.2.0/.githooks/pre-push +27 -0
- urlscope-0.2.0/.github/dependabot.yml +20 -0
- urlscope-0.2.0/.github/workflows/ci.yml +94 -0
- urlscope-0.2.0/.github/workflows/gitleaks.yml +21 -0
- urlscope-0.2.0/.github/workflows/live-api.yml +44 -0
- urlscope-0.2.0/.github/workflows/release.yml +113 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/.gitignore +0 -1
- urlscope-0.2.0/.gitleaks.toml +51 -0
- urlscope-0.2.0/.python-version +1 -0
- urlscope-0.2.0/BACKLOG.md +7 -0
- urlscope-0.2.0/CLAUDE.md +93 -0
- urlscope-0.2.0/PKG-INFO +249 -0
- urlscope-0.2.0/README.md +222 -0
- urlscope-0.2.0/SECURITY.md +15 -0
- urlscope-0.2.0/docs/design.md +107 -0
- urlscope-0.2.0/pyproject.toml +73 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/__init__.py +1 -1
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/_client.py +39 -19
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/_http.py +80 -12
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/_sync.py +13 -2
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/models/_quota.py +3 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/models/_result.py +69 -3
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/models/_search.py +8 -0
- urlscope-0.2.0/tests/conftest.py +197 -0
- urlscope-0.2.0/tests/fixtures/quota_user_live.json +163 -0
- urlscope-0.2.0/tests/fixtures/result_clean.json +140 -0
- urlscope-0.2.0/tests/fixtures/result_malicious.json +171 -0
- urlscope-0.2.0/tests/fixtures/result_scored.json +161 -0
- urlscope-0.2.0/tests/fixtures/search_common.json +125 -0
- urlscope-0.2.0/tests/fixtures/search_empty.json +7 -0
- urlscope-0.2.0/tests/fixtures/search_ip.json +55 -0
- urlscope-0.2.0/tests/fixtures/search_malicious.json +75 -0
- urlscope-0.2.0/tests/fixtures/submission_error_dns.json +12 -0
- urlscope-0.2.0/tests/fixtures/submission_error_override_safety.json +13 -0
- urlscope-0.2.0/tests/fixtures/submission_success_optional.json +15 -0
- urlscope-0.2.0/tests/fixtures/submission_success_public.json +9 -0
- urlscope-0.2.0/tests/live/conftest.py +98 -0
- urlscope-0.2.0/tests/live/test_live_api.py +173 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/tests/test_artifacts.py +10 -8
- urlscope-0.2.0/tests/test_errors.py +253 -0
- urlscope-0.2.0/tests/test_quota.py +79 -0
- urlscope-0.2.0/tests/test_result.py +255 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/tests/test_retry.py +25 -16
- urlscope-0.2.0/tests/test_search.py +196 -0
- urlscope-0.2.0/tests/test_submit.py +144 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/tests/test_sync.py +17 -34
- urlscope-0.2.0/uv.lock +725 -0
- urlscope-0.1.3rc1/.github/workflows/ci.yml +0 -46
- urlscope-0.1.3rc1/.github/workflows/publish-pypi.yml +0 -58
- urlscope-0.1.3rc1/.github/workflows/publish-testpypi.yml +0 -60
- urlscope-0.1.3rc1/.github/workflows/release.yml +0 -59
- urlscope-0.1.3rc1/AGENTS.md +0 -44
- urlscope-0.1.3rc1/PKG-INFO +0 -176
- urlscope-0.1.3rc1/README.md +0 -158
- urlscope-0.1.3rc1/pyproject.toml +0 -45
- urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/checklists/requirements.md +0 -36
- urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/contracts/public-api.md +0 -179
- urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/data-model.md +0 -213
- urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/plan.md +0 -90
- urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/quickstart.md +0 -130
- urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/research.md +0 -110
- urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/spec.md +0 -209
- urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/tasks.md +0 -262
- urlscope-0.1.3rc1/tests/conftest.py +0 -183
- urlscope-0.1.3rc1/tests/test_errors.py +0 -166
- urlscope-0.1.3rc1/tests/test_quota.py +0 -69
- urlscope-0.1.3rc1/tests/test_result.py +0 -135
- urlscope-0.1.3rc1/tests/test_search.py +0 -131
- urlscope-0.1.3rc1/tests/test_submit.py +0 -101
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/LICENSE +0 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/_exceptions.py +0 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/models/__init__.py +0 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/models/_submission.py +0 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/src/urlscope/py.typed +0 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/tests/test_auth.py +0 -0
- {urlscope-0.1.3rc1 → urlscope-0.2.0}/tests/test_context.py +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Block commits whose MESSAGE contains a secret ($1 = message file).
|
|
3
|
+
# Content scans never see the message, so it is scanned as plain text.
|
|
4
|
+
command -v gitleaks >/dev/null 2>&1 || { echo "⚠️ gitleaks not installed — skipping" >&2; exit 0; }
|
|
5
|
+
# --config is required: config autodetection follows --source (a file under .git/),
|
|
6
|
+
# not the cwd, so without it only the default rules would apply.
|
|
7
|
+
gitleaks detect --no-git --source "$1" --config .gitleaks.toml --redact -v || { # v8.19+: gitleaks dir
|
|
8
|
+
echo "❌ gitleaks: secret in the commit MESSAGE — commit blocked" >&2; exit 1; }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Block commits whose staged changes contain a secret.
|
|
3
|
+
command -v gitleaks >/dev/null 2>&1 || { echo "⚠️ gitleaks not installed — skipping" >&2; exit 0; }
|
|
4
|
+
gitleaks protect --staged --redact -v || { # v8.19+ equivalent: gitleaks git --staged
|
|
5
|
+
echo "❌ gitleaks: secret in staged changes — commit blocked" >&2; exit 1; }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Block pushes whose new commits contain a secret, in content or in messages.
|
|
3
|
+
# stdin: "<local_ref> <local_sha> <remote_ref> <remote_sha>" per pushed ref.
|
|
4
|
+
|
|
5
|
+
# Advisory, never blocks: GitHub disables scheduled workflows after 60 days without
|
|
6
|
+
# repo activity, and a disabled workflow ignores every trigger, pushes included.
|
|
7
|
+
if command -v gh >/dev/null 2>&1; then
|
|
8
|
+
for wf in gitleaks.yml live-api.yml; do
|
|
9
|
+
# on an HTTP error (e.g. 404 before the workflow exists) gh prints the error body
|
|
10
|
+
# to stdout and exits non-zero, so a failed call is skipped, not reported as a state
|
|
11
|
+
st=$(timeout 5 gh api "repos/{owner}/{repo}/actions/workflows/$wf" --jq .state </dev/null 2>/dev/null) || continue
|
|
12
|
+
[ -n "$st" ] && [ "$st" != active ] && echo "⚠️ workflow $wf is '$st' — it will not run on GitHub (gh workflow enable $wf)" >&2
|
|
13
|
+
done
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
command -v gitleaks >/dev/null 2>&1 || { echo "⚠️ gitleaks not installed — skipping" >&2; exit 0; }
|
|
17
|
+
z=0000000000000000000000000000000000000000; fail=0
|
|
18
|
+
tmp=$(mktemp -d) || exit 0; trap 'rm -rf "$tmp"' EXIT
|
|
19
|
+
while read -r _ local_sha _ remote_sha; do
|
|
20
|
+
[ "$local_sha" = "$z" ] && continue # deleting a ref
|
|
21
|
+
if [ "$remote_sha" = "$z" ]; then set -- "$local_sha" --not --remotes # new branch
|
|
22
|
+
else set -- "$remote_sha..$local_sha"; fi # existing branch: new commits only
|
|
23
|
+
gitleaks detect --log-opts="$*" --redact -v || fail=1 # v8.19+: gitleaks git --log-opts=...
|
|
24
|
+
git log --format=%B "$@" > "$tmp/m" 2>/dev/null
|
|
25
|
+
[ -s "$tmp/m" ] && { gitleaks detect --no-git --source "$tmp/m" --config .gitleaks.toml --redact -v || fail=1; }
|
|
26
|
+
done
|
|
27
|
+
[ "$fail" -eq 0 ] || { echo "❌ push blocked (see finding above)" >&2; exit 1; }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
|
|
3
|
+
# Version updates wait a week after a release (cooldown); security updates do not.
|
|
4
|
+
updates:
|
|
5
|
+
- package-ecosystem: "github-actions"
|
|
6
|
+
directory: "/"
|
|
7
|
+
schedule:
|
|
8
|
+
interval: "weekly"
|
|
9
|
+
cooldown:
|
|
10
|
+
default-days: 7
|
|
11
|
+
|
|
12
|
+
- package-ecosystem: "uv"
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "weekly"
|
|
16
|
+
cooldown:
|
|
17
|
+
default-days: 7
|
|
18
|
+
# The lower bounds in pyproject.toml are what CI's lowest-deps job proves,
|
|
19
|
+
# so Dependabot only moves uv.lock and leaves the bounds alone.
|
|
20
|
+
versioning-strategy: "lockfile-only"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
checks:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
env:
|
|
16
|
+
UV_PYTHON: ${{ matrix.python-version }} # .python-version would otherwise pick 3.15 for every job
|
|
17
|
+
UV_LOCKED: "1" # fail if uv.lock is out of date instead of rewriting it
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
python-version:
|
|
22
|
+
- "3.11"
|
|
23
|
+
- "3.12"
|
|
24
|
+
- "3.13"
|
|
25
|
+
- "3.14"
|
|
26
|
+
- "3.15"
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- name: Check out repository
|
|
30
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
31
|
+
with:
|
|
32
|
+
persist-credentials: false
|
|
33
|
+
|
|
34
|
+
- name: Set up uv
|
|
35
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
36
|
+
with:
|
|
37
|
+
enable-cache: true
|
|
38
|
+
cache-dependency-glob: uv.lock
|
|
39
|
+
|
|
40
|
+
- name: Set up Python
|
|
41
|
+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
42
|
+
with:
|
|
43
|
+
python-version: ${{ matrix.python-version }}
|
|
44
|
+
|
|
45
|
+
- name: Install dependencies
|
|
46
|
+
run: uv sync
|
|
47
|
+
|
|
48
|
+
- name: Run tests
|
|
49
|
+
run: uv run pytest tests/
|
|
50
|
+
|
|
51
|
+
- name: Run Ruff
|
|
52
|
+
run: uv run ruff check src/ tests/
|
|
53
|
+
|
|
54
|
+
- name: Check formatting
|
|
55
|
+
run: uv run ruff format --check src/ tests/
|
|
56
|
+
|
|
57
|
+
- name: Run mypy
|
|
58
|
+
run: uv run mypy src/
|
|
59
|
+
|
|
60
|
+
lowest-deps:
|
|
61
|
+
# The lower bounds in pyproject.toml hold only as far as this job proves them:
|
|
62
|
+
# the oldest supported Python with the oldest allowed httpx2 and pydantic.
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
env:
|
|
65
|
+
UV_PYTHON: "3.11"
|
|
66
|
+
|
|
67
|
+
steps:
|
|
68
|
+
- name: Check out repository
|
|
69
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
70
|
+
with:
|
|
71
|
+
persist-credentials: false
|
|
72
|
+
|
|
73
|
+
- name: Set up uv
|
|
74
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
75
|
+
with:
|
|
76
|
+
enable-cache: true
|
|
77
|
+
cache-dependency-glob: uv.lock
|
|
78
|
+
|
|
79
|
+
- name: Set up Python
|
|
80
|
+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
81
|
+
with:
|
|
82
|
+
python-version: "3.11"
|
|
83
|
+
|
|
84
|
+
- name: Install locked dependencies
|
|
85
|
+
run: uv sync --locked
|
|
86
|
+
|
|
87
|
+
- name: Downgrade runtime dependencies to their lower bounds
|
|
88
|
+
run: |
|
|
89
|
+
uv pip compile pyproject.toml --resolution lowest-direct -o "$RUNNER_TEMP/lowest.txt"
|
|
90
|
+
uv pip install -r "$RUNNER_TEMP/lowest.txt"
|
|
91
|
+
uv pip list | grep -E '^(httpx2|httpcore2|pydantic|pydantic-core) '
|
|
92
|
+
|
|
93
|
+
- name: Run tests
|
|
94
|
+
run: uv run --no-sync pytest tests/ # --no-sync keeps the downgraded versions
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: gitleaks
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
schedule: [{ cron: '17 4 * * 1' }] # weekly re-audit of full history
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
permissions: { contents: read }
|
|
8
|
+
jobs:
|
|
9
|
+
scan:
|
|
10
|
+
runs-on: ubuntu-24.04 # its apt gitleaks (8.16) matches the local one; bump deliberately
|
|
11
|
+
timeout-minutes: 10 # fail fast if an apt mirror hangs (default is 6 h)
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0 # full history for content scan + git log --all
|
|
16
|
+
persist-credentials: false
|
|
17
|
+
- run: sudo apt-get update && sudo apt-get install -y gitleaks
|
|
18
|
+
- run: gitleaks detect --source . --config .gitleaks.toml --redact -v # content
|
|
19
|
+
- run: | # messages
|
|
20
|
+
git log --all --format=%B > "$RUNNER_TEMP/m.txt"
|
|
21
|
+
gitleaks detect --no-git --source "$RUNNER_TEMP/m.txt" --config .gitleaks.toml --redact -v
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: live-api
|
|
2
|
+
|
|
3
|
+
# Tests against the real urlscan.io API (tests/live, marker "live"). Each run makes
|
|
4
|
+
# two private scans of https://example.com. GitHub disables this schedule after 60
|
|
5
|
+
# days without repository activity; .githooks/pre-push warns when that happens.
|
|
6
|
+
on:
|
|
7
|
+
schedule: [{ cron: '23 5 * * 1' }] # weekly
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
live:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
environment: live-api # holds the URLSCAN_API_KEY secret; deploys from main only
|
|
17
|
+
timeout-minutes: 15
|
|
18
|
+
env:
|
|
19
|
+
UV_LOCKED: "1"
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Check out repository
|
|
23
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
24
|
+
with:
|
|
25
|
+
persist-credentials: false
|
|
26
|
+
|
|
27
|
+
- name: Set up uv
|
|
28
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
29
|
+
with:
|
|
30
|
+
enable-cache: true
|
|
31
|
+
cache-dependency-glob: uv.lock
|
|
32
|
+
|
|
33
|
+
- name: Set up Python
|
|
34
|
+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
35
|
+
with:
|
|
36
|
+
python-version-file: .python-version
|
|
37
|
+
|
|
38
|
+
- name: Install dependencies
|
|
39
|
+
run: uv sync
|
|
40
|
+
|
|
41
|
+
- name: Run tests against the live urlscan.io API
|
|
42
|
+
env:
|
|
43
|
+
URLSCAN_API_KEY: ${{ secrets.URLSCAN_API_KEY }}
|
|
44
|
+
run: uv run pytest tests/ -m live -v
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
# A tag publishes: test-v<version> to TestPyPI, v<version> to PyPI. The tag must match
|
|
4
|
+
# __version__ in src/urlscope/__init__.py. One job builds and checks the distributions
|
|
5
|
+
# once; the publish jobs only upload that artifact, and only they get the OIDC token
|
|
6
|
+
# for PyPI trusted publishing. Environment "pypi" waits for the owner's approval.
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags:
|
|
10
|
+
- "v*"
|
|
11
|
+
- "test-v*"
|
|
12
|
+
workflow_dispatch: # build and check only; publishing needs a tag
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Check out repository
|
|
23
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
24
|
+
with:
|
|
25
|
+
persist-credentials: false
|
|
26
|
+
|
|
27
|
+
- name: Set up uv
|
|
28
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
29
|
+
with:
|
|
30
|
+
enable-cache: true
|
|
31
|
+
cache-dependency-glob: uv.lock
|
|
32
|
+
|
|
33
|
+
- name: Set up Python
|
|
34
|
+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
35
|
+
with:
|
|
36
|
+
python-version-file: .python-version
|
|
37
|
+
|
|
38
|
+
- name: Verify tag matches package version
|
|
39
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
40
|
+
run: |
|
|
41
|
+
TAG_VERSION="${GITHUB_REF_NAME#test-}"
|
|
42
|
+
TAG_VERSION="${TAG_VERSION#v}"
|
|
43
|
+
PACKAGE_VERSION="$(python - <<'PY'
|
|
44
|
+
from pathlib import Path
|
|
45
|
+
import re
|
|
46
|
+
|
|
47
|
+
text = Path("src/urlscope/__init__.py").read_text()
|
|
48
|
+
match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', text, re.MULTILINE)
|
|
49
|
+
if match is None:
|
|
50
|
+
raise SystemExit("Could not find __version__ in src/urlscope/__init__.py")
|
|
51
|
+
print(match.group(1))
|
|
52
|
+
PY
|
|
53
|
+
)"
|
|
54
|
+
|
|
55
|
+
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
|
|
56
|
+
echo "Tag version ($TAG_VERSION) does not match package version ($PACKAGE_VERSION)."
|
|
57
|
+
exit 1
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
- name: Build distributions
|
|
61
|
+
run: uv build
|
|
62
|
+
|
|
63
|
+
- name: Validate distributions
|
|
64
|
+
run: uvx twine==7.0.0 check --strict dist/*
|
|
65
|
+
|
|
66
|
+
- name: Upload distributions
|
|
67
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
68
|
+
with:
|
|
69
|
+
name: dist
|
|
70
|
+
path: dist/
|
|
71
|
+
if-no-files-found: error
|
|
72
|
+
|
|
73
|
+
publish-testpypi:
|
|
74
|
+
if: startsWith(github.ref, 'refs/tags/test-v')
|
|
75
|
+
needs: build
|
|
76
|
+
runs-on: ubuntu-latest
|
|
77
|
+
environment:
|
|
78
|
+
name: testpypi # deploys from test-v* tags only
|
|
79
|
+
url: https://test.pypi.org/p/urlscope
|
|
80
|
+
permissions:
|
|
81
|
+
id-token: write # trusted publishing
|
|
82
|
+
|
|
83
|
+
steps:
|
|
84
|
+
- name: Download distributions
|
|
85
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
86
|
+
with:
|
|
87
|
+
name: dist
|
|
88
|
+
path: dist/
|
|
89
|
+
|
|
90
|
+
- name: Publish to TestPyPI
|
|
91
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
92
|
+
with:
|
|
93
|
+
repository-url: https://test.pypi.org/legacy/
|
|
94
|
+
|
|
95
|
+
publish-pypi:
|
|
96
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
97
|
+
needs: build
|
|
98
|
+
runs-on: ubuntu-latest
|
|
99
|
+
environment:
|
|
100
|
+
name: pypi # deploys from v* tags only, after the owner approves
|
|
101
|
+
url: https://pypi.org/p/urlscope
|
|
102
|
+
permissions:
|
|
103
|
+
id-token: write # trusted publishing
|
|
104
|
+
|
|
105
|
+
steps:
|
|
106
|
+
- name: Download distributions
|
|
107
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
108
|
+
with:
|
|
109
|
+
name: dist
|
|
110
|
+
path: dist/
|
|
111
|
+
|
|
112
|
+
- name: Publish to PyPI
|
|
113
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
@@ -98,7 +98,6 @@ ipython_config.py
|
|
|
98
98
|
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
99
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
100
|
# commonly ignored for libraries.
|
|
101
|
-
uv.lock
|
|
102
101
|
|
|
103
102
|
# poetry
|
|
104
103
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
title = "urlscope gitleaks config"
|
|
2
|
+
|
|
3
|
+
[extend]
|
|
4
|
+
useDefault = true # keep the full built-in ruleset
|
|
5
|
+
|
|
6
|
+
[allowlist] # gitleaks v8.25+ also accepts [[allowlists]]
|
|
7
|
+
description = "false positives"
|
|
8
|
+
paths = ['''\.gitleaks\.toml'''] # skip this file (it carries rule regexes)
|
|
9
|
+
# regexes = ['''YOUR_[A-Z_]*_(KEY|TOKEN)'''] # add real false positives here as they appear
|
|
10
|
+
|
|
11
|
+
# --- Add-on rules: they only ADD coverage, never replace -----------------------
|
|
12
|
+
# useDefault = true keeps every built-in rule; these are appended on top. Each id is
|
|
13
|
+
# unique and prefixed (jw-), so no built-in rule is overridden or disabled.
|
|
14
|
+
#
|
|
15
|
+
# The built-in generic-api-key rule is the only net for prefix-less secrets, and its
|
|
16
|
+
# own stopword allowlist silently disables it based on the secret's value (e.g. every
|
|
17
|
+
# "sk-ant-..." key contains "ant"). Prefix- or name-anchored rules fire regardless, so
|
|
18
|
+
# add one for every credential format this project actually uses.
|
|
19
|
+
#
|
|
20
|
+
# Keyword hygiene: a keyword that also occurs in ordinary text suppresses
|
|
21
|
+
# generic-api-key on the same line, even when the rule's regex does not match.
|
|
22
|
+
# Keep keywords specific to the credential and validate every change against a
|
|
23
|
+
# corpus of fake keys (one per file) before committing it.
|
|
24
|
+
|
|
25
|
+
[[rules]]
|
|
26
|
+
id = "jw-openrouter-key"
|
|
27
|
+
description = "OpenRouter API key (sk-or-v1-)"
|
|
28
|
+
regex = '''sk-or-v1-[0-9a-f]{64}'''
|
|
29
|
+
keywords = ["sk-or-v1-"]
|
|
30
|
+
|
|
31
|
+
[[rules]]
|
|
32
|
+
id = "jw-anthropic-key"
|
|
33
|
+
description = "Anthropic API key (sk-ant-)"
|
|
34
|
+
regex = '''\bsk-ant-[A-Za-z0-9]{2,12}-[A-Za-z0-9_-]{80,120}\b'''
|
|
35
|
+
keywords = ["sk-ant-"] # loose middle segment survives api03 -> admin01 etc.
|
|
36
|
+
|
|
37
|
+
# The urlscan.io API key is a bare UUID, and so is every scan id in this repository
|
|
38
|
+
# (fixtures, result URLs), so both rules anchor on the name that carries the key.
|
|
39
|
+
# Separators cover .env and shell assignments, YAML and JSON keys, os.environ["..."],
|
|
40
|
+
# monkeypatch.setenv("...", "..."), HTTP headers and keyword arguments.
|
|
41
|
+
[[rules]]
|
|
42
|
+
id = "jw-urlscan-key"
|
|
43
|
+
description = "urlscan.io API key (UUID) under a URLSCAN_*KEY name"
|
|
44
|
+
regex = '''(?i)\burlscan[_-]?(?:api[_-]?)?key\b["'\]]{0,2}\s*[:=,]\s*['"]?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b'''
|
|
45
|
+
keywords = ["urlscan"]
|
|
46
|
+
|
|
47
|
+
[[rules]]
|
|
48
|
+
id = "jw-urlscan-key-generic-name"
|
|
49
|
+
description = "UUID-shaped API key under an API-Key / api_key name (urlscan header, client argument)"
|
|
50
|
+
regex = '''(?i)\bapi[_-]key\b["'\]]{0,2}\s*[:=]\s*['"]?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b'''
|
|
51
|
+
keywords = ["key"] # generic-api-key's own keyword: shadows nothing
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.15
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Backlog
|
|
2
|
+
|
|
3
|
+
## Future Enhancements
|
|
4
|
+
|
|
5
|
+
- Verify the non-`scans` search datasources: `search(datasource=...)` already accepts `hostnames`, `certificates`, `incidents`, and `notifications`, but the models are verified only against `scans` results. Check whether their results parse (for example, `SearchResultItem.id` requires `_id`) and which account plans can use them.
|
|
6
|
+
- Evaluate optional endpoint support for response/download artifacts and discovery helpers: `/responses/{fileHash}/`, `/downloads/{fileHash}`, `/api/v1/hostname/{hostname}`, `/api/v1/availableCountries`, and `/api/v1/userAgents`.
|
|
7
|
+
- Consider keyless use: urlscan answers `search` and `quotas` (with limits scoped to the client's IP address) without an `API-Key` header, while `UrlscopeClient` requires a key at construction.
|
urlscope-0.2.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# urlscope
|
|
2
|
+
|
|
3
|
+
Async-first Python client for the urlscan.io API, published on PyPI as `urlscope`. The code
|
|
4
|
+
is the source of truth for what the library does. [docs/design.md](docs/design.md) records why
|
|
5
|
+
it is built this way and how the live urlscan API behaves; ideas outside the current scope live
|
|
6
|
+
in [BACKLOG.md](BACKLOG.md).
|
|
7
|
+
|
|
8
|
+
## Layout
|
|
9
|
+
|
|
10
|
+
- `src/urlscope/_client.py`: `UrlscopeClient`, the async client (submit, polling, results,
|
|
11
|
+
search, artifacts, quotas).
|
|
12
|
+
- `src/urlscope/_sync.py`: `SyncClient`, which runs a fresh async client per call.
|
|
13
|
+
- `src/urlscope/_http.py`: the transport on `httpx2.AsyncClient`: API key, error mapping,
|
|
14
|
+
429 retries.
|
|
15
|
+
- `src/urlscope/_exceptions.py`: the exception hierarchy.
|
|
16
|
+
- `src/urlscope/models/`: Pydantic response models.
|
|
17
|
+
- `src/urlscope/__init__.py`: public exports and `__version__`, the only place the version lives
|
|
18
|
+
(`pyproject.toml` reads it).
|
|
19
|
+
- `tests/`: mocked tests, one file per feature area, shared fixtures in `tests/conftest.py` and
|
|
20
|
+
sanitized payloads in `tests/fixtures/`. `tests/live/`: tests against the real API.
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv sync # Python from .python-version, dev group included
|
|
26
|
+
git config core.hooksPath .githooks # once per clone: gitleaks hooks
|
|
27
|
+
uv run pytest tests/ # mocked tests; live tests are deselected
|
|
28
|
+
uv run --env-file .env pytest -m live # live tests: real key, two private scans per run
|
|
29
|
+
uv run ruff check src/ tests/
|
|
30
|
+
uv run ruff format --check src/ tests/
|
|
31
|
+
uv run mypy src/ # strict
|
|
32
|
+
uv build && uvx twine check --strict dist/*
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To run the mocked tests on another supported Python without touching `.venv`:
|
|
36
|
+
`UV_PROJECT_ENVIRONMENT=<scratch dir> uv run --python 3.11 pytest tests/`.
|
|
37
|
+
|
|
38
|
+
## Conventions
|
|
39
|
+
|
|
40
|
+
- Python 3.11-3.15 (`requires-python >=3.11` and the CI matrix); complete type annotations,
|
|
41
|
+
mypy in strict mode, ruff for lint and format.
|
|
42
|
+
- `snake_case` for modules, functions and variables, `PascalCase` for classes; `_`-prefixed
|
|
43
|
+
modules are internal, and public names are exported from `src/urlscope/__init__.py`.
|
|
44
|
+
- Every model uses `ConfigDict(extra="allow", populate_by_name=True)`; camelCase wire names map
|
|
45
|
+
to snake_case fields through `Field(alias=...)`, e.g. `apexDomain` to `apex_domain`.
|
|
46
|
+
- Runtime dependencies are `httpx2` and `pydantic` only. Their lower bounds in `pyproject.toml`
|
|
47
|
+
are what CI's `lowest-deps` job proves (Python 3.11 with the oldest allowed versions); for
|
|
48
|
+
Python dependencies Dependabot moves only `uv.lock`.
|
|
49
|
+
|
|
50
|
+
## Tests
|
|
51
|
+
|
|
52
|
+
- pytest with pytest-asyncio in auto mode. HTTP is mocked with respx through pytest-httpx2:
|
|
53
|
+
request the `httpx2_mock` fixture and build responses as `httpx.Response` (respx does not
|
|
54
|
+
accept `httpx2.Response` yet, so `httpx` stays a dev dependency). The fixture fails on routes
|
|
55
|
+
that are never called and on requests without a route.
|
|
56
|
+
- Prefer shared fixtures in `tests/conftest.py` over inline payloads. Assert on values, not on
|
|
57
|
+
`id()` or other runtime reuse details, unless identity is what the test checks.
|
|
58
|
+
- To fake time or randomness, replace the module references in `urlscope._client` or
|
|
59
|
+
`urlscope._http` (`time`, `asyncio`, `random`) with stand-ins, as `fake_clock` in
|
|
60
|
+
`tests/test_result.py` and `tests/test_retry.py` do; never patch attributes of the global
|
|
61
|
+
modules, which the event loop and other code share.
|
|
62
|
+
- Live tests (`tests/live/`, marker `live`) run on demand and weekly in CI (`live-api.yml`,
|
|
63
|
+
environment `live-api`, secret `URLSCAN_API_KEY`). They fail on HTTP errors and on responses
|
|
64
|
+
that no longer fit the models, and list unmodeled fields in the summary; `KNOWN_UNMODELED` in
|
|
65
|
+
`tests/live/conftest.py` names the sections left untyped on purpose. Without a key they error
|
|
66
|
+
instead of skipping. GitHub disables scheduled workflows after 60 days without repository
|
|
67
|
+
activity; `.githooks/pre-push` warns when that has happened.
|
|
68
|
+
- When the live API differs from the models, change the models, the tests and the quirks in
|
|
69
|
+
`docs/design.md` together; no silent compatibility hacks.
|
|
70
|
+
|
|
71
|
+
## Commits and releases
|
|
72
|
+
|
|
73
|
+
- Commit directly to `main`: one coherent change per commit, an imperative subject and a body
|
|
74
|
+
that says why.
|
|
75
|
+
- Release: bump `__version__`, commit and push; push the tag `test-v<version>` to publish to
|
|
76
|
+
TestPyPI and check the result there; then push `v<version>` to publish to PyPI. `release.yml`
|
|
77
|
+
builds once, checks the tag against `__version__` and publishes through trusted publishing;
|
|
78
|
+
environment `pypi` waits for the owner's approval. Push one tag at a time
|
|
79
|
+
(`git push origin v<version>`), never `--tags`.
|
|
80
|
+
- Release tags cannot be moved or deleted (a repository ruleset), and PyPI never accepts the same
|
|
81
|
+
version twice; fixing a published tag means a new version.
|
|
82
|
+
|
|
83
|
+
## Security
|
|
84
|
+
|
|
85
|
+
- Never commit API keys. The key comes from `URLSCAN_API_KEY` (locally from the git-ignored
|
|
86
|
+
`.env`) or the `api_key` argument.
|
|
87
|
+
- Gitleaks scans staged content, commit messages and pushed ranges locally (`.githooks/`, rules in
|
|
88
|
+
`.gitleaks.toml`) and the full history in CI. Validate a `.gitleaks.toml` change on a corpus of
|
|
89
|
+
fake keys, one per file, against the current config: a rule's keywords can switch off the
|
|
90
|
+
built-in generic rule.
|
|
91
|
+
- Keep fixtures and examples sanitized; do not commit captured scan artifacts or sensitive
|
|
92
|
+
payloads.
|
|
93
|
+
- Publishing uses PyPI trusted publishing only; no long-lived PyPI tokens.
|