Skip to content

Commit cb71bd2

Browse files
committed
fix: improve merge detection
1 parent 7af45bc commit cb71bd2

File tree

5 files changed

+1384
-97
lines changed

5 files changed

+1384
-97
lines changed

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,70 @@ The CLI determines which files to scan based on the following logic:
285285
- **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`
286286
- **Auto-detection**: Most CI/CD scenarios now work with just `socketcli --target-path /path/to/repo --scm github --pr-number $PR_NUM`
287287
288+
## CI/CD Platform Notes
289+
290+
### Buildkite Integration
291+
292+
Buildkite triggers may require special environment variable setup when integrated with GitLab or other source control systems.
293+
294+
#### Event Type Override
295+
296+
If you encounter "Unknown event type trigger" in Buildkite-triggered jobs, you can override the event type:
297+
298+
```bash
299+
# Override Buildkite pipeline event type to merge_request_event
300+
export CI_PIPELINE_SOURCE=merge_request_event
301+
socketcli --target-path $BUILDKITE_BUILD_CHECKOUT_PATH --scm gitlab
302+
```
303+
304+
#### Troubleshooting Missing MR Variables
305+
306+
To verify if GitLab MR environment variables are available in your Buildkite pipeline:
307+
308+
```bash
309+
# Add this debugging snippet to your Buildkite pipeline
310+
echo "=== GitLab MR Environment Variables ==="
311+
echo "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME: ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-'NOT SET'}"
312+
echo "CI_MERGE_REQUEST_TARGET_BRANCH_NAME: ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-'NOT SET'}"
313+
echo "CI_MERGE_REQUEST_IID: ${CI_MERGE_REQUEST_IID:-'NOT SET'}"
314+
echo "CI_PIPELINE_SOURCE: ${CI_PIPELINE_SOURCE:-'NOT SET'}"
315+
echo "========================================"
316+
```
317+
318+
If these variables are missing, the CLI will fall back to merge-aware Git diff detection, which may produce partial results for complex merge scenarios.
319+
320+
#### Buildkite-Specific Configuration
321+
322+
For optimal detection in Buildkite environments triggered by GitLab:
323+
324+
```bash
325+
# Example Buildkite pipeline step
326+
steps:
327+
- label: "Socket Security Scan"
328+
command: |
329+
# Override event type if needed
330+
export CI_PIPELINE_SOURCE=merge_request_event
331+
332+
# Run Socket scan with GitLab SCM detection
333+
socketcli \
334+
--target-path $BUILDKITE_BUILD_CHECKOUT_PATH \
335+
--scm gitlab \
336+
--pr-number ${CI_MERGE_REQUEST_IID:-0} \
337+
--enable-debug
338+
```
339+
340+
### Advanced Configuration Options
341+
342+
#### Default Branch Detection Matrix
343+
344+
| Scenario | `--default-branch` | `--ignore-commit-files` | Behavior |
345+
|----------|-------------------|------------------------|----------|
346+
| **PR/MR Context** | Not set | Not set | Auto-detects as `false` (PR scans) |
347+
| **Main Branch Push** | Not set | Not set | Auto-detects as `true` (main branch) |
348+
| **Force Default** | `--default-branch` | Not set | Forces `true` regardless of context |
349+
| **Force API Mode** | Not set | `--ignore-commit-files` | Full scan, default branch auto-detected |
350+
| **Override Both** | `--default-branch` | `--ignore-commit-files` | Forces default branch + full scan |
351+
288352
## Debugging and Troubleshooting
289353
290354
### Saving Submitted Files List

pyproject.toml

Lines changed: 1 addition & 1 deletion
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.2.5"
9+
version = "2.3.0"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

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.2.5'
2+
__version__ = '2.3.0'

0 commit comments

Comments
 (0)