Skip to content

Commit 60219d3

Browse files
rreusserlelia
andauthored
Add bun and vlt lockfiles (#202)
* Add bun and vlt lockfiles * Add bun.lockb * Add unit tests for bun.lock, bun.lockb, and vlt-lock.json manifest matching Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> * Bump version to 2.2.87 Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> * Add missing version refs Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> --------- Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> Co-authored-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent 206efe9 commit 60219d3

4 files changed

Lines changed: 55 additions & 3 deletions

File tree

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.2.86"
9+
version = "2.2.88"
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,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.2.86'
2+
__version__ = '2.2.88'
33
USER_AGENT = f'SocketPythonCLI/{__version__}'

socketsecurity/core/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@
3838
},
3939
"pnpm-workspace.yml": {
4040
"pattern": "pnpm-workspace.yml"
41+
},
42+
"bun.lock": {
43+
"pattern": "bun.lock"
44+
},
45+
"bun.lockb": {
46+
"pattern": "bun.lockb"
47+
},
48+
"vlt-lock.json": {
49+
"pattern": "vlt-lock.json"
4150
}
4251
},
4352
"pypi": {
@@ -105,4 +114,4 @@
105114
"pattern": "packages.lock.json"
106115
}
107116
}
108-
}
117+
}

tests/core/test_has_manifest_files.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from unittest.mock import patch
22

33
from socketsecurity.core import Core
4+
from socketsecurity.core.utils import socket_globs
45

56
# Minimal patterns matching what the Socket API returns
67
MOCK_PATTERNS = {
78
"npm": {
89
"packagejson": {"pattern": "package.json"},
910
"packagelockjson": {"pattern": "package-lock.json"},
1011
"yarnlock": {"pattern": "yarn.lock"},
12+
"bunlock": {"pattern": "bun.lock"},
13+
"bunlockb": {"pattern": "bun.lockb"},
14+
"vltlockjson": {"pattern": "vlt-lock.json"},
1115
},
1216
"pypi": {
1317
"requirements": {"pattern": "*requirements.txt"},
@@ -66,3 +70,42 @@ def test_dot_slash_prefix_normalized(self, mock_patterns):
6670
def test_pom_xml_root(self, mock_patterns):
6771
core = Core.__new__(Core)
6872
assert core.has_manifest_files(["pom.xml"]) is True
73+
74+
def test_bun_lock_root(self, mock_patterns):
75+
core = Core.__new__(Core)
76+
assert core.has_manifest_files(["bun.lock"]) is True
77+
78+
def test_bun_lockb_root(self, mock_patterns):
79+
core = Core.__new__(Core)
80+
assert core.has_manifest_files(["bun.lockb"]) is True
81+
82+
def test_vlt_lock_json_root(self, mock_patterns):
83+
core = Core.__new__(Core)
84+
assert core.has_manifest_files(["vlt-lock.json"]) is True
85+
86+
def test_bun_lock_subdirectory(self, mock_patterns):
87+
core = Core.__new__(Core)
88+
assert core.has_manifest_files(["apps/web/bun.lock"]) is True
89+
90+
91+
@patch.object(Core, "get_supported_patterns", side_effect=RuntimeError("API unreachable"))
92+
@patch.object(Core, "__init__", lambda self, *a, **kw: None)
93+
class TestHasManifestFilesFallback:
94+
"""Exercises the socket_globs fallback path used when the Socket API is unreachable."""
95+
96+
def test_fallback_matches_bun_lock(self, mock_patterns):
97+
core = Core.__new__(Core)
98+
assert core.has_manifest_files(["bun.lock"]) is True
99+
100+
def test_fallback_matches_bun_lockb(self, mock_patterns):
101+
core = Core.__new__(Core)
102+
assert core.has_manifest_files(["bun.lockb"]) is True
103+
104+
def test_fallback_matches_vlt_lock_json(self, mock_patterns):
105+
core = Core.__new__(Core)
106+
assert core.has_manifest_files(["vlt-lock.json"]) is True
107+
108+
def test_fallback_patterns_dict_contains_new_entries(self, mock_patterns):
109+
assert "bun.lock" in socket_globs["npm"]
110+
assert "bun.lockb" in socket_globs["npm"]
111+
assert "vlt-lock.json" in socket_globs["npm"]

0 commit comments

Comments
 (0)