sdo-client 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.
- sdo_client-0.1.0/.editorconfig +22 -0
- sdo_client-0.1.0/.gitattributes +5 -0
- sdo_client-0.1.0/.github/CODEOWNERS +3 -0
- sdo_client-0.1.0/.github/dependabot.yml +46 -0
- sdo_client-0.1.0/.github/workflows/ci.yml +122 -0
- sdo_client-0.1.0/.github/workflows/commits.yml +50 -0
- sdo_client-0.1.0/.github/workflows/publish.yml +194 -0
- sdo_client-0.1.0/.github/workflows/security.yml +144 -0
- sdo_client-0.1.0/.gitignore +12 -0
- sdo_client-0.1.0/CHANGELOG.md +191 -0
- sdo_client-0.1.0/CONTRIBUTING.md +322 -0
- sdo_client-0.1.0/LICENSE +201 -0
- sdo_client-0.1.0/MIGRATING.md +150 -0
- sdo_client-0.1.0/NOTICE +8 -0
- sdo_client-0.1.0/PKG-INFO +377 -0
- sdo_client-0.1.0/README.md +344 -0
- sdo_client-0.1.0/SECURITY.md +151 -0
- sdo_client-0.1.0/api-surface.txt +434 -0
- sdo_client-0.1.0/examples/plugins_and_async.py +23 -0
- sdo_client-0.1.0/examples/quickstart.py +14 -0
- sdo_client-0.1.0/examples/render_geo_and_extract.py +23 -0
- sdo_client-0.1.0/pyproject.toml +92 -0
- sdo_client-0.1.0/requirements-audit.in +8 -0
- sdo_client-0.1.0/requirements-audit.txt +426 -0
- sdo_client-0.1.0/requirements-build.in +13 -0
- sdo_client-0.1.0/requirements-build.txt +509 -0
- sdo_client-0.1.0/requirements-dev.in +24 -0
- sdo_client-0.1.0/requirements-dev.txt +886 -0
- sdo_client-0.1.0/src/sdo/__init__.py +74 -0
- sdo_client-0.1.0/src/sdo/_decompress.py +253 -0
- sdo_client-0.1.0/src/sdo/_encoding.py +739 -0
- sdo_client-0.1.0/src/sdo/_json.py +50 -0
- sdo_client-0.1.0/src/sdo/_logging.py +93 -0
- sdo_client-0.1.0/src/sdo/_secret.py +74 -0
- sdo_client-0.1.0/src/sdo/_transport.py +639 -0
- sdo_client-0.1.0/src/sdo/_urls.py +80 -0
- sdo_client-0.1.0/src/sdo/_version.py +8 -0
- sdo_client-0.1.0/src/sdo/_wire.py +126 -0
- sdo_client-0.1.0/src/sdo/client.py +459 -0
- sdo_client-0.1.0/src/sdo/config.py +452 -0
- sdo_client-0.1.0/src/sdo/errors.py +247 -0
- sdo_client-0.1.0/src/sdo/jobs.py +490 -0
- sdo_client-0.1.0/src/sdo/plugins.py +143 -0
- sdo_client-0.1.0/src/sdo/py.typed +0 -0
- sdo_client-0.1.0/src/sdo/response.py +177 -0
- sdo_client-0.1.0/src/sdo/usage.py +62 -0
- sdo_client-0.1.0/tests/conformance.json +5915 -0
- sdo_client-0.1.0/tests/conformance.json.sha256 +1 -0
- sdo_client-0.1.0/tests/conftest.py +14 -0
- sdo_client-0.1.0/tests/test_api_surface.py +121 -0
- sdo_client-0.1.0/tests/test_client.py +293 -0
- sdo_client-0.1.0/tests/test_config.py +257 -0
- sdo_client-0.1.0/tests/test_conformance.py +928 -0
- sdo_client-0.1.0/tests/test_decompress.py +211 -0
- sdo_client-0.1.0/tests/test_docs.py +71 -0
- sdo_client-0.1.0/tests/test_docs_conformance.py +215 -0
- sdo_client-0.1.0/tests/test_jobs.py +424 -0
- sdo_client-0.1.0/tests/test_plugins.py +186 -0
- sdo_client-0.1.0/tests/test_response.py +335 -0
- sdo_client-0.1.0/tests/test_security.py +505 -0
- sdo_client-0.1.0/tests/test_transport.py +747 -0
- sdo_client-0.1.0/tools/api_surface.py +176 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
insert_final_newline = true
|
|
8
|
+
trim_trailing_whitespace = true
|
|
9
|
+
indent_style = space
|
|
10
|
+
indent_size = 2
|
|
11
|
+
|
|
12
|
+
[*.go]
|
|
13
|
+
indent_style = tab
|
|
14
|
+
|
|
15
|
+
[*.py]
|
|
16
|
+
indent_size = 4
|
|
17
|
+
|
|
18
|
+
[*.md]
|
|
19
|
+
trim_trailing_whitespace = false
|
|
20
|
+
|
|
21
|
+
[Makefile]
|
|
22
|
+
indent_style = tab
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Every text file is checked out with LF on every platform: Windows runners
|
|
3
|
+
# would otherwise convert the checkout to CRLF, which breaks byte-exact
|
|
4
|
+
# goldens (the sha256-checked conformance corpus, api-surface.txt).
|
|
5
|
+
* text=auto eol=lf
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Keeps pip dependencies and SHA-pinned actions current. The cooldown waits for
|
|
3
|
+
# a release to age before proposing it, so a compromised release has time to be
|
|
4
|
+
# caught and yanked upstream first.
|
|
5
|
+
#
|
|
6
|
+
# pip is security-only (open-pull-requests-limit: 0 stops version-update
|
|
7
|
+
# pull requests; security updates are not limited by it). Dependabot recompiles
|
|
8
|
+
# the hash-pinned requirements-{dev,build,audit}.txt files without uv's
|
|
9
|
+
# --universal, which drops the platform-specific pins (colorama on Windows) and
|
|
10
|
+
# breaks the Windows install. Version bumps are made by hand with the uv
|
|
11
|
+
# command in each .in file's header.
|
|
12
|
+
version: 2
|
|
13
|
+
updates:
|
|
14
|
+
- package-ecosystem: pip
|
|
15
|
+
directory: /
|
|
16
|
+
schedule:
|
|
17
|
+
interval: weekly
|
|
18
|
+
open-pull-requests-limit: 0
|
|
19
|
+
commit-message:
|
|
20
|
+
prefix: chore
|
|
21
|
+
include: scope
|
|
22
|
+
labels: ["dependencies"]
|
|
23
|
+
cooldown:
|
|
24
|
+
default-days: 7
|
|
25
|
+
groups:
|
|
26
|
+
# hatchling is pinned in pyproject.toml [build-system] and in two
|
|
27
|
+
# requirement files; tests/test_api_surface.py fails until they agree.
|
|
28
|
+
# Groups apply to version updates unless told otherwise, and pip only
|
|
29
|
+
# gets security updates here.
|
|
30
|
+
build-backend:
|
|
31
|
+
applies-to: security-updates
|
|
32
|
+
patterns: ["hatchling"]
|
|
33
|
+
- package-ecosystem: github-actions
|
|
34
|
+
directory: /
|
|
35
|
+
schedule:
|
|
36
|
+
interval: weekly
|
|
37
|
+
open-pull-requests-limit: 10
|
|
38
|
+
commit-message:
|
|
39
|
+
prefix: chore
|
|
40
|
+
include: scope
|
|
41
|
+
labels: ["dependencies"]
|
|
42
|
+
cooldown:
|
|
43
|
+
default-days: 7
|
|
44
|
+
groups:
|
|
45
|
+
github-actions:
|
|
46
|
+
patterns: ["*"]
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
name: ci
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
# Least privilege by default; jobs opt in to what they need.
|
|
10
|
+
permissions: {}
|
|
11
|
+
|
|
12
|
+
# Every job runs on GitHub-hosted runners: free for a public repository, a
|
|
13
|
+
# clean image every time, and no code from outside the org ever reaches the
|
|
14
|
+
# org's persistent self-hosted runners. CodeQL is the one exception: its result
|
|
15
|
+
# upload and its own status calls are GitHub API requests, which the org's IP
|
|
16
|
+
# allow list only accepts from the self-hosted runners, so it runs there for
|
|
17
|
+
# same-repository events only; a pull request from a fork is not analysed
|
|
18
|
+
# (its code must not reach those runners) and is analysed on main once merged.
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
lint:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
27
|
+
with:
|
|
28
|
+
persist-credentials: false
|
|
29
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
30
|
+
with:
|
|
31
|
+
python-version: "3.12"
|
|
32
|
+
# Every tool is pinned with a hash (requirements-dev.txt); the package
|
|
33
|
+
# itself is installed without resolving anything else.
|
|
34
|
+
- run: python -m pip install --require-hashes -r requirements-dev.txt
|
|
35
|
+
- run: python -m pip install --no-deps --no-build-isolation -e .
|
|
36
|
+
- run: ruff check src tests tools examples
|
|
37
|
+
- run: ruff format --check src tests tools examples
|
|
38
|
+
|
|
39
|
+
typecheck:
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
permissions:
|
|
42
|
+
contents: read
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
45
|
+
with:
|
|
46
|
+
persist-credentials: false
|
|
47
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
48
|
+
with:
|
|
49
|
+
python-version: "3.11"
|
|
50
|
+
- run: python -m pip install --require-hashes -r requirements-dev.txt
|
|
51
|
+
- run: python -m pip install --no-deps --no-build-isolation -e .
|
|
52
|
+
# mypy --strict over src/sdo (configured in pyproject.toml): the package
|
|
53
|
+
# ships py.typed, so its annotations are part of the contract.
|
|
54
|
+
- run: mypy
|
|
55
|
+
|
|
56
|
+
test:
|
|
57
|
+
runs-on: ${{ matrix.os }}
|
|
58
|
+
permissions:
|
|
59
|
+
contents: read
|
|
60
|
+
strategy:
|
|
61
|
+
fail-fast: false
|
|
62
|
+
matrix:
|
|
63
|
+
os: [ubuntu-latest]
|
|
64
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
65
|
+
include:
|
|
66
|
+
- { os: macos-latest, python-version: "3.13" }
|
|
67
|
+
- { os: windows-latest, python-version: "3.13" }
|
|
68
|
+
steps:
|
|
69
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
70
|
+
with:
|
|
71
|
+
persist-credentials: false
|
|
72
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
73
|
+
with:
|
|
74
|
+
python-version: ${{ matrix.python-version }}
|
|
75
|
+
- run: python -m pip install --require-hashes -r requirements-dev.txt
|
|
76
|
+
- run: python -m pip install --no-deps --no-build-isolation -e .
|
|
77
|
+
- run: python -m pytest --cov=sdo --cov-report=term-missing --cov-branch --cov-fail-under=99
|
|
78
|
+
|
|
79
|
+
# Public-API drift gate: regenerate the golden and fail if it differs from the
|
|
80
|
+
# committed api-surface.txt. Any add/remove/rename/signature change to the
|
|
81
|
+
# public surface must be accompanied by a regenerated golden.
|
|
82
|
+
api-surface:
|
|
83
|
+
runs-on: ubuntu-latest
|
|
84
|
+
permissions:
|
|
85
|
+
contents: read
|
|
86
|
+
steps:
|
|
87
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
88
|
+
with:
|
|
89
|
+
persist-credentials: false
|
|
90
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
91
|
+
with:
|
|
92
|
+
python-version: "3.12"
|
|
93
|
+
- run: python -m pip install --require-hashes -r requirements-dev.txt
|
|
94
|
+
- run: python -m pip install --no-deps --no-build-isolation -e .
|
|
95
|
+
- name: Regenerate the public API surface
|
|
96
|
+
run: python tools/api_surface.py > api-surface.txt
|
|
97
|
+
- name: Fail if the public API changed without updating the golden
|
|
98
|
+
run: |
|
|
99
|
+
git diff --exit-code api-surface.txt \
|
|
100
|
+
|| (echo "::error::public API changed — regenerate api-surface.txt (python tools/api_surface.py > api-surface.txt) and commit" && exit 1)
|
|
101
|
+
|
|
102
|
+
codeql:
|
|
103
|
+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
|
104
|
+
runs-on: self-hosted
|
|
105
|
+
permissions:
|
|
106
|
+
contents: read
|
|
107
|
+
actions: read
|
|
108
|
+
security-events: write
|
|
109
|
+
steps:
|
|
110
|
+
# The persistent runners may still hold root-owned files that an older,
|
|
111
|
+
# container-based job left in this workspace or in the runner's temp
|
|
112
|
+
# directory (CodeQL writes its PR diff range there); reclaim both.
|
|
113
|
+
- name: Reclaim the workspace
|
|
114
|
+
working-directory: ${{ github.workspace }}
|
|
115
|
+
run: docker run --rm -v "$PWD:/w" -v "$RUNNER_TEMP:/t" busybox:1.37.0@sha256:66a6306db78bf2dbf3487f293aa8d6990d8e506fdffab9cc43fe422becf886e4 chown -R "$(id -u):$(id -g)" /w /t
|
|
116
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
117
|
+
with:
|
|
118
|
+
persist-credentials: false
|
|
119
|
+
- uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
|
120
|
+
with:
|
|
121
|
+
languages: python
|
|
122
|
+
- uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
name: commits
|
|
3
|
+
|
|
4
|
+
# A workflow of its own so that editing a pull request's title or description
|
|
5
|
+
# (`edited`) re-runs only this check, not the whole CI.
|
|
6
|
+
on:
|
|
7
|
+
pull_request:
|
|
8
|
+
types: [opened, edited, synchronize, reopened]
|
|
9
|
+
|
|
10
|
+
permissions: {}
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
# Every commit of a pull request needs a Conventional Commit subject and a DCO
|
|
14
|
+
# sign-off, and the pull request title, which becomes the squash commit's
|
|
15
|
+
# subject, must be a Conventional Commit subject too (see CONTRIBUTING.md).
|
|
16
|
+
commits:
|
|
17
|
+
name: commits
|
|
18
|
+
if: github.event_name == 'pull_request'
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
permissions:
|
|
21
|
+
contents: read
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
24
|
+
with:
|
|
25
|
+
fetch-depth: 0
|
|
26
|
+
persist-credentials: false
|
|
27
|
+
- name: Conventional Commit subjects and DCO sign-offs
|
|
28
|
+
env:
|
|
29
|
+
BASE: ${{ github.event.pull_request.base.sha }}
|
|
30
|
+
HEAD: ${{ github.event.pull_request.head.sha }}
|
|
31
|
+
TITLE: ${{ github.event.pull_request.title }}
|
|
32
|
+
run: |
|
|
33
|
+
set -euo pipefail
|
|
34
|
+
fail=0
|
|
35
|
+
for sha in $(git rev-list --no-merges "$BASE..$HEAD"); do
|
|
36
|
+
subject=$(git log -1 --format=%s "$sha")
|
|
37
|
+
if ! printf '%s\n' "$subject" | grep -qE '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9][a-z0-9/_.-]*\))?!?: .+'; then
|
|
38
|
+
echo "::error::$sha: not a Conventional Commit subject: $subject"; fail=1
|
|
39
|
+
fi
|
|
40
|
+
# Bots (Dependabot) cannot certify the DCO; everyone else signs off.
|
|
41
|
+
case "$(git log -1 --format=%ae "$sha")" in *'[bot]@users.noreply.github.com') continue ;; esac
|
|
42
|
+
if ! git log -1 --format=%B "$sha" | grep -qE '^Signed-off-by: .+ <.+@.+>$'; then
|
|
43
|
+
echo "::error::$sha: missing Signed-off-by trailer (commit with git commit -s)"; fail=1
|
|
44
|
+
fi
|
|
45
|
+
done
|
|
46
|
+
# The squash merge uses the pull request title as the commit subject.
|
|
47
|
+
if ! printf '%s\n' "$TITLE" | grep -qE '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9][a-z0-9/_.-]*\))?!?: .+'; then
|
|
48
|
+
echo "::error::pull request title is not a Conventional Commit subject: $TITLE"; fail=1
|
|
49
|
+
fi
|
|
50
|
+
exit "$fail"
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Split build (no id-token) -> minimal publish (OIDC trusted publishing). The
|
|
3
|
+
# build job installs only the hash-pinned build chain and runs nothing else
|
|
4
|
+
# between `python -m build` and the artifact upload (the tests already ran in
|
|
5
|
+
# CI on the same commit, which must be on main). The publish job carries zero
|
|
6
|
+
# third-party deps and only downloads the prebuilt artifact, mitigating
|
|
7
|
+
# OIDC-token-theft worms.
|
|
8
|
+
#
|
|
9
|
+
# Two channels, chosen by the tag (trunk-based: every tag is on main):
|
|
10
|
+
# vX.Y.Z-rc.N -> TestPyPI (environment `prerelease`; _version.py = X.Y.ZrcN)
|
|
11
|
+
# vX.Y.Z -> PyPI (environment `release`; _version.py = X.Y.Z)
|
|
12
|
+
name: publish
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
tags: ["v*"]
|
|
17
|
+
# Manual run: checks the trusted-publisher token exchange for this workflow
|
|
18
|
+
# without uploading anything (see the publisher-check job).
|
|
19
|
+
workflow_dispatch:
|
|
20
|
+
inputs:
|
|
21
|
+
index:
|
|
22
|
+
description: Index to check against
|
|
23
|
+
type: choice
|
|
24
|
+
options: [testpypi, pypi]
|
|
25
|
+
default: testpypi
|
|
26
|
+
|
|
27
|
+
permissions: {}
|
|
28
|
+
|
|
29
|
+
jobs:
|
|
30
|
+
build:
|
|
31
|
+
# Forks and mirrors never publish; a manual run only checks the publisher.
|
|
32
|
+
if: github.repository_owner == 'scrape-do' && github.event_name == 'push'
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
permissions:
|
|
35
|
+
contents: read
|
|
36
|
+
outputs:
|
|
37
|
+
channel: ${{ steps.check.outputs.channel }}
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
40
|
+
with:
|
|
41
|
+
fetch-depth: 0 # the main-ancestry guard needs origin/main and history
|
|
42
|
+
persist-credentials: false
|
|
43
|
+
- name: The tag is on main, names the package version and picks the channel
|
|
44
|
+
id: check
|
|
45
|
+
run: |
|
|
46
|
+
set -euo pipefail
|
|
47
|
+
git merge-base --is-ancestor "$GITHUB_SHA" origin/main \
|
|
48
|
+
|| { echo "::error::$GITHUB_REF_NAME ($GITHUB_SHA) is not on main"; exit 1; }
|
|
49
|
+
tag="$GITHUB_REF_NAME"
|
|
50
|
+
if [[ "$tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)-rc\.([0-9]+)$ ]]; then
|
|
51
|
+
channel="test"; want="${BASH_REMATCH[1]}rc${BASH_REMATCH[2]}" # PEP 440 spelling
|
|
52
|
+
elif [[ "$tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
|
53
|
+
channel="live"; want="${BASH_REMATCH[1]}"
|
|
54
|
+
else
|
|
55
|
+
echo "::error::$tag is neither vX.Y.Z nor vX.Y.Z-rc.N"; exit 1
|
|
56
|
+
fi
|
|
57
|
+
version="$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' src/sdo/_version.py)"
|
|
58
|
+
if [ "$version" != "$want" ]; then
|
|
59
|
+
echo "::error::tag $tag needs src/sdo/_version.py = ${want}, found ${version}"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
echo "channel=$channel" >> "$GITHUB_OUTPUT"
|
|
63
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
64
|
+
with:
|
|
65
|
+
python-version: "3.12"
|
|
66
|
+
# build, hatchling (+ its dependencies) and twine, every one hash-pinned.
|
|
67
|
+
- run: python -m pip install --require-hashes -r requirements-build.txt
|
|
68
|
+
# --no-isolation: build with the pinned hatchling instead of letting
|
|
69
|
+
# build resolve the backend's dependencies afresh.
|
|
70
|
+
- run: python -m build --no-isolation # sdist + wheel into dist/
|
|
71
|
+
# The same metadata check the publish action runs, so a metadata version
|
|
72
|
+
# it cannot read fails here, before the approval gate.
|
|
73
|
+
- run: twine check --strict dist/*
|
|
74
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
75
|
+
with:
|
|
76
|
+
name: dist
|
|
77
|
+
path: dist/
|
|
78
|
+
|
|
79
|
+
publish-test:
|
|
80
|
+
needs: build
|
|
81
|
+
if: needs.build.outputs.channel == 'test'
|
|
82
|
+
runs-on: ubuntu-latest
|
|
83
|
+
environment: prerelease # approval gate for release candidates
|
|
84
|
+
permissions:
|
|
85
|
+
contents: read
|
|
86
|
+
id-token: write # OIDC trusted publishing (TestPyPI) — no stored token
|
|
87
|
+
steps:
|
|
88
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
89
|
+
with:
|
|
90
|
+
name: dist
|
|
91
|
+
path: dist/
|
|
92
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
93
|
+
with:
|
|
94
|
+
repository-url: https://test.pypi.org/legacy/
|
|
95
|
+
|
|
96
|
+
publish:
|
|
97
|
+
needs: build
|
|
98
|
+
if: needs.build.outputs.channel == 'live'
|
|
99
|
+
runs-on: ubuntu-latest
|
|
100
|
+
environment: release # require a manual approval gate
|
|
101
|
+
permissions:
|
|
102
|
+
contents: read
|
|
103
|
+
id-token: write # OIDC trusted publishing — no stored token
|
|
104
|
+
steps:
|
|
105
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
106
|
+
with:
|
|
107
|
+
name: dist
|
|
108
|
+
path: dist/
|
|
109
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
110
|
+
|
|
111
|
+
smoke:
|
|
112
|
+
needs: [build, publish-test, publish]
|
|
113
|
+
# Exactly one of the two publish jobs ran; smoke whichever did.
|
|
114
|
+
if: ${{ always() && (needs.publish-test.result == 'success' || needs.publish.result == 'success') }}
|
|
115
|
+
runs-on: ubuntu-latest
|
|
116
|
+
permissions:
|
|
117
|
+
contents: read
|
|
118
|
+
steps:
|
|
119
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
120
|
+
with:
|
|
121
|
+
python-version: "3.12"
|
|
122
|
+
# Post-publish smoke: install from the public index and import. The index
|
|
123
|
+
# and its CDN can lag the upload, so retry with backoff before failing.
|
|
124
|
+
- name: Install the published version and import it
|
|
125
|
+
env:
|
|
126
|
+
CHANNEL: ${{ needs.build.outputs.channel }}
|
|
127
|
+
run: |
|
|
128
|
+
set -euo pipefail
|
|
129
|
+
v="${GITHUB_REF_NAME#v}"
|
|
130
|
+
export SDO_EXPECTED_VERSION="${v/-rc./rc}" # PEP 440 spelling
|
|
131
|
+
index=()
|
|
132
|
+
if [ "$CHANNEL" = test ]; then
|
|
133
|
+
# The candidate comes from TestPyPI; its dependencies from PyPI.
|
|
134
|
+
index=(--index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/)
|
|
135
|
+
fi
|
|
136
|
+
for delay in 15 30 60 120 240; do
|
|
137
|
+
# Not hash-pinned on purpose: this installs the version just published,
|
|
138
|
+
# whose hashes exist only on the index, to prove a user's install works.
|
|
139
|
+
if python -m pip install --no-cache-dir "${index[@]}" "sdo-client==${SDO_EXPECTED_VERSION}"; then
|
|
140
|
+
python -c "import os, sdo; assert sdo.__version__ == os.environ['SDO_EXPECTED_VERSION'], sdo.__version__; print('installed', sdo.__version__)"
|
|
141
|
+
exit 0
|
|
142
|
+
fi
|
|
143
|
+
echo "sdo-client==${SDO_EXPECTED_VERSION} is not installable yet; retrying in ${delay}s"
|
|
144
|
+
sleep "$delay"
|
|
145
|
+
done
|
|
146
|
+
echo "::error::sdo-client==${SDO_EXPECTED_VERSION} never became installable"
|
|
147
|
+
exit 1
|
|
148
|
+
|
|
149
|
+
# `workflow_dispatch` only: asks the chosen index to exchange this job's OIDC
|
|
150
|
+
# token for an upload token, the same exchange the publish action performs,
|
|
151
|
+
# and prints the claims the index matches against and its answer. Nothing is
|
|
152
|
+
# uploaded and a minted token is never printed (it expires on its own). On
|
|
153
|
+
# an index with a pending publisher, a successful exchange creates the empty
|
|
154
|
+
# project, as the first upload would.
|
|
155
|
+
publisher-check:
|
|
156
|
+
if: github.repository_owner == 'scrape-do' && github.event_name == 'workflow_dispatch'
|
|
157
|
+
runs-on: ubuntu-latest
|
|
158
|
+
environment: ${{ inputs.index == 'pypi' && 'release' || 'prerelease' }}
|
|
159
|
+
permissions:
|
|
160
|
+
id-token: write
|
|
161
|
+
steps:
|
|
162
|
+
- name: Exchange the GitHub OIDC token with the index
|
|
163
|
+
env:
|
|
164
|
+
INDEX_HOST: ${{ inputs.index == 'pypi' && 'pypi.org' || 'test.pypi.org' }}
|
|
165
|
+
run: |
|
|
166
|
+
set -euo pipefail
|
|
167
|
+
audience="$(curl -sSf "https://${INDEX_HOST}/_/oidc/audience" \
|
|
168
|
+
| python3 -c 'import json, sys; print(json.load(sys.stdin)["audience"])')"
|
|
169
|
+
id_token="$(curl -sSf -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
|
|
170
|
+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=${audience}" \
|
|
171
|
+
| python3 -c 'import json, sys; print(json.load(sys.stdin)["value"])')"
|
|
172
|
+
echo "::add-mask::$id_token"
|
|
173
|
+
ID_TOKEN="$id_token" python3 - <<'PY'
|
|
174
|
+
import base64, json, os
|
|
175
|
+
payload = os.environ["ID_TOKEN"].split(".")[1]
|
|
176
|
+
claims = json.loads(base64.urlsafe_b64decode(payload + "=" * (-len(payload) % 4)))
|
|
177
|
+
for k in ("sub", "repository", "repository_owner", "repository_owner_id", "repository_id",
|
|
178
|
+
"workflow_ref", "job_workflow_ref", "environment", "ref", "event_name", "aud"):
|
|
179
|
+
print(f"{k}: {json.dumps(claims.get(k))}")
|
|
180
|
+
PY
|
|
181
|
+
body="$(ID_TOKEN="$id_token" python3 -c 'import json, os; print(json.dumps({"token": os.environ["ID_TOKEN"]}))')"
|
|
182
|
+
code="$(curl -sS -o mint.json -w '%{http_code}' -X POST -H "Content-Type: application/json" \
|
|
183
|
+
--data "$body" "https://${INDEX_HOST}/_/oidc/mint-token")"
|
|
184
|
+
echo "exchange with ${INDEX_HOST}: HTTP $code"
|
|
185
|
+
python3 - <<'PY'
|
|
186
|
+
import json
|
|
187
|
+
d = json.load(open("mint.json"))
|
|
188
|
+
if d.get("success"):
|
|
189
|
+
print("The index accepted the token for this workflow (upload token not printed).")
|
|
190
|
+
else:
|
|
191
|
+
print(json.dumps({k: v for k, v in d.items() if k != "token"}, indent=2))
|
|
192
|
+
PY
|
|
193
|
+
rm -f mint.json
|
|
194
|
+
[ "$code" = "200" ]
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Security battery: secret scan, dependency vulnerability scans, supply-chain
|
|
3
|
+
# posture (Scorecard) and an SBOM. Every action is pinned to a full commit SHA.
|
|
4
|
+
name: security
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main]
|
|
9
|
+
pull_request:
|
|
10
|
+
# Weekly, so a new advisory against unchanged code still surfaces.
|
|
11
|
+
schedule:
|
|
12
|
+
- cron: "17 5 * * 1"
|
|
13
|
+
|
|
14
|
+
# Least privilege by default; each job opts in to exactly what it needs.
|
|
15
|
+
permissions: {}
|
|
16
|
+
|
|
17
|
+
# Every job runs on GitHub-hosted runners except Scorecard, which reads the
|
|
18
|
+
# repository through the GitHub API: the org's IP allow list only accepts
|
|
19
|
+
# those calls from the self-hosted runners.
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
# Secret scanning across the full git history. Uses a version-pinned, checksum
|
|
23
|
+
# -verified gitleaks binary (license-free, no org entitlement required).
|
|
24
|
+
gitleaks:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
permissions:
|
|
27
|
+
contents: read
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0 # full history for a complete secret scan
|
|
32
|
+
persist-credentials: false
|
|
33
|
+
- name: Scan git history for secrets (gitleaks)
|
|
34
|
+
env:
|
|
35
|
+
GITLEAKS_VERSION: 8.30.1
|
|
36
|
+
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
|
|
37
|
+
run: |
|
|
38
|
+
set -euo pipefail
|
|
39
|
+
curl -sSfL --retry 5 --retry-delay 10 --retry-all-errors -o gitleaks.tar.gz \
|
|
40
|
+
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
|
|
41
|
+
echo "${GITLEAKS_SHA256} gitleaks.tar.gz" | sha256sum -c -
|
|
42
|
+
tar -xzf gitleaks.tar.gz gitleaks
|
|
43
|
+
# The config and the ignore list come from this workflow, never from the
|
|
44
|
+
# checkout: a pull request could otherwise add a .gitleaks.toml or a
|
|
45
|
+
# .gitleaksignore that allowlists the secret it introduces.
|
|
46
|
+
cfg="$(mktemp -d "$RUNNER_TEMP/gitleaks.XXXXXX")"
|
|
47
|
+
printf '[extend]\nuseDefault = true\n' > "$cfg/gitleaks.toml"
|
|
48
|
+
./gitleaks git . --no-banner --redact --exit-code 1 \
|
|
49
|
+
--config "$cfg/gitleaks.toml" --gitleaks-ignore-path "$cfg"
|
|
50
|
+
|
|
51
|
+
# --- dependency vulnerability scan (OSV) --------------------------------
|
|
52
|
+
osv-scanner:
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
permissions:
|
|
55
|
+
contents: read
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
58
|
+
with:
|
|
59
|
+
persist-credentials: false
|
|
60
|
+
# The hash-pinned requirement files are the lockfiles: the runtime
|
|
61
|
+
# dependencies and every dev, build and audit tool CI installs.
|
|
62
|
+
- uses: google/osv-scanner-action/osv-scanner-action@b1d267aea5211fa648d9d442fa64b90dbdcbdd36 # v2.7.0
|
|
63
|
+
with:
|
|
64
|
+
scan-args: |-
|
|
65
|
+
--lockfile=requirements-dev.txt
|
|
66
|
+
--lockfile=requirements-build.txt
|
|
67
|
+
--lockfile=requirements-audit.txt
|
|
68
|
+
|
|
69
|
+
# --- Python dependency audit -------------------------------------------
|
|
70
|
+
pip-audit:
|
|
71
|
+
runs-on: ubuntu-latest
|
|
72
|
+
permissions:
|
|
73
|
+
contents: read
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
76
|
+
with:
|
|
77
|
+
persist-credentials: false
|
|
78
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
79
|
+
with:
|
|
80
|
+
python-version: "3.12"
|
|
81
|
+
- name: Install pip-audit (hash-pinned)
|
|
82
|
+
run: python -m pip install --require-hashes -r requirements-audit.txt
|
|
83
|
+
# Audits the pinned files as written (no resolution, nothing installed).
|
|
84
|
+
- name: Audit the pinned dependencies for known vulnerabilities
|
|
85
|
+
run: |
|
|
86
|
+
pip-audit --disable-pip --strict \
|
|
87
|
+
-r requirements-dev.txt -r requirements-build.txt -r requirements-audit.txt
|
|
88
|
+
|
|
89
|
+
# --- SBOM generation + artifact upload ----------------------------------
|
|
90
|
+
sbom:
|
|
91
|
+
runs-on: ubuntu-latest
|
|
92
|
+
permissions:
|
|
93
|
+
contents: read
|
|
94
|
+
steps:
|
|
95
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
96
|
+
with:
|
|
97
|
+
persist-credentials: false
|
|
98
|
+
- name: Generate SBOM (syft)
|
|
99
|
+
uses: anchore/sbom-action@66cbf4bc1f1c0d2edc94016e65bc221b6bb0ad6c # v0.24.3
|
|
100
|
+
with:
|
|
101
|
+
path: .
|
|
102
|
+
format: spdx-json
|
|
103
|
+
output-file: sdo-sdk-python.spdx.json
|
|
104
|
+
artifact-name: sdo-sdk-python.spdx.json
|
|
105
|
+
upload-artifact: true
|
|
106
|
+
|
|
107
|
+
# --- OpenSSF Scorecard ----------------------------------------------------
|
|
108
|
+
# For the default branch only (pushes to main and the weekly run). It reads
|
|
109
|
+
# the repository through the GitHub API, which the org's IP allow list only
|
|
110
|
+
# permits from the self-hosted runners. Publishing to the Scorecard API needs
|
|
111
|
+
# a GitHub-hosted runner, so results go to code scanning only.
|
|
112
|
+
scorecard:
|
|
113
|
+
if: github.event_name != 'pull_request'
|
|
114
|
+
runs-on: self-hosted
|
|
115
|
+
permissions:
|
|
116
|
+
security-events: write # upload the SARIF to code scanning
|
|
117
|
+
contents: read
|
|
118
|
+
actions: read
|
|
119
|
+
steps:
|
|
120
|
+
# The persistent runners may still hold root-owned files that an older,
|
|
121
|
+
# container-based job left in this workspace or in the runner's temp
|
|
122
|
+
# directory; reclaim both.
|
|
123
|
+
- name: Reclaim the workspace
|
|
124
|
+
working-directory: ${{ github.workspace }}
|
|
125
|
+
run: docker run --rm -v "$PWD:/w" -v "$RUNNER_TEMP:/t" busybox:1.37.0@sha256:66a6306db78bf2dbf3487f293aa8d6990d8e506fdffab9cc43fe422becf886e4 chown -R "$(id -u):$(id -g)" /w /t
|
|
126
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
127
|
+
with:
|
|
128
|
+
persist-credentials: false
|
|
129
|
+
- name: Run OpenSSF Scorecard
|
|
130
|
+
uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0
|
|
131
|
+
with:
|
|
132
|
+
results_file: results.sarif
|
|
133
|
+
results_format: sarif
|
|
134
|
+
publish_results: false
|
|
135
|
+
- name: Upload Scorecard SARIF artifact
|
|
136
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
137
|
+
with:
|
|
138
|
+
name: scorecard-results
|
|
139
|
+
path: results.sarif
|
|
140
|
+
retention-days: 5
|
|
141
|
+
- name: Upload Scorecard results to code scanning
|
|
142
|
+
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
|
143
|
+
with:
|
|
144
|
+
sarif_file: results.sarif
|