File size: 1,389 Bytes
8df6aa0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""AppSecBench top-level orchestrator.

Runs the full pipeline: build -> validate -> statistics.

Usage:
    python appsecbench.py            # build + validate + statistics
    python appsecbench.py --no-build # validate + statistics only
"""
from __future__ import annotations

import argparse
import subprocess
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parent
SCRIPTS = ROOT / "scripts"


def run(mod: str, *extra) -> int:
    cmd = [sys.executable, str(SCRIPTS / mod)] + list(extra)
    print(f"\n>>> {' '.join(cmd)}")
    return subprocess.call(cmd)


def main():
    ap = argparse.ArgumentParser(description="AppSecBench pipeline orchestrator")
    ap.add_argument("--no-build", action="store_true", help="skip generation, only validate+stats")
    ap.add_argument("--no-validate", action="store_true")
    ap.add_argument("--no-stats", action="store_true")
    args = ap.parse_args()

    if not args.no_build:
        if run("build.py") != 0:
            print("BUILD FAILED"); return 1
    if not args.no_validate:
        if run("validate.py") != 0:
            print("VALIDATION FAILED"); return 1
    if not args.no_stats:
        if run("statistics.py") != 0:
            print("STATISTICS FAILED"); return 1
    print("\nAppSecBench pipeline complete.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())