socketdev 3.0.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.
Files changed (46) hide show
  1. socketdev-3.0.0/.github/CODEOWNERS +1 -0
  2. socketdev-3.0.0/.github/workflows/pr-preview.yml +131 -0
  3. socketdev-3.0.0/.github/workflows/release.yml +75 -0
  4. socketdev-3.0.0/.github/workflows/version-check.yml +90 -0
  5. socketdev-3.0.0/.gitignore +16 -0
  6. socketdev-3.0.0/.hooks/sync_version.py +95 -0
  7. socketdev-3.0.0/.python-version +1 -0
  8. socketdev-3.0.0/LICENSE +21 -0
  9. socketdev-3.0.0/PKG-INFO +830 -0
  10. socketdev-3.0.0/README.rst +779 -0
  11. socketdev-3.0.0/pyproject.toml +126 -0
  12. socketdev-3.0.0/scripts/build.sh +21 -0
  13. socketdev-3.0.0/scripts/deploy-test-pypi.sh +50 -0
  14. socketdev-3.0.0/socketdev/__init__.py +69 -0
  15. socketdev-3.0.0/socketdev/apitokens/__init__.py +0 -0
  16. socketdev-3.0.0/socketdev/auditlog/__init__.py +0 -0
  17. socketdev-3.0.0/socketdev/core/api.py +144 -0
  18. socketdev-3.0.0/socketdev/core/classes.py +148 -0
  19. socketdev-3.0.0/socketdev/core/dedupe.py +105 -0
  20. socketdev-3.0.0/socketdev/core/issues.py +2101 -0
  21. socketdev-3.0.0/socketdev/dependencies/__init__.py +48 -0
  22. socketdev-3.0.0/socketdev/diffscans/__init__.py +105 -0
  23. socketdev-3.0.0/socketdev/exceptions.py +47 -0
  24. socketdev-3.0.0/socketdev/export/__init__.py +75 -0
  25. socketdev-3.0.0/socketdev/fullscans/__init__.py +888 -0
  26. socketdev-3.0.0/socketdev/historical/__init__.py +84 -0
  27. socketdev-3.0.0/socketdev/labels/__init__.py +121 -0
  28. socketdev-3.0.0/socketdev/licensemetadata/__init__.py +27 -0
  29. socketdev-3.0.0/socketdev/log.py +4 -0
  30. socketdev-3.0.0/socketdev/npm/__init__.py +28 -0
  31. socketdev-3.0.0/socketdev/openapi/__init__.py +19 -0
  32. socketdev-3.0.0/socketdev/org/__init__.py +34 -0
  33. socketdev-3.0.0/socketdev/purl/__init__.py +41 -0
  34. socketdev-3.0.0/socketdev/quota/__init__.py +19 -0
  35. socketdev-3.0.0/socketdev/report/__init__.py +72 -0
  36. socketdev-3.0.0/socketdev/repos/__init__.py +165 -0
  37. socketdev-3.0.0/socketdev/repositories/__init__.py +31 -0
  38. socketdev-3.0.0/socketdev/sbom/__init__.py +62 -0
  39. socketdev-3.0.0/socketdev/settings/__init__.py +172 -0
  40. socketdev-3.0.0/socketdev/threatfeed/__init__.py +0 -0
  41. socketdev-3.0.0/socketdev/tools/__init__.py +65 -0
  42. socketdev-3.0.0/socketdev/triage/__init__.py +47 -0
  43. socketdev-3.0.0/socketdev/utils/__init__.py +284 -0
  44. socketdev-3.0.0/socketdev/version.py +1 -0
  45. socketdev-3.0.0/tests/integration/test_diffscans_integration.py +319 -0
  46. socketdev-3.0.0/uv.lock +1203 -0
@@ -0,0 +1 @@
1
+ * @socketdev/eng
@@ -0,0 +1,131 @@
1
+ name: PR Preview
2
+ on:
3
+ pull_request:
4
+ types: [opened, synchronize, ready_for_review]
5
+
6
+ jobs:
7
+ preview:
8
+ runs-on: ubuntu-latest
9
+ permissions:
10
+ id-token: write
11
+ contents: read
12
+ pull-requests: write
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: '3.x'
20
+
21
+ # Install all dependencies from pyproject.toml
22
+ - name: Install dependencies
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ pip install hatchling==1.27.0
26
+ pip install hatch==1.14.0
27
+
28
+ - name: Inject full dynamic version
29
+ run: python .hooks/sync_version.py --dev
30
+
31
+ - name: Check if version exists on Test PyPI
32
+ id: version_check
33
+ run: |
34
+ VERSION=$(hatch version | cut -d+ -f1)
35
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
36
+ if curl -s -f https://test.pypi.org/pypi/socketdev/$VERSION/json > /dev/null; then
37
+ echo "Version ${VERSION} already exists on Test PyPI"
38
+ echo "exists=true" >> $GITHUB_OUTPUT
39
+ else
40
+ echo "Version ${VERSION} not found on Test PyPI - proceeding with test deployment"
41
+ echo "exists=false" >> $GITHUB_OUTPUT
42
+ fi
43
+
44
+ - name: Clean previous builds
45
+ run: rm -rf dist/ build/ *.egg-info
46
+
47
+ - name: Get Hatch version
48
+ id: version
49
+ run: |
50
+ VERSION=$(hatch version | cut -d+ -f1)
51
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
52
+
53
+ - name: Build package
54
+ if: steps.version_check.outputs.exists != 'true'
55
+ run: |
56
+ hatch build
57
+
58
+ - name: Publish to Test PyPI
59
+ if: steps.version_check.outputs.exists != 'true'
60
+ uses: pypa/gh-action-pypi-publish@v1.12.4
61
+ with:
62
+ repository-url: https://test.pypi.org/legacy/
63
+ verbose: true
64
+
65
+ - name: Comment on PR
66
+ if: steps.version_check.outputs.exists != 'true'
67
+ uses: actions/github-script@v7
68
+ env:
69
+ VERSION: ${{ env.VERSION }}
70
+ with:
71
+ script: |
72
+ const version = process.env.VERSION;
73
+ const prNumber = context.payload.pull_request.number;
74
+ const owner = context.repo.owner;
75
+ const repo = context.repo.repo;
76
+ // Find existing bot comments
77
+ const comments = await github.rest.issues.listComments({
78
+ owner: context.repo.owner,
79
+ repo: context.repo.repo,
80
+ issue_number: prNumber,
81
+ });
82
+
83
+ const botComment = comments.data.find(comment =>
84
+ comment.user.type === 'Bot' &&
85
+ comment.body.includes('🚀 Preview package published!')
86
+ );
87
+
88
+ const comment = `
89
+ 🚀 Preview package published!
90
+
91
+ Install with:
92
+ \`\`\`bash
93
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketdev==${version}
94
+ \`\`\``;
95
+
96
+ if (botComment) {
97
+ // Update existing comment
98
+ await github.rest.issues.updateComment({
99
+ owner: owner,
100
+ repo: repo,
101
+ comment_id: botComment.id,
102
+ body: comment
103
+ });
104
+ } else {
105
+ // Create new comment
106
+ await github.rest.issues.createComment({
107
+ owner: owner,
108
+ repo: repo,
109
+ issue_number: prNumber,
110
+ body: comment
111
+ });
112
+ }
113
+
114
+ - name: Verify package is available
115
+ if: steps.version_check.outputs.exists != 'true'
116
+ id: verify_package
117
+ env:
118
+ VERSION: ${{ env.VERSION }}
119
+ run: |
120
+ for i in {1..30}; do
121
+ if pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketdev==${VERSION}; then
122
+ echo "Package ${VERSION} is now available and installable on Test PyPI"
123
+ pip uninstall -y socketdev
124
+ echo "success=true" >> $GITHUB_OUTPUT
125
+ exit 0
126
+ fi
127
+ echo "Attempt $i: Package not yet installable, waiting 20s... (${i}/30)"
128
+ sleep 20
129
+ done
130
+ echo "success=false" >> $GITHUB_OUTPUT
131
+ exit 1
@@ -0,0 +1,75 @@
1
+ name: Release
2
+ on:
3
+ release:
4
+ types: [published]
5
+
6
+ jobs:
7
+ release:
8
+ runs-on: ubuntu-latest
9
+ permissions:
10
+ id-token: write
11
+ contents: read
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ with:
15
+ fetch-depth: 0
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: '3.x'
19
+
20
+ # Install all dependencies from pyproject.toml
21
+ - name: Install dependencies
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install hatchling==1.27.0
25
+ pip install hatch==1.14.0
26
+
27
+ - name: Get Version
28
+ id: version
29
+ run: |
30
+ RAW_VERSION=$(hatch version)
31
+ echo "VERSION=$RAW_VERSION" >> $GITHUB_ENV
32
+ if [ "v$RAW_VERSION" != "${{ github.ref_name }}" ]; then
33
+ echo "Error: Git tag (${{ github.ref_name }}) does not match hatch version (v$RAW_VERSION)"
34
+ exit 1
35
+ fi
36
+
37
+ - name: Check if version exists on PyPI
38
+ id: version_check
39
+ env:
40
+ VERSION: ${{ env.VERSION }}
41
+ run: |
42
+ if curl -s -f https://pypi.org/pypi/socketdev/$VERSION/json > /dev/null; then
43
+ echo "Version ${VERSION} already exists on PyPI"
44
+ echo "pypi_exists=true" >> $GITHUB_OUTPUT
45
+ else
46
+ echo "Version ${VERSION} not found on PyPI - proceeding with PyPI deployment"
47
+ echo "pypi_exists=false" >> $GITHUB_OUTPUT
48
+ fi
49
+
50
+ - name: Build package
51
+ if: steps.version_check.outputs.pypi_exists != 'true'
52
+ run: |
53
+ hatch build
54
+
55
+ - name: Publish to PyPI
56
+ if: steps.version_check.outputs.pypi_exists != 'true'
57
+ uses: pypa/gh-action-pypi-publish@v1.12.4
58
+
59
+ - name: Verify package is installable
60
+ id: verify_package
61
+ env:
62
+ VERSION: ${{ env.VERSION }}
63
+ run: |
64
+ for i in {1..30}; do
65
+ if pip install socketdev==${VERSION}; then
66
+ echo "Package ${VERSION} is now available and installable on PyPI"
67
+ pip uninstall -y socketdev
68
+ echo "success=true" >> $GITHUB_OUTPUT
69
+ exit 0
70
+ fi
71
+ echo "Attempt $i: Package not yet installable, waiting 20s... (${i}/30)"
72
+ sleep 20
73
+ done
74
+ echo "success=false" >> $GITHUB_OUTPUT
75
+ exit 1
@@ -0,0 +1,90 @@
1
+ name: Version Check
2
+ on:
3
+ pull_request:
4
+ types: [opened, synchronize, ready_for_review]
5
+ paths:
6
+ - 'socketdev/**'
7
+ - 'setup.py'
8
+ - 'pyproject.toml'
9
+
10
+ jobs:
11
+ check_version:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0 # Fetch all history for all branches
17
+
18
+ - name: Check version increment
19
+ id: version_check
20
+ run: |
21
+ # Get version from current PR
22
+ PR_VERSION=$(grep -o "__version__.*" socketdev/version.py | awk '{print $3}' | tr -d '"' | tr -d "'")
23
+ echo "PR_VERSION=$PR_VERSION" >> $GITHUB_ENV
24
+
25
+ # Get version from main branch
26
+ git checkout origin/main
27
+ MAIN_VERSION=$(grep -o "__version__.*" socketdev/version.py | awk '{print $3}' | tr -d '"' | tr -d "'")
28
+ echo "MAIN_VERSION=$MAIN_VERSION" >> $GITHUB_ENV
29
+
30
+ # Compare versions using Python
31
+ python3 -c "
32
+ from packaging import version
33
+ pr_ver = version.parse('${PR_VERSION}')
34
+ main_ver = version.parse('${MAIN_VERSION}')
35
+ if pr_ver <= main_ver:
36
+ print(f'❌ Version must be incremented! Main: {main_ver}, PR: {pr_ver}')
37
+ exit(1)
38
+ print(f'✅ Version properly incremented from {main_ver} to {pr_ver}')
39
+ "
40
+
41
+ - name: Manage PR Comment
42
+ uses: actions/github-script@v7
43
+ if: always()
44
+ env:
45
+ MAIN_VERSION: ${{ env.MAIN_VERSION }}
46
+ PR_VERSION: ${{ env.PR_VERSION }}
47
+ CHECK_RESULT: ${{ steps.version_check.outcome }}
48
+ with:
49
+ script: |
50
+ const success = process.env.CHECK_RESULT === 'success';
51
+ const prNumber = context.payload.pull_request.number;
52
+ const owner = context.repo.owner;
53
+ const repo = context.repo.repo;
54
+ const comments = await github.rest.issues.listComments({
55
+ owner: owner,
56
+ repo: repo,
57
+ issue_number: prNumber,
58
+ });
59
+
60
+ const versionComment = comments.data.find(comment =>
61
+ comment.user.type === 'Bot' &&
62
+ comment.body.includes('Version Check')
63
+ );
64
+
65
+ if (versionComment) {
66
+ if (success) {
67
+ // Delete the warning comment if check passes
68
+ await github.rest.issues.deleteComment({
69
+ owner: owner,
70
+ repo: repo,
71
+ comment_id: versionComment.id
72
+ });
73
+ } else {
74
+ // Update existing warning
75
+ await github.rest.issues.updateComment({
76
+ owner: owner,
77
+ repo: repo,
78
+ comment_id: versionComment.id,
79
+ body: `❌ **Version Check Failed**\n\nPlease increment...`
80
+ });
81
+ }
82
+ } else if (!success) {
83
+ // Create new warning comment only if check fails
84
+ await github.rest.issues.createComment({
85
+ owner: owner,
86
+ repo: repo,
87
+ issue_number: prNumber,
88
+ body: `❌ **Version Check Failed**\n\nPlease increment...`
89
+ });
90
+ }
@@ -0,0 +1,16 @@
1
+ *.json
2
+ main.py
3
+ venv
4
+ .idea
5
+ .DS_Store
6
+ *.zip
7
+ *.pyc
8
+ test.py
9
+ .venv
10
+ build
11
+ dist
12
+ *.build
13
+ *.dist
14
+ *.egg-info
15
+ *.cpython-312.pyc
16
+ example-socket-export.py
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env python3
2
+ import subprocess
3
+ import pathlib
4
+ import re
5
+ import sys
6
+ import urllib.request
7
+ import json
8
+
9
+ VERSION_FILE = pathlib.Path("socketdev/version.py")
10
+ PYPROJECT_FILE = pathlib.Path("pyproject.toml")
11
+
12
+ VERSION_PATTERN = re.compile(r"__version__\s*=\s*['\"]([^'\"]+)['\"]")
13
+ PYPROJECT_PATTERN = re.compile(r'^version\s*=\s*".*"$', re.MULTILINE)
14
+ PYPI_API = "https://test.pypi.org/pypi/socketdev/json"
15
+
16
+ def read_version_from_version_file(path: pathlib.Path) -> str:
17
+ content = path.read_text()
18
+ match = VERSION_PATTERN.search(content)
19
+ if not match:
20
+ print(f"❌ Could not find __version__ in {path}")
21
+ sys.exit(1)
22
+ return match.group(1)
23
+
24
+ def read_version_from_git(path: str) -> str:
25
+ try:
26
+ output = subprocess.check_output(["git", "show", f"HEAD:{path}"], text=True)
27
+ match = VERSION_PATTERN.search(output)
28
+ if not match:
29
+ return None
30
+ return match.group(1)
31
+ except subprocess.CalledProcessError:
32
+ return None
33
+
34
+ def bump_patch_version(version: str) -> str:
35
+ if ".dev" in version:
36
+ version = version.split(".dev")[0]
37
+ parts = version.split(".")
38
+ parts[-1] = str(int(parts[-1]) + 1)
39
+ return ".".join(parts)
40
+
41
+ def fetch_existing_versions() -> set:
42
+ try:
43
+ with urllib.request.urlopen(PYPI_API) as response:
44
+ data = json.load(response)
45
+ return set(data.get("releases", {}).keys())
46
+ except Exception as e:
47
+ print(f"⚠️ Warning: Failed to fetch existing versions from Test PyPI: {e}")
48
+ return set()
49
+
50
+ def find_next_available_dev_version(base_version: str) -> str:
51
+ existing_versions = fetch_existing_versions()
52
+ for i in range(1, 100):
53
+ candidate = f"{base_version}.dev{i}"
54
+ if candidate not in existing_versions:
55
+ return candidate
56
+ print("❌ Could not find available .devN slot after 100 attempts.")
57
+ sys.exit(1)
58
+
59
+ def inject_version(version: str):
60
+ print(f"🔁 Updating version to: {version}")
61
+
62
+ # Update version.py
63
+ VERSION_FILE.write_text(f'__version__ = "{version}"\n')
64
+
65
+ # Update pyproject.toml if it has a version field (it shouldn't with hatch, but just in case)
66
+ pyproject = PYPROJECT_FILE.read_text()
67
+ if PYPROJECT_PATTERN.search(pyproject):
68
+ new_pyproject = PYPROJECT_PATTERN.sub(f'version = "{version}"', pyproject)
69
+ PYPROJECT_FILE.write_text(new_pyproject)
70
+
71
+ def main():
72
+ dev_mode = "--dev" in sys.argv
73
+ current_version = read_version_from_version_file(VERSION_FILE)
74
+ previous_version = read_version_from_git("socketdev/version.py")
75
+
76
+ print(f"Current: {current_version}, Previous: {previous_version}")
77
+
78
+ if current_version == previous_version:
79
+ if dev_mode:
80
+ base_version = current_version.split(".dev")[0] if ".dev" in current_version else current_version
81
+ new_version = find_next_available_dev_version(base_version)
82
+ inject_version(new_version)
83
+ print("⚠️ Version was unchanged — auto-bumped. Please git add + commit again.")
84
+ sys.exit(0)
85
+ else:
86
+ new_version = bump_patch_version(current_version)
87
+ inject_version(new_version)
88
+ print("⚠️ Version was unchanged — auto-bumped. Please git add + commit again.")
89
+ sys.exit(1)
90
+ else:
91
+ print("✅ Version already bumped — proceeding.")
92
+ sys.exit(0)
93
+
94
+ if __name__ == "__main__":
95
+ main()
@@ -0,0 +1 @@
1
+ 3.12.7
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Socket Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.