socketsecurity 1.0.12__tar.gz → 1.0.14__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.
- {socketsecurity-1.0.12/socketsecurity.egg-info → socketsecurity-1.0.14}/PKG-INFO +1 -1
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/__init__.py +1 -1
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/__init__.py +60 -48
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/socketcli.py +7 -3
- {socketsecurity-1.0.12 → socketsecurity-1.0.14/socketsecurity.egg-info}/PKG-INFO +1 -1
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/LICENSE +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/README.md +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/pyproject.toml +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/setup.cfg +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/classes.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/exceptions.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/git_interface.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/github.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/gitlab.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/issues.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/licenses.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/messages.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity/core/scm_comments.py +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity.egg-info/SOURCES.txt +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity.egg-info/dependency_links.txt +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity.egg-info/entry_points.txt +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity.egg-info/requires.txt +0 -0
- {socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity.egg-info/top_level.txt +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
__author__ = 'socket.dev'
|
|
2
|
-
__version__ = '1.0.
|
|
2
|
+
__version__ = '1.0.14'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from pathlib import PurePath
|
|
3
|
-
|
|
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 = {
|
|
@@ -396,8 +398,10 @@ class Core:
|
|
|
396
398
|
:param files: override finding the manifest files using the glob matcher
|
|
397
399
|
:return:
|
|
398
400
|
"""
|
|
399
|
-
all_files =
|
|
401
|
+
all_files = set()
|
|
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,20 @@ 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}")
|
|
415
|
+
glob_start = time.time()
|
|
409
416
|
files = glob(file_path, recursive=True)
|
|
417
|
+
glob_end = time.time()
|
|
418
|
+
glob_total_time = glob_end - glob_start
|
|
419
|
+
log.debug(f"Glob for pattern {file_path} took {glob_total_time:.2f} seconds")
|
|
410
420
|
else:
|
|
421
|
+
log.debug("Files found from commit")
|
|
411
422
|
files = Core.match_supported_files(path, files)
|
|
423
|
+
name_fix_start = time.time()
|
|
412
424
|
for file in files:
|
|
425
|
+
# log.debug(f"Getting file and path for {file_path}")
|
|
413
426
|
if platform.system() == "Windows":
|
|
414
427
|
file = file.replace("\\", "/")
|
|
415
428
|
if path not in file:
|
|
@@ -417,7 +430,15 @@ class Core:
|
|
|
417
430
|
found_path, file_name = file.rsplit("/", 1)
|
|
418
431
|
details = (found_path, file_name)
|
|
419
432
|
if details not in all_files:
|
|
420
|
-
all_files.
|
|
433
|
+
all_files.add(details)
|
|
434
|
+
name_fix_end = time.time()
|
|
435
|
+
total_name_fix = name_fix_end - name_fix_start
|
|
436
|
+
log.debug(f"Total Time for name fix for {file_path} was {total_name_fix:.6f}")
|
|
437
|
+
log.debug("Finished Find Files")
|
|
438
|
+
end_time = time.time()
|
|
439
|
+
total_time = end_time - start_time
|
|
440
|
+
log.info(f"Found {len(all_files)} in {total_time:.2f} seconds")
|
|
441
|
+
all_files = list(all_files)
|
|
421
442
|
return all_files
|
|
422
443
|
|
|
423
444
|
@staticmethod
|
|
@@ -512,9 +533,7 @@ class Core:
|
|
|
512
533
|
:return:
|
|
513
534
|
"""
|
|
514
535
|
if no_change:
|
|
515
|
-
|
|
516
|
-
diff.id = "no_diff_ran"
|
|
517
|
-
return diff
|
|
536
|
+
return Diff()
|
|
518
537
|
files = Core.find_files(path, new_files)
|
|
519
538
|
if files is None or len(files) == 0:
|
|
520
539
|
return Diff()
|
|
@@ -557,25 +576,20 @@ class Core:
|
|
|
557
576
|
new_scan_alerts = {}
|
|
558
577
|
head_scan_alerts = {}
|
|
559
578
|
consolidated = []
|
|
560
|
-
previous_versions = []
|
|
561
|
-
previous_capabilities = {}
|
|
562
579
|
for package_id in new_packages:
|
|
563
580
|
purl, package = Core.create_purl(package_id, new_packages)
|
|
564
|
-
|
|
565
|
-
base_purl = f"{base_name}@{purl.version}"
|
|
581
|
+
base_purl = f"{purl.ecosystem}/{purl.name}@{purl.version}"
|
|
566
582
|
if package_id not in head_packages and package.direct and base_purl not in consolidated:
|
|
567
583
|
diff.new_packages.append(purl)
|
|
568
584
|
consolidated.append(base_purl)
|
|
569
|
-
previous_versions.append(base_name)
|
|
570
585
|
new_scan_alerts = Core.create_issue_alerts(package, new_scan_alerts, new_packages)
|
|
571
586
|
for package_id in head_packages:
|
|
572
587
|
purl, package = Core.create_purl(package_id, head_packages)
|
|
573
|
-
|
|
574
|
-
if package_id not in new_packages and package.direct and base_name not in previous_versions:
|
|
588
|
+
if package_id not in new_packages and package.direct:
|
|
575
589
|
diff.removed_packages.append(purl)
|
|
576
590
|
head_scan_alerts = Core.create_issue_alerts(package, head_scan_alerts, head_packages)
|
|
577
591
|
diff.new_alerts = Core.compare_issue_alerts(new_scan_alerts, head_scan_alerts, diff.new_alerts)
|
|
578
|
-
diff.new_capabilities = Core.
|
|
592
|
+
diff.new_capabilities = Core.compare_capabilities(new_packages, head_packages)
|
|
579
593
|
diff = Core.add_capabilities_to_purl(diff)
|
|
580
594
|
return diff
|
|
581
595
|
|
|
@@ -595,50 +609,48 @@ class Core:
|
|
|
595
609
|
return diff
|
|
596
610
|
|
|
597
611
|
@staticmethod
|
|
598
|
-
def
|
|
599
|
-
new_packages: dict,
|
|
600
|
-
old_packages: dict
|
|
601
|
-
) -> dict:
|
|
612
|
+
def compare_capabilities(new_packages: dict, head_packages: dict) -> dict:
|
|
602
613
|
capabilities = {}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
614
|
+
for package_id in new_packages:
|
|
615
|
+
package: Package
|
|
616
|
+
head_package: Package
|
|
617
|
+
package = new_packages[package_id]
|
|
618
|
+
if package_id in head_packages:
|
|
619
|
+
head_package = head_packages[package_id]
|
|
620
|
+
for alert in package.alerts:
|
|
621
|
+
if alert not in head_package.alerts:
|
|
622
|
+
capabilities = Core.check_alert_capabilities(package, capabilities, package_id, head_package)
|
|
623
|
+
else:
|
|
624
|
+
capabilities = Core.check_alert_capabilities(package, capabilities, package_id)
|
|
625
|
+
|
|
612
626
|
return capabilities
|
|
613
627
|
|
|
614
628
|
@staticmethod
|
|
615
|
-
def
|
|
629
|
+
def check_alert_capabilities(
|
|
630
|
+
package: Package,
|
|
631
|
+
capabilities: dict,
|
|
632
|
+
package_id: str,
|
|
633
|
+
head_package: Package = None
|
|
634
|
+
) -> dict:
|
|
616
635
|
alert_types = {
|
|
617
636
|
"envVars": "Environment",
|
|
618
637
|
"networkAccess": "Network",
|
|
619
638
|
"filesystemAccess": "File System",
|
|
620
639
|
"shellAccess": "Shell"
|
|
621
640
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
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
|
|
641
|
+
|
|
642
|
+
for alert in package.alerts:
|
|
643
|
+
new_alert = True
|
|
644
|
+
if head_package is not None and alert in head_package.alerts:
|
|
645
|
+
new_alert = False
|
|
646
|
+
if alert["type"] in alert_types and new_alert:
|
|
647
|
+
value = alert_types[alert["type"]]
|
|
648
|
+
if package_id not in capabilities:
|
|
649
|
+
capabilities[package_id] = [value]
|
|
650
|
+
else:
|
|
651
|
+
if value not in capabilities[package_id]:
|
|
652
|
+
capabilities[package_id].append(value)
|
|
653
|
+
return capabilities
|
|
642
654
|
|
|
643
655
|
@staticmethod
|
|
644
656
|
def compare_issue_alerts(new_scan_alerts: dict, head_scan_alerts: dict, alerts: list) -> list:
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import json
|
|
3
|
+
|
|
4
|
+
import socketsecurity.core
|
|
3
5
|
from socketsecurity.core import Core, __version__
|
|
4
6
|
from socketsecurity.core.classes import FullScanParams, Diff, Package, Issue
|
|
5
7
|
from socketsecurity.core.messages import Messages
|
|
@@ -10,7 +12,9 @@ import os
|
|
|
10
12
|
import sys
|
|
11
13
|
import logging
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
log_format = "%(asctime)s: %(message)s"
|
|
16
|
+
logging.basicConfig(level=logging.INFO, format=log_format)
|
|
17
|
+
socketsecurity.core.log.setLevel(level=logging.INFO)
|
|
14
18
|
log = logging.getLogger("socketcli")
|
|
15
19
|
blocking_disabled = False
|
|
16
20
|
|
|
@@ -211,7 +215,7 @@ def main_code():
|
|
|
211
215
|
arguments = parser.parse_args()
|
|
212
216
|
debug = arguments.enable_debug
|
|
213
217
|
if debug:
|
|
214
|
-
logging.basicConfig(level=logging.DEBUG)
|
|
218
|
+
logging.basicConfig(level=logging.DEBUG, format=log_format)
|
|
215
219
|
log.setLevel(logging.DEBUG)
|
|
216
220
|
Core.enable_debug_log(logging.DEBUG)
|
|
217
221
|
log.debug("Debug logging enabled")
|
|
@@ -287,7 +291,7 @@ def main_code():
|
|
|
287
291
|
default_branch = scm.is_default_branch
|
|
288
292
|
|
|
289
293
|
base_api_url = os.getenv("BASE_API_URL") or None
|
|
290
|
-
core = Core(token=api_token, request_timeout=
|
|
294
|
+
core = Core(token=api_token, request_timeout=1200, base_api_url=base_api_url)
|
|
291
295
|
no_change = True
|
|
292
296
|
if ignore_commit_files:
|
|
293
297
|
no_change = False
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{socketsecurity-1.0.12 → socketsecurity-1.0.14}/socketsecurity.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|