flutter-security-analyzer 1.0.1__py3-none-any.whl
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.
- flutter_security_analyzer/__init__.py +12 -0
- flutter_security_analyzer/__main__.py +8 -0
- flutter_security_analyzer/core/__init__.py +15 -0
- flutter_security_analyzer/core/config.py +128 -0
- flutter_security_analyzer/core/scanner.py +543 -0
- flutter_security_analyzer/main.py +150 -0
- flutter_security_analyzer/mappers/__init__.py +9 -0
- flutter_security_analyzer/mappers/masvs_mapper.py +308 -0
- flutter_security_analyzer/patterns/__init__.py +32 -0
- flutter_security_analyzer/patterns/auth_patterns.py +95 -0
- flutter_security_analyzer/patterns/base_pattern.py +514 -0
- flutter_security_analyzer/patterns/code_patterns.py +103 -0
- flutter_security_analyzer/patterns/crypto_patterns.py +78 -0
- flutter_security_analyzer/patterns/network_patterns.py +61 -0
- flutter_security_analyzer/patterns/pattern_registry.py +164 -0
- flutter_security_analyzer/patterns/platform_patterns.py +97 -0
- flutter_security_analyzer/patterns/privacy_patterns.py +64 -0
- flutter_security_analyzer/patterns/resilience_patterns.py +68 -0
- flutter_security_analyzer/patterns/storage_patterns.py +111 -0
- flutter_security_analyzer/reporters/__init__.py +11 -0
- flutter_security_analyzer/reporters/console_reporter.py +165 -0
- flutter_security_analyzer/reporters/html_reporter.py +230 -0
- flutter_security_analyzer/reporters/json_reporter.py +107 -0
- flutter_security_analyzer/utils/__init__.py +7 -0
- flutter_security_analyzer-1.0.1.dist-info/METADATA +239 -0
- flutter_security_analyzer-1.0.1.dist-info/RECORD +30 -0
- flutter_security_analyzer-1.0.1.dist-info/WHEEL +5 -0
- flutter_security_analyzer-1.0.1.dist-info/entry_points.txt +2 -0
- flutter_security_analyzer-1.0.1.dist-info/licenses/LICENSE +21 -0
- flutter_security_analyzer-1.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Flutter Security Scanner
|
|
3
|
+
|
|
4
|
+
A static analysis tool for detecting security vulnerabilities in Flutter/Dart
|
|
5
|
+
applications with OWASP MASVS compliance mapping.
|
|
6
|
+
|
|
7
|
+
Author: Caleb Elebhose
|
|
8
|
+
MSc Cybersecurity - University of Chester
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__version__ = '1.0.1'
|
|
12
|
+
__author__ = 'Caleb Elebhose'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Core Module
|
|
3
|
+
|
|
4
|
+
Contains the main scanner components.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .scanner import SecurityScanner, Finding, ScanResults
|
|
8
|
+
from .config import ScannerConfig
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
'SecurityScanner',
|
|
12
|
+
'Finding',
|
|
13
|
+
'ScanResults',
|
|
14
|
+
'ScannerConfig'
|
|
15
|
+
]
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Scanner Configuration Module
|
|
3
|
+
|
|
4
|
+
Handles configuration loading and validation for the security scanner.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import List, Optional
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class ScannerConfig:
|
|
15
|
+
"""
|
|
16
|
+
Configuration settings for the security scanner.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
min_severity: Minimum severity level to report
|
|
20
|
+
masvs_categories: Filter results to specific MASVS categories
|
|
21
|
+
verbose: Enable verbose output
|
|
22
|
+
config_file: Path to optional configuration file
|
|
23
|
+
exclude_patterns: File patterns to exclude from scanning
|
|
24
|
+
include_tests: Whether to scan test files
|
|
25
|
+
max_file_size_kb: Maximum file size to scan (in KB)
|
|
26
|
+
"""
|
|
27
|
+
min_severity: str = 'low'
|
|
28
|
+
masvs_categories: Optional[List[str]] = None
|
|
29
|
+
verbose: bool = False
|
|
30
|
+
config_file: Optional[str] = None
|
|
31
|
+
exclude_patterns: List[str] = field(default_factory=lambda: ['*.g.dart', '*.freezed.dart'])
|
|
32
|
+
include_tests: bool = False
|
|
33
|
+
max_file_size_kb: int = 1024 # 1MB default
|
|
34
|
+
|
|
35
|
+
# Severity levels in order
|
|
36
|
+
SEVERITY_LEVELS = ['info', 'low', 'medium', 'high', 'critical']
|
|
37
|
+
|
|
38
|
+
# Valid MASVS categories
|
|
39
|
+
MASVS_CATEGORIES = [
|
|
40
|
+
'STORAGE',
|
|
41
|
+
'CRYPTO',
|
|
42
|
+
'AUTH',
|
|
43
|
+
'NETWORK',
|
|
44
|
+
'PLATFORM',
|
|
45
|
+
'CODE',
|
|
46
|
+
'RESILIENCE',
|
|
47
|
+
'PRIVACY'
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
def __post_init__(self):
|
|
51
|
+
"""Validate and load configuration after initialization."""
|
|
52
|
+
self._validate_severity()
|
|
53
|
+
self._validate_categories()
|
|
54
|
+
|
|
55
|
+
if self.config_file:
|
|
56
|
+
self._load_config_file()
|
|
57
|
+
|
|
58
|
+
def _validate_severity(self):
|
|
59
|
+
"""Validate severity level."""
|
|
60
|
+
if self.min_severity not in self.SEVERITY_LEVELS:
|
|
61
|
+
raise ValueError(
|
|
62
|
+
f"Invalid severity level: {self.min_severity}. "
|
|
63
|
+
f"Must be one of: {', '.join(self.SEVERITY_LEVELS)}"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def _validate_categories(self):
|
|
67
|
+
"""Validate MASVS categories."""
|
|
68
|
+
if self.masvs_categories:
|
|
69
|
+
for category in self.masvs_categories:
|
|
70
|
+
if category not in self.MASVS_CATEGORIES:
|
|
71
|
+
raise ValueError(
|
|
72
|
+
f"Invalid MASVS category: {category}. "
|
|
73
|
+
f"Must be one of: {', '.join(self.MASVS_CATEGORIES)}"
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def _load_config_file(self):
|
|
77
|
+
"""Load configuration from JSON file."""
|
|
78
|
+
config_path = Path(self.config_file)
|
|
79
|
+
|
|
80
|
+
if not config_path.exists():
|
|
81
|
+
raise FileNotFoundError(f"Configuration file not found: {self.config_file}")
|
|
82
|
+
|
|
83
|
+
try:
|
|
84
|
+
with open(config_path, 'r') as f:
|
|
85
|
+
config_data = json.load(f)
|
|
86
|
+
except json.JSONDecodeError as e:
|
|
87
|
+
raise ValueError(f"Invalid JSON in configuration file: {e}")
|
|
88
|
+
|
|
89
|
+
# Apply configuration values
|
|
90
|
+
if 'min_severity' in config_data:
|
|
91
|
+
self.min_severity = config_data['min_severity']
|
|
92
|
+
self._validate_severity()
|
|
93
|
+
|
|
94
|
+
if 'masvs_categories' in config_data:
|
|
95
|
+
self.masvs_categories = config_data['masvs_categories']
|
|
96
|
+
self._validate_categories()
|
|
97
|
+
|
|
98
|
+
if 'exclude_patterns' in config_data:
|
|
99
|
+
self.exclude_patterns = config_data['exclude_patterns']
|
|
100
|
+
|
|
101
|
+
if 'include_tests' in config_data:
|
|
102
|
+
self.include_tests = config_data['include_tests']
|
|
103
|
+
|
|
104
|
+
if 'max_file_size_kb' in config_data:
|
|
105
|
+
self.max_file_size_kb = config_data['max_file_size_kb']
|
|
106
|
+
|
|
107
|
+
def to_dict(self) -> dict:
|
|
108
|
+
"""Convert configuration to dictionary."""
|
|
109
|
+
return {
|
|
110
|
+
'min_severity': self.min_severity,
|
|
111
|
+
'masvs_categories': self.masvs_categories,
|
|
112
|
+
'verbose': self.verbose,
|
|
113
|
+
'exclude_patterns': self.exclude_patterns,
|
|
114
|
+
'include_tests': self.include_tests,
|
|
115
|
+
'max_file_size_kb': self.max_file_size_kb
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@classmethod
|
|
119
|
+
def from_dict(cls, data: dict) -> 'ScannerConfig':
|
|
120
|
+
"""Create configuration from dictionary."""
|
|
121
|
+
return cls(
|
|
122
|
+
min_severity=data.get('min_severity', 'low'),
|
|
123
|
+
masvs_categories=data.get('masvs_categories'),
|
|
124
|
+
verbose=data.get('verbose', False),
|
|
125
|
+
exclude_patterns=data.get('exclude_patterns', ['*.g.dart', '*.freezed.dart']),
|
|
126
|
+
include_tests=data.get('include_tests', False),
|
|
127
|
+
max_file_size_kb=data.get('max_file_size_kb', 1024)
|
|
128
|
+
)
|