socketsecurity 1.0.7__tar.gz → 1.0.8__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.7/socketsecurity.egg-info → socketsecurity-1.0.8}/PKG-INFO +1 -1
  2. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/__init__.py +1 -1
  3. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/__init__.py +46 -37
  4. {socketsecurity-1.0.7 → socketsecurity-1.0.8/socketsecurity.egg-info}/PKG-INFO +1 -1
  5. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/LICENSE +0 -0
  6. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/README.md +0 -0
  7. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/pyproject.toml +0 -0
  8. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/setup.cfg +0 -0
  9. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/classes.py +0 -0
  10. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/exceptions.py +0 -0
  11. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/git_interface.py +0 -0
  12. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/github.py +0 -0
  13. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/gitlab.py +0 -0
  14. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/issues.py +0 -0
  15. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/licenses.py +0 -0
  16. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/messages.py +0 -0
  17. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/core/scm_comments.py +0 -0
  18. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity/socketcli.py +0 -0
  19. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity.egg-info/SOURCES.txt +0 -0
  20. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity.egg-info/dependency_links.txt +0 -0
  21. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity.egg-info/entry_points.txt +0 -0
  22. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/socketsecurity.egg-info/requires.txt +0 -0
  23. {socketsecurity-1.0.7 → socketsecurity-1.0.8}/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.7
3
+ Version: 1.0.8
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.7'
2
+ __version__ = '1.0.8'
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  from pathlib import PurePath
3
-
3
+ from semver.version import Version
4
4
  import requests
5
5
  from urllib.parse import urlencode
6
6
  import base64
@@ -512,7 +512,9 @@ class Core:
512
512
  :return:
513
513
  """
514
514
  if no_change:
515
- return Diff()
515
+ diff = Diff()
516
+ diff.id = "no_diff_ran"
517
+ return diff
516
518
  files = Core.find_files(path, new_files)
517
519
  if files is None or len(files) == 0:
518
520
  return Diff()
@@ -555,20 +557,25 @@ class Core:
555
557
  new_scan_alerts = {}
556
558
  head_scan_alerts = {}
557
559
  consolidated = []
560
+ previous_versions = []
561
+ previous_capabilities = {}
558
562
  for package_id in new_packages:
559
563
  purl, package = Core.create_purl(package_id, new_packages)
560
- base_purl = f"{purl.ecosystem}/{purl.name}@{purl.version}"
564
+ base_name = f"{purl.ecosystem}/{purl.name}"
565
+ base_purl = f"{base_name}@{purl.version}"
561
566
  if package_id not in head_packages and package.direct and base_purl not in consolidated:
562
567
  diff.new_packages.append(purl)
563
568
  consolidated.append(base_purl)
569
+ previous_versions.append(base_name)
564
570
  new_scan_alerts = Core.create_issue_alerts(package, new_scan_alerts, new_packages)
565
571
  for package_id in head_packages:
566
572
  purl, package = Core.create_purl(package_id, head_packages)
567
- if package_id not in new_packages and package.direct:
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:
568
575
  diff.removed_packages.append(purl)
569
576
  head_scan_alerts = Core.create_issue_alerts(package, head_scan_alerts, head_packages)
570
577
  diff.new_alerts = Core.compare_issue_alerts(new_scan_alerts, head_scan_alerts, diff.new_alerts)
571
- diff.new_capabilities = Core.compare_capabilities(new_packages, head_packages)
578
+ diff.new_capabilities = Core.check_alert_capabilities(new_packages, head_packages)
572
579
  diff = Core.add_capabilities_to_purl(diff)
573
580
  return diff
574
581
 
@@ -588,48 +595,50 @@ class Core:
588
595
  return diff
589
596
 
590
597
  @staticmethod
591
- def compare_capabilities(new_packages: dict, head_packages: dict) -> dict:
598
+ def check_alert_capabilities(
599
+ new_packages: dict,
600
+ old_packages: dict
601
+ ) -> dict:
592
602
  capabilities = {}
593
- for package_id in new_packages:
594
- package: Package
595
- head_package: Package
596
- package = new_packages[package_id]
597
- if package_id in head_packages:
598
- head_package = head_packages[package_id]
599
- for alert in package.alerts:
600
- if alert not in head_package.alerts:
601
- capabilities = Core.check_alert_capabilities(package, capabilities, package_id, head_package)
602
- else:
603
- capabilities = Core.check_alert_capabilities(package, capabilities, package_id)
604
-
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
612
  return capabilities
606
613
 
607
614
  @staticmethod
608
- def check_alert_capabilities(
609
- package: Package,
610
- capabilities: dict,
611
- package_id: str,
612
- head_package: Package = None
613
- ) -> dict:
615
+ def compare_version_capabilities(packages: dict, capabilities_details: dict) -> dict:
614
616
  alert_types = {
615
617
  "envVars": "Environment",
616
618
  "networkAccess": "Network",
617
619
  "filesystemAccess": "File System",
618
620
  "shellAccess": "Shell"
619
621
  }
620
-
621
- for alert in package.alerts:
622
- new_alert = True
623
- if head_package is not None and alert in head_package.alerts:
624
- new_alert = False
625
- if alert["type"] in alert_types and new_alert:
626
- value = alert_types[alert["type"]]
627
- if package_id not in capabilities:
628
- capabilities[package_id] = [value]
629
- else:
630
- if value not in capabilities[package_id]:
631
- capabilities[package_id].append(value)
632
- return capabilities
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.parse(package.version)
633
+ last_version = Version.parse(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
633
642
 
634
643
  @staticmethod
635
644
  def compare_issue_alerts(new_scan_alerts: dict, head_scan_alerts: dict, alerts: list) -> list:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: socketsecurity
3
- Version: 1.0.7
3
+ Version: 1.0.8
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
File without changes
File without changes