Skip to content

Commit 69f7121

Browse files
committed
Merge main into docs/include-module-folders-behavior
# Conflicts: # CHANGELOG.md # docs/ci-cd.md
2 parents 481a20a + b3dc63f commit 69f7121

26 files changed

Lines changed: 1891 additions & 258 deletions

‎CHANGELOG.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@
22

33
## 2.14.0
44

5+
### Upgrade notes
6+
7+
- Without a GitHub or GitLab SCM adapter, `--strict-blocking` now compares scans
8+
even when no manifest changed. This includes default-branch pushes and scans of
9+
non-git paths. These runs can now fail on Block findings or comparison errors
10+
and need the [API token scopes for comparison runs](docs/troubleshooting.md#api-token-permissions).
11+
- If you use the GitHub Actions example, replace the combined workflow with the
12+
[PR workflow](workflows/github-actions.yml) and require its `socket-security`
13+
check. Install the [push workflow](workflows/github-actions-push.yml) in the
14+
same change: the PR workflow doesn't run on pushes, so without it the
15+
default-branch baseline stops updating and PR comparisons run against an old
16+
scan. Install the
17+
[ignore-command workflow](workflows/github-actions-comments.yml) if you use PR
18+
ignore commands.
19+
520
### Changed
621

722
- Updated the Socket Python SDK (`socketdev`) to 3.6.4. This can increase
823
advisory counts in full-scan JSON, SARIF, and GitLab security reports, and
924
in the existing findings shown in GitLab security and FOSSA diff reports.
25+
- Skipped GitHub events and GitLab pipeline sources now warn that no scan ran.
1026

1127
### Fixed
1228

@@ -15,9 +31,29 @@
1531
table. When a finding has both Warn and Block actions, Block takes precedence.
1632
- SARIF reports use advisory IDs to distinguish findings on the same package
1733
and manifest.
34+
- Comparisons with missing or invalid package lists fail with exit `3` by
35+
default. `--exit-code-on-api-error` can remap the code, and
36+
`--disable-blocking` takes precedence.
37+
- `--strict-blocking` checks existing Block findings on code-only changes.
38+
GitHub and GitLab pull request comments show those findings under Existing
39+
alerts.
40+
- With `--scm github`, reopened pull requests and pull requests marked ready for
41+
review run the PR scan.
42+
- GitHub pull request comment runs exit `0` and leave the Socket security
43+
comment unchanged when there are no Socket ignore commands to process.
44+
- Under `--strict-blocking --disable-blocking`, the PR/MR comment and console
45+
summary no longer say that existing Block alerts fail the run.
46+
- The "This package" link in GitHub and GitLab security comments opens the
47+
affected package version on socket.dev. License findings for different
48+
namespaces appear in separate rows, and generated ignore commands identify
49+
the package by its scope or namespace.
50+
- Large PR/MR security comments fit within GitHub's size limit and show how many
51+
new or existing findings were omitted. Policy checks and reports use all findings.
1852

1953
### Documentation
2054

55+
- The [CI guide](docs/ci-cd.md#required-github-checks) describes GitHub required
56+
checks and the GitHub Actions workflow migration.
2157
- The README's upgrade notes for 2.13 and 2.14 are combined into one short
2258
[section](README.md#upgrading-from-212-or-earlier).
2359
- Clarified that `--include-module-folders` discovers dependency manifests.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ JSON:
205205

206206
Prebuilt workflow examples:
207207

208-
- [GitHub Actions](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/github-actions.yml)
208+
- GitHub Actions for [pull requests](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/github-actions.yml), [pushes](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/github-actions-push.yml), and [ignore commands](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/github-actions-comments.yml)
209209
- [Buildkite](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/buildkite.yml)
210210
- [GitLab CI](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/gitlab-ci.yml)
211211
- [Bitbucket Pipelines](https://github.com/SocketDev/socket-python-cli/blob/main/workflows/bitbucket-pipelines.yml)

‎docs/ci-cd.md‎

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ they also hide findings and usage errors. Even with exit `0`, a setup/API failur
8484
does not mean a clean scan; check the logs for a completed report.
8585

8686
Findings block only when a [diff comparison runs](#scan-type-by-pipeline).
87-
SCM event filters can also skip unsupported events with exit `0`; confirm a report
88-
was created when validating a new workflow.
89-
`--strict-blocking` also checks existing blocking alerts; an incomplete comparison
90-
or incomplete existing-alert data is an infrastructure failure. See the
87+
SCM event filters can also skip unsupported events with exit `0` and a warning
88+
(see [Skipped events](#skipped-events)); confirm a report was created when
89+
validating a new workflow.
90+
The CLI treats comparisons marked incomplete or returned with missing or
91+
invalid package lists as infrastructure failures. With `--strict-blocking`,
92+
incomplete existing-alert data is also an infrastructure failure. See the
9193
[upgrade notes](../README.md#upgrading-from-212-or-earlier) when updating existing CI rules.
9294

9395
## Config file usage in CI
@@ -137,6 +139,11 @@ Buildkite-specific config-file format is required.
137139
SOCKET_SECURITY_API_TOKEN: ${{ secrets.SOCKET_SECURITY_API_TOKEN }}
138140
```
139141

142+
With `--scm github`, `issue_comment` runs process Socket ignore commands on the
143+
pull request. When there are no commands to process, the run exits `0` and
144+
leaves the security comment unchanged. Use a dedicated `pull_request` scan job
145+
for any required check that gates merges on scan findings.
146+
140147
#### GitHub Actions: scan changed monorepo workspaces independently
141148

142149
GitHub Actions `paths` filters only decide whether a workflow starts. They do not
@@ -499,27 +506,75 @@ pipelines:
499506

500507
## Scan type by pipeline
501508

502-
With `--scm github` or `--scm gitlab`, the detected event decides the scan type:
509+
With `--scm github` or `--scm gitlab`, the adapter uses the event and PR/MR
510+
context to select the scan type. A push given a PR/MR number can use the
511+
comparison path.
503512

504513
| Event | Scan | Blocks the build |
505514
|:------|:-----|:-----------------|
506-
| Pull request / merge request | Diff scan against the repository's baseline | Yes, on new blocking alerts; also existing blockers with `--strict-blocking` |
507-
| Any other pipeline, including default-branch pushes | Full scan | No |
515+
| Supported pull request / merge request events | Diff scan against the repository's baseline when a comparison runs | Yes, on new blocking alerts and on existing blockers with `--strict-blocking` |
516+
| Push without a PR/MR number, including default-branch pushes | Full scan | No blocking on findings |
508517

509-
A full scan has no baseline, so it cannot tell a newly introduced alert from one
510-
that was already there. Rather than block on a number that would mean something
511-
different depending on which output format was enabled, those runs behave as if
512-
`--disable-blocking` was supplied and report through the Dashboard instead. This
513-
matches how the CLI already treats a run with no supported manifest files.
518+
With changed-file detection, a PR/MR with no supported manifest change runs a
519+
full scan by default. Use `--strict-blocking` or `--ignore-commit-files` to
520+
compare it. Full scans report through the Dashboard. A branch pipeline without
521+
PR/MR context stays in full-scan mode even with `--enable-diff`,
522+
`--ignore-commit-files`, or `--strict-blocking`.
514523

515-
The event type is authoritative once `--scm` is set: `--enable-diff` and
516-
`--ignore-commit-files` do not turn a branch pipeline into a comparison. To diff
517-
a branch build, drop `--scm` and use `--enable-diff` with `--integration`, which
518-
runs the comparison without the PR comment adapter.
524+
Without a GitHub or GitLab SCM adapter, `--strict-blocking` runs a comparison
525+
even when no supported manifest changed. This includes default-branch pushes and
526+
scans of non-git paths. A Block finding exits `1`. A comparison infrastructure
527+
error exits `3` by default. Check the [API token scopes for comparison runs](troubleshooting.md#api-token-permissions)
528+
when upgrading a pipeline that previously ran only full scans.
519529

520530
`--generate-license` and `--legal-format fossa` work on both paths; a full scan
521531
fetches the package list for them.
522532

533+
### Skipped events
534+
535+
With `--scm github`, `pull_request` runs scan on the `opened`, `synchronize`,
536+
`reopened` and `ready_for_review` actions. Other actions (`closed`, `labeled`,
537+
`edited`, and others) and unsupported events log a warning and exit `0` without
538+
scanning. `issue_comment` handles ignore commands. With `--scm gitlab`, the
539+
recognized scan sources are `web`, `merge_request_event`, `push`, `api`, and
540+
`pipeline`. Other sources, apart from the comment flow, also warn and exit `0`
541+
without scanning.
542+
543+
- A GitHub merge queue evaluates required checks on the `merge_group` commit.
544+
The CLI skips that event. Use a check that scans the merge group for
545+
[merge queue enforcement](https://docs.github.com/en/pull-requests/how-tos/merge-and-close-pull-requests/troubleshooting-required-status-checks#status-checks-with-github-actions-and-a-merge-queue).
546+
- GitHub runs `pull_request_target` in the base repository context, and the CLI
547+
skips it. Under GitHub's default fork settings, `pull_request` runs cannot
548+
access the Socket API secret. The CLI exits with its infrastructure error code
549+
if the token is missing. See GitHub's guidance for
550+
[securing workflows that handle fork PRs](https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target).
551+
552+
### Required GitHub checks
553+
554+
Use the [PR workflow](../workflows/github-actions.yml) for the required
555+
`socket-security` check. If your workflow skips drafts, include
556+
`ready_for_review` in its `pull_request.types` so marking a PR ready starts the scan.
557+
Use the [push workflow](../workflows/github-actions-push.yml) to update the
558+
default-branch baseline and scan branch pushes. Use the
559+
[ignore-command workflow](../workflows/github-actions-comments.yml) if your
560+
repository handles ignore commands in PR comments.
561+
562+
GitHub normally checks the PR's test merge commit when it has a status and
563+
otherwise checks the head commit. The default PR checkout uses the test merge
564+
commit, while a push run uses the pushed commit. Keep the required job name
565+
exclusive to the PR workflow in either setup. A job skipped by a job-level
566+
`if` in a shared workflow can still report a successful check. See GitHub's
567+
[required status check rules](https://docs.github.com/en/pull-requests/how-tos/merge-and-close-pull-requests/troubleshooting-required-status-checks).
568+
569+
When replacing the combined example, copy the PR workflow to the existing
570+
workflow path and remove any other jobs named `socket-security`. Confirm the
571+
PR job reports the check named in branch protection. Add the push workflow in
572+
the same change: the PR workflow doesn't run on pushes, so without it the
573+
default-branch baseline stops updating and later PR comparisons run against an
574+
old scan. If you use
575+
`--strict-blocking` as a merge gate, verify a reopened PR with an existing
576+
Block alert fails and a completed clean comparison passes.
577+
523578
## Pull request and Dashboard association
524579

525580
The CLI sends the resolved pull request number with each full scan and attaches
@@ -642,7 +697,7 @@ listed thinly or not at all.
642697

643698
Prebuilt examples in this repo:
644699

645-
- [`../workflows/github-actions.yml`](../workflows/github-actions.yml)
700+
- GitHub Actions for [pull requests](../workflows/github-actions.yml), [pushes](../workflows/github-actions-push.yml), and [ignore commands](../workflows/github-actions-comments.yml)
646701
- [`../workflows/buildkite.yml`](../workflows/buildkite.yml)
647702
- [`../workflows/gitlab-ci.yml`](../workflows/gitlab-ci.yml)
648703
- [`../workflows/bitbucket-pipelines.yml`](../workflows/bitbucket-pipelines.yml)

0 commit comments

Comments
 (0)