guard release code against redaction placeholders
This commit is contained in:
@@ -404,7 +404,7 @@ if __name__ == '__main__':
|
||||
print(f"行星经度: { {k: f'{v:.1f}' for k,v in test_planets.items()} }")
|
||||
print()
|
||||
|
||||
result = narayana_dasha_full_report(test_lagna, test_planets, test_age, REDACTED_YEAR)
|
||||
result = narayana_dasha_full_report(test_lagna, test_planets, test_age, 1990)
|
||||
|
||||
print("=== 大运序列 ===")
|
||||
for p in result['mahadasha_sequence']:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@@ -120,6 +121,25 @@ def scan_text(
|
||||
return findings
|
||||
|
||||
|
||||
def scan_executable_redaction_names(path: Path, text: str) -> list[dict[str, object]]:
|
||||
"""Reject unquoted privacy placeholders that would raise at runtime."""
|
||||
if path.suffix.lower() != ".py":
|
||||
return []
|
||||
try:
|
||||
tree = ast.parse(text, filename=str(path))
|
||||
except SyntaxError:
|
||||
return []
|
||||
try:
|
||||
display_path = path.relative_to(ROOT).as_posix()
|
||||
except ValueError:
|
||||
display_path = path.as_posix()
|
||||
return [
|
||||
{"rule_id": "executable_redaction_placeholder", "path": display_path, "line": node.lineno}
|
||||
for node in ast.walk(tree)
|
||||
if isinstance(node, ast.Name) and node.id.startswith("REDACTED_")
|
||||
]
|
||||
|
||||
|
||||
def build_report(root: Path = ROOT) -> dict[str, object]:
|
||||
findings: list[dict[str, object]] = []
|
||||
scanned = 0
|
||||
@@ -131,6 +151,7 @@ def build_report(root: Path = ROOT) -> dict[str, object]:
|
||||
text = path.read_text(encoding="utf-8", errors="ignore")
|
||||
scanned += 1
|
||||
findings.extend(scan_text(path, text, patterns))
|
||||
findings.extend(scan_executable_redaction_names(path, text))
|
||||
return {
|
||||
"scope": "public_release_privacy_scan",
|
||||
"scanned_files": scanned,
|
||||
|
||||
@@ -630,8 +630,8 @@ if __name__ == '__main__':
|
||||
print(f" swisseph可用: {HAS_SWE}")
|
||||
print()
|
||||
|
||||
# 测试:private birth datetime +8 的出生盘,计算 2026 年太阳返照
|
||||
test_birth_year, test_birth_month, test_birth_day = REDACTED_YEAR, 4, 17
|
||||
# Generic public smoke fixture, calculating the 2026 solar return.
|
||||
test_birth_year, test_birth_month, test_birth_day = 1990, 4, 17
|
||||
test_birth_hour, test_birth_minute = 14, 45
|
||||
test_lat, test_lon, test_tz = 36.4667, 114.2, 8.0
|
||||
test_target_year = 2026
|
||||
|
||||
Reference in New Issue
Block a user