socketsecurity 2.13.0__py3-none-any.whl → 2.13.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  __author__ = 'socket.dev'
2
- __version__ = '2.13.0'
2
+ __version__ = '2.13.2'
3
3
  USER_AGENT_NAME = 'socket-python-cli'
4
4
  USER_AGENT = f'{USER_AGENT_NAME}/{__version__}'
@@ -2795,7 +2795,12 @@ class Core:
2795
2795
  top_package = packages.get(top_id)
2796
2796
  if top_package:
2797
2797
  manifests = ""
2798
- top_purl = f"{top_package.type}/{top_package.name}@{top_package.version}"
2798
+ ancestor_name = (
2799
+ f"{top_package.namespace}/{top_package.name}"
2800
+ if top_package.namespace
2801
+ else top_package.name
2802
+ )
2803
+ top_purl = f"{top_package.type}/{ancestor_name}@{top_package.version}"
2799
2804
  if hasattr(top_package, "manifestFiles") and top_package.manifestFiles:
2800
2805
  for manifest_data in top_package.manifestFiles:
2801
2806
  manifest_file = manifest_data.get("file")
@@ -78,18 +78,10 @@ class Messages:
78
78
  # Remove leading slashes
79
79
  clean_path = clean_path.lstrip('/')
80
80
 
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"
83
83
  if config and hasattr(config, 'scm'):
84
84
  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"
93
85
 
94
86
  # Generate URL based on SCM type using config information
95
87
  # NEVER use diff.diff_url for SCM URLs - those are Socket URLs for "View report" links
@@ -861,6 +853,35 @@ class Messages:
861
853
  """
862
854
  return escape(Messages.inline_html_text(value))
863
855
 
856
+ # Enough to name the usual one or two ancestors without letting a package
857
+ # pulled in by dozens of direct dependencies swamp the alert row.
858
+ INTRODUCED_BY_LIMIT = 5
859
+
860
+ @staticmethod
861
+ def introduced_by_html(alert: Issue) -> str:
862
+ """Name the direct dependencies that pulled a transitive package in.
863
+
864
+ Returns an empty string for a direct dependency, or for a transitive one
865
+ whose ancestors are not in this scan, so the row only gains a line when
866
+ there is an ancestor to name.
867
+ """
868
+ ancestors = []
869
+ for entry in getattr(alert, "introduced_by", None) or []:
870
+ if not isinstance(entry, (list, tuple)) or not entry:
871
+ continue
872
+ source = entry[0]
873
+ if source and source != "direct" and source not in ancestors:
874
+ ancestors.append(source)
875
+ if not ancestors:
876
+ return ""
877
+
878
+ shown = ancestors[:Messages.INTRODUCED_BY_LIMIT]
879
+ names = ", ".join(f"<code>{Messages.html_text(name)}</code>" for name in shown)
880
+ hidden = len(ancestors) - len(shown)
881
+ if hidden:
882
+ names += f" and {hidden} more"
883
+ return f"<p><strong>Introduced by:</strong> {names}</p>"
884
+
864
885
  @staticmethod
865
886
  def html_attr(value) -> str:
866
887
  """Escape a value for an HTML attribute, quotes included.
@@ -990,6 +1011,7 @@ class Messages:
990
1011
  ) if show_ignore else ""
991
1012
  row += f""" </ul>
992
1013
  <p><strong>From:</strong> <a href="{Messages.html_attr(license_manifest_url)}">Manifest File</a></p>
1014
+ {Messages.introduced_by_html(first_alert)}
993
1015
  <p>ℹ️ Read more on: <a href="{Messages.html_attr(first_alert.purl)}">This package</a> | <a href="https://socket.dev/alerts/license">What is a license policy violation?</a></p>
994
1016
  <blockquote>
995
1017
  <p><em>Next steps:</em> Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at <strong>support@socket.dev</strong>.</p>
@@ -1039,6 +1061,7 @@ class Messages:
1039
1061
  <p><strong>Note:</strong> {Messages.html_text(alert.description)}</p>
1040
1062
  {patched_version_html}
1041
1063
  <p><strong>Source:</strong> <a href="{Messages.html_attr(manifest_url)}">Manifest File</a></p>
1064
+ {Messages.introduced_by_html(alert)}
1042
1065
  <p>ℹ️ Read more on:
1043
1066
  <a href="{Messages.html_attr(alert.purl)}">This package</a> |
1044
1067
  <a href="{Messages.html_attr(alert.url)}">This alert</a> |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: socketsecurity
3
- Version: 2.13.0
3
+ Version: 2.13.2
4
4
  Summary: Socket Security CLI for CI/CD
5
5
  Project-URL: Homepage, https://socket.dev
6
6
  Author-email: Douglas Coburn <douglas@socket.dev>
@@ -44,15 +44,15 @@ Requires-Dist: packaging==26.3
44
44
  Requires-Dist: prettytable==3.18.0
45
45
  Requires-Dist: python-dotenv==1.2.4
46
46
  Requires-Dist: requests==2.34.2
47
- Requires-Dist: socketdev==3.6.2
47
+ Requires-Dist: socketdev==3.6.3
48
48
  Provides-Extra: dev
49
49
  Requires-Dist: hatch==1.18.2; extra == 'dev'
50
50
  Requires-Dist: pre-commit==4.7.0; extra == 'dev'
51
- Requires-Dist: ruff==0.17.4; extra == 'dev'
51
+ Requires-Dist: ruff==0.17.5; extra == 'dev'
52
52
  Requires-Dist: twine==7.0.0; extra == 'dev'
53
- Requires-Dist: uv==0.13.7; extra == 'dev'
53
+ Requires-Dist: uv==0.13.8; extra == 'dev'
54
54
  Provides-Extra: test
55
- Requires-Dist: pytest-asyncio==1.4.1.post1; extra == 'test'
55
+ Requires-Dist: pytest-asyncio==1.5.0; extra == 'test'
56
56
  Requires-Dist: pytest-cov==7.1.0; extra == 'test'
57
57
  Requires-Dist: pytest-mock==3.17.0; extra == 'test'
58
58
  Requires-Dist: pytest-watch==4.2.0; extra == 'test'
@@ -79,6 +79,10 @@ pip install socketsecurity
79
79
  export SOCKET_SECURITY_API_TOKEN="<token>"
80
80
  ```
81
81
 
82
+ The token needs more than scan-creation access. Most missing scopes fail the run, and
83
+ a token without the `diff-scans` scopes falls back with only a warning. See
84
+ [`docs/troubleshooting.md#api-token-permissions`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#api-token-permissions).
85
+
82
86
  ### 3) Run a basic scan
83
87
 
84
88
  ```bash
@@ -1,11 +1,11 @@
1
1
  LICENSE,sha256=42PY8FVn2DIlllI33b2wn91DeorIVqORc6Q9uw11DUU,1066
2
- socketsecurity/__init__.py,sha256=18ZLt_to4r-mDBA60paxnu9DhG4WwnM1eSUqwjvz6bs,135
2
+ socketsecurity/__init__.py,sha256=3cMzMO5ntUrV4IMcbfO8rLh1hsBuvU4ITFeZBmTlqok,135
3
3
  socketsecurity/config.py,sha256=7n7LkGVxzvg1b9wkttJ2tY7NPeGOorOPo9xzizxR7dw,52957
4
4
  socketsecurity/exit_codes.py,sha256=T7EQSOLcLmQhcFIlsMAlTVLDp5qntFJNypdeOTOpTI8,1702
5
5
  socketsecurity/fossa_compat.py,sha256=NO_bRlZkuzDNel2C-6lLfPbWAYwLta5gYWAVhtRaJAc,17596
6
6
  socketsecurity/output.py,sha256=O750SeMCAXrBpQcxxPKR2HOtlicIj9YP8aY9QKu1t8E,18630
7
7
  socketsecurity/socketcli.py,sha256=ZgoYYXnbjdyXItFJbROITW0kleca2uspmsk1k8NNWUM,53170
8
- socketsecurity/core/__init__.py,sha256=BSHPVzoDgyrrejmP4w7Tj1XUrY8Rz7PKotjvHbZWBn8,137026
8
+ socketsecurity/core/__init__.py,sha256=Q6eizwomCuu9F7NtxcWsTIwk-tmZ7nby1C-PPJzitK4,137248
9
9
  socketsecurity/core/alert_selection.py,sha256=QGhwFvhyEeuTYECh81-4eWIFZsKDuK_kh836CAbZ4oI,9336
10
10
  socketsecurity/core/classes.py,sha256=JAz-Pvr-3vHKIuMs03TcuKpielptkdpo7P7DYXoDxOA,22405
11
11
  socketsecurity/core/cli_client.py,sha256=sytvK-IB4f_5Vf_KLgVXcTx3ZkcHE8-Knw8S5fgPTng,3584
@@ -16,7 +16,7 @@ socketsecurity/core/git_remote.py,sha256=IlKfzv0l22eZXkdHvJHhG9s_bMCFJ_9YH8t6KSY
16
16
  socketsecurity/core/lazy_file_loader.py,sha256=QQTchRRAHoITR3b5vvL-9seHNTO3vGSMEtFaoPRHK-w,5182
17
17
  socketsecurity/core/log_uploader.py,sha256=JHmL4kRT5rJG27rAtsA8NyN5FKZvZuNriqRSn0JoWjg,3287
18
18
  socketsecurity/core/logging.py,sha256=eNlKgWlUFIZzVVpNYpdGM6Qy2X5RrHr_uOR3JmGvFTc,1093
19
- socketsecurity/core/messages.py,sha256=DIBLAxOqKrMUSUTy03nFqlLgUcrF-Byfazt-vv27JuM,69916
19
+ socketsecurity/core/messages.py,sha256=4Llwd_rVtCftfT6uhWPZuqh3Zq8JOR22UUZNPmEa0ps,70881
20
20
  socketsecurity/core/pull_request.py,sha256=30eLwGjvJhwjc6SAN3W3kKnEjWCyJ0aWpgPtzJFaOkk,7804
21
21
  socketsecurity/core/resource_utils.py,sha256=5Jy1CEaTJJ7a8xDfptKY1UvtIiJxhbyta25W5anBedc,2070
22
22
  socketsecurity/core/scm_comments.py,sha256=hCHZVLh2-XwCNGAoWTQxSSEZ7LC-gQHSu-MrGzOmIaM,15788
@@ -41,8 +41,8 @@ socketsecurity/plugins/teams.py,sha256=j7Z1QYPrj9KHcpp6k5UnM3-MspQ9g-K9lswv36CUI
41
41
  socketsecurity/plugins/webhook.py,sha256=0mUVxJtMKX5rvdVRD12fx3or03HEU9Kdl48EQHZzc7g,441
42
42
  socketsecurity/plugins/formatters/__init__.py,sha256=9FQBrh1Ju30Tlo4d2ao91-qQaRdcEX0A3Gu_0kk-Kno,145
43
43
  socketsecurity/plugins/formatters/slack.py,sha256=PO8UmZMBwt-2a2y3XPB47zPTarbiiJbUc_f1G64wC8o,9876
44
- socketsecurity-2.13.0.dist-info/METADATA,sha256=8_BoswNrc0a_ijnuYoud6XhxPEhXNNrthhle83k2qcw,14589
45
- socketsecurity-2.13.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
46
- socketsecurity-2.13.0.dist-info/entry_points.txt,sha256=89ullhKkHRQUMGAXard1jWN2xNDL3qleyKOTAqnIyzY,103
47
- socketsecurity-2.13.0.dist-info/licenses/LICENSE,sha256=42PY8FVn2DIlllI33b2wn91DeorIVqORc6Q9uw11DUU,1066
48
- socketsecurity-2.13.0.dist-info/RECORD,,
44
+ socketsecurity-2.13.2.dist-info/METADATA,sha256=3h3O715fspONw_EiN_DIq5pbE1SHZkCsArVA9gld9Y4,14901
45
+ socketsecurity-2.13.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
46
+ socketsecurity-2.13.2.dist-info/entry_points.txt,sha256=89ullhKkHRQUMGAXard1jWN2xNDL3qleyKOTAqnIyzY,103
47
+ socketsecurity-2.13.2.dist-info/licenses/LICENSE,sha256=42PY8FVn2DIlllI33b2wn91DeorIVqORc6Q9uw11DUU,1066
48
+ socketsecurity-2.13.2.dist-info/RECORD,,