Skip to content

Commit c9df808

Browse files
authored
fix: include license violations in diff results + SDK 2.1.8 upgrade (#111)
* feat: upgrade to SDK 2.1.8 with lazy loading and improved committer handling - Upgrade socket-sdk-python dependency to version 2.1.8 to support lazy file loading capabilities - Enable lazy file loading in fullscans.post() with use_lazy_loading=True and max_open_files=50 to prevent "Too many open files" errors when processing large numbers of manifest files - Remove custom lazy_file_loader module as this functionality is now handled by the SDK - Fix committer display format by implementing proper priority order: 1. CLI --committers argument (highest priority) 2. CI/CD SCM username (GITHUB_ACTOR, GITLAB_USER_LOGIN, BITBUCKET_STEP_TRIGGERER_UUID) 3. Git username extracted from email patterns (e.g., GitHub noreply emails) 4. Git email address 5. Git author name (fallback) - Add get_formatted_committer() method to Git class to properly format committer strings instead of displaying raw git.Actor objects - Include license alerts in diff processing by removing licenseSpdxDisj filter condition - Change ulimit warning messages from log.warning to log.debug to reduce noise - Update create_full_scan() method signature to accept file paths directly instead of pre-processed file objects - Remove deprecated load_files_for_sending() method as lazy loading is now handled by the SDK This update improves performance for large repositories, provides better committer identification in CI/CD environments, and ensures license violations are properly reported. * feat: add --enable-diff flag and improve license policy violation handling - Add --enable-diff flag to force differential scanning even when using --integration api - Improve license policy violation grouping and display in PR comments - Fix alert consolidation logic to prevent duplicate alerts based on manifest files - Enhance empty baseline scan creation with proper file cleanup - Add comprehensive test coverage for new enable_diff functionality - Update documentation with new scanning mode examples and usage patterns The --enable-diff flag enables differential mode without SCM integration, useful for getting diff reports while using the API integration type. License policy violations are now properly grouped by package and displayed with consistent formatting in GitHub PR comments. * changes for license processing * Fixing login issues for pushing Docker image * Another docker fix * bumping minor version since the PR ended up having a lot of changes
1 parent 095b0cc commit c9df808

File tree

13 files changed

+268
-74
lines changed

13 files changed

+268
-74
lines changed

.github/workflows/docker-stable.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,24 @@ jobs:
2121
fi
2222
echo "Version ${{ inputs.version }} found on PyPI - proceeding with release"
2323
24-
- name: Login to Docker Hub
25-
uses: docker/login-action@v3
26-
with:
27-
username: ${{ secrets.DOCKERHUB_USERNAME }}
28-
password: ${{ secrets.DOCKERHUB_TOKEN }}
29-
3024
- name: Set up QEMU
3125
uses: docker/setup-qemu-action@v3
3226

3327
- name: Set up Docker Buildx
3428
uses: docker/setup-buildx-action@v3
3529

30+
- name: Login to Docker Hub with Organization Token
31+
uses: docker/login-action@v3
32+
with:
33+
username: ${{ secrets.DOCKERHUB_USERNAME }}
34+
password: ${{ secrets.DOCKERHUB_TOKEN }}
35+
3636
- name: Build & Push Stable Docker
3737
uses: docker/build-push-action@v5
3838
with:
3939
push: true
4040
platforms: linux/amd64,linux/arm64
4141
tags: socketdev/cli:stable
4242
build-args: |
43-
CLI_VERSION=${{ inputs.version }}
43+
CLI_VERSION=${{ inputs.version }}
44+

.github/workflows/pr-preview.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,19 @@ jobs:
119119
echo "success=false" >> $GITHUB_OUTPUT
120120
exit 1
121121
122-
- name: Login to Docker Hub
123-
if: steps.verify_package.outputs.success == 'true'
124-
uses: docker/login-action@v3
125-
with:
126-
username: ${{ secrets.DOCKERHUB_USERNAME }}
127-
password: ${{ secrets.DOCKERHUB_TOKEN }}
128-
129122
- name: Set up QEMU
130123
uses: docker/setup-qemu-action@v3
131124

132125
- name: Set up Docker Buildx
133126
uses: docker/setup-buildx-action@v3
134127

128+
- name: Login to Docker Hub with Organization Token
129+
if: steps.verify_package.outputs.success == 'true'
130+
uses: docker/login-action@v3
131+
with:
132+
username: ${{ secrets.DOCKERHUB_USERNAME }}
133+
password: ${{ secrets.DOCKERHUB_TOKEN }}
134+
135135
- name: Build & Push Docker Preview
136136
if: steps.verify_package.outputs.success == 'true'
137137
uses: docker/build-push-action@v5

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ jobs:
6868
if: steps.version_check.outputs.pypi_exists != 'true'
6969
uses: pypa/gh-action-pypi-publish@v1.12.4
7070

71-
- name: Login to Docker Hub
72-
uses: docker/login-action@v3
73-
with:
74-
username: ${{ secrets.DOCKERHUB_USERNAME }}
75-
password: ${{ secrets.DOCKERHUB_TOKEN }}
76-
7771
- name: Set up QEMU
7872
uses: docker/setup-qemu-action@v3
7973

8074
- name: Set up Docker Buildx
8175
uses: docker/setup-buildx-action@v3
8276

77+
- name: Login to Docker Hub with Organization Token
78+
uses: docker/login-action@v3
79+
with:
80+
username: ${{ secrets.DOCKERHUB_USERNAME }}
81+
password: ${{ secrets.DOCKERHUB_TOKEN }}
82+
8383
- name: Verify package is installable
8484
id: verify_package
8585
env:

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ If you don't want to provide the Socket API Token every time then you can use th
116116
|:-------------------------|:---------|:--------|:----------------------------------------------------------------------|
117117
| --ignore-commit-files | False | False | Ignore commit files |
118118
| --disable-blocking | False | False | Disable blocking mode |
119+
| --enable-diff | False | False | Enable diff mode even when using --integration api (forces diff mode without SCM integration) |
119120
| --scm | False | api | Source control management type |
120121
| --timeout | False | | Timeout in seconds for API requests |
121122
| --include-module-folders | False | False | If enabled will include manifest files from folders like node_modules |
@@ -205,13 +206,15 @@ The CLI determines which files to scan based on the following logic:
205206
- **Differential Mode**: When manifest files are detected in changes, performs a diff scan with PR/MR comment integration
206207
- **API Mode**: When no manifest files are in changes, creates a full scan report without PR comments but still scans the entire repository
207208
- **Force Mode**: With `--ignore-commit-files`, always performs a full scan regardless of changes
209+
- **Forced Diff Mode**: With `--enable-diff`, forces differential mode even when using `--integration api` (without SCM integration)
208210

209211
### Examples
210212

211213
- **Commit with manifest file**: If your commit includes changes to `package.json`, a differential scan will be triggered automatically with PR comment integration.
212214
- **Commit without manifest files**: If your commit only changes non-manifest files (like `.github/workflows/socket.yaml`), the CLI automatically switches to API mode and performs a full repository scan.
213215
- **Using `--files`**: If you specify `--files '["package.json"]'`, the CLI will check if this file exists and is a manifest file before determining scan type.
214216
- **Using `--ignore-commit-files`**: This forces a full scan of all manifest files in the target path, regardless of what's in your commit.
217+
- **Using `--enable-diff`**: Forces diff mode without SCM integration - useful when you want differential scanning but are using `--integration api`. For example: `socketcli --integration api --enable-diff --target-path /path/to/repo`
215218
- **Auto-detection**: Most CI/CD scenarios now work with just `socketcli --target-path /path/to/repo --scm github --pr-number $PR_NUM`
216219
217220
## Debugging and Troubleshooting

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.1.35"
9+
version = "2.2.0"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [
@@ -16,7 +16,7 @@ dependencies = [
1616
'GitPython',
1717
'packaging',
1818
'python-dotenv',
19-
'socket-sdk-python>=2.1.5,<3'
19+
'socket-sdk-python>=2.1.8,<3'
2020
]
2121
readme = "README.md"
2222
description = "Socket Security CLI for CI/CD"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ requests==2.32.4
5959
# via socketsecurity
6060
smmap==5.0.2
6161
# via gitdb
62-
socket-sdk-python==2.1.5
62+
socket-sdk-python==2.1.8
6363
# via socketsecurity
6464
typing-extensions==4.12.2
6565
# via socket-sdk-python

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.1.35'
2+
__version__ = '2.2.0'

socketsecurity/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class CliConfig:
4848
integration_type: IntegrationType = "api"
4949
integration_org_slug: Optional[str] = None
5050
pending_head: bool = False
51+
enable_diff: bool = False
5152
timeout: Optional[int] = 1200
5253
exclude_license_details: bool = False
5354
include_module_folders: bool = False
@@ -421,6 +422,12 @@ def create_argument_parser() -> argparse.ArgumentParser:
421422
action="store_true",
422423
help=argparse.SUPPRESS
423424
)
425+
advanced_group.add_argument(
426+
"--enable-diff",
427+
dest="enable_diff",
428+
action="store_true",
429+
help="Enable diff mode even when using --integration api (forces diff mode without SCM integration)"
430+
)
424431
advanced_group.add_argument(
425432
"--scm",
426433
metavar="<type>",

0 commit comments

Comments
 (0)