GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add Bitbucket PR comment support by obarrera · Pull Request #206 · SocketDev/socket-python-cli

Conversation

@obarrera

@obarrera Orlando Barrera II (obarrera) commented May 28, 2026 •
edited by lelia
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

  • Adds socketsecurity/core/scm/bitbucket.py with BitbucketConfig + Bitbucket SCM that posts/updates Dependency Overview and Security Issue comments on Bitbucket Cloud PRs, mirroring the GitHub and GitLab modules.
  • Reads BITBUCKET_* Pipelines env vars; supports Bearer (BITBUCKET_TOKEN) or Basic auth (BITBUCKET_USERNAME + BITBUCKET_APP_PASSWORD). BITBUCKET_API_URL lets Server/Data Center users point at a self-hosted REST API.
  • Normalizes Bitbucket's {content: {raw}, user: {nickname, uuid}} payload onto the shared Comment dataclass so the existing Comments helpers, ignore-command flow, and security-comment scrubbing all work unchanged.
  • Substitutes Bitbucket's missing reaction API with a hidden <!-- socket-ignore-processed --> marker that has_thumbsup_reaction looks for on subsequent runs.
  • Wires --scm bitbucket into socketcli.py and updates workflows/bitbucket-pipelines.yml to use it.

Why

The Bitbucket comment implementation was partially completed, but couldn't get the API to accept comments. Most likely culprit: GitHub-style {"body": "..."} form-encoded payloads, where Bitbucket Cloud requires JSON {"content": {"raw": "..."}} with Content-Type: application/json. This PR uses that shape.

Out of scope

  • Azure DevOps — left for a follow-up since it's a separate API surface.
  • Live smoke test on a real Bitbucket workspace — a test instance still needs to be set up.

Test plan

  • uv run pytest tests/unit/test_bitbucket.py — 15 new tests covering env parsing (Bearer + Basic + missing creds), default-branch detection, event-type detection, comment normalization (raw content, deleted, missing fields), POST/PUT payload shape, and create-vs-update dispatch.
  • uv run pytest tests/unit -q --no-cov — 164 passed, 2 pre-existing skips.
  • End-to-end run against a Bitbucket Cloud PR on a workspace with BITBUCKET_TOKEN configured.
  • End-to-end run with BITBUCKET_USERNAME / BITBUCKET_APP_PASSWORD to confirm Basic auth path.
  • Verify ignore-comment flow: post @SocketSecurity ignore npm/[email protected], re-run, confirm alert filtered + hidden marker appended.
  • (Optional) Bitbucket Server / Data Center run with BITBUCKET_API_URL override.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@obarrera @claude
Add Bitbucket PR comment support (CE-89)
37de6a0
Adds a Bitbucket SCM implementation mirroring the GitHub/GitLab modules
so socketcli can post and update Dependency Overview and Security Issue
comments on Bitbucket Cloud pull requests. Includes config from
BITBUCKET_* Pipelines env vars (Bearer token or username/app-password
auth), comment shape normalization onto the existing Comment dataclass,
and unit tests covering env parsing, event detection, normalization, and
POST/PUT payload shape.

Refs CE-89

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions

github-actions Bot commented May 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.2.92.dev1

Docker image: socketdev/cli:pr-206

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lelia and others added 2 commits May 28, 2026 12:48
@lelia
Apply Bitbucket SCM review feedback
46f6de5
- Fix paginated comment fetch: previous code passed base_url='' for the
  absolute 'next' URL, which CliClient (falsy check) silently mapped to
  Socket's API base. Split the URL into origin + path so the request
  hits Bitbucket.
- Drop content.get('markup') body fallback (markup is the format name,
  not body text); fall back to content.get('html') instead.
- Remove dead hasattr() branch in has_thumbsup_reaction.
- Move PROCESSED_MARKER to top of class with a comment explaining why
  there's no Bearer/Basic auth-fallback retry like GitLab has.
- Document that --scm bitbucket exits 2 without BITBUCKET_TOKEN or
  BITBUCKET_USERNAME+BITBUCKET_APP_PASSWORD set.
- Expand tests: pagination (origin split, no-next, error response,
  no-PR), has_thumbsup_reaction (marker present/absent, no-PR,
  exception swallowing), _mark_comment_processed (append, idempotence,
  swallow update error), check_for_socket_comments classification, and
  _split_absolute_url round-trip.

Signed-off-by: lelia <[email protected]>
@obarrera @claude
Bump version to 2.2.91
6f520e6
Required by the check_version workflow now that main is at 2.2.90. Bumps
__version__ in socketsecurity/__init__.py and pyproject.toml; uv.lock
regenerated.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@lelia lelia changed the title Add Bitbucket PR comment support (CE-89) Add Bitbucket PR comment support May 28, 2026
@obarrera @claude
Apply code-review improvements + bump to 2.2.92
96433ee
- Cache comment bodies in get_comments_for_pr so has_thumbsup_reaction
  resolves from memory instead of issuing one extra GET per ignore
  comment on every run. _mark_comment_processed refreshes the cache so
  in-run repeat checks also hit it.
- Guard against {"values": null} responses from Bitbucket Cloud — the
  previous .get("values", []) default only fires on missing key, so a
  null value would TypeError on iteration.
- Fail fast in BitbucketConfig.from_env when workspace or repo_slug
  can't be determined, rather than building 404-bound URLs deeper in
  the request flow.
- Drop typing.Tuple in favor of built-in tuple (project targets 3.11+).
- Document BITBUCKET_DEFAULT_BRANCH in the example pipeline since
  Bitbucket Pipelines doesn't export the repo default branch.
- Add tests for cache hits, cache fallback, mark-processed cache
  refresh, null-values pagination, and the new workspace/repo
  validation exit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@lelia lelia added the enhancement New feature or request label May 31, 2026

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@obarrera @lelia
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.