From 0544d7c4588edf9eb3cb1842935647b242f7bff4 Mon Sep 17 00:00:00 2001 From: Dylan Pulver Date: Thu, 24 Oct 2024 08:58:17 -0400 Subject: [PATCH] fix/clean-code --- safety/scan/command.py | 26 +++++++++---------- safety/scan/ecosystems/python/dependencies.py | 5 ---- safety/scan/finder/file_finder.py | 1 - 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/safety/scan/command.py b/safety/scan/command.py index 8e39ad8..3a8ff88 100644 --- a/safety/scan/command.py +++ b/safety/scan/command.py @@ -245,7 +245,7 @@ def scan(ctx: typer.Context, """ Scans a project (defaulted to the current directory) for supply-chain security and configuration issues """ - + if not ctx.obj.metadata.authenticated: raise SafetyError("Authentication required. Please run 'safety auth login' to authenticate before using this command.") @@ -313,8 +313,6 @@ def scan(ctx: typer.Context, with console.status(wait_msg, spinner=DEFAULT_SPINNER) as status: for path, analyzed_file in process_files(paths=file_paths, config=config): - print("now here", analyzed_file.dependency_results.dependencies) - print("now here", analyzed_file.file_type) count += len(analyzed_file.dependency_results.dependencies) # Update exit code if vulnerabilities are found @@ -372,7 +370,7 @@ def sort_vulns_by_score(vuln: Vulnerability) -> int: detailed_output=detailed_output) lines = [] - + if spec.remediation.recommended: total_resolved_vulns += spec.remediation.vulnerabilities_found @@ -442,18 +440,18 @@ def sort_vulns_by_score(vuln: Vulnerability) -> int: telemetry=telemetry, files=[], projects=[ctx.obj.project]) - + total_issues_with_duplicates, total_ignored_issues = get_vulnerability_summary(report.as_v30()) - + print_summary( - console=console, - total_issues_with_duplicates=total_issues_with_duplicates, + console=console, + total_issues_with_duplicates=total_issues_with_duplicates, total_ignored_issues=total_ignored_issues, - project=ctx.obj.project, - dependencies_count=count, - fixes_count=fixes_count, - resolved_vulns_per_fix=total_resolved_vulns, - is_detailed_output=detailed_output, + project=ctx.obj.project, + dependencies_count=count, + fixes_count=fixes_count, + resolved_vulns_per_fix=total_resolved_vulns, + is_detailed_output=detailed_output, ignored_vulns_data=ignored_vulns_data ) @@ -797,7 +795,7 @@ def get_vulnerability_summary(report: Dict[str, Any]) -> Tuple[int, int]: Args: report (ReportModel): The report containing vulnerability data. - + Returns: Tuple[int, int]: A tuple containing: - Total number of issues (including duplicates) diff --git a/safety/scan/ecosystems/python/dependencies.py b/safety/scan/ecosystems/python/dependencies.py index c07d386..005f846 100644 --- a/safety/scan/ecosystems/python/dependencies.py +++ b/safety/scan/ecosystems/python/dependencies.py @@ -272,7 +272,6 @@ def read_virtual_environment_dependencies(f: InspectableFile) -> Generator[Pytho def read_pyproject_toml_dependencies(file: Path) -> Generator[PythonDependency, None, None]: data = toml.load(file) - print(data) dependencies = [] # Handle 'build-system.requires' @@ -304,12 +303,8 @@ def read_pyproject_toml_dependencies(file: Path) -> Generator[PythonDependency, else: dependencies.append(dep) - print("dependencies") - print(dependencies) for dep in dependencies: dep_name, dep_version = (dep.split("==") + [None])[:2] - print(dep_name) - print(dep_version) yield PythonDependency( name=dep_name, version=dep_version, diff --git a/safety/scan/finder/file_finder.py b/safety/scan/finder/file_finder.py index 4c7282b..c328475 100644 --- a/safety/scan/finder/file_finder.py +++ b/safety/scan/finder/file_finder.py @@ -75,7 +75,6 @@ def __init__( self.target = target self.include_files = include_files - print("include_files", include_files) # If no handlers are provided, initialize them from the ecosystem mapping if not handlers: handlers = set(ECOSYSTEM_HANDLER_MAPPING[ecosystem]()