Skip to content

feat(scan): scan Bazel targets with --bazel - #1788

Draft
Jeppe Fredsgaard Blaabjerg (jfblaa) wants to merge 1 commit into
v1.xfrom
jfblaa/bazel-sca-v1x
Draft

Jeppe Fredsgaard Blaabjerg (jfblaa) wants to merge 1 commit into
v1.xfrom
jfblaa/bazel-sca-v1x

Conversation

@jfblaa

Copy link
Copy Markdown
Contributor

Heads up, reviewer

[Edit me, human!]


Claude Code · claude-opus-5-5

socket scan create <root> --bazel -- <patterns> scans only the Bazel targets the patterns match, from the workspace root, instead of discovering manifests. Coana resolves the patterns as bazel build does and generates one Socket facts file for those targets. With --reach, it analyses the JVM, Python and JavaScript targets. --bazel is hidden.

This needs a Coana release with coana-tech/coana-package-manager#2890, so it stays a draft until that release is pinned.

Behaviour
  • Patterns go after --, as on Bazel's own command line, so a negative pattern such as -//app/legacy/... is no flag. A pattern before --, or any short flag the command does not declare, is refused with a message saying to move it.
  • One TARGET before --: the workspace root, the directory holding MODULE.bazel, REPO.bazel, WORKSPACE or WORKSPACE.bazel. --bazel is refused with --auto-manifest, --dynamic-sbom-inference, --uv-members and --exclude-paths.
  • Only the facts file is uploaded. Reachability is narrowed to the ecosystems of the targets Coana analyses, and a warning names the other targets, whose dependencies are scanned without reachability.
  • Bazel comes from SOCKET_CLI_BAZEL_PATH, else bazelisk or bazel on PATH. socket manifest bazel now also takes SOCKET_CLI_BAZEL_PATH ahead of --bazel, in every build, as Gradle, Maven and sbt take theirs (changelog entry included).
  • Facts generation passes Coana the run's --purpose, as every other build does, and a reachability run compiles the targets.
Not in this PR
  • Bazel settings from socket.json (binary, flags, bazelrc). A Bazel scan takes none yet.
  • One workspace-root check shared with socket manifest bazel and auto-detection, which do not know REPO.bazel.
  • socket fix for Bazel builds (REA-1372).
Tests
  • cmd-scan-create.test.mts: the accepted forms, and each refusal, including a pattern before --; a declared short flag with an attached value is accepted.
  • handle-create-new-scan.test.mts: a Bazel scan uploads the facts file alone and narrows reachability to its targets' ecosystems.
  • bin-detect.test.mts: SOCKET_CLI_BAZEL_PATH ahead of --bazel; a scan's error names only SOCKET_CLI_BAZEL_PATH.
  • End to end in a testing org, with a local Coana build of #2890:
    • JVM and mixed Python/Java scans gave function-level reachable traces.
    • npm: lodash _.template was reachable from main.js, and the packages it never calls were unreachable.
    • Rust and Go scans uploaded every package with its advisories.

Closes REA-1247
Closes REA-1249
Closes REA-1250
Closes REA-1251
Closes REA-1303

🤖 Generated with Claude Code

Scans only the Bazel targets the patterns after `--` name, from the
workspace root, in place of manifest discovery. Coana resolves the
patterns as `bazel build` takes them and generates the Socket facts;
reachability analyses the JVM, Python and JavaScript targets.

Facts generation passes Coana the run's `--purpose`, as every other
build does, and a reachability run compiles the targets.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant