Skip to content

Commit 726258b

Browse files
committed
Merge remote-tracking branch 'origin/main' into lelia/patched-version-and-pr-context
# Conflicts: # CHANGELOG.md # pyproject.toml # socketsecurity/__init__.py # uv.lock
2 parents 6ce6d48 + 88408dc commit 726258b

15 files changed

Lines changed: 984 additions & 141 deletions

CHANGELOG.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,32 @@
120120
CLI authored, so both are now escaped at the point they are interpolated. The
121121
alert markers can no longer be terminated early by a package name. Slack, Jira
122122
and console output are unchanged, since none of them render HTML.
123-
123+
## 2.8.3
124+
125+
### Fixed: GitLab report serialization and workspace baselines
126+
127+
- Full-scan package identities and Socket links now preserve namespaced packages
128+
when the SDK returns enum-backed ecosystem values.
129+
- Namespaced package links separate the namespace from the name instead of
130+
concatenating them, so Maven links no longer fuse groupId and artifactId into a
131+
single unresolvable path segment. A namespaced package whose namespace is
132+
missing now logs a warning rather than emitting a broken link silently.
133+
- GitLab dependency-scanning reports emit CVE and GHSA identifiers from current
134+
API fields while remaining compatible with legacy CVE data.
135+
- GitLab report findings record the manifest they came from when the package's
136+
introducing chain is unavailable, instead of reporting the location as
137+
`unknown`, and report whether a dependency is direct from the package record
138+
rather than inferring it from a dependency-path string that is never produced.
139+
- `--base-commit-sha` degrades to the nearest scanned ancestor of the requested
140+
commit instead of failing the run, and logs which commit was used and how far
141+
back it is. Squash merges, rebases, and multi-commit pushes all leave a merge
142+
base unscanned even when default-branch scanning is configured correctly. The
143+
lookup follows paginated scan history and the run still fails when no scanned
144+
ancestor is reachable or the exact-commit lookup itself fails.
145+
- Implicit diff baselines are selected from the same workspace, scan type,
146+
repository, and default branch, including when no workspace is supplied. A
147+
baseline lookup that fails is reported as an API error instead of resolving to
148+
an empty baseline, and temporary scans are skipped when selecting one.
124149
## 2.8.2
125150

126151
### Changed: bump pinned @coana-tech/cli to 15.10.41

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,22 @@ socketcli --enable-gitlab-security --gitlab-security-file gl-dependency-scanning
4444

4545
### PR scan diffed against the merge base
4646

47-
By default, PR scans are diffed against the repository's latest head scan. To diff against
48-
the exact commit your PR branched from instead, pass the merge base as the baseline:
47+
By default, PR scans are diffed against the repository's latest matching head scan. To
48+
prefer the commit your PR branched from as the baseline, pass the merge base:
4949

5050
```bash
5151
BASE_SHA=$(git merge-base origin/main HEAD)
5252
socketcli --pr-number 123 --base-commit-sha "$BASE_SHA"
5353
```
5454

55-
> **Requirement:** `--base-commit-sha` only works if Socket already has a full scan for that
56-
> exact commit. In practice this means your CI must run `socketcli` on **every commit that
57-
> lands on your default branch** — not just some of them. If merges can land without a scan
58-
> (skipped/canceled builds, `[skip ci]`, path-filtered pipelines), the PR scan will fail with
59-
> exit code 3 rather than silently diff against the wrong baseline. See
55+
> The CLI uses the exact commit's newest matching full scan when one exists. Otherwise, it
56+
> searches up to 100 first-parent commits in the local checkout and uses the nearest scanned
57+
> ancestor, with a warning that the diff is wider than the merge base. Run `socketcli`
58+
> regularly on your default branch and ensure PR checkouts contain enough history for that
59+
> walk. The run fails with the configured API-error exit code only when no scanned ancestor
60+
> is reachable (or when the scan lookup itself fails). See
6061
> [`docs/cli-reference.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/cli-reference.md)
61-
> for the full requirements and a backfill pattern that makes PR jobs self-sufficient.
62+
> for the full behavior and an optional exact-baseline backfill pattern.
6263
6364
A specific full scan ID also works: `--base-scan-id <id>`.
6465

docs/ci-cd.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,14 @@ generator rather than a static YAML file:
395395
BASE_SHA=$(git merge-base "origin/${TARGET}" HEAD)
396396
```
397397

398-
- **Emit the backfill step conditionally from the generator.** The generator is the
399-
natural place for the "does a baseline scan exist?" check
398+
- **If an exact baseline is required, emit a backfill step conditionally from the
399+
generator.** The generator is the natural place for the "does an exact baseline
400+
scan exist?" check
400401
(`GET /orgs/{org}/full-scans?repo=<repo>&commit_hash=$BASE_SHA&per_page=1`): only
401402
emit the baseline-scan step when it returns nothing. The emitted pipeline then shows
402-
in the UI whether a backfill will run.
403+
in the UI whether a backfill will run. Without a backfill, the CLI automatically
404+
uses the nearest scanned first-parent ancestor within 100 commits and warns that
405+
the diff is wider.
403406

404407
- **Keep the backfill inside one command step.** The checkout-base → scan →
405408
checkout-PR sequence must not be split across steps — steps can land on different
@@ -408,17 +411,18 @@ generator rather than a static YAML file:
408411
checkout: `git worktree add /tmp/socket-base "$BASE_SHA"` then
409412
`socketcli --target-path /tmp/socket-base --branch "$TARGET" --disable-blocking`.
410413

411-
- **Soft-fail infra errors, not findings.** A missing baseline (or any API error)
412-
exits with code 3 (`--exit-code-on-api-error` to change it); real findings exit 1.
414+
- **Soft-fail infra errors, not findings.** No reachable scanned ancestor (or any API
415+
error) exits with code 3 (`--exit-code-on-api-error` to change it); real findings exit 1.
413416
[`soft_fail: [{exit_status: 3}]`](https://buildkite.com/docs/pipelines/configure/step-types/command-step)
414417
on the PR scan step keeps infra errors from blocking merges while security findings
415418
still do.
416419

417420
- **["Cancel intermediate builds"](https://buildkite.com/docs/pipelines/configure/canceling-builds#cancel-running-intermediate-builds)
418-
on the default branch is the main source of baseline gaps.** Canceled builds never
419-
scan their commit, so merge-base lookups for PRs based on those commits fail. The
420-
conditional backfill step above is the remedy; there is no per-step exemption from
421-
build cancellation in Buildkite. If you need strict scan-once semantics for
421+
on the default branch is a common source of exact-baseline gaps.** Canceled builds
422+
never scan their commit, so these PRs fall back to an older scanned ancestor. Use
423+
the conditional backfill step above when an exact merge-base comparison is required;
424+
there is no per-step exemption from build cancellation in Buildkite. If you need
425+
strict scan-once semantics for
422426
concurrent backfills of the same merge base, serialize the backfill step with a
423427
[concurrency group](https://buildkite.com/docs/pipelines/configure/workflows/controlling-concurrency)
424428
keyed on the merge-base SHA.

docs/cli-reference.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,24 +256,22 @@ If you don't want to provide the Socket API Token every time then you can use th
256256
| `--commit-message` | False | *auto* | Commit message (auto-detected from git) |
257257
| `--commit-sha` | False | *auto* | Commit SHA (auto-detected from git) |
258258
| `--base-scan-id` | False | | Full scan ID to diff against, overriding the repository's head scan as the baseline. Mutually exclusive with `--base-commit-sha` |
259-
| `--base-commit-sha`| False | | Commit SHA to diff against, overriding the repository's head scan as the baseline. The most recent full scan for that commit is used; the CLI errors (exit code 3, or `--exit-code-on-api-error`) if no scan exists for it. Mutually exclusive with `--base-scan-id` |
259+
| `--base-commit-sha`| False | | Commit SHA to prefer as the diff baseline, overriding the repository's head scan. The CLI uses its most recent matching full scan or the nearest scanned first-parent ancestor within 100 local commits. It errors (exit code 3, or `--exit-code-on-api-error`) if no scanned ancestor is reachable. Mutually exclusive with `--base-scan-id` |
260260

261-
> **Diffing against the merge base** — by default, PR scans are diffed against the repository's *latest* head scan, which may include newer default-branch commits than your PR branched from. To diff against the exact commit your PR is based on, compute the merge base and pass it as the baseline:
261+
> **Diffing against the merge base** — by default, PR scans are diffed against the repository's latest matching head scan, which may include newer default-branch commits than your PR branched from. To prefer the commit your PR is based on, compute the merge base and pass it as the baseline:
262262
>
263263
> ```shell
264264
> BASE_SHA=$(git merge-base origin/main HEAD)
265265
> socketcli --pr-number 123 --base-commit-sha "$BASE_SHA"
266266
> ```
267267
>
268-
> **Requirement: a full scan must already exist for the merge-base commit.** `--base-commit-sha` does not create a scan of that commit; it looks up an existing one. That lookup only succeeds if your CI runs `socketcli` on **every commit that lands on your default branch** — every merge and direct push, not just periodic or latest-only scans. Common ways commits slip through without a scan:
268+
> `--base-commit-sha` does not create a scan of that commit. The CLI first looks for the newest non-temporary scan matching the repository, workspace, scan type, and exact commit. If the exact commit was not scanned, it walks up to 100 first-parent commits from that SHA in the local checkout and uses the nearest matching scanned ancestor. It logs a warning with the selected commit and distance because this produces a wider diff than the merge base.
269269
>
270-
> - CI settings that cancel or skip intermediate builds when newer commits land (e.g. Buildkite's ["cancel intermediate builds"](https://buildkite.com/docs/pipelines/configure/canceling-builds#cancel-running-intermediate-builds))
271-
> - `[skip ci]` commits, path-filtered pipelines, or failed/canceled scan steps
272-
> - merge-base commits that predate your Socket rollout
270+
> Run `socketcli` regularly on the default branch so recent ancestors have scans. PR checkouts must also retain the merge base and enough first-parent history; shallow clones can shorten the search. Gaps are expected when CI cancels intermediate builds, commits use `[skip ci]`, pipelines are path-filtered, or the merge base predates your Socket rollout.
273271
>
274-
> If no scan exists for the commit, the CLI **fails** (exit code 3, or your `--exit-code-on-api-error` value; exit 0 with `--disable-blocking`) instead of silently falling back to the head scan — a wrong baseline would misreport which alerts the PR introduces. Don't adopt this flag without default-branch scan coverage in place; you'll fail PR builds on lookup misses.
272+
> If no scanned ancestor is reachable within the local 100-commit walk, the CLI **fails** (exit code 3, or your `--exit-code-on-api-error` value; exit 0 with `--disable-blocking`) instead of silently falling back to the repository head. API or permission failures also fail rather than being treated as a missing exact scan.
275273
>
276-
> **Backfill pattern** — if your default-branch coverage has gaps, the PR job can create the missing baseline itself before scanning:
274+
> **Optional exact-baseline backfill** — if the wider ancestor fallback is not acceptable, the PR job can create the missing exact baseline before scanning:
277275
>
278276
> ```shell
279277
> BASE_SHA=$(git merge-base origin/main HEAD)
@@ -285,7 +283,7 @@ If you don't want to provide the Socket API Token every time then you can use th
285283
> socketcli --pr-number 123 --base-commit-sha "$BASE_SHA"
286284
> ```
287285
>
288-
> Run the baseline step with `--disable-blocking` (findings on the default branch must not fail the PR job) and an explicit `--branch`, since branch auto-detection is unreliable at a detached HEAD.
286+
> Run the baseline step with `--disable-blocking` (findings on the default branch must not fail the PR job) and an explicit `--branch`, since branch auto-detection is unreliable at a detached HEAD. Without this step, the CLI automatically uses the nearest scanned ancestor.
289287
>
290288
> Buildkite users with dynamically generated pipelines: see [Merge-base baselines in Buildkite](ci-cd.md#merge-base-baselines-in-buildkite-dynamic-pipelines) for generation-time vs. step-time guidance.
291289

socketsecurity/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,9 @@ def create_argument_parser() -> argparse.ArgumentParser:
610610
metavar="<sha>",
611611
default=None,
612612
help="Commit SHA to diff the new scan against, overriding the repository's head "
613-
"scan as the baseline. The most recent full scan matching this commit (e.g. "
614-
"the merge base from 'git merge-base origin/main HEAD') is used; the CLI "
615-
"errors if no scan exists for it. Mutually exclusive with --base-scan-id."
613+
"scan as the baseline. The CLI uses the most recent matching full scan, or "
614+
"the nearest scanned first-parent ancestor within 100 local commits when "
615+
"the commit itself was not scanned. Mutually exclusive with --base-scan-id."
616616
)
617617

618618
# Path and File options

0 commit comments

Comments
 (0)