Skip to content

Commit f322058

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/comment-package-links
2 parents fefa5b1 + b398288 commit f322058

6 files changed

Lines changed: 32 additions & 14 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## 2.13.1
3+
## 2.13.2
44

55
### Fixed
66

@@ -9,6 +9,14 @@
99
socket.dev. It pointed at the bare package coordinate, such as
1010
`handlebars@4.0.11`, which GitHub and GitLab resolve as a broken relative link.
1111

12+
### Changed
13+
14+
- Manifest file links in PR comments and reports pick the source host only from
15+
`--scm`. The fallback that guessed GitHub, GitLab, or Bitbucket from the Socket
16+
diff URL never produced a link and has been removed.
17+
18+
## 2.13.1
19+
1220
### Documentation
1321

1422
- New [API token permissions](docs/troubleshooting.md#api-token-permissions) guide:

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.13.1"
9+
version = "2.13.2"
1010
requires-python = ">= 3.11"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

‎socketsecurity/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.13.1'
2+
__version__ = '2.13.2'
33
USER_AGENT_NAME = 'socket-python-cli'
44
USER_AGENT = f'{USER_AGENT_NAME}/{__version__}'

‎socketsecurity/core/messages.py‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,10 @@ def get_manifest_file_url(diff: Diff, manifest_path: str, config=None) -> str:
7878
# Remove leading slashes
7979
clean_path = clean_path.lstrip('/')
8080

81-
# Determine SCM type from config or diff_url
82-
scm_type = "api" # Default to API
81+
# diff.diff_url points at Socket, not the SCM, so only config decides.
82+
scm_type = "api"
8383
if config and hasattr(config, 'scm'):
8484
scm_type = config.scm.lower()
85-
elif hasattr(diff, 'diff_url') and diff.diff_url:
86-
diff_url = diff.diff_url.lower()
87-
if 'github.com' in diff_url or 'github' in diff_url:
88-
scm_type = "github"
89-
elif 'gitlab' in diff_url:
90-
scm_type = "gitlab"
91-
elif 'bitbucket' in diff_url:
92-
scm_type = "bitbucket"
9385

9486
# Generate URL based on SCM type using config information
9587
# NEVER use diff.diff_url for SCM URLs - those are Socket URLs for "View report" links

‎tests/unit/test_messages.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,21 @@ def test_manifest_link_falls_back_to_the_report_without_a_repository_url():
102102
url = Messages.get_manifest_file_url(diff, "app/package.json", config)
103103

104104
assert url == "https://socket.dev/report/123?tab=files&file=app%2Fpackage.json"
105+
106+
107+
108+
def test_manifest_link_does_not_guess_the_scm_from_the_diff_url():
109+
"""Without an explicit scm, a GitHub-looking diff_url falls back to the report."""
110+
111+
class _NoScmConfig:
112+
branch = "main"
113+
repository_url = "https://github.com/acme/widgets"
114+
115+
diff = Diff(
116+
diff_url="https://github.com/acme/widgets/pull/1",
117+
report_url="https://socket.dev/report/123",
118+
)
119+
120+
url = Messages.get_manifest_file_url(diff, "app/package.json", _NoScmConfig())
121+
122+
assert url == "https://socket.dev/report/123?tab=files&file=app%2Fpackage.json"

‎uv.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)