socketsecurity 1.0.12__tar.gz → 1.0.13__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 (23) hide show
  1. {socketsecurity-1.0.12/socketsecurity.egg-info → socketsecurity-1.0.13}/PKG-INFO +1 -1
  2. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/__init__.py +1 -1
  3. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/__init__.py +49 -46
  4. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/socketcli.py +3 -2
  5. {socketsecurity-1.0.12 → socketsecurity-1.0.13/socketsecurity.egg-info}/PKG-INFO +1 -1
  6. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/LICENSE +0 -0
  7. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/README.md +0 -0
  8. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/pyproject.toml +0 -0
  9. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/setup.cfg +0 -0
  10. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/classes.py +0 -0
  11. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/exceptions.py +0 -0
  12. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/git_interface.py +0 -0
  13. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/github.py +0 -0
  14. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/gitlab.py +0 -0
  15. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/issues.py +0 -0
  16. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/licenses.py +0 -0
  17. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/messages.py +0 -0
  18. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity/core/scm_comments.py +0 -0
  19. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity.egg-info/SOURCES.txt +0 -0
  20. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity.egg-info/dependency_links.txt +0 -0
  21. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity.egg-info/entry_points.txt +0 -0
  22. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity.egg-info/requires.txt +0 -0
  23. {socketsecurity-1.0.12 → socketsecurity-1.0.13}/socketsecurity.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: socketsecurity
3
- Version: 1.0.12
3
+ Version: 1.0.13
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,2 +1,2 @@
1
1
  __author__ = 'socket.dev'
2
- __version__ = '1.0.12'
2
+ __version__ = '1.0.13'
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  from pathlib import PurePath
3
- from packaging.version import Version
3
+
4
4
  import requests
5
5
  from urllib.parse import urlencode
6
6
  import base64
@@ -46,6 +46,8 @@ org_slug = None
46
46
  all_new_alerts = False
47
47
  security_policy = {}
48
48
  log = logging.getLogger("socketdev")
49
+ log_format = "%(asctime)s %(funcName)20s() %(message)s"
50
+ logging.basicConfig(format=log_format)
49
51
  log.addHandler(logging.NullHandler())
50
52
 
51
53
  socket_globs = {
@@ -398,6 +400,8 @@ class Core:
398
400
  """
399
401
  all_files = []
400
402
  files_provided = False
403
+ log.debug("Starting Find Files")
404
+ start_time = time.time()
401
405
  if files is not None and len(files) > 0:
402
406
  files_provided = True
403
407
  for ecosystem in socket_globs:
@@ -405,11 +409,15 @@ class Core:
405
409
  for file_name in patterns:
406
410
  pattern = patterns[file_name]["pattern"]
407
411
  file_path = f"{path}/**/{pattern}"
412
+
408
413
  if not files_provided:
414
+ log.debug(f"Globbing {file_path}")
409
415
  files = glob(file_path, recursive=True)
410
416
  else:
417
+ log.debug("Files found from commit")
411
418
  files = Core.match_supported_files(path, files)
412
419
  for file in files:
420
+ log.debug(f"Checking {file} for match")
413
421
  if platform.system() == "Windows":
414
422
  file = file.replace("\\", "/")
415
423
  if path not in file:
@@ -418,6 +426,10 @@ class Core:
418
426
  details = (found_path, file_name)
419
427
  if details not in all_files:
420
428
  all_files.append(details)
429
+ log.debug("Finished Find Files")
430
+ end_time = time.time()
431
+ total_time = end_time - start_time
432
+ log.info(f"Found {len(all_files)} in {total_time: 2f} seconds")
421
433
  return all_files
422
434
 
423
435
  @staticmethod
@@ -512,9 +524,7 @@ class Core:
512
524
  :return:
513
525
  """
514
526
  if no_change:
515
- diff = Diff()
516
- diff.id = "no_diff_ran"
517
- return diff
527
+ return Diff()
518
528
  files = Core.find_files(path, new_files)
519
529
  if files is None or len(files) == 0:
520
530
  return Diff()
@@ -557,25 +567,20 @@ class Core:
557
567
  new_scan_alerts = {}
558
568
  head_scan_alerts = {}
559
569
  consolidated = []
560
- previous_versions = []
561
- previous_capabilities = {}
562
570
  for package_id in new_packages:
563
571
  purl, package = Core.create_purl(package_id, new_packages)
564
- base_name = f"{purl.ecosystem}/{purl.name}"
565
- base_purl = f"{base_name}@{purl.version}"
572
+ base_purl = f"{purl.ecosystem}/{purl.name}@{purl.version}"
566
573
  if package_id not in head_packages and package.direct and base_purl not in consolidated:
567
574
  diff.new_packages.append(purl)
568
575
  consolidated.append(base_purl)
569
- previous_versions.append(base_name)
570
576
  new_scan_alerts = Core.create_issue_alerts(package, new_scan_alerts, new_packages)
571
577
  for package_id in head_packages:
572
578
  purl, package = Core.create_purl(package_id, head_packages)
573
- base_name = f"{purl.ecosystem}/{purl.name}"
574
- if package_id not in new_packages and package.direct and base_name not in previous_versions:
579
+ if package_id not in new_packages and package.direct:
575
580
  diff.removed_packages.append(purl)
576
581
  head_scan_alerts = Core.create_issue_alerts(package, head_scan_alerts, head_packages)
577
582
  diff.new_alerts = Core.compare_issue_alerts(new_scan_alerts, head_scan_alerts, diff.new_alerts)
578
- diff.new_capabilities = Core.check_alert_capabilities(new_packages, head_packages)
583
+ diff.new_capabilities = Core.compare_capabilities(new_packages, head_packages)
579
584
  diff = Core.add_capabilities_to_purl(diff)
580
585
  return diff
581
586
 
@@ -595,50 +600,48 @@ class Core:
595
600
  return diff
596
601
 
597
602
  @staticmethod
598
- def check_alert_capabilities(
599
- new_packages: dict,
600
- old_packages: dict
601
- ) -> dict:
603
+ def compare_capabilities(new_packages: dict, head_packages: dict) -> dict:
602
604
  capabilities = {}
603
- capabilities_details = {}
604
- capabilities_details = Core.compare_version_capabilities(old_packages, capabilities_details)
605
- capabilities_details = Core.compare_version_capabilities(new_packages, capabilities_details)
606
- for base_name in capabilities_details:
607
- data = capabilities_details[base_name]
608
- package_id = data["package_id"]
609
- package_capabilities = data["capabilities"]
610
- if len(package_capabilities) > 0:
611
- capabilities[package_id] = package_capabilities
605
+ for package_id in new_packages:
606
+ package: Package
607
+ head_package: Package
608
+ package = new_packages[package_id]
609
+ if package_id in head_packages:
610
+ head_package = head_packages[package_id]
611
+ for alert in package.alerts:
612
+ if alert not in head_package.alerts:
613
+ capabilities = Core.check_alert_capabilities(package, capabilities, package_id, head_package)
614
+ else:
615
+ capabilities = Core.check_alert_capabilities(package, capabilities, package_id)
616
+
612
617
  return capabilities
613
618
 
614
619
  @staticmethod
615
- def compare_version_capabilities(packages: dict, capabilities_details: dict) -> dict:
620
+ def check_alert_capabilities(
621
+ package: Package,
622
+ capabilities: dict,
623
+ package_id: str,
624
+ head_package: Package = None
625
+ ) -> dict:
616
626
  alert_types = {
617
627
  "envVars": "Environment",
618
628
  "networkAccess": "Network",
619
629
  "filesystemAccess": "File System",
620
630
  "shellAccess": "Shell"
621
631
  }
622
- for package_id in packages:
623
- package: Package
624
- package = packages[package_id]
625
- base_name = f"{package.type}/{package.name}"
626
- if base_name not in capabilities_details:
627
- capabilities_details[base_name] = {
628
- "last_version": package.version,
629
- "package_id": package.id,
630
- "capabilities": []
631
- }
632
- new_version = Version(package.version)
633
- last_version = Version(capabilities_details[base_name]["last_version"])
634
- previous_capabilities = capabilities_details[base_name]["capabilities"]
635
- if new_version > last_version:
636
- capabilities_details[base_name]["last_version"] = package.version
637
- for alert in package.alerts:
638
- value = alert_types[alert["type"]]
639
- if value not in previous_capabilities or len(previous_capabilities) == 0:
640
- capabilities_details[base_name]["capabilities"].append(value)
641
- return capabilities_details
632
+
633
+ for alert in package.alerts:
634
+ new_alert = True
635
+ if head_package is not None and alert in head_package.alerts:
636
+ new_alert = False
637
+ if alert["type"] in alert_types and new_alert:
638
+ value = alert_types[alert["type"]]
639
+ if package_id not in capabilities:
640
+ capabilities[package_id] = [value]
641
+ else:
642
+ if value not in capabilities[package_id]:
643
+ capabilities[package_id].append(value)
644
+ return capabilities
642
645
 
643
646
  @staticmethod
644
647
  def compare_issue_alerts(new_scan_alerts: dict, head_scan_alerts: dict, alerts: list) -> list:
@@ -211,7 +211,8 @@ def main_code():
211
211
  arguments = parser.parse_args()
212
212
  debug = arguments.enable_debug
213
213
  if debug:
214
- logging.basicConfig(level=logging.DEBUG)
214
+ log_format = "%(asctime)s %(funcName)20s() %(message)s"
215
+ logging.basicConfig(level=logging.DEBUG, format=log_format)
215
216
  log.setLevel(logging.DEBUG)
216
217
  Core.enable_debug_log(logging.DEBUG)
217
218
  log.debug("Debug logging enabled")
@@ -287,7 +288,7 @@ def main_code():
287
288
  default_branch = scm.is_default_branch
288
289
 
289
290
  base_api_url = os.getenv("BASE_API_URL") or None
290
- core = Core(token=api_token, request_timeout=6000, base_api_url=base_api_url)
291
+ core = Core(token=api_token, request_timeout=1200, base_api_url=base_api_url)
291
292
  no_change = True
292
293
  if ignore_commit_files:
293
294
  no_change = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: socketsecurity
3
- Version: 1.0.12
3
+ Version: 1.0.13
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>
File without changes