socketsecurity 2.2.79__tar.gz → 2.2.81__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.
- socketsecurity-2.2.81/.github/workflows/docker-stable.yml +51 -0
- socketsecurity-2.2.81/.github/workflows/e2e-test.yml +99 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/workflows/pr-preview.yml +1 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/workflows/release.yml +7 -4
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/workflows/version-check.yml +6 -0
- socketsecurity-2.2.81/.github/zizmor.yml +3 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/PKG-INFO +20 -20
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/README.md +19 -19
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/docs/cli-reference.md +32 -3
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/pyproject.toml +1 -1
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/__init__.py +1 -1
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/__init__.py +65 -2
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/messages.py +41 -7
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/socketcli.py +11 -2
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/e2e/fixtures/simple-npm/package.json +2 -2
- socketsecurity-2.2.81/tests/e2e/fixtures/simple-pypi/requirements.txt +3 -0
- socketsecurity-2.2.81/tests/e2e/validate-gitlab.sh +63 -0
- socketsecurity-2.2.81/tests/e2e/validate-json.sh +33 -0
- socketsecurity-2.2.81/tests/e2e/validate-reachability.sh +65 -0
- socketsecurity-2.2.81/tests/e2e/validate-sarif.sh +19 -0
- socketsecurity-2.2.81/tests/e2e/validate-scan.sh +16 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_gitlab_format.py +175 -2
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/uv.lock +1 -1
- socketsecurity-2.2.79/.github/workflows/docker-stable.yml +0 -44
- socketsecurity-2.2.79/.github/workflows/e2e-test.yml +0 -195
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/CODEOWNERS +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/PULL_REQUEST_TEMPLATE/bug-fix.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/PULL_REQUEST_TEMPLATE/improvement.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.github/workflows/python-tests.yml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.gitignore +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.hooks/sync_version.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.pre-commit-config.yaml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/.python-version +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/CHANGELOG.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/Dockerfile +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/LICENSE +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/Makefile +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/docs/ci-cd.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/docs/development.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/docs/troubleshooting.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/examples/config/sarif-dashboard-parity.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/examples/config/sarif-dashboard-parity.toml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/examples/config/sarif-diff-ci-cd.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/examples/config/sarif-diff-ci-cd.toml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/examples/config/sarif-instance-detail.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/examples/config/sarif-instance-detail.toml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/instructions/gitlab-commit-status/uat.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/pytest.ini +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/scripts/build_container.sh +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/scripts/build_container_flexible.sh +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/scripts/deploy-test-docker.sh +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/scripts/deploy-test-pypi.sh +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/scripts/docker-entrypoint.sh +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/scripts/run.sh +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/session.md +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socket.yml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/config.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/alert_selection.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/classes.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/cli_client.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/exceptions.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/git_interface.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/helper/__init__.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/helper/socket_facts_loader.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/lazy_file_loader.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/logging.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/resource_utils.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/scm/__init__.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/scm/base.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/scm/client.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/scm/github.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/scm/gitlab.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/scm_comments.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/socket_config.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/tools/reachability.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/core/utils.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/output.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/__init__.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/base.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/formatters/__init__.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/formatters/slack.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/jira.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/manager.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/slack.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/teams.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/socketsecurity/plugins/webhook.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/__init__.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/core/conftest.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/core/create_diff_input.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/core/test_diff_alerts.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/core/test_diff_generation.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/core/test_has_manifest_files.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/core/test_package_and_alerts.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/core/test_sdk_methods.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/core/test_supporting_methods.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/fullscans/create_response.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/fullscans/diff/stream_diff.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/fullscans/diff/stream_diff_full.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/fullscans/head_scan/metadata.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/fullscans/head_scan/stream_scan.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/fullscans/head_scan/stream_scan_full.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/fullscans/new_scan/metadata.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/fullscans/new_scan/stream_scan.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/repos/repo_info_error.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/repos/repo_info_no_head.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/repos/repo_info_success.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/data/settings/security-policy.json +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/e2e/fixtures/simple-npm/index.js +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/__init__.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_alert_selection.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_cli_config.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_client.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_config.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_gitlab_auth.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_gitlab_auth_fallback.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_gitlab_commit_status.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_output.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/tests/unit/test_slack_plugin.py +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/workflows/bitbucket-pipelines.yml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/workflows/buildkite.yml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/workflows/github-actions.yml +0 -0
- {socketsecurity-2.2.79 → socketsecurity-2.2.81}/workflows/gitlab-ci.yml +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Mark Release as Stable
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
inputs:
|
|
5
|
+
version:
|
|
6
|
+
description: 'Version to mark as stable (e.g., 1.2.3)'
|
|
7
|
+
required: true
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
stable:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
17
|
+
with:
|
|
18
|
+
persist-credentials: false
|
|
19
|
+
|
|
20
|
+
- name: Check if version exists in PyPI
|
|
21
|
+
id: version_check
|
|
22
|
+
env:
|
|
23
|
+
INPUT_VERSION: ${{ inputs.version }}
|
|
24
|
+
run: |
|
|
25
|
+
if ! curl -s -f "https://pypi.org/pypi/socketsecurity/${INPUT_VERSION}/json" > /dev/null; then
|
|
26
|
+
echo "Error: Version ${INPUT_VERSION} not found on PyPI"
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
echo "Version ${INPUT_VERSION} found on PyPI - proceeding with release"
|
|
30
|
+
|
|
31
|
+
- name: Set up QEMU
|
|
32
|
+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
|
|
33
|
+
|
|
34
|
+
- name: Set up Docker Buildx
|
|
35
|
+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
|
36
|
+
|
|
37
|
+
- name: Login to Docker Hub with Organization Token
|
|
38
|
+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
|
39
|
+
with:
|
|
40
|
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
41
|
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
42
|
+
|
|
43
|
+
- name: Build & Push Stable Docker
|
|
44
|
+
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
|
|
45
|
+
with:
|
|
46
|
+
push: true
|
|
47
|
+
platforms: linux/amd64,linux/arm64
|
|
48
|
+
tags: socketdev/cli:stable
|
|
49
|
+
build-args: |
|
|
50
|
+
CLI_VERSION=${{ inputs.version }}
|
|
51
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
name: E2E Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
e2e:
|
|
14
|
+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
include:
|
|
20
|
+
- name: scan
|
|
21
|
+
args: >-
|
|
22
|
+
--target-path tests/e2e/fixtures/simple-npm
|
|
23
|
+
--disable-blocking
|
|
24
|
+
--enable-debug
|
|
25
|
+
validate: tests/e2e/validate-scan.sh
|
|
26
|
+
|
|
27
|
+
- name: sarif
|
|
28
|
+
args: >-
|
|
29
|
+
--target-path tests/e2e/fixtures/simple-npm
|
|
30
|
+
--sarif-file /tmp/results.sarif
|
|
31
|
+
--disable-blocking
|
|
32
|
+
validate: tests/e2e/validate-sarif.sh
|
|
33
|
+
|
|
34
|
+
- name: reachability
|
|
35
|
+
args: >-
|
|
36
|
+
--target-path tests/e2e/fixtures/simple-npm
|
|
37
|
+
--reach
|
|
38
|
+
--disable-blocking
|
|
39
|
+
--enable-debug
|
|
40
|
+
validate: tests/e2e/validate-reachability.sh
|
|
41
|
+
setup-node: "true"
|
|
42
|
+
|
|
43
|
+
- name: gitlab
|
|
44
|
+
args: >-
|
|
45
|
+
--target-path tests/e2e/fixtures/simple-npm
|
|
46
|
+
--enable-gitlab-security
|
|
47
|
+
--disable-blocking
|
|
48
|
+
validate: tests/e2e/validate-gitlab.sh
|
|
49
|
+
|
|
50
|
+
- name: json
|
|
51
|
+
args: >-
|
|
52
|
+
--target-path tests/e2e/fixtures/simple-npm
|
|
53
|
+
--enable-json
|
|
54
|
+
--disable-blocking
|
|
55
|
+
validate: tests/e2e/validate-json.sh
|
|
56
|
+
|
|
57
|
+
- name: pypi
|
|
58
|
+
args: >-
|
|
59
|
+
--target-path tests/e2e/fixtures/simple-pypi
|
|
60
|
+
--disable-blocking
|
|
61
|
+
--enable-debug
|
|
62
|
+
validate: tests/e2e/validate-scan.sh
|
|
63
|
+
|
|
64
|
+
name: e2e-${{ matrix.name }}
|
|
65
|
+
steps:
|
|
66
|
+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
|
67
|
+
with:
|
|
68
|
+
fetch-depth: 0
|
|
69
|
+
persist-credentials: false
|
|
70
|
+
|
|
71
|
+
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
|
|
72
|
+
with:
|
|
73
|
+
python-version: '3.12'
|
|
74
|
+
|
|
75
|
+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
|
|
76
|
+
if: matrix.setup-node == 'true'
|
|
77
|
+
with:
|
|
78
|
+
node-version: '20'
|
|
79
|
+
|
|
80
|
+
- name: Install CLI from local repo
|
|
81
|
+
run: |
|
|
82
|
+
python -m pip install --upgrade pip
|
|
83
|
+
pip install .
|
|
84
|
+
|
|
85
|
+
- name: Install uv
|
|
86
|
+
if: matrix.setup-node == 'true'
|
|
87
|
+
run: pip install uv
|
|
88
|
+
|
|
89
|
+
- name: Run Socket CLI
|
|
90
|
+
env:
|
|
91
|
+
SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_CLI_API_TOKEN }}
|
|
92
|
+
run: |
|
|
93
|
+
set -o pipefail
|
|
94
|
+
socketcli ${{ matrix.args }} 2>&1 | tee /tmp/e2e-output.log
|
|
95
|
+
|
|
96
|
+
- name: Validate results
|
|
97
|
+
env:
|
|
98
|
+
SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_CLI_API_TOKEN }}
|
|
99
|
+
run: bash ${{ matrix.validate }}
|
|
@@ -13,6 +13,7 @@ jobs:
|
|
|
13
13
|
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
|
14
14
|
with:
|
|
15
15
|
fetch-depth: 0
|
|
16
|
+
persist-credentials: false
|
|
16
17
|
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
|
|
17
18
|
with:
|
|
18
19
|
python-version: '3.13'
|
|
@@ -26,11 +27,13 @@ jobs:
|
|
|
26
27
|
|
|
27
28
|
- name: Get Version
|
|
28
29
|
id: version
|
|
30
|
+
env:
|
|
31
|
+
REF_NAME: ${{ github.ref_name }}
|
|
29
32
|
run: |
|
|
30
33
|
RAW_VERSION=$(hatch version)
|
|
31
34
|
echo "VERSION=$RAW_VERSION" >> $GITHUB_ENV
|
|
32
|
-
if [ "v$RAW_VERSION" != "$
|
|
33
|
-
echo "Error: Git tag ($
|
|
35
|
+
if [ "v$RAW_VERSION" != "$REF_NAME" ]; then
|
|
36
|
+
echo "Error: Git tag ($REF_NAME) does not match hatch version (v$RAW_VERSION)"
|
|
34
37
|
exit 1
|
|
35
38
|
fi
|
|
36
39
|
|
|
@@ -52,7 +55,7 @@ jobs:
|
|
|
52
55
|
env:
|
|
53
56
|
VERSION: ${{ env.VERSION }}
|
|
54
57
|
run: |
|
|
55
|
-
if curl -s -f "https://hub.docker.com/v2/repositories/socketdev/cli/tags/${
|
|
58
|
+
if curl -s -f "https://hub.docker.com/v2/repositories/socketdev/cli/tags/${VERSION}" > /dev/null; then
|
|
56
59
|
echo "Docker image socketdev/cli:${VERSION} already exists"
|
|
57
60
|
echo "docker_exists=true" >> $GITHUB_OUTPUT
|
|
58
61
|
else
|
|
@@ -113,4 +116,4 @@ jobs:
|
|
|
113
116
|
socketdev/cli:latest
|
|
114
117
|
socketdev/cli:${{ env.VERSION }}
|
|
115
118
|
build-args: |
|
|
116
|
-
CLI_VERSION=${{ env.VERSION }}
|
|
119
|
+
CLI_VERSION=${{ env.VERSION }}
|
|
@@ -7,6 +7,11 @@ on:
|
|
|
7
7
|
- 'setup.py'
|
|
8
8
|
- 'pyproject.toml'
|
|
9
9
|
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
pull-requests: write
|
|
13
|
+
issues: write
|
|
14
|
+
|
|
10
15
|
jobs:
|
|
11
16
|
check_version:
|
|
12
17
|
runs-on: ubuntu-latest
|
|
@@ -14,6 +19,7 @@ jobs:
|
|
|
14
19
|
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
|
15
20
|
with:
|
|
16
21
|
fetch-depth: 0 # Fetch all history for all branches
|
|
22
|
+
persist-credentials: false
|
|
17
23
|
|
|
18
24
|
- name: Check version increment
|
|
19
25
|
id: version_check
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: socketsecurity
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.81
|
|
4
4
|
Summary: Socket Security CLI for CI/CD
|
|
5
5
|
Project-URL: Homepage, https://socket.dev
|
|
6
6
|
Author-email: Douglas Coburn <douglas@socket.dev>
|
|
@@ -60,7 +60,7 @@ Description-Content-Type: text/markdown
|
|
|
60
60
|
|
|
61
61
|
Socket Python CLI for Socket scans, diff reporting, reachability analysis, and SARIF/GitLab exports.
|
|
62
62
|
|
|
63
|
-
Comprehensive docs are available in [`docs/`](docs
|
|
63
|
+
Comprehensive docs are available in [`docs/`](https://github.com/SocketDev/socket-python-cli/tree/main/docs) for full flag reference, CI/CD-specific guidance, and contributor setup.
|
|
64
64
|
|
|
65
65
|
## Quick start
|
|
66
66
|
|
|
@@ -85,8 +85,8 @@ socketcli --target-path .
|
|
|
85
85
|
## Common use cases
|
|
86
86
|
|
|
87
87
|
This section covers the paved path/common workflows.
|
|
88
|
-
For advanced options and exhaustive details, see [`docs/cli-reference.md`](docs/cli-reference.md).
|
|
89
|
-
For CI/CD-specific guidance, see [`docs/ci-cd.md`](docs/ci-cd.md).
|
|
88
|
+
For advanced options and exhaustive details, see [`docs/cli-reference.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/cli-reference.md).
|
|
89
|
+
For CI/CD-specific guidance, see [`docs/ci-cd.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/ci-cd.md).
|
|
90
90
|
|
|
91
91
|
### Basic policy scan (no SARIF)
|
|
92
92
|
|
|
@@ -149,7 +149,7 @@ socketcli \
|
|
|
149
149
|
Dashboard parity note:
|
|
150
150
|
- Full-scope SARIF is the closest match for dashboard-style filtering.
|
|
151
151
|
- Exact result counts can still differ from the dashboard due to backend/API consolidation differences and grouping semantics.
|
|
152
|
-
- See [`docs/troubleshooting.md#dashboard-vs-cli-result-counts`](docs/troubleshooting.md#dashboard-vs-cli-result-counts).
|
|
152
|
+
- See [`docs/troubleshooting.md#dashboard-vs-cli-result-counts`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#dashboard-vs-cli-result-counts).
|
|
153
153
|
|
|
154
154
|
## Config files (`--config`)
|
|
155
155
|
|
|
@@ -195,23 +195,23 @@ socketcli --config .socketcli.toml --target-path .
|
|
|
195
195
|
Reference sample configs:
|
|
196
196
|
|
|
197
197
|
TOML:
|
|
198
|
-
- [`examples/config/sarif-dashboard-parity.toml`](examples/config/sarif-dashboard-parity.toml)
|
|
199
|
-
- [`examples/config/sarif-instance-detail.toml`](examples/config/sarif-instance-detail.toml)
|
|
200
|
-
- [`examples/config/sarif-diff-ci-cd.toml`](examples/config/sarif-diff-ci-cd.toml)
|
|
198
|
+
- [`examples/config/sarif-dashboard-parity.toml`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-dashboard-parity.toml)
|
|
199
|
+
- [`examples/config/sarif-instance-detail.toml`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-instance-detail.toml)
|
|
200
|
+
- [`examples/config/sarif-diff-ci-cd.toml`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-diff-ci-cd.toml)
|
|
201
201
|
|
|
202
202
|
JSON:
|
|
203
|
-
- [`examples/config/sarif-dashboard-parity.json`](examples/config/sarif-dashboard-parity.json)
|
|
204
|
-
- [`examples/config/sarif-instance-detail.json`](examples/config/sarif-instance-detail.json)
|
|
205
|
-
- [`examples/config/sarif-diff-ci-cd.json`](examples/config/sarif-diff-ci-cd.json)
|
|
203
|
+
- [`examples/config/sarif-dashboard-parity.json`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-dashboard-parity.json)
|
|
204
|
+
- [`examples/config/sarif-instance-detail.json`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-instance-detail.json)
|
|
205
|
+
- [`examples/config/sarif-diff-ci-cd.json`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-diff-ci-cd.json)
|
|
206
206
|
|
|
207
207
|
## CI/CD examples
|
|
208
208
|
|
|
209
209
|
Prebuilt workflow examples:
|
|
210
210
|
|
|
211
|
-
- [GitHub Actions](workflows/github-actions.yml)
|
|
212
|
-
- [Buildkite](workflows/buildkite.yml)
|
|
213
|
-
- [GitLab CI](workflows/gitlab-ci.yml)
|
|
214
|
-
- [Bitbucket Pipelines](workflows/bitbucket-pipelines.yml)
|
|
211
|
+
- [GitHub Actions](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/github-actions.yml)
|
|
212
|
+
- [Buildkite](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/buildkite.yml)
|
|
213
|
+
- [GitLab CI](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/gitlab-ci.yml)
|
|
214
|
+
- [Bitbucket Pipelines](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/bitbucket-pipelines.yml)
|
|
215
215
|
|
|
216
216
|
Minimal pattern:
|
|
217
217
|
|
|
@@ -224,7 +224,7 @@ Minimal pattern:
|
|
|
224
224
|
|
|
225
225
|
## Common gotchas
|
|
226
226
|
|
|
227
|
-
See [`docs/troubleshooting.md`](docs/troubleshooting.md#common-gotchas).
|
|
227
|
+
See [`docs/troubleshooting.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#common-gotchas).
|
|
228
228
|
|
|
229
229
|
## Quick verification checks
|
|
230
230
|
|
|
@@ -245,7 +245,7 @@ jq '.runs[0].results | length' sarif-diff-reachable.sarif
|
|
|
245
245
|
|
|
246
246
|
## Documentation reference
|
|
247
247
|
|
|
248
|
-
- Full CLI reference: [`docs/cli-reference.md`](docs/cli-reference.md)
|
|
249
|
-
- CI/CD guide: [`docs/ci-cd.md`](docs/ci-cd.md)
|
|
250
|
-
- Troubleshooting guide: [`docs/troubleshooting.md`](docs/troubleshooting.md)
|
|
251
|
-
- Development guide: [`docs/development.md`](docs/development.md)
|
|
248
|
+
- Full CLI reference: [`docs/cli-reference.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/cli-reference.md)
|
|
249
|
+
- CI/CD guide: [`docs/ci-cd.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/ci-cd.md)
|
|
250
|
+
- Troubleshooting guide: [`docs/troubleshooting.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md)
|
|
251
|
+
- Development guide: [`docs/development.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/development.md)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Socket Python CLI for Socket scans, diff reporting, reachability analysis, and SARIF/GitLab exports.
|
|
4
4
|
|
|
5
|
-
Comprehensive docs are available in [`docs/`](docs
|
|
5
|
+
Comprehensive docs are available in [`docs/`](https://github.com/SocketDev/socket-python-cli/tree/main/docs) for full flag reference, CI/CD-specific guidance, and contributor setup.
|
|
6
6
|
|
|
7
7
|
## Quick start
|
|
8
8
|
|
|
@@ -27,8 +27,8 @@ socketcli --target-path .
|
|
|
27
27
|
## Common use cases
|
|
28
28
|
|
|
29
29
|
This section covers the paved path/common workflows.
|
|
30
|
-
For advanced options and exhaustive details, see [`docs/cli-reference.md`](docs/cli-reference.md).
|
|
31
|
-
For CI/CD-specific guidance, see [`docs/ci-cd.md`](docs/ci-cd.md).
|
|
30
|
+
For advanced options and exhaustive details, see [`docs/cli-reference.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/cli-reference.md).
|
|
31
|
+
For CI/CD-specific guidance, see [`docs/ci-cd.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/ci-cd.md).
|
|
32
32
|
|
|
33
33
|
### Basic policy scan (no SARIF)
|
|
34
34
|
|
|
@@ -91,7 +91,7 @@ socketcli \
|
|
|
91
91
|
Dashboard parity note:
|
|
92
92
|
- Full-scope SARIF is the closest match for dashboard-style filtering.
|
|
93
93
|
- Exact result counts can still differ from the dashboard due to backend/API consolidation differences and grouping semantics.
|
|
94
|
-
- See [`docs/troubleshooting.md#dashboard-vs-cli-result-counts`](docs/troubleshooting.md#dashboard-vs-cli-result-counts).
|
|
94
|
+
- See [`docs/troubleshooting.md#dashboard-vs-cli-result-counts`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#dashboard-vs-cli-result-counts).
|
|
95
95
|
|
|
96
96
|
## Config files (`--config`)
|
|
97
97
|
|
|
@@ -137,23 +137,23 @@ socketcli --config .socketcli.toml --target-path .
|
|
|
137
137
|
Reference sample configs:
|
|
138
138
|
|
|
139
139
|
TOML:
|
|
140
|
-
- [`examples/config/sarif-dashboard-parity.toml`](examples/config/sarif-dashboard-parity.toml)
|
|
141
|
-
- [`examples/config/sarif-instance-detail.toml`](examples/config/sarif-instance-detail.toml)
|
|
142
|
-
- [`examples/config/sarif-diff-ci-cd.toml`](examples/config/sarif-diff-ci-cd.toml)
|
|
140
|
+
- [`examples/config/sarif-dashboard-parity.toml`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-dashboard-parity.toml)
|
|
141
|
+
- [`examples/config/sarif-instance-detail.toml`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-instance-detail.toml)
|
|
142
|
+
- [`examples/config/sarif-diff-ci-cd.toml`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-diff-ci-cd.toml)
|
|
143
143
|
|
|
144
144
|
JSON:
|
|
145
|
-
- [`examples/config/sarif-dashboard-parity.json`](examples/config/sarif-dashboard-parity.json)
|
|
146
|
-
- [`examples/config/sarif-instance-detail.json`](examples/config/sarif-instance-detail.json)
|
|
147
|
-
- [`examples/config/sarif-diff-ci-cd.json`](examples/config/sarif-diff-ci-cd.json)
|
|
145
|
+
- [`examples/config/sarif-dashboard-parity.json`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-dashboard-parity.json)
|
|
146
|
+
- [`examples/config/sarif-instance-detail.json`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-instance-detail.json)
|
|
147
|
+
- [`examples/config/sarif-diff-ci-cd.json`](https://github.com/SocketDev/socket-python-cli/blob/main/examples/config/sarif-diff-ci-cd.json)
|
|
148
148
|
|
|
149
149
|
## CI/CD examples
|
|
150
150
|
|
|
151
151
|
Prebuilt workflow examples:
|
|
152
152
|
|
|
153
|
-
- [GitHub Actions](workflows/github-actions.yml)
|
|
154
|
-
- [Buildkite](workflows/buildkite.yml)
|
|
155
|
-
- [GitLab CI](workflows/gitlab-ci.yml)
|
|
156
|
-
- [Bitbucket Pipelines](workflows/bitbucket-pipelines.yml)
|
|
153
|
+
- [GitHub Actions](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/github-actions.yml)
|
|
154
|
+
- [Buildkite](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/buildkite.yml)
|
|
155
|
+
- [GitLab CI](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/gitlab-ci.yml)
|
|
156
|
+
- [Bitbucket Pipelines](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/bitbucket-pipelines.yml)
|
|
157
157
|
|
|
158
158
|
Minimal pattern:
|
|
159
159
|
|
|
@@ -166,7 +166,7 @@ Minimal pattern:
|
|
|
166
166
|
|
|
167
167
|
## Common gotchas
|
|
168
168
|
|
|
169
|
-
See [`docs/troubleshooting.md`](docs/troubleshooting.md#common-gotchas).
|
|
169
|
+
See [`docs/troubleshooting.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#common-gotchas).
|
|
170
170
|
|
|
171
171
|
## Quick verification checks
|
|
172
172
|
|
|
@@ -187,7 +187,7 @@ jq '.runs[0].results | length' sarif-diff-reachable.sarif
|
|
|
187
187
|
|
|
188
188
|
## Documentation reference
|
|
189
189
|
|
|
190
|
-
- Full CLI reference: [`docs/cli-reference.md`](docs/cli-reference.md)
|
|
191
|
-
- CI/CD guide: [`docs/ci-cd.md`](docs/ci-cd.md)
|
|
192
|
-
- Troubleshooting guide: [`docs/troubleshooting.md`](docs/troubleshooting.md)
|
|
193
|
-
- Development guide: [`docs/development.md`](docs/development.md)
|
|
190
|
+
- Full CLI reference: [`docs/cli-reference.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/cli-reference.md)
|
|
191
|
+
- CI/CD guide: [`docs/ci-cd.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/ci-cd.md)
|
|
192
|
+
- Troubleshooting guide: [`docs/troubleshooting.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md)
|
|
193
|
+
- Development guide: [`docs/development.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/development.md)
|
|
@@ -700,17 +700,44 @@ The GitLab report includes **actionable security alerts** based on your Socket p
|
|
|
700
700
|
|
|
701
701
|
All alert types are included in the GitLab report if they're marked as `error` or `warn` by your Socket Security policy, ensuring the Security Dashboard shows only actionable findings.
|
|
702
702
|
|
|
703
|
+
### Alert Population: GitLab vs JSON/SARIF
|
|
704
|
+
|
|
705
|
+
The GitLab Security Dashboard report and the JSON/SARIF diff outputs use different alert selection strategies, reflecting their distinct purposes:
|
|
706
|
+
|
|
707
|
+
| Output Format | Default Alerts | With `--strict-blocking` |
|
|
708
|
+
|:---|:---|:---|
|
|
709
|
+
| `--enable-gitlab-security` | **All** alerts (new + existing) | All alerts (same) |
|
|
710
|
+
| `--enable-json` | New alerts only | New + existing alerts |
|
|
711
|
+
| `--enable-sarif` (diff scope) | New alerts only | New + existing alerts |
|
|
712
|
+
|
|
713
|
+
**Why the difference?** GitLab's Security Dashboard is designed to present the full security posture of a project. An empty dashboard on a scan with no dependency changes would be misleading -- the vulnerabilities still exist, they just didn't change. By contrast, JSON and SARIF in diff scope are designed to answer "what changed?" and only include existing alerts when `--strict-blocking` explicitly requests it.
|
|
714
|
+
|
|
715
|
+
> **Tip:** If you use `--enable-json` alongside `--enable-gitlab-security`, the GitLab report may contain more vulnerabilities than the JSON output. This is expected. To make JSON output match, add `--strict-blocking`.
|
|
716
|
+
|
|
717
|
+
### Alert Ignoring via PR/MR Comments
|
|
718
|
+
|
|
719
|
+
When using the CLI with SCM integration (`--scm github` or `--scm gitlab`), users can ignore specific alerts by reacting to Socket's PR/MR comments. Ignored alerts are removed from `--enable-json`, `--enable-sarif`, and console output.
|
|
720
|
+
|
|
721
|
+
However, the GitLab Security Dashboard report includes **all** alerts matching your security policy (new and existing), regardless of comment-based ignores. This ensures the Security Dashboard always reflects the full set of known issues. To suppress a vulnerability from the GitLab report, adjust the alert's policy in Socket's dashboard rather than ignoring it via a PR comment.
|
|
722
|
+
|
|
703
723
|
### Report Schema
|
|
704
724
|
|
|
705
|
-
Socket CLI generates reports compliant with [GitLab Dependency Scanning schema version 15.0.0](https://
|
|
725
|
+
Socket CLI generates reports compliant with [GitLab Dependency Scanning schema version 15.0.0](https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/blob/v15.0.0/dist/dependency-scanning-report-format.json). The reports include:
|
|
706
726
|
|
|
707
|
-
- **Scan metadata**: Analyzer and scanner information
|
|
727
|
+
- **Scan metadata**: Analyzer and scanner information with ISO 8601 timestamps
|
|
708
728
|
- **Vulnerabilities**: Detailed vulnerability data with:
|
|
709
729
|
- Unique deterministic UUIDs for tracking
|
|
710
730
|
- Package location and dependency information
|
|
711
731
|
- Severity levels mapped from Socket's analysis
|
|
712
732
|
- Socket-specific alert types and CVE identifiers
|
|
713
733
|
- Links to Socket.dev for detailed analysis
|
|
734
|
+
- **Dependency files**: Manifest files and their dependencies discovered during the scan
|
|
735
|
+
|
|
736
|
+
**Schema compatibility:** The v15.0.0 schema is supported across all GitLab versions 12.0+ (both self-hosted and cloud). The report includes the `dependency_files` field, which is required by v15.0.0 and accepted as an optional extra by newer schema versions, ensuring maximum compatibility across GitLab instances.
|
|
737
|
+
|
|
738
|
+
### Performance Notes
|
|
739
|
+
|
|
740
|
+
When `--enable-gitlab-security` (or `--enable-json` / `--enable-sarif`) is used with a full scan (non-diff mode), the CLI fetches package and alert data from the scan results to populate the report. This adds time proportional to the number of packages in the scan. Without these output flags, no additional data is fetched and scan performance is unchanged.
|
|
714
741
|
|
|
715
742
|
### Requirements
|
|
716
743
|
|
|
@@ -726,7 +753,9 @@ Socket CLI generates reports compliant with [GitLab Dependency Scanning schema v
|
|
|
726
753
|
- Ensure the report file follows the correct schema format
|
|
727
754
|
|
|
728
755
|
**Empty vulnerabilities array:**
|
|
729
|
-
-
|
|
756
|
+
- The GitLab report includes both new and existing alerts, so repeated scans of the same repo should still populate the report as long as Socket detects actionable issues
|
|
757
|
+
- If the report is empty, verify the Socket dashboard shows alerts for the scanned packages -- an empty report means no error/warn-level alerts exist
|
|
758
|
+
- For full scans (non-diff mode), ensure you are using `--enable-gitlab-security` so alert data is fetched
|
|
730
759
|
- Check Socket.dev dashboard for full analysis details
|
|
731
760
|
|
|
732
761
|
## Development
|
|
@@ -659,9 +659,48 @@ class Core:
|
|
|
659
659
|
diff.report_url = f"{base_socket}/{self.config.org_slug}/sbom/{new_full_scan.id}"
|
|
660
660
|
diff.diff_url = diff.report_url
|
|
661
661
|
diff.id = new_full_scan.id
|
|
662
|
-
diff.packages = {}
|
|
663
662
|
|
|
664
|
-
|
|
663
|
+
needs_alerts = (
|
|
664
|
+
self.cli_config is not None
|
|
665
|
+
and (
|
|
666
|
+
self.cli_config.enable_gitlab_security
|
|
667
|
+
or self.cli_config.enable_json
|
|
668
|
+
or self.cli_config.enable_sarif
|
|
669
|
+
)
|
|
670
|
+
)
|
|
671
|
+
|
|
672
|
+
if needs_alerts:
|
|
673
|
+
log.info("Output format requires alerts, fetching SBOM data for full scan")
|
|
674
|
+
sbom_start = time.time()
|
|
675
|
+
sbom_artifacts_dict = self.get_sbom_data(new_full_scan.id)
|
|
676
|
+
sbom_artifacts = self.get_sbom_data_list(sbom_artifacts_dict)
|
|
677
|
+
packages = self._create_packages_dict_without_license_text(sbom_artifacts)
|
|
678
|
+
diff.packages = packages
|
|
679
|
+
|
|
680
|
+
all_alerts_collection: Dict[str, List[Issue]] = {}
|
|
681
|
+
for package_id, package in packages.items():
|
|
682
|
+
self.add_package_alerts_to_collection(
|
|
683
|
+
package=package,
|
|
684
|
+
alerts_collection=all_alerts_collection,
|
|
685
|
+
packages=packages
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
consolidated: Set[str] = set()
|
|
689
|
+
for alert_key, alerts in all_alerts_collection.items():
|
|
690
|
+
for alert in alerts:
|
|
691
|
+
alert_str = f"{alert.purl},{alert.type}"
|
|
692
|
+
if (alert.error or alert.warn) and alert_str not in consolidated:
|
|
693
|
+
diff.new_alerts.append(alert)
|
|
694
|
+
consolidated.add(alert_str)
|
|
695
|
+
|
|
696
|
+
sbom_end = time.time()
|
|
697
|
+
log.info(
|
|
698
|
+
f"Fetched {len(packages)} packages and {len(diff.new_alerts)} alerts "
|
|
699
|
+
f"in {sbom_end - sbom_start:.2f}s"
|
|
700
|
+
)
|
|
701
|
+
else:
|
|
702
|
+
diff.packages = {}
|
|
703
|
+
|
|
665
704
|
return diff
|
|
666
705
|
|
|
667
706
|
def get_full_scan(self, full_scan_id: str) -> FullScan:
|
|
@@ -712,6 +751,30 @@ class Core:
|
|
|
712
751
|
|
|
713
752
|
return packages
|
|
714
753
|
|
|
754
|
+
@staticmethod
|
|
755
|
+
def _create_packages_dict_without_license_text(
|
|
756
|
+
sbom_artifacts: list[SocketArtifact],
|
|
757
|
+
) -> dict[str, Package]:
|
|
758
|
+
"""Like create_packages_dict but skips the license-metadata API call.
|
|
759
|
+
|
|
760
|
+
Used when we only need packages for alert extraction (e.g. populating
|
|
761
|
+
GitLab/JSON/SARIF reports from a full scan) and don't need license text.
|
|
762
|
+
"""
|
|
763
|
+
packages: dict[str, Package] = {}
|
|
764
|
+
top_level_count: dict[str, int] = {}
|
|
765
|
+
for artifact in sbom_artifacts:
|
|
766
|
+
package = Package.from_socket_artifact(asdict(artifact))
|
|
767
|
+
if package.id not in packages:
|
|
768
|
+
packages[package.id] = package
|
|
769
|
+
if package.topLevelAncestors:
|
|
770
|
+
for top_id in package.topLevelAncestors:
|
|
771
|
+
top_level_count[top_id] = top_level_count.get(top_id, 0) + 1
|
|
772
|
+
|
|
773
|
+
for package_id, package in packages.items():
|
|
774
|
+
package.transitives = top_level_count.get(package_id, 0)
|
|
775
|
+
|
|
776
|
+
return packages
|
|
777
|
+
|
|
715
778
|
def get_package_license_text(self, package: Package) -> str:
|
|
716
779
|
"""
|
|
717
780
|
Gets the license text for a package if available.
|
|
@@ -3,7 +3,7 @@ import logging
|
|
|
3
3
|
import os
|
|
4
4
|
import re
|
|
5
5
|
import uuid
|
|
6
|
-
from datetime import datetime
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
from mdutils import MdUtils
|
|
9
9
|
from prettytable import PrettyTable
|
|
@@ -593,6 +593,20 @@ class Messages:
|
|
|
593
593
|
output["new_alerts"].append(json.loads(str(alert)))
|
|
594
594
|
return output
|
|
595
595
|
|
|
596
|
+
@staticmethod
|
|
597
|
+
def _pkg_type_to_package_manager(pkg_type: str) -> str:
|
|
598
|
+
"""Map Socket pkg_type to GitLab package_manager name for dependency_files."""
|
|
599
|
+
mapping = {
|
|
600
|
+
"npm": "npm",
|
|
601
|
+
"pypi": "pip",
|
|
602
|
+
"go": "go",
|
|
603
|
+
"maven": "maven",
|
|
604
|
+
"gem": "bundler",
|
|
605
|
+
"nuget": "nuget",
|
|
606
|
+
"cargo": "cargo",
|
|
607
|
+
}
|
|
608
|
+
return mapping.get(pkg_type, pkg_type or "unknown")
|
|
609
|
+
|
|
596
610
|
@staticmethod
|
|
597
611
|
def map_socket_severity_to_gitlab(severity: str) -> str:
|
|
598
612
|
"""
|
|
@@ -743,15 +757,18 @@ class Messages:
|
|
|
743
757
|
}
|
|
744
758
|
},
|
|
745
759
|
"type": "dependency_scanning",
|
|
746
|
-
"start_time": datetime.
|
|
747
|
-
"end_time": datetime.
|
|
760
|
+
"start_time": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S"),
|
|
761
|
+
"end_time": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S"),
|
|
748
762
|
"status": "success"
|
|
749
763
|
},
|
|
750
|
-
"vulnerabilities": []
|
|
764
|
+
"vulnerabilities": [],
|
|
765
|
+
"dependency_files": []
|
|
751
766
|
}
|
|
752
767
|
|
|
753
|
-
|
|
754
|
-
|
|
768
|
+
dep_files_map: dict = {}
|
|
769
|
+
|
|
770
|
+
all_alerts = list(diff.new_alerts) + list(getattr(diff, 'unchanged_alerts', []))
|
|
771
|
+
for alert in all_alerts:
|
|
755
772
|
vulnerability = {
|
|
756
773
|
"id": Messages.generate_uuid_from_alert_gitlab(alert),
|
|
757
774
|
"category": "dependency_scanning",
|
|
@@ -764,12 +781,29 @@ class Messages:
|
|
|
764
781
|
"location": Messages.extract_location_gitlab(alert)
|
|
765
782
|
}
|
|
766
783
|
|
|
767
|
-
# Add solution if available
|
|
768
784
|
if hasattr(alert, 'suggestion') and alert.suggestion:
|
|
769
785
|
vulnerability["solution"] = alert.suggestion
|
|
770
786
|
|
|
771
787
|
gitlab_report["vulnerabilities"].append(vulnerability)
|
|
772
788
|
|
|
789
|
+
file_path = vulnerability["location"]["file"]
|
|
790
|
+
if file_path != "unknown":
|
|
791
|
+
pkg_manager = Messages._pkg_type_to_package_manager(
|
|
792
|
+
alert.pkg_type if hasattr(alert, 'pkg_type') else ""
|
|
793
|
+
)
|
|
794
|
+
if file_path not in dep_files_map:
|
|
795
|
+
dep_files_map[file_path] = {
|
|
796
|
+
"path": file_path,
|
|
797
|
+
"package_manager": pkg_manager,
|
|
798
|
+
"dependencies": []
|
|
799
|
+
}
|
|
800
|
+
dep_files_map[file_path]["dependencies"].append({
|
|
801
|
+
"package": {"name": alert.pkg_name},
|
|
802
|
+
"version": alert.pkg_version
|
|
803
|
+
})
|
|
804
|
+
|
|
805
|
+
gitlab_report["dependency_files"] = list(dep_files_map.values())
|
|
806
|
+
|
|
773
807
|
return gitlab_report
|
|
774
808
|
|
|
775
809
|
@staticmethod
|