Skip to content

Link "This package" in PR/MR comments to the package page - #465

Draft
David Larsen (dc-larsen) wants to merge 5 commits into
mainfrom
fix/comment-package-links
Draft

David Larsen (dc-larsen) wants to merge 5 commits into
mainfrom
fix/comment-package-links

Conversation

@dc-larsen

@dc-larsen David Larsen (dc-larsen) commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Every row of the PR/MR security comment has a "Read more on: This package" link whose href is the bare package coordinate:

<a href="handlebars@4.0.11">This package</a>

GitHub and GitLab treat that as a relative link, so it opens .../pull/handlebars@4.0.11 (a 404) instead of the package page. Since #453, --strict-blocking comments also list existing alerts with the same row templates, so the broken link shows on existing-alert rows too. Found while verifying 2.13.0 against real pull request scans: on a test pull request all 38 rows had a relative link.

Root Cause

Messages.security_alert_row and Messages.license_group_row render href="{alert.purl}". In the CLI, Issue.purl is the bare coordinate ([namespace/]name@version, set in Core.update_package_values), not a URL. The alert row has done this since the HTML comment template was added (#79), and the license row since license groups were added (#111). #453 did not introduce it; it reuses both templates for the existing-alerts table.

Fix

Both rows now link "This package" to alert.url, the package overview URL that Package.socket_url already builds: https://socket.dev/<ecosystem>/package/<namespace>/<name>/overview/<version>, with the namespace as its own path segment (npm scope, Maven groupId, Go module path). It is the same URL the Markdown, Slack and Jira outputs already use for the package link, and it goes through Messages.html_attr as before. GitHub and GitLab post the same rendered comment, so both are fixed.

Overlap, for a maintainer call:

Tests

  • tests/unit/test_comment_package_links.py (new, 21 cases). Each case starts from a diff artifact as the API returns it and goes through Package.from_diff_artifact, Core.update_package_values and Core.add_package_alerts_to_collection to the rendered comment. Alert rows and license rows for npm, scoped npm (@babel/traverse), PyPI, Maven (org.apache.logging.log4j/log4j-core), Go (github.com/gin-gonic/gin), NuGet, RubyGems and Cargo link to the expected https://socket.dev/... URL; the existing-alerts table does the same; no row on either SCM has a relative link; a hostile package name stays attribute-escaped. All 21 fail on main.
  • Full suite with all Socket API key variables unset: uv run pytest -q tests/unit/ tests/core/: 1022 passed (1001 on main). uv run ruff check, uv lock --locked --offline, git diff --check and uv build pass.
  • End to end against a test org, on a throwaway private pull request (npm: lodash 4.17.11 + handlebars 4.0.11 on the default branch; the pull request adds vm2 3.9.11), --scm github --strict-blocking. 2.13.0 from PyPI posted the comment, then this branch updated it. The hrefs come from the comment body, and the rendered links from the API's body_html:
2.13.0 This branch
"This package" href (38 rows: 35 vm2, 3 existing) vm2@3.9.11, handlebars@4.0.11, lodash@4.17.11, minimist@0.0.10 https://socket.dev/npm/package/vm2/overview/3.9.11, .../handlebars/overview/4.0.11, .../lodash/overview/4.17.11, .../minimist/overview/0.0.10
Rendered link relative, resolves under the pull request URL absolute, rel="nofollow"
Exit code / row count 1 / 38 1 / 38

Other open 2.13.x fixes

2.13.1 and 2.13.2 were released from main on 2026-11-20, so this branch merges main at v2.13.2 and bumps to 2.13.3 in pyproject.toml, socketsecurity/__init__.py and uv.lock, with its CHANGELOG entries under a new ## 2.13.3 heading. #459, #460, #461, #462, #463, #464 and #465 all make the same bump, so the version files merge cleanly between them, and once one merges the rest ride main's unreleased 2.13.3 (Version Check accepts a version equal to main's while it is above the latest PyPI release). Merging a second one conflicts only in CHANGELOG.md: keep one ## 2.13.3 heading and combine the bullets under its subsections (Upgrade notes, Changed, Fixed, Documentation, in that order). There are no code conflicts between them. If main releases 2.13.3 before this merges, bump to the next patch again.

Public Changelog

The "This package" link in PR/MR security comments opens the package's page on socket.dev. It used to be a broken relative link.

Each security comment row linked "This package" to the bare package
coordinate (alert.purl, e.g. handlebars@4.0.11), so GitHub and GitLab
resolved it as a relative link to a page that does not exist. The alert
rows have done this since the HTML comment template was introduced, and
license rows since they were added; the --strict-blocking existing-alerts
table reuses both templates.

Both rows now use alert.url, the package overview URL that
Package.socket_url builds with the namespace (npm scope, Maven groupId, Go
module path). The Markdown, Slack and Jira outputs already link the package
with that URL.
…inks

# Conflicts:
#	CHANGELOG.md
#	socketsecurity/core/messages.py
2.13.2 was released from main, so this change needs the next patch version.

This branch was successfully deployed

1 active deployment
socket-firewall — 04dfec2a Deployed Nov 20, 2026 by dc-larsen via python-sfw-smoke-enterprise #667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant