Repository navigation
Expand file tree
/
Copy pathhypercheck.py
More file actions
63 lines (48 loc) · 2.36 KB
/
Copy pathhypercheck.py
File metadata and controls
63 lines (48 loc) · 2.36 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
import argparse
import sys
import warnings
import warnings
import logging
warnings.filterwarnings("ignore")
logging.basicConfig(
filename='hypercheck.log',
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger("hypercheck")
from scanner import SecurityScanner
from ai_model import HyperCheckAI
from reporter import Reporter
from rich.console import Console
def main():
parser = argparse.ArgumentParser(description="HyperCheck AI - ML-powered DevSecOps passive auditor")
parser.add_argument("--target", required=True, help="Target URL to scan (e.g., http://localhost:8000)")
parser.add_argument("--auth-token", help="Optional Bearer token for authenticated endpoints")
parser.add_argument("--json-out", help="Path to export JSON report", default="hypercheck_report.json")
parser.add_argument("--verbose", action="store_true", help="Print detailed list of all failed checks")
args = parser.parse_args()
console = Console()
scanner = SecurityScanner(args.target, args.auth_token)
feature_keys = scanner.get_feature_keys()
logger.info(f"Starting HyperCheck AI scan on target: {args.target}")
console.print(f"[bold blue]Initializing HyperCheck AI...[/bold blue]")
console.print(f"Generating massive synthetic dataset and training AI on {len(feature_keys)} security features...")
ai_engine = HyperCheckAI(feature_keys)
console.print(f"[bold blue]Scanning {args.target}...[/bold blue]")
features, raw_results, error = scanner.scan()
if error:
console.print(f"[bold red]Scan failed: {error}[/bold red]")
sys.exit(1)
console.print(f"[bold blue]Analyzing extracted features with AI...[/bold blue]")
risk_level, risk_score = ai_engine.predict_risk(features)
reporter = Reporter()
reporter.generate_terminal_report(args.target, features, raw_results, risk_level, risk_score, verbose=args.verbose)
reporter.export_json(args.target, features, raw_results, risk_level, risk_score, args.json_out)
if risk_level in ["High", "Critical"]:
logger.error(f"Failing build! High/Critical risk detected: {risk_level}")
sys.exit(1)
else:
logger.info(f"Scan completed successfully with acceptable risk: {risk_level}")
sys.exit(0)
if __name__ == "__main__":
main()