This commit is contained in:
Iliyan Angelov
2025-12-01 06:50:10 +02:00
parent 91f51bc6fe
commit 62c1fe5951
4682 changed files with 544807 additions and 31208 deletions

View File

@@ -0,0 +1,58 @@
from abc import ABC, abstractmethod
from typing import List
from safety_schemas.models import Ecosystem, FileType, ConfigModel, DependencyResultModel
from typer import FileTextWrite
NOT_IMPLEMENTED = "Not implemented funtion"
class Inspectable(ABC):
"""
Abstract base class defining the interface for objects that can be inspected for dependencies.
"""
@abstractmethod
def inspect(self, config: ConfigModel) -> DependencyResultModel:
"""
Inspects the object and returns the result of the dependency analysis.
Args:
config (ConfigModel): The configuration model for inspection.
Returns:
DependencyResultModel: The result of the dependency inspection.
"""
return NotImplementedError(NOT_IMPLEMENTED)
class Remediable(ABC):
"""
Abstract base class defining the interface for objects that can be remediated.
"""
@abstractmethod
def remediate(self):
"""
Remediates the object to address any detected issues.
"""
return NotImplementedError(NOT_IMPLEMENTED)
class InspectableFile(Inspectable):
"""
Represents an inspectable file within a specific ecosystem and file type.
"""
def __init__(self, file: FileTextWrite):
"""
Initializes an InspectableFile instance.
Args:
file (FileTextWrite): The file to be inspected.
"""
self.file = file
self.ecosystem: Ecosystem
self.file_type: FileType
self.dependency_results: DependencyResultModel = \
DependencyResultModel(dependencies=[])