Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## 2.11.11

### Changed: use lowercase Python CLI User-Agent

- Use `socket-python-cli/` consistently for direct API and SDK requests.

### Changed: bump the Socket Python SDK to 3.6.2

- Bumped the pinned Socket Python SDK (`socketdev`) from `3.6.1` to `3.6.2`
to reject retired API credentials before use.

### Changed: bump pinned Coana CLI to 15.14.1

- Bumped the pinned reachability engine (the Coana CLI) from `15.14.0` to
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"gitpython==3.2.1",
"packaging==26.3",
"python-dotenv==1.2.4",
"socketdev==3.6.1",
"socketdev==3.6.2",
"beautifulsoup4==4.15.0",
"markdown==3.11.2",
"brotli==1.2.1; platform_python_implementation == 'CPython'",
Expand Down
3 changes: 2 additions & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__author__ = 'socket.dev'
__version__ = '2.11.11'
USER_AGENT = f'SocketPythonCLI/{__version__}'
USER_AGENT_NAME = 'socket-python-cli'
USER_AGENT = f'{USER_AGENT_NAME}/{__version__}'
3 changes: 2 additions & 1 deletion socketsecurity/socketcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from socketdev import socketdev
from socketdev.fullscans import FullScanParams

from socketsecurity import USER_AGENT_NAME
from socketsecurity.config import CliConfig, truncate_commit_message
from socketsecurity.core import Core
from socketsecurity.core.classes import Diff
Expand Down Expand Up @@ -240,7 +241,7 @@ def apply_git_context(config: CliConfig) -> Tuple[bool, Optional[Git]]:


def build_socket_sdk(config: CliConfig) -> socketdev:
cli_user_agent_string = f"SocketPythonCLI/{config.version}"
cli_user_agent_string = f"{USER_AGENT_NAME}/{config.version}"
return socketdev(
token=config.api_token,
timeout=get_api_request_timeout(config),
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/test_user_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pytest
import requests

from socketsecurity import __version__
from socketsecurity.config import CliConfig
from socketsecurity.core.cli_client import CliClient
from socketsecurity.core.socket_config import SocketConfig
from socketsecurity.socketcli import build_socket_sdk


@pytest.mark.parametrize("transport", ["direct", "sdk"])
def test_cli_api_requests_identify_the_same_product(monkeypatch, transport):
captured = []

def send(session, request, **kwargs):
captured.append(request)
response = requests.Response()
response.status_code = 200
response._content = b"{}"
return response

monkeypatch.setattr(requests.sessions.Session, "send", send)
if transport == "direct":
CliClient(SocketConfig(api_key="synthetic-test-token")).request(
"organizations"
)
else:
sdk = build_socket_sdk(
CliConfig(api_token="synthetic-test-token", repo="test-repo")
)
sdk.api.do_request("organizations")

assert len(captured) == 1
assert captured[0].headers["User-Agent"] == f"socket-python-cli/{__version__}"
assert captured[0].headers["Authorization"].startswith("Basic ")
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading