You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FIXED BUGS:
- Default branch detection was not working properly in git repositories
- make_default_branch and set_as_pending_head were inconsistently set
- CLI would skip scans when manifest files hadn't changed (should always scan)
- --default-branch flag was being overridden by SCM detection
- GitLab CI integration wasn't detecting default branch correctly
CORRECTED BEHAVIOR:
- Always perform scans regardless of manifest file changes (API mode when no manifests changed)
- Proper default branch detection priority system:
1. Explicit --default-branch flag (highest priority)
2. CI environment variables (GitHub Actions, GitLab CI)
3. Git repository analysis via git_repo.is_default_branch
4. Fallback to false
- Both make_default_branch and set_as_pending_head now synchronized correctly
- Force API mode enables non-blocking behavior when no manifest files changed
ENHANCED AUTO-DETECTION:
- Repository name from git remote origin (was manual)
- Branch, commit SHA, message, and committer from git (was manual)
- Changed files from git commit (was manual)
- Better error handling for non-git repositories
SIMPLIFIED CI/CD USAGE:
- Most parameters now optional due to git auto-detection
- Added production-ready workflow examples:
- workflows/github-actions.yml - GitHub Actions with concurrency control
- workflows/gitlab-ci.yml - GitLab CI with environment detection
- workflows/bitbucket-pipelines.yml - Bitbucket with path filtering
- Updated README with corrected parameter documentation
The CLI now works as users expected:
- GitHub: socketcli --target-path --scm github --pr-number
- GitLab: socketcli --target-path --scm gitlab --pr-number
- Local: socketcli --target-path ./project
The Socket Security CLI was created to enable integrations with other tools like GitHub Actions, Gitlab, BitBucket, local use cases and more. The tool will get the head scan for the provided repo from Socket, create a new one, and then report any new alerts detected. If there are new alerts against the Socket security policy it'll exit with a non-Zero exit code.
3
+
The Socket Security CLI was created to enable integrations with other tools like GitHub Actions, GitLab, BitBucket, local use cases and more. The tool will get the head scan for the provided repo from Socket, create a new one, and then report any new alerts detected. If there are new alerts against the Socket security policy it'll exit with a non-Zero exit code.
4
+
5
+
## Quick Start
6
+
7
+
The CLI now features automatic detection of git repository information, making it much simpler to use in CI/CD environments. Most parameters are now optional and will be detected automatically from your git repository.
| --files | False | *auto* | Files to analyze (JSON array string). Auto-detected from git commit changes when not specified |
48
87
| --excluded-ecosystems | False | [] | List of ecosystems to exclude from analysis (JSON array string). You can get supported files from the [Supported Files API](https://docs.socket.dev/reference/getsupportedfiles) |
49
88
| --license-file-name | False | `license_output.json` | Name of the file to save the license details to if enabled |
50
89
| --save-submitted-files-list | False | | Save list of submitted file names to JSON file for debugging purposes |
51
90
| --save-manifest-tar | False | | Save all manifest files to a compressed tar.gz archive with original directory structure |
3. **Git repository analysis**: Compares current branch with repository's default branch
177
+
4. **Fallback**: Defaults to `false` if none of the above methods succeed
178
+
179
+
Both `--default-branch` and `--pending-head` parameters are automatically synchronized to ensure consistent behavior.
180
+
181
+
### Scan Behavior
182
+
183
+
The CLI determines scanning behavior intelligently:
184
+
185
+
- **Manifest files changed**: Performs differential scan with PR/MR comments when supported
186
+
- **No manifest files changed**: Creates full repository scan report without waiting for diff results
187
+
- **Force API mode**: When no supported manifest files are detected, automatically enables non-blocking mode
188
+
117
189
## File Selection Behavior
118
190
119
191
The CLI determines which files to scan based on the following logic:
120
192
121
-
1. **Git Commit Files**: By default, the CLI checks files changed in the current git commit first. If any of these files match supported manifest patterns (like package.json, requirements.txt, etc.), a scan is triggered.
193
+
1. **Git Commit Files (Default)**: The CLI automatically checks files changed in the current git commit. If any of these files match supported manifest patterns (like package.json, requirements.txt, etc.), a scan is triggered.
194
+
195
+
2. **`--files` Parameter Override**: When specified, this parameter takes precedence over git commit detection. It accepts a JSON array of file paths to check for manifest files.
196
+
197
+
3. **`--ignore-commit-files` Flag**: When set, git commit files are ignored completely, and the CLI will scan all manifest files in the target directory regardless of what changed.
122
198
123
-
2. **`--files` Parameter**: If no git commit exists, or no manifest files are found inthe commit changes, the CLI checks filesspecified via the `--files` parameter. This parameter accepts a JSON array of file paths.
199
+
4. **Automatic Fallback**: If no manifest files are found in git commit changes and no `--files` are specified, the CLI automatically switches to "API mode" and performs a full repository scan.
124
200
125
-
3.**`--ignore-commit-files`**: When this flag is set, git commit files are ignored completely, and only files specified in`--files` are considered. This also forces a scan regardless of whether manifest files are present.
201
+
> **Important**: The CLI doesn't scan only the specified files - it uses them to determine whether a scan should be performed and what type of scan to run. When triggered, it searches the entire `--target-path`for all supported manifest files.
126
202
127
-
4. **No Manifest Files**: If no manifest files are found in either git commit changes or `--files` (and `--ignore-commit-files` is not set), the scan is skipped.
203
+
### Scanning Modes
128
204
129
-
>**Note**: The CLI does not scan only the specified files - it uses them to determine whether a scan should be performed. When a scan is triggered, it searches the entire `--target-path`for all supported manifest files.
205
+
- **Differential Mode**: When manifest files are detected in changes, performs a diff scan with PR/MR comment integration
206
+
- **API Mode**: When no manifest files are in changes, creates a full scan report without PR comments but still scans the entire repository
207
+
- **Force Mode**: With `--ignore-commit-files`, always performs a full scan regardless of changes
130
208
131
209
### Examples
132
210
133
-
- **Commit with manifest file**: If your commit includes changes to `package.json`, a scan will be triggered automatically.
134
-
- **Commit without manifest files**: If your commit only changes non-manifest files (like `.github/workflows/socket.yaml`), no scan will be performed unless you use `--files` or `--ignore-commit-files`.
135
-
- **Using `--files`**: If you specify `--files '["package.json"]'`, the CLI will check if this file exists and is a manifest file before triggering a scan.
136
-
- **Using `--ignore-commit-files`**: This forces a scan of all manifest files in the target path, regardless of what's in your commit.
211
+
- **Commit with manifest file**: If your commit includes changes to `package.json`, a differential scan will be triggered automatically with PR comment integration.
212
+
- **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.
213
+
- **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.
214
+
- **Using `--ignore-commit-files`**: This forces a full scan of all manifest files in the target path, regardless of what's in your commit.
215
+
- **Auto-detection**: Most CI/CD scenarios now work with just `socketcli --target-path /path/to/repo --scm github --pr-number $PR_NUM`
0 commit comments