Skip to content

Commit be87c34

Browse files
authored
Fix stale didYouMean props (#81)
* test: failing regression for stale didYouMean props * fix(issues): drop stale didYouMean props, add detectedAt Resolves CUS2-5. The didYouMean class declared four props (alternatePackage, downloads, downloadsRatio, editDistance) but the current OpenAPI schema (socket-sdk-js/openapi.json:9298) only emits { alternatePackage, detectedAt }. The three stale keys were dead at runtime and detectedAt was missing a human-readable label entirely. Updated to match the schema. * chore(release): bump to 3.1.1 and sync pyproject.toml Run via .hooks/sync_version.py after merging origin/main (now at 3.1.0 from lelia's purl PR). Keeps pyproject.toml and socketdev/version.py in lockstep, as flagged in code review. * chore: sync uv.lock to 3.1.1
1 parent 8b668fd commit be87c34

5 files changed

Lines changed: 32 additions & 4 deletions

File tree

pyproject.toml

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

55
[project]
66
name = "socketdev"
7-
version = "3.1.0"
7+
version = "3.1.1"
88
requires-python = ">= 3.9"
99
dependencies = [
1010
'requests',

socketdev/core/issues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ class didYouMean:
463463

464464
def __init__(self):
465465
self.description = "Package name is similar to other popular packages and may not be the package you want."
466-
self.props = {"alternatePackage": "Alternate package", "downloads": "Downloads", "downloadsRatio": "Download ratio", "editDistance": "Edit distance"}
466+
self.props = {"alternatePackage": "Alternate package", "detectedAt": "Detected at"}
467467
self.suggestion = "Use care when consuming similarly named packages and ensure that you did not intend to consume a different package. Malicious packages often publish using similar names as existing popular packages."
468468
self.title = "Possible typosquat attack"
469469
self.emoji = "\ud83e\uddd0"

socketdev/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.1.0"
1+
__version__ = "3.1.1"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Contract test for the didYouMean alert-type class's props.
2+
3+
The OpenAPI schema (`socket-sdk-js/openapi.json` around line 9298) declares
4+
that the API emits `didYouMean` alerts with ``props: { alternatePackage,
5+
detectedAt }``. The Python SDK previously declared four props
6+
(``alternatePackage``, ``downloads``, ``downloadsRatio``, ``editDistance``);
7+
the latter three are no longer in the API schema and were dead keys at
8+
runtime — and ``detectedAt`` was missing.
9+
10+
Tracks CUS2-5. Sibling of CUS2-4.
11+
"""
12+
13+
import unittest
14+
15+
from socketdev.core.issues import didYouMean
16+
17+
18+
class TestDidYouMeanProps(unittest.TestCase):
19+
def test_props_match_openapi_schema(self):
20+
"""API emits props { alternatePackage, detectedAt } (openapi.json:9298)."""
21+
issue = didYouMean()
22+
self.assertEqual(set(issue.props.keys()), {"alternatePackage", "detectedAt"})
23+
24+
def test_props_label_strings_are_non_empty(self):
25+
"""Every props key must have a non-empty human-readable label."""
26+
issue = didYouMean()
27+
for key, label in issue.props.items():
28+
self.assertTrue(label, f"props[{key!r}] label should not be empty")

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)