File size: 1,197 Bytes
92c4ae6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import enum
from pathlib import Path
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
class Severity(str, enum.Enum):
CRITICAL = "CRITICAL"
HIGH = "HIGH"
MEDIUM = "MEDIUM"
LOW = "LOW"
INFO = "INFO"
class Finding(BaseModel):
"""
Represents a single security finding detected by an analyzer.
"""
rule_id: str
category: str
severity: Severity
file_path: str
line_number: int
line_content: Optional[str] = None
description: str
remediation: Optional[str] = None
metadata: Dict[str, Any] = Field(default_factory=dict)
class ScanResult(BaseModel):
"""
Results from scanning a single skill or directory.
"""
is_safe: bool
max_severity: Severity
findings: List[Finding]
scan_duration: float
files_scanned: int
analyzers_run: List[str]
class SecurityRule(BaseModel):
"""
Definition of a security rule for pattern matching.
"""
id: str
category: str
severity: Severity
patterns: List[str]
exclude_patterns: List[str] = Field(default_factory=list)
file_types: List[str]
description: str
remediation: Optional[str] = None
|