feat: Add SCM-aware manifest file URL generation and fix report links #119
+123
−21
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.
Bug Description:
Manifest files in security comments were incorrectly linking to Socket dashboard URLs (like
https://socket.dev/dashboard/org/socketdev-demo/diff/06e956ff...
) instead of proper SCM URLs (likehttps://github.com/socketdev-demo/javascript-threats/blob/main/package.json
) whenscm=github/gitlab/bitbucket
. Additionally, "View full report" links were using the wrong URL type for different scan contexts.Impact:
Root Cause
The
Messages.security_comment_template()
method was directly usingalert.manifests
as href URLs without any processing. The manifest paths contained build agent paths and weren't converted to proper SCM URLs based on the repository type. Additionally, the method was missing logic to generate SCM-specific URLs using repository configuration and environment variables.The "View full report" link was hardcoded to use
report_url
instead of intelligently choosing betweendiff_url
(for PR comparisons) andreport_url
(for SBOM views).Fix
Added
get_manifest_file_url()
method that intelligently generates proper URLs based on SCM type:opt/buildagent/work/
,home/runner/work/
)GITHUB_SERVER_URL
,CI_SERVER_URL
,BITBUCKET_SERVER_URL
Updated
security_comment_template()
method to:get_manifest_file_url()
for both security alerts and license violationsdiff_url
for PRs, fallback toreport_url
for non-PR scansEnhanced infrastructure:
os
module import for environment variable accessbase_path
parameter tocreate_full_scan()
for better path handlingPublic Changelog
Fixed manifest file links in security comments to properly link to source code files in GitHub, GitLab, and Bitbucket repositories instead of Socket dashboard pages. Fixed "View full report" links to show appropriate content based on scan context.