평가 캐시와 개인정보 마스킹 보강
This commit is contained in:
parent
f0771db919
commit
6a81ec596c
11 changed files with 737 additions and 14 deletions
47
scripts/evaluate-pii-masking.py
Normal file
47
scripts/evaluate-pii-masking.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
API_ROOT = REPO_ROOT / "apps" / "api"
|
||||
sys.path.insert(0, str(API_ROOT))
|
||||
|
||||
from app.services.pii_masking_eval import evaluate_fixture # noqa: E402
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="Evaluate local PII masking fixtures.")
|
||||
parser.add_argument(
|
||||
"--fixtures",
|
||||
default=str(REPO_ROOT / "data" / "privacy" / "pii-masking-ko-fixtures.json"),
|
||||
)
|
||||
parser.add_argument("--json", action="store_true")
|
||||
return parser
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args()
|
||||
report = evaluate_fixture(Path(args.fixtures))
|
||||
if args.json:
|
||||
print(json.dumps(report, ensure_ascii=False, indent=2, sort_keys=True))
|
||||
else:
|
||||
status = "PASS" if report["passed"] else "FAIL"
|
||||
print(
|
||||
f"{status}: {report['cases_passed']}/{report['cases_total']} cases, "
|
||||
f"entity_recall={report['expected_entity_recall']}, "
|
||||
f"forbidden_removed={report['forbidden_substring_removal']}, "
|
||||
f"unexpected_entity_violations={report['unexpected_entity_violations']}"
|
||||
)
|
||||
for result in report["results"]:
|
||||
if not result["passed"]:
|
||||
print(json.dumps(result, ensure_ascii=False, sort_keys=True))
|
||||
return 0 if report["passed"] else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue