socketsecurity 0.0.76__tar.gz → 0.0.78__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {socketsecurity-0.0.76/socketsecurity.egg-info → socketsecurity-0.0.78}/PKG-INFO +1 -1
  2. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/pyproject.toml +5 -2
  3. socketsecurity-0.0.78/socketsecurity/__init__.py +2 -0
  4. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/core/__init__.py +19 -5
  5. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/core/classes.py +23 -3
  6. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/core/github.py +16 -8
  7. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/core/messages.py +13 -28
  8. {socketsecurity-0.0.76 → socketsecurity-0.0.78/socketsecurity.egg-info}/PKG-INFO +1 -1
  9. socketsecurity-0.0.76/socketsecurity/__init__.py +0 -4
  10. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/LICENSE +0 -0
  11. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/README.md +0 -0
  12. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/setup.cfg +0 -0
  13. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/core/exceptions.py +0 -0
  14. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/core/gitlab.py +0 -0
  15. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/core/issues.py +0 -0
  16. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/core/licenses.py +0 -0
  17. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity/socketcli.py +0 -0
  18. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity.egg-info/SOURCES.txt +0 -0
  19. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity.egg-info/dependency_links.txt +0 -0
  20. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity.egg-info/entry_points.txt +0 -0
  21. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity.egg-info/requires.txt +0 -0
  22. {socketsecurity-0.0.76 → socketsecurity-0.0.78}/socketsecurity.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: socketsecurity
3
- Version: 0.0.76
3
+ Version: 0.0.78
4
4
  Summary: Socket Security CLI for CI/CD
5
5
  Author-email: Douglas Coburn <douglas@socket.dev>
6
6
  Maintainer-email: Douglas Coburn <douglas@socket.dev>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "socketsecurity"
7
- version = "0.0.76"
7
+ dynamic = ["version"]
8
8
  requires-python = ">= 3.9"
9
9
  dependencies = [
10
10
  'requests',
@@ -40,4 +40,7 @@ Homepage = "https://socket.dev"
40
40
  include = [
41
41
  "socketsecurity",
42
42
  "socketsecurity.core"
43
- ]
43
+ ]
44
+
45
+ [tool.setuptools.dynamic]
46
+ version = {attr = "socketsecurity.__version__"}
@@ -0,0 +1,2 @@
1
+ __author__ = 'socket.dev'
2
+ __version__ = '0.0.78'
@@ -6,6 +6,7 @@ import json
6
6
  from socketsecurity.core.exceptions import (
7
7
  APIFailure, APIKeyMissing, APIAccessDenied, APIInsufficientQuota, APIResourceNotFound, APICloudflareError
8
8
  )
9
+ from socketsecurity import __version__
9
10
  from socketsecurity.core.licenses import Licenses
10
11
  from socketsecurity.core.issues import AllIssues
11
12
  from socketsecurity.core.classes import (
@@ -23,9 +24,6 @@ import platform
23
24
  from glob import glob
24
25
  import time
25
26
 
26
-
27
- __author__ = 'socket.dev'
28
- __version__ = '0.0.76'
29
27
  __all__ = [
30
28
  "Core",
31
29
  "log",
@@ -93,6 +91,18 @@ def do_request(
93
91
  files=files,
94
92
  timeout=timeout
95
93
  )
94
+ output_headers = headers
95
+ output_headers['Authorization'] = "Basic API_KEY_REDACTED"
96
+ output = {
97
+ "url": url,
98
+ "headers": output_headers,
99
+ "status_code": response.status_code,
100
+ "body": response.text,
101
+ "payload": payload,
102
+ "files": files,
103
+ "timeout": timeout
104
+ }
105
+ log.debug(output)
96
106
  if response.status_code <= 399:
97
107
  return response
98
108
  elif response.status_code == 400:
@@ -672,7 +682,9 @@ class Core:
672
682
  title=title,
673
683
  suggestion=suggestion,
674
684
  next_step_title=next_step_title,
675
- introduced_by=introduced_by
685
+ introduced_by=introduced_by,
686
+ purl=package.purl,
687
+ url=package.url
676
688
  )
677
689
  if issue_alert.key not in alerts:
678
690
  alerts[issue_alert.key] = [issue_alert]
@@ -732,7 +744,9 @@ class Core:
732
744
  introduced_by=introduced_by,
733
745
  author=package.author or [],
734
746
  size=package.size,
735
- transitives=package.transitives
747
+ transitives=package.transitives,
748
+ url=package.url,
749
+ purl=package.purl
736
750
  )
737
751
  return purl, package
738
752
 
@@ -86,6 +86,7 @@ class Package:
86
86
  transitives: int
87
87
  license: str
88
88
  license_text: str
89
+ purl: str
89
90
 
90
91
  def __init__(self, **kwargs):
91
92
  if kwargs:
@@ -122,6 +123,8 @@ class Package:
122
123
  self.license = "NoLicenseFound"
123
124
  if not hasattr(self, "license_text"):
124
125
  self.license_text = ""
126
+ self.url = f"https://socket.dev/{self.type}/package/{self.name}/overview/{self.version}"
127
+ self.purl = f"{self.type}/{self.name}@{self.version}"
125
128
 
126
129
  def __str__(self):
127
130
  return json.dumps(self.__dict__)
@@ -159,8 +162,6 @@ class Issue:
159
162
  self.introduced_by = []
160
163
  if not hasattr(self, "manifests"):
161
164
  self.manifests = ""
162
- self.url = f"https://socket.dev/{self.pkg_type}/{self.pkg_name}/overview/{self.pkg_version}"
163
- self.purl = f"{self.pkg_type}/{self.pkg_name}@{self.pkg_version}"
164
165
 
165
166
  def __str__(self):
166
167
  return json.dumps(self.__dict__)
@@ -324,12 +325,15 @@ class Purl:
324
325
  version: str
325
326
  ecosystem: str
326
327
  direct: bool
327
- author: str
328
+ author: list
328
329
  size: int
329
330
  transitives: int
330
331
  introduced_by: list
331
332
  capabilities: dict
332
333
  is_new: bool
334
+ author_url: str
335
+ url: str
336
+ purl: str
333
337
 
334
338
  def __init__(self, **kwargs):
335
339
  if kwargs:
@@ -341,6 +345,22 @@ class Purl:
341
345
  self.capabilities = {}
342
346
  if not hasattr(self, "is_new"):
343
347
  self.is_new = False
348
+ self.author_url = Purl.generate_author_data(self.author, self.ecosystem)
349
+
350
+ @staticmethod
351
+ def generate_author_data(authors: list, ecosystem: str) -> str:
352
+ """
353
+ Creates the Author links for the package
354
+ :param authors:
355
+ :param ecosystem:
356
+ :return:
357
+ """
358
+ authors_str = ""
359
+ for author in authors:
360
+ author_url = f"https://socket.dev/{ecosystem}/user/{author}"
361
+ authors += f"[{author}]({author_url}),"
362
+ authors_str = authors_str.rstrip(",")
363
+ return authors_str
344
364
 
345
365
  def __str__(self):
346
366
  return json.dumps(self.__dict__)
@@ -280,15 +280,23 @@ class Github:
280
280
  ignore_all = True
281
281
  else:
282
282
  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)
285
286
  ignore_commands.append(data)
286
287
  return ignore_all, ignore_commands
287
288
 
288
289
  @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:
290
298
  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 == "*"):
292
300
  result = True
293
301
  return result
294
302
 
@@ -317,13 +325,13 @@ class Github:
317
325
  if "start-socket-alerts-table" in line:
318
326
  start = True
319
327
  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("|")
321
329
  details, _ = package.split("](")
322
- ecosystem, details = details.split("/", 1)
330
+ pkg_ecosystem, details = details.strip("[").split("/", 1)
323
331
  pkg_name, pkg_version = details.split("@")
324
332
  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):
327
335
  ignore = True
328
336
  if not ignore:
329
337
  lines.append(line)
@@ -146,9 +146,10 @@ class Messages:
146
146
  if ignore not in ignore_commands:
147
147
  ignore_commands.append(ignore)
148
148
  manifest_str, sources = Messages.create_sources(alert, "console")
149
+ purl_url = f"[{alert.purl}]({alert.url})"
149
150
  row = [
150
151
  alert.title,
151
- alert.url,
152
+ purl_url,
152
153
  ", ".join(sources),
153
154
  manifest_str
154
155
  ]
@@ -219,17 +220,16 @@ class Messages:
219
220
  added: Purl
220
221
  package_url = Messages.create_purl_link(added)
221
222
  capabilities = ", ".join(added.capabilities)
222
- if capabilities is not None and capabilities != "":
223
- row = [
224
- package_url,
225
- added.direct,
226
- capabilities,
227
- added.transitives,
228
- f"{added.size} KB",
229
- Messages.generate_author_data(added)
230
- ]
231
- overview_table.extend(row)
232
- count += 1
223
+ row = [
224
+ package_url,
225
+ added.direct,
226
+ capabilities,
227
+ added.transitives,
228
+ f"{added.size} KB",
229
+ added.author_url
230
+ ]
231
+ overview_table.extend(row)
232
+ count += 1
233
233
  num_of_overview_rows = count + 1
234
234
  md.new_table(
235
235
  columns=num_of_overview_columns,
@@ -239,20 +239,6 @@ class Messages:
239
239
  )
240
240
  return md
241
241
 
242
- @staticmethod
243
- def generate_author_data(package: Purl):
244
- """
245
- Creates the Author links for the Dependency Overview Template
246
- :param package:
247
- :return:
248
- """
249
- authors = ""
250
- for author in package.author:
251
- author_url = f"https://socket.dev/{package.ecosystem}/user/{author}"
252
- authors += f"[{author}]({author_url}),"
253
- authors = authors.rstrip(",")
254
- return authors
255
-
256
242
  @staticmethod
257
243
  def create_purl_link(details: Purl) -> str:
258
244
  """
@@ -260,8 +246,7 @@ class Messages:
260
246
  :param details: Purl - Details about the package needed to create the URLs
261
247
  :return:
262
248
  """
263
- purl = f"{details.ecosystem}/{details.name}@{details.version}"
264
- package_url = f"[{purl}](https://socket.dev/{details.ecosystem}/{details.name}/overview/{details.version})"
249
+ package_url = f"[{details.purl}]({details.url})"
265
250
  return package_url
266
251
 
267
252
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: socketsecurity
3
- Version: 0.0.76
3
+ Version: 0.0.78
4
4
  Summary: Socket Security CLI for CI/CD
5
5
  Author-email: Douglas Coburn <douglas@socket.dev>
6
6
  Maintainer-email: Douglas Coburn <douglas@socket.dev>
@@ -1,4 +0,0 @@
1
- import socketsecurity.core
2
-
3
- __author__ = 'socket.dev'
4
- __version = socketsecurity.core.__version__
File without changes