Skip to content

Commit 43a9c2e

Browse files
authored
Revert commits (#87)
* Revert "Fixed logic for removed dependencies triggering dependency overview and fixed regex expander" This reverts commit 73e1ce2. * Revert "Added helper function for converting gfm output" This reverts commit e039fb7.
1 parent 73e1ce2 commit 43a9c2e

File tree

8 files changed

+36
-175
lines changed

8 files changed

+36
-175
lines changed

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.1.5"
9+
version = "2.1.3"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.1.5'
2+
__version__ = '2.1.3'

socketsecurity/core/__init__.py

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -133,40 +133,25 @@ def create_sbom_output(self, diff: Diff) -> dict:
133133
@staticmethod
134134
def expand_brace_pattern(pattern: str) -> List[str]:
135135
"""
136-
Recursively expands brace expressions (e.g., {a,b,c}) into separate patterns, supporting nested braces.
137-
"""
138-
def recursive_expand(pat: str) -> List[str]:
139-
stack = []
140-
for i, c in enumerate(pat):
141-
if c == '{':
142-
stack.append(i)
143-
elif c == '}' and stack:
144-
start = stack.pop()
145-
if not stack:
146-
# Found the outermost pair
147-
before = pat[:start]
148-
after = pat[i+1:]
149-
inner = pat[start+1:i]
150-
# Split on commas not inside nested braces
151-
options = []
152-
depth = 0
153-
last = 0
154-
for j, ch in enumerate(inner):
155-
if ch == '{':
156-
depth += 1
157-
elif ch == '}':
158-
depth -= 1
159-
elif ch == ',' and depth == 0:
160-
options.append(inner[last:j])
161-
last = j+1
162-
options.append(inner[last:])
163-
results = []
164-
for opt in options:
165-
expanded = before + opt + after
166-
results.extend(recursive_expand(expanded))
167-
return results
168-
return [pat]
169-
return recursive_expand(pattern)
136+
Expands brace expressions (e.g., {a,b,c}) into separate patterns.
137+
"""
138+
brace_regex = re.compile(r"\{([^{}]+)\}")
139+
140+
# Expand all brace groups
141+
expanded_patterns = [pattern]
142+
while any("{" in p for p in expanded_patterns):
143+
new_patterns = []
144+
for pat in expanded_patterns:
145+
match = brace_regex.search(pat)
146+
if match:
147+
options = match.group(1).split(",") # Extract values inside {}
148+
prefix, suffix = pat[:match.start()], pat[match.end():]
149+
new_patterns.extend([prefix + opt + suffix for opt in options])
150+
else:
151+
new_patterns.append(pat)
152+
expanded_patterns = new_patterns
153+
154+
return expanded_patterns
170155

171156
@staticmethod
172157
def is_excluded(file_path: str, excluded_dirs: Set[str]) -> bool:
@@ -191,7 +176,13 @@ def find_files(self, path: str) -> List[str]:
191176
files: Set[str] = set()
192177

193178
# Get supported patterns from the API
194-
patterns = self.get_supported_patterns()
179+
try:
180+
patterns = self.get_supported_patterns()
181+
except Exception as e:
182+
log.error(f"Error getting supported patterns from API: {e}")
183+
log.warning("Falling back to local patterns")
184+
from .utils import socket_globs as fallback_patterns
185+
patterns = fallback_patterns
195186

196187
for ecosystem in patterns:
197188
if ecosystem in self.config.excluded_ecosystems:

socketsecurity/core/classes.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class AlertCounts(TypedDict):
9797
low: int
9898

9999
@dataclass(kw_only=True)
100-
class Package():
100+
class Package(SocketArtifactLink):
101101
"""
102102
Represents a package detected in a Socket Security scan.
103103
@@ -106,23 +106,16 @@ class Package():
106106
"""
107107

108108
# Common properties from both artifact types
109-
type: str
109+
id: str
110110
name: str
111111
version: str
112-
release: str
113-
diffType: str
114-
id: str
115-
author: List[str] = field(default_factory=list)
112+
type: str
116113
score: SocketScore
117114
alerts: List[SocketAlert]
115+
author: List[str] = field(default_factory=list)
118116
size: Optional[int] = None
119117
license: Optional[str] = None
120118
namespace: Optional[str] = None
121-
topLevelAncestors: Optional[List[str]] = None
122-
direct: Optional[bool] = False
123-
manifestFiles: Optional[List[SocketManifestReference]] = None
124-
dependencies: Optional[List[str]] = None
125-
artifact: Optional[SocketArtifactLink] = None
126119

127120
# Package-specific fields
128121
license_text: str = ""
@@ -210,9 +203,7 @@ def from_diff_artifact(cls, data: dict) -> "Package":
210203
manifestFiles=ref.get("manifestFiles", []),
211204
dependencies=ref.get("dependencies"),
212205
artifact=ref.get("artifact"),
213-
namespace=data.get('namespace', None),
214-
release=ref.get("release", None),
215-
diffType=ref.get("diffType", None),
206+
namespace=data.get('namespace', None)
216207
)
217208

218209
class Issue:

socketsecurity/core/helper/__init__.py

Lines changed: 0 additions & 119 deletions
This file was deleted.

socketsecurity/core/messages.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ def create_security_comment_json(diff: Diff) -> dict:
292292
output = {
293293
"scan_failed": scan_failed,
294294
"new_alerts": [],
295-
"full_scan_id": diff.id,
296-
"diff_url": diff.diff_url
295+
"full_scan_id": diff.id
297296
}
298297
for alert in diff.new_alerts:
299298
alert: Issue

socketsecurity/output.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ def output_console_comments(self, diff_report: Diff, sbom_file_name: Optional[st
6666

6767
console_security_comment = Messages.create_console_security_alert_table(diff_report)
6868
self.logger.info("Security issues detected by Socket Security:")
69-
self.logger.info(f"Diff Url: {diff_report.diff_url}")
70-
self.logger.info(f"\n{console_security_comment}")
69+
self.logger.info(console_security_comment)
7170

7271
def output_console_json(self, diff_report: Diff, sbom_file_name: Optional[str] = None) -> None:
7372
"""Outputs JSON formatted results"""

socketsecurity/socketcli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def main_code():
235235
log.debug("Updated security comment with no new alerts")
236236

237237
# FIXME: diff.new_packages is never populated, neither is removed_packages
238-
if (len(diff.new_packages) == 0) or config.disable_overview:
238+
if (len(diff.new_packages) == 0 and len(diff.removed_packages) == 0) or config.disable_overview:
239239
if not update_old_overview_comment:
240240
new_overview_comment = False
241241
log.debug("No new/removed packages or Dependency Overview comment disabled")

0 commit comments

Comments
 (0)