socketdev 3.3.0__tar.gz → 3.4.2__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.
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/workflows/dependency-review.yml +3 -3
- socketdev-3.4.2/.github/workflows/package-check.yml +58 -0
- socketdev-3.4.2/.github/workflows/pr-preview.yml +198 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/workflows/release.yml +2 -2
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/workflows/version-check.yml +1 -1
- {socketdev-3.3.0 → socketdev-3.4.2}/.hooks/sync_version.py +31 -0
- socketdev-3.4.2/CONTRIBUTING.md +49 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/PKG-INFO +1 -1
- {socketdev-3.3.0 → socketdev-3.4.2}/pyproject.toml +1 -1
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/core/dedupe.py +12 -9
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/diffscans/__init__.py +38 -4
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/exceptions.py +28 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/fullscans/__init__.py +64 -5
- socketdev-3.4.2/socketdev/purl/__init__.py +176 -0
- socketdev-3.4.2/socketdev/version.py +1 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/test_all_endpoints_unit.py +239 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/test_exceptions.py +6 -0
- socketdev-3.4.2/tests/unit/test_socket_purl_type.py +141 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/uv.lock +25 -25
- socketdev-3.3.0/.github/workflows/pr-preview.yml +0 -141
- socketdev-3.3.0/socketdev/purl/__init__.py +0 -55
- socketdev-3.3.0/socketdev/version.py +0 -1
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/CODEOWNERS +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/PULL_REQUEST_TEMPLATE/bug-fix.md +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/PULL_REQUEST_TEMPLATE/improvement.md +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/actions/setup-hatch/action.yml +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/actions/setup-sfw/action.yml +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.github/dependabot.yml +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.gitignore +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/.python-version +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/LICENSE +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/README.rst +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/scripts/build.sh +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/scripts/deploy-test-pypi.sh +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/alertfullscansearch/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/alerts/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/alerttypes/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/analytics/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/apitokens/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/auditlog/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/basics/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/core/api.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/core/classes.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/core/issues.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/dependencies/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/export/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/fixes/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/historical/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/labels/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/licensemetadata/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/log.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/npm/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/openapi/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/org/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/quota/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/report/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/repos/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/repositories/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/sbom/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/settings/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/supportedfiles/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/telemetry/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/threatfeed/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/tools/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/triage/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/uploadmanifests/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/utils/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/socketdev/webhooks/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/README.md +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/conftest.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/integration/test_all_endpoints.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/integration/test_comprehensive_integration.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/integration/test_diffscans_integration.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/integration/test_new_endpoints.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/run_tests.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/__init__.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/test_dedupe.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/test_issues_did_you_mean_props.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/test_socket_alert_category.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/test_socket_sdk_unit.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/test_upload_manifests.py +0 -0
- {socketdev-3.3.0 → socketdev-3.4.2}/tests/unit/test_working_endpoints_unit.py +0 -0
|
@@ -40,7 +40,7 @@ jobs:
|
|
|
40
40
|
workflow_or_action_changed: ${{ steps.diff.outputs.workflow_or_action_changed }}
|
|
41
41
|
is_trusted: ${{ steps.trust.outputs.is_trusted }}
|
|
42
42
|
steps:
|
|
43
|
-
- uses: actions/checkout@
|
|
43
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
44
44
|
with:
|
|
45
45
|
fetch-depth: 0
|
|
46
46
|
persist-credentials: false
|
|
@@ -124,7 +124,7 @@ jobs:
|
|
|
124
124
|
runs-on: ubuntu-latest
|
|
125
125
|
timeout-minutes: 15
|
|
126
126
|
steps:
|
|
127
|
-
- uses: actions/checkout@
|
|
127
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
128
128
|
with:
|
|
129
129
|
fetch-depth: 1
|
|
130
130
|
persist-credentials: false
|
|
@@ -197,7 +197,7 @@ jobs:
|
|
|
197
197
|
timeout-minutes: 15
|
|
198
198
|
environment: socket-firewall
|
|
199
199
|
steps:
|
|
200
|
-
- uses: actions/checkout@
|
|
200
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
201
201
|
with:
|
|
202
202
|
fetch-depth: 1
|
|
203
203
|
persist-credentials: false
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: Package Check
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: package-check-${{ github.event.pull_request.number || github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
package-check:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
timeout-minutes: 10
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
22
|
+
with:
|
|
23
|
+
fetch-depth: 1
|
|
24
|
+
persist-credentials: false
|
|
25
|
+
|
|
26
|
+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.12"
|
|
29
|
+
|
|
30
|
+
- name: Install build tooling
|
|
31
|
+
uses: ./.github/actions/setup-hatch
|
|
32
|
+
|
|
33
|
+
- name: Install test and distribution tooling
|
|
34
|
+
run: python -m pip install ".[test]" "twine>=4.0.0"
|
|
35
|
+
|
|
36
|
+
- name: Run unit tests
|
|
37
|
+
run: python -m pytest -q tests/unit
|
|
38
|
+
|
|
39
|
+
- name: Build distributions
|
|
40
|
+
run: hatch build
|
|
41
|
+
|
|
42
|
+
- name: Validate distributions
|
|
43
|
+
run: python -m twine check dist/*
|
|
44
|
+
|
|
45
|
+
- name: Install and smoke-test wheel
|
|
46
|
+
run: |
|
|
47
|
+
python -m venv "$RUNNER_TEMP/package-check"
|
|
48
|
+
"$RUNNER_TEMP/package-check/bin/pip" install --upgrade pip
|
|
49
|
+
"$RUNNER_TEMP/package-check/bin/pip" install dist/*.whl
|
|
50
|
+
"$RUNNER_TEMP/package-check/bin/python" -c "import socketdev; from socketdev.version import __version__; print('wheel smoke OK', __version__)"
|
|
51
|
+
|
|
52
|
+
- name: Upload distributions
|
|
53
|
+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
54
|
+
with:
|
|
55
|
+
name: socketdev-${{ github.sha }}
|
|
56
|
+
path: dist/*
|
|
57
|
+
if-no-files-found: error
|
|
58
|
+
retention-days: 14
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
name: Publish PR Preview
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [labeled]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
pr_number:
|
|
9
|
+
description: Pull request number to publish
|
|
10
|
+
required: true
|
|
11
|
+
type: string
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: publish-pr-preview-${{ github.event.pull_request.number || github.run_id }}
|
|
15
|
+
cancel-in-progress: false
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
context:
|
|
19
|
+
if: >-
|
|
20
|
+
github.event_name == 'workflow_dispatch' ||
|
|
21
|
+
(github.event.label.name == 'publish-preview' &&
|
|
22
|
+
github.event.pull_request.head.repo.full_name == github.repository)
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
timeout-minutes: 5
|
|
25
|
+
permissions:
|
|
26
|
+
contents: read
|
|
27
|
+
pull-requests: read
|
|
28
|
+
outputs:
|
|
29
|
+
pr_number: ${{ steps.context.outputs.pr_number }}
|
|
30
|
+
head_sha: ${{ steps.context.outputs.head_sha }}
|
|
31
|
+
steps:
|
|
32
|
+
- name: Validate pull request context
|
|
33
|
+
id: context
|
|
34
|
+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
35
|
+
env:
|
|
36
|
+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
37
|
+
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
38
|
+
INPUT_PR_NUMBER: ${{ inputs.pr_number }}
|
|
39
|
+
WORKFLOW_REF: ${{ github.ref }}
|
|
40
|
+
with:
|
|
41
|
+
script: |
|
|
42
|
+
const rawPrNumber = context.eventName === 'workflow_dispatch'
|
|
43
|
+
? process.env.INPUT_PR_NUMBER
|
|
44
|
+
: process.env.EVENT_PR_NUMBER;
|
|
45
|
+
if (!/^[1-9][0-9]*$/.test(rawPrNumber || '')) {
|
|
46
|
+
core.setFailed('Pull request number must contain ASCII digits only.');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (context.eventName === 'workflow_dispatch') {
|
|
51
|
+
const defaultRef = `refs/heads/${process.env.DEFAULT_BRANCH}`;
|
|
52
|
+
if (process.env.WORKFLOW_REF !== defaultRef) {
|
|
53
|
+
core.setFailed(`Run manual previews from ${defaultRef}.`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const prNumber = Number(rawPrNumber);
|
|
59
|
+
if (!Number.isSafeInteger(prNumber)) {
|
|
60
|
+
core.setFailed('Pull request number is outside the supported range.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const {data: pullRequest} = await github.rest.pulls.get({
|
|
64
|
+
owner: context.repo.owner,
|
|
65
|
+
repo: context.repo.repo,
|
|
66
|
+
pull_number: prNumber,
|
|
67
|
+
});
|
|
68
|
+
if (pullRequest.state !== 'open') {
|
|
69
|
+
core.setFailed(`Pull request #${prNumber} is not open.`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (pullRequest.head.repo?.full_name !== `${context.repo.owner}/${context.repo.repo}`) {
|
|
73
|
+
core.setFailed('Preview publication is limited to branches in this repository.');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
core.setOutput('pr_number', String(prNumber));
|
|
78
|
+
core.setOutput('head_sha', pullRequest.head.sha);
|
|
79
|
+
|
|
80
|
+
build:
|
|
81
|
+
needs: context
|
|
82
|
+
runs-on: ubuntu-latest
|
|
83
|
+
timeout-minutes: 10
|
|
84
|
+
permissions:
|
|
85
|
+
contents: read
|
|
86
|
+
outputs:
|
|
87
|
+
preview_version: ${{ steps.version.outputs.preview_version }}
|
|
88
|
+
steps:
|
|
89
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
90
|
+
with:
|
|
91
|
+
ref: ${{ needs.context.outputs.head_sha }}
|
|
92
|
+
fetch-depth: 0
|
|
93
|
+
persist-credentials: false
|
|
94
|
+
|
|
95
|
+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
96
|
+
with:
|
|
97
|
+
python-version: "3.12"
|
|
98
|
+
|
|
99
|
+
- name: Install build tooling
|
|
100
|
+
uses: ./.github/actions/setup-hatch
|
|
101
|
+
|
|
102
|
+
- name: Install distribution validator
|
|
103
|
+
run: python -m pip install "twine>=4.0.0"
|
|
104
|
+
|
|
105
|
+
- name: Inject deterministic preview version
|
|
106
|
+
env:
|
|
107
|
+
PREVIEW_ID: ${{ github.run_id }}
|
|
108
|
+
RUN_ATTEMPT: ${{ github.run_attempt }}
|
|
109
|
+
run: |
|
|
110
|
+
PREVIEW_ID=$((PREVIEW_ID * 100 + RUN_ATTEMPT))
|
|
111
|
+
python .hooks/sync_version.py --dev --preview-id "$PREVIEW_ID" --skip-lock
|
|
112
|
+
|
|
113
|
+
- name: Read preview version
|
|
114
|
+
id: version
|
|
115
|
+
run: echo "preview_version=$(hatch version)" >> "$GITHUB_OUTPUT"
|
|
116
|
+
|
|
117
|
+
- name: Build and validate distributions
|
|
118
|
+
run: |
|
|
119
|
+
hatch build
|
|
120
|
+
python -m twine check dist/*
|
|
121
|
+
|
|
122
|
+
- name: Install and smoke-test wheel locally
|
|
123
|
+
run: |
|
|
124
|
+
python -m venv "$RUNNER_TEMP/preview-check"
|
|
125
|
+
"$RUNNER_TEMP/preview-check/bin/pip" install --upgrade pip
|
|
126
|
+
"$RUNNER_TEMP/preview-check/bin/pip" install dist/*.whl
|
|
127
|
+
"$RUNNER_TEMP/preview-check/bin/python" -c "import socketdev; from socketdev.version import __version__; print('preview wheel smoke OK', __version__)"
|
|
128
|
+
|
|
129
|
+
- name: Upload preview distributions
|
|
130
|
+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
131
|
+
with:
|
|
132
|
+
name: socketdev-preview-${{ github.run_id }}-${{ github.run_attempt }}
|
|
133
|
+
path: dist/*
|
|
134
|
+
if-no-files-found: error
|
|
135
|
+
retention-days: 14
|
|
136
|
+
|
|
137
|
+
publish:
|
|
138
|
+
needs: [context, build]
|
|
139
|
+
runs-on: ubuntu-latest
|
|
140
|
+
timeout-minutes: 10
|
|
141
|
+
permissions:
|
|
142
|
+
contents: read
|
|
143
|
+
id-token: write
|
|
144
|
+
pull-requests: write
|
|
145
|
+
steps:
|
|
146
|
+
- name: Download preview distributions
|
|
147
|
+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
148
|
+
with:
|
|
149
|
+
name: socketdev-preview-${{ github.run_id }}-${{ github.run_attempt }}
|
|
150
|
+
path: dist
|
|
151
|
+
|
|
152
|
+
- name: Publish to TestPyPI
|
|
153
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
|
|
154
|
+
with:
|
|
155
|
+
repository-url: https://test.pypi.org/legacy/
|
|
156
|
+
verbose: true
|
|
157
|
+
|
|
158
|
+
- name: Comment on pull request
|
|
159
|
+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
160
|
+
env:
|
|
161
|
+
PREVIEW_VERSION: ${{ needs.build.outputs.preview_version }}
|
|
162
|
+
PR_NUMBER: ${{ needs.context.outputs.pr_number }}
|
|
163
|
+
with:
|
|
164
|
+
script: |
|
|
165
|
+
const marker = '<!-- socketdev-pr-preview -->';
|
|
166
|
+
const prNumber = Number(process.env.PR_NUMBER);
|
|
167
|
+
const version = process.env.PREVIEW_VERSION;
|
|
168
|
+
const body = `${marker}
|
|
169
|
+
🚀 SDK preview published: \`socketdev==${version}\`
|
|
170
|
+
|
|
171
|
+
\`\`\`bash
|
|
172
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketdev==${version}
|
|
173
|
+
\`\`\`
|
|
174
|
+
|
|
175
|
+
TestPyPI's package index can take several minutes to expose a newly uploaded version.`;
|
|
176
|
+
const {data: comments} = await github.rest.issues.listComments({
|
|
177
|
+
owner: context.repo.owner,
|
|
178
|
+
repo: context.repo.repo,
|
|
179
|
+
issue_number: prNumber,
|
|
180
|
+
});
|
|
181
|
+
const existing = comments.find(comment =>
|
|
182
|
+
comment.user.type === 'Bot' && comment.body.includes(marker)
|
|
183
|
+
);
|
|
184
|
+
if (existing) {
|
|
185
|
+
await github.rest.issues.updateComment({
|
|
186
|
+
owner: context.repo.owner,
|
|
187
|
+
repo: context.repo.repo,
|
|
188
|
+
comment_id: existing.id,
|
|
189
|
+
body,
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
await github.rest.issues.createComment({
|
|
193
|
+
owner: context.repo.owner,
|
|
194
|
+
repo: context.repo.repo,
|
|
195
|
+
issue_number: prNumber,
|
|
196
|
+
body,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
@@ -10,7 +10,7 @@ jobs:
|
|
|
10
10
|
id-token: write
|
|
11
11
|
contents: read
|
|
12
12
|
steps:
|
|
13
|
-
- uses: actions/checkout@
|
|
13
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
14
14
|
with:
|
|
15
15
|
fetch-depth: 0
|
|
16
16
|
persist-credentials: false
|
|
@@ -53,7 +53,7 @@ jobs:
|
|
|
53
53
|
|
|
54
54
|
- name: Publish to PyPI
|
|
55
55
|
if: steps.version_check.outputs.pypi_exists != 'true'
|
|
56
|
-
uses: pypa/gh-action-pypi-publish@
|
|
56
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
|
|
57
57
|
|
|
58
58
|
- name: Verify package is installable
|
|
59
59
|
id: verify_package
|
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
if: github.event.pull_request.user.login != 'dependabot[bot]'
|
|
21
21
|
runs-on: ubuntu-latest
|
|
22
22
|
steps:
|
|
23
|
-
- uses: actions/checkout@
|
|
23
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
24
24
|
with:
|
|
25
25
|
fetch-depth: 0 # Fetch all history for all branches
|
|
26
26
|
persist-credentials: false
|
|
@@ -124,13 +124,44 @@ def run_uv_lock() -> bool:
|
|
|
124
124
|
return before != after
|
|
125
125
|
|
|
126
126
|
|
|
127
|
+
def read_preview_id():
|
|
128
|
+
if "--preview-id" not in sys.argv:
|
|
129
|
+
return None
|
|
130
|
+
|
|
131
|
+
option_index = sys.argv.index("--preview-id")
|
|
132
|
+
try:
|
|
133
|
+
preview_id = sys.argv[option_index + 1]
|
|
134
|
+
except IndexError:
|
|
135
|
+
print("❌ `--preview-id` requires a numeric value.")
|
|
136
|
+
sys.exit(1)
|
|
137
|
+
|
|
138
|
+
if not preview_id.isascii() or not preview_id.isdigit():
|
|
139
|
+
print("❌ `--preview-id` must contain ASCII digits only.")
|
|
140
|
+
sys.exit(1)
|
|
141
|
+
return preview_id
|
|
142
|
+
|
|
143
|
+
|
|
127
144
|
def main():
|
|
128
145
|
dev_mode = "--dev" in sys.argv
|
|
146
|
+
skip_lock = "--skip-lock" in sys.argv
|
|
147
|
+
preview_id = read_preview_id()
|
|
129
148
|
current_version = read_version_from_version_file(VERSION_FILE)
|
|
130
149
|
previous_version = read_version_from_git("socketdev/version.py")
|
|
131
150
|
|
|
132
151
|
print(f"Current: {current_version}, Previous: {previous_version}")
|
|
133
152
|
|
|
153
|
+
if preview_id is not None:
|
|
154
|
+
if not dev_mode:
|
|
155
|
+
print("❌ `--preview-id` can only be used with `--dev`.")
|
|
156
|
+
sys.exit(1)
|
|
157
|
+
base_version = current_version.split(".dev")[0]
|
|
158
|
+
new_version = f"{base_version}.dev{preview_id}"
|
|
159
|
+
inject_version(new_version)
|
|
160
|
+
if not skip_lock:
|
|
161
|
+
run_uv_lock()
|
|
162
|
+
print(f"✅ Prepared deterministic preview version {new_version}.")
|
|
163
|
+
sys.exit(0)
|
|
164
|
+
|
|
134
165
|
if current_version == previous_version:
|
|
135
166
|
if dev_mode:
|
|
136
167
|
base_version = current_version.split(".dev")[0] if ".dev" in current_version else current_version
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Development setup
|
|
4
|
+
|
|
5
|
+
Use Python 3.9 or newer. Create and activate a virtual environment, then
|
|
6
|
+
install the package with its development and test dependencies:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
python -m venv .venv
|
|
10
|
+
source .venv/bin/activate
|
|
11
|
+
python -m pip install -e ".[dev,test]"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Before opening a pull request, run the focused checks for your change. The
|
|
15
|
+
complete local check is:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
python -m pytest
|
|
19
|
+
hatch build
|
|
20
|
+
python -m twine check dist/*
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Pull request validation
|
|
24
|
+
|
|
25
|
+
The `Package Check` workflow runs automatically for pull requests. It runs the
|
|
26
|
+
unit tests, builds and validates the distributions, smoke-tests the wheel, and
|
|
27
|
+
uploads the distributions as workflow artifacts. It does not publish a package.
|
|
28
|
+
|
|
29
|
+
## Publishing a pull request preview
|
|
30
|
+
|
|
31
|
+
Preview publication is intentionally opt-in. Only request a preview for code
|
|
32
|
+
that is trusted to run with the repository's publishing permissions.
|
|
33
|
+
|
|
34
|
+
For a pull request from this repository, apply the `publish-preview` label. The
|
|
35
|
+
`Publish PR Preview` workflow will build and validate a uniquely versioned
|
|
36
|
+
`socketdev` prerelease, publish it to TestPyPI, and add or update a pull request
|
|
37
|
+
comment with the exact version and installation command. Both label-triggered
|
|
38
|
+
and manually dispatched previews are limited to open pull requests whose
|
|
39
|
+
branches belong to this repository.
|
|
40
|
+
|
|
41
|
+
The workflow reacts when the label is added; pushing another commit while the
|
|
42
|
+
label remains on the pull request does not publish a new preview. To publish the
|
|
43
|
+
new pull request head or retry a failed publication, remove `publish-preview`
|
|
44
|
+
and apply it again.
|
|
45
|
+
|
|
46
|
+
Maintainers can also open **Actions > Publish PR Preview > Run workflow**, run
|
|
47
|
+
it from the repository's default branch, and enter the pull request number.
|
|
48
|
+
Manual dispatch is useful when a label should remain unchanged or a
|
|
49
|
+
publication needs to be retried.
|
|
@@ -11,8 +11,8 @@ class Dedupe:
|
|
|
11
11
|
@staticmethod
|
|
12
12
|
def alert_key(alert: dict) -> tuple:
|
|
13
13
|
return (
|
|
14
|
-
alert
|
|
15
|
-
alert
|
|
14
|
+
alert.get("type"),
|
|
15
|
+
alert.get("severity"),
|
|
16
16
|
alert.get("category"),
|
|
17
17
|
Dedupe.normalize_file_path(alert.get("file")),
|
|
18
18
|
alert.get("start"),
|
|
@@ -23,8 +23,8 @@ class Dedupe:
|
|
|
23
23
|
def consolidate_and_merge_alerts(package_group: List[Dict[str, Any]]) -> Dict[str, Any]:
|
|
24
24
|
def alert_identity(alert: dict) -> tuple:
|
|
25
25
|
return (
|
|
26
|
-
alert
|
|
27
|
-
alert
|
|
26
|
+
alert.get("type"),
|
|
27
|
+
alert.get("severity"),
|
|
28
28
|
alert.get("category"),
|
|
29
29
|
Dedupe.normalize_file_path(alert.get("file")),
|
|
30
30
|
alert.get("start"),
|
|
@@ -41,14 +41,17 @@ class Dedupe:
|
|
|
41
41
|
identity = alert_identity(alert)
|
|
42
42
|
|
|
43
43
|
if identity not in alert_map:
|
|
44
|
-
# Build alert dict with only fields that exist in the original alert
|
|
44
|
+
# Build alert dict with only fields that exist in the original alert.
|
|
45
|
+
# Use .get() for key/type/severity/action so synthetic status rows
|
|
46
|
+
# (e.g. pendingScan/notFound), which are built server-side from a
|
|
47
|
+
# minimal {type, key} base, don't raise KeyError here.
|
|
45
48
|
consolidated_alert = {
|
|
46
|
-
"key": alert
|
|
47
|
-
"type": alert
|
|
48
|
-
"severity": alert
|
|
49
|
+
"key": alert.get("key"), # keep the first key seen
|
|
50
|
+
"type": alert.get("type"),
|
|
51
|
+
"severity": alert.get("severity"),
|
|
49
52
|
"releases": [release],
|
|
50
53
|
"props": alert.get("props", []),
|
|
51
|
-
"action": alert
|
|
54
|
+
"action": alert.get("action")
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
# Only include optional fields if they exist in the original alert
|
|
@@ -21,12 +21,45 @@ class DiffScans:
|
|
|
21
21
|
log.error(f"Error listing diff scans: {response.status_code}, message: {response.text}")
|
|
22
22
|
return {}
|
|
23
23
|
|
|
24
|
-
def get(self, org_slug: str, diff_scan_id: str) -> dict:
|
|
25
|
-
"""Fetch a diff scan by ID.
|
|
24
|
+
def get(self, org_slug: str, diff_scan_id: str, params: Optional[Dict[str, Any]] = None) -> dict:
|
|
25
|
+
"""Fetch a diff scan by ID.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
org_slug: Organization slug
|
|
29
|
+
diff_scan_id: The ID of the diff scan to fetch
|
|
30
|
+
params: Optional query parameters. Supports:
|
|
31
|
+
cached: When "true", return pre-computed results immediately
|
|
32
|
+
(200) or a processing status (202) instead of holding
|
|
33
|
+
the connection open while the diff is computed.
|
|
34
|
+
omit_unchanged: When "true", omit unchanged artifacts.
|
|
35
|
+
omit_license_details: When "true", omit license details.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
dict: On 200, the API response containing the diff_scan object.
|
|
39
|
+
On 202 (results still processing when cached=true), a dict of
|
|
40
|
+
{"status": "processing", "id": diff_scan_id} so callers can
|
|
41
|
+
poll until the diff scan is ready. Empty dict on error.
|
|
42
|
+
"""
|
|
43
|
+
import urllib.parse
|
|
26
44
|
path = f"orgs/{org_slug}/diff-scans/{diff_scan_id}"
|
|
45
|
+
if params:
|
|
46
|
+
path += "?" + urllib.parse.urlencode(params, doseq=True)
|
|
27
47
|
response = self.api.do_request(path=path, method="GET")
|
|
28
48
|
if response.status_code == 200:
|
|
29
49
|
return response.json()
|
|
50
|
+
if response.status_code == 202:
|
|
51
|
+
result = {}
|
|
52
|
+
try:
|
|
53
|
+
body = response.json()
|
|
54
|
+
if isinstance(body, dict):
|
|
55
|
+
result.update(body)
|
|
56
|
+
except ValueError:
|
|
57
|
+
pass
|
|
58
|
+
# HTTP 202 always means the requested diff is still processing.
|
|
59
|
+
# Keep any additional response fields, but make the polling
|
|
60
|
+
# sentinel and requested resource ID authoritative for callers.
|
|
61
|
+
result.update({"status": "processing", "id": diff_scan_id})
|
|
62
|
+
return result
|
|
30
63
|
log.error(f"Error fetching diff scan: {response.status_code}, message: {response.text}")
|
|
31
64
|
return {}
|
|
32
65
|
|
|
@@ -61,7 +94,8 @@ class DiffScans:
|
|
|
61
94
|
import urllib.parse
|
|
62
95
|
path = f"orgs/{org_slug}/diff-scans/from-repo/{repo_slug}"
|
|
63
96
|
if params:
|
|
64
|
-
|
|
97
|
+
# doseq=True so list values (e.g. committers) become repeated params
|
|
98
|
+
path += "?" + urllib.parse.urlencode(params, doseq=True)
|
|
65
99
|
|
|
66
100
|
# Use lazy loading if requested
|
|
67
101
|
if use_lazy_loading:
|
|
@@ -80,7 +114,7 @@ class DiffScans:
|
|
|
80
114
|
import urllib.parse
|
|
81
115
|
path = f"orgs/{org_slug}/diff-scans/from-ids"
|
|
82
116
|
if params:
|
|
83
|
-
path += "?" + urllib.parse.urlencode(params)
|
|
117
|
+
path += "?" + urllib.parse.urlencode(params, doseq=True)
|
|
84
118
|
response = self.api.do_request(path=path, method="POST")
|
|
85
119
|
if response.status_code in (200, 201):
|
|
86
120
|
return response.json()
|
|
@@ -78,3 +78,31 @@ class APIBadGateway(APIFailure):
|
|
|
78
78
|
|
|
79
79
|
def __init__(self, *args):
|
|
80
80
|
super().__init__(*args, status_code=502)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class APIPartialResponse(APIFailure):
|
|
84
|
+
"""Raised by ``purl.post(strict=True)`` when the batch response omits requested inputs.
|
|
85
|
+
|
|
86
|
+
The batch purl API is fail-open: input purls whose resolution/analysis has not
|
|
87
|
+
completed are silently dropped from the response unless the caller opts in via
|
|
88
|
+
``alerts=True`` (synthetic ``pendingScan``/``notFound`` rows) or ``poll=True`` (a
|
|
89
|
+
bounded fail-closed wait). ``strict=True`` turns that silent omission into this
|
|
90
|
+
explicit error so callers get a first-class "partial batch" signal without having
|
|
91
|
+
to diff the response themselves.
|
|
92
|
+
|
|
93
|
+
The ``missing`` attribute holds the requested purls that were absent from the
|
|
94
|
+
response (the HTTP call itself succeeded, so there is no status code). A missing
|
|
95
|
+
row may reflect pending analysis, a malformed or unknown purl, or a response contract
|
|
96
|
+
failure, so blindly retrying is not guaranteed to succeed. Callers that need a bounded
|
|
97
|
+
wait should use ``poll=True``; callers that need omission reasons should request
|
|
98
|
+
``alerts=True`` and/or ``purl_errors=True``.
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
def __init__(self, *args, missing=None):
|
|
102
|
+
super().__init__(*args)
|
|
103
|
+
self.missing = list(missing or [])
|
|
104
|
+
|
|
105
|
+
def is_transient_error(self) -> bool:
|
|
106
|
+
# The HTTP request completed successfully, and the omission reason may be
|
|
107
|
+
# permanent. Server-side polling is the explicit bounded retry mechanism.
|
|
108
|
+
return False
|
|
@@ -12,9 +12,46 @@ log = logging.getLogger("socketdev")
|
|
|
12
12
|
|
|
13
13
|
class SocketPURL_Type(str, Enum):
|
|
14
14
|
UNKNOWN = "unknown"
|
|
15
|
+
APK = "apk"
|
|
16
|
+
BITBUCKET = "bitbucket"
|
|
17
|
+
CARGO = "cargo"
|
|
18
|
+
COCOAPODS = "cocoapods"
|
|
19
|
+
COMPOSER = "composer"
|
|
20
|
+
CONAN = "conan"
|
|
21
|
+
CONDA = "conda"
|
|
22
|
+
CRAN = "cran"
|
|
23
|
+
DEB = "deb"
|
|
24
|
+
DOCKER = "docker"
|
|
25
|
+
GEM = "gem"
|
|
26
|
+
GENERIC = "generic"
|
|
27
|
+
GITHUB = "github"
|
|
28
|
+
GOLANG = "golang"
|
|
29
|
+
HACKAGE = "hackage"
|
|
30
|
+
HEX = "hex"
|
|
31
|
+
HUGGINGFACE = "huggingface"
|
|
32
|
+
LUAROCKS = "luarocks"
|
|
33
|
+
MAVEN = "maven"
|
|
34
|
+
MLFLOW = "mlflow"
|
|
15
35
|
NPM = "npm"
|
|
36
|
+
NUGET = "nuget"
|
|
37
|
+
OCI = "oci"
|
|
38
|
+
PUB = "pub"
|
|
16
39
|
PYPI = "pypi"
|
|
17
|
-
|
|
40
|
+
RPM = "rpm"
|
|
41
|
+
SWIFT = "swift"
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def _missing_(cls, value):
|
|
45
|
+
# The API can emit purl types this SDK does not know about yet. Fall
|
|
46
|
+
# back to UNKNOWN instead of raising so one artifact cannot fail an
|
|
47
|
+
# entire response parse (same forward-compat approach as
|
|
48
|
+
# SocketCategory, https://github.com/SocketDev/socket-sdk-python/issues/78).
|
|
49
|
+
log.warning(
|
|
50
|
+
"Unknown SocketPURL_Type %r; falling back to UNKNOWN. "
|
|
51
|
+
"Upgrade socketdev to pick up newer purl types.",
|
|
52
|
+
value,
|
|
53
|
+
)
|
|
54
|
+
return cls.UNKNOWN
|
|
18
55
|
|
|
19
56
|
|
|
20
57
|
class SocketIssueSeverity(str, Enum):
|
|
@@ -726,13 +763,24 @@ class FullScanStreamResponse:
|
|
|
726
763
|
|
|
727
764
|
@classmethod
|
|
728
765
|
def from_dict(cls, data: dict) -> "FullScanStreamResponse":
|
|
766
|
+
artifacts = None
|
|
767
|
+
if data.get("artifacts"):
|
|
768
|
+
artifacts = {}
|
|
769
|
+
for artifact_id, raw in data["artifacts"].items():
|
|
770
|
+
try:
|
|
771
|
+
artifacts[artifact_id] = SocketArtifact.from_dict(raw)
|
|
772
|
+
except Exception:
|
|
773
|
+
# One malformed artifact should not fail the whole stream.
|
|
774
|
+
log.warning(
|
|
775
|
+
"Skipping artifact %s that could not be parsed",
|
|
776
|
+
artifact_id,
|
|
777
|
+
exc_info=True,
|
|
778
|
+
)
|
|
729
779
|
return cls(
|
|
730
780
|
success=data["success"],
|
|
731
781
|
status=data["status"],
|
|
732
782
|
message=data.get("message"),
|
|
733
|
-
artifacts=
|
|
734
|
-
if data.get("artifacts")
|
|
735
|
-
else None,
|
|
783
|
+
artifacts=artifacts,
|
|
736
784
|
)
|
|
737
785
|
|
|
738
786
|
|
|
@@ -907,7 +955,18 @@ class FullScans:
|
|
|
907
955
|
stream_str.append(item)
|
|
908
956
|
stream_deduped = Dedupe.dedupe(stream_str, batched=False)
|
|
909
957
|
for batch in stream_deduped:
|
|
910
|
-
|
|
958
|
+
try:
|
|
959
|
+
artifact_id = batch["id"]
|
|
960
|
+
if not isinstance(artifact_id, str) or not artifact_id:
|
|
961
|
+
raise TypeError("artifact id must be a non-empty string")
|
|
962
|
+
artifacts[artifact_id] = batch
|
|
963
|
+
except (KeyError, TypeError):
|
|
964
|
+
# A malformed artifact should not discard valid stream results
|
|
965
|
+
# before FullScanStreamResponse can parse them individually.
|
|
966
|
+
log.warning(
|
|
967
|
+
"Skipping artifact without a usable id",
|
|
968
|
+
exc_info=True,
|
|
969
|
+
)
|
|
911
970
|
if use_types:
|
|
912
971
|
return FullScanStreamResponse.from_dict({"success": True, "status": 200, "artifacts": artifacts})
|
|
913
972
|
return artifacts
|