Skip to content

Commit 26277c1

Browse files
authored
Added fixes for the Github Comment workflow (#5)
1 parent 513b079 commit 26277c1

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

pyproject.toml

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

55
[project]
66
name = "socketsecurity"
7-
version = "0.0.76"
7+
version = "0.0.77"
88
requires-python = ">= 3.9"
99
dependencies = [
1010
'requests',

socketsecurity/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
__author__ = 'socket.dev'
28-
__version__ = '0.0.76'
28+
__version__ = '0.0.77'
2929
__all__ = [
3030
"Core",
3131
"log",

socketsecurity/core/github.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,23 @@ def get_ignore_options(comments: dict) -> [bool, list]:
280280
ignore_all = True
281281
else:
282282
command = command.lstrip("ignore").strip()
283-
name, version = command.split("@")
284-
data = f"{name}, {version}"
283+
name, version = command.rsplit("@", 1)
284+
ecosystem, name = name.split("/", 1)
285+
data = (ecosystem, name, version)
285286
ignore_commands.append(data)
286287
return ignore_all, ignore_commands
287288

288289
@staticmethod
289-
def is_ignore(pkg_name: str, pkg_version: str, name: str, version: str) -> bool:
290+
def is_ignore(
291+
pkg_ecosystem: str,
292+
pkg_name: str,
293+
pkg_version: str,
294+
ecosystem: str,
295+
name: str,
296+
version: str
297+
) -> bool:
290298
result = False
291-
if pkg_name == name and (pkg_version == version or version == "*"):
299+
if pkg_ecosystem == ecosystem and pkg_name == name and (pkg_version == version or version == "*"):
292300
result = True
293301
return result
294302

@@ -317,13 +325,13 @@ def process_security_comment(comment: GithubComment, comments) -> str:
317325
if "start-socket-alerts-table" in line:
318326
start = True
319327
elif start and "end-socket-alerts-table" not in line and not Github.is_heading_line(line) and line != '':
320-
title, package, introduced_by, manifest = line.lstrip("|").rstrip("|").split("|")
328+
title, package, introduced_by, manifest = line.strip("|").split("|")
321329
details, _ = package.split("](")
322-
ecosystem, details = details.split("/", 1)
330+
pkg_ecosystem, details = details.strip("[").split("/", 1)
323331
pkg_name, pkg_version = details.split("@")
324332
ignore = False
325-
for name, version in ignore_commands:
326-
if ignore_all or Github.is_ignore(pkg_name, pkg_version, name, version):
333+
for ecosystem, name, version in ignore_commands:
334+
if ignore_all or Github.is_ignore(pkg_ecosystem, pkg_name, pkg_version, ecosystem, name, version):
327335
ignore = True
328336
if not ignore:
329337
lines.append(line)

socketsecurity/core/messages.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ def create_security_alert_table(diff: Diff, md: MdUtils) -> (MdUtils, list, dict
146146
if ignore not in ignore_commands:
147147
ignore_commands.append(ignore)
148148
manifest_str, sources = Messages.create_sources(alert, "console")
149+
purl_url = f"[{alert.purl}]({alert.url})"
149150
row = [
150151
alert.title,
151-
alert.url,
152+
purl_url,
152153
", ".join(sources),
153154
manifest_str
154155
]

0 commit comments

Comments
 (0)