diff --git a/safety/scan/command.py b/safety/scan/command.py index c5543de6..3a8ff88e 100644 --- a/safety/scan/command.py +++ b/safety/scan/command.py @@ -45,7 +45,6 @@ class ScannableEcosystems(Enum): """Enum representing scannable ecosystems.""" PYTHON = Ecosystem.PYTHON.value - def process_report( obj: Any, console: Console, report: ReportModel, output: str, save_as: Optional[Tuple[str, Path]], **kwargs @@ -246,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.") @@ -371,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 @@ -441,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 ) @@ -796,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 9be67c67..a8dd4372 100644 --- a/safety/scan/ecosystems/python/dependencies.py +++ b/safety/scan/ecosystems/python/dependencies.py @@ -2,7 +2,6 @@ from pathlib import Path import sys from typing import Generator, List, Optional - from safety_schemas.models import FileType, PythonDependency from safety_schemas.models.package import PythonSpecification from ..base import InspectableFile @@ -270,7 +269,6 @@ def read_virtual_environment_dependencies(f: InspectableFile) -> Generator[Pytho latest_version_without_known_vulnerabilities=None, more_info_url=None) - def get_dependencies(f: InspectableFile) -> List[PythonDependency]: """ Gets the dependencies for the given inspectable file. @@ -285,10 +283,11 @@ def get_dependencies(f: InspectableFile) -> List[PythonDependency]: return [] if f.file_type in [FileType.REQUIREMENTS_TXT, FileType.POETRY_LOCK, - FileType.PIPENV_LOCK]: + FileType.PIPENV_LOCK, FileType.PYPROJECT_TOML]: return list(read_dependencies(f.file, resolve=True)) if f.file_type == FileType.VIRTUAL_ENVIRONMENT: return list(read_virtual_environment_dependencies(f)) - return [] \ No newline at end of file + + return [] diff --git a/safety/scan/finder/file_finder.py b/safety/scan/finder/file_finder.py index 1aab8400..4765e348 100644 --- a/safety/scan/finder/file_finder.py +++ b/safety/scan/finder/file_finder.py @@ -149,8 +149,10 @@ def process_directory(self, dir_path: str, max_deep: Optional[int] = None) -> Tu files[file_type.value] = set() files[file_type.value].add(inspectable_file) break + level += 1 + return dir_path, files def search(self) -> Tuple[str, Dict[str, Set[Path]]]: diff --git a/safety/scan/finder/handlers.py b/safety/scan/finder/handlers.py index 80a3db6d..0b0672cb 100644 --- a/safety/scan/finder/handlers.py +++ b/safety/scan/finder/handlers.py @@ -2,8 +2,7 @@ import os from pathlib import Path from types import MappingProxyType -from typing import Dict, List, Optional, Optional, Tuple - +from typing import Dict, List, Optional from safety_schemas.models import Ecosystem, FileType @@ -52,7 +51,7 @@ def can_handle(self, root: str, file_name: str, include_files: Dict[FileType, Li return None @abstractmethod - def download_required_assets(self, session) -> Dict[str, str]: + def download_required_assets(self, session): """ Abstract method to download required assets for handling files. Should be implemented by subclasses. @@ -109,12 +108,10 @@ def __init__(self) -> None: super().__init__() self.ecosystem = Ecosystem.SAFETY_PROJECT - def download_required_assets(self, session) -> None: - """ - No required assets to download for Safety project files. - """ + def download_required_assets(self, session): pass + # Mapping of ecosystems to their corresponding file handlers ECOSYSTEM_HANDLER_MAPPING = MappingProxyType({ Ecosystem.PYTHON: PythonFileHandler,