MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / get_default_rules

Function get_default_rules

src/pyspector/config.py:55–78  ·  view source on GitHub ↗

Loads the built-in TOML rules file from package resources. Substitutes the `__SHARED_PLACEHOLDERS__` sentinel inside any rule's exclude_pattern with the value of `[defaults].exclude_pattern_placeholder`, so the placeholder/dummy-secret regex lives in one place rather than being copy

(ai_scan: bool = False)

Source from the content-addressed store, hash-verified

53 return deepcopy(DEFAULT_CONFIG)
54
55def get_default_rules(ai_scan: bool = False) -> str:
56 """Loads the built-in TOML rules file from package resources.
57
58 Substitutes the `__SHARED_PLACEHOLDERS__` sentinel inside any rule's
59 exclude_pattern with the value of `[defaults].exclude_pattern_placeholder`,
60 so the placeholder/dummy-secret regex lives in one place rather than being
61 copy-pasted across every format-specific rule.
62 """
63 try:
64 base_rules = pkg_resources.files('pyspector.rules').joinpath('built-in-rules.toml').read_text(encoding='utf-8')
65 if ai_scan:
66 click.echo("[*] AI scanning enabled. Loading additional AI/LLM rules.")
67 ai_rules = pkg_resources.files('pyspector.rules').joinpath('built-in-rules-ai.toml').read_text(encoding='utf-8')
68 text = base_rules + "\n" + ai_rules
69 else:
70 text = base_rules
71
72 # Inline shared placeholder regex into rule-level exclude_patterns
73 m = _PLACEHOLDER_KEY_RX.search(text)
74 if m and _PLACEHOLDER_SENTINEL in text:
75 text = text.replace(_PLACEHOLDER_SENTINEL, m.group(1))
76 return text
77 except Exception as e:
78 raise FileNotFoundError(f"Could not load built-in-rules.toml from package data! Error: {e}")

Callers 13

run_pyspector_aiFunction · 0.90
run_pyspectorFunction · 0.90
runFunction · 0.90
run_pyspectorFunction · 0.90
run_pyspectorFunction · 0.90
runFunction · 0.90
run_pyspectorFunction · 0.90
_scan_to_issuesFunction · 0.85

Calls

no outgoing calls

Tested by 11

run_pyspector_aiFunction · 0.72
run_pyspectorFunction · 0.72
runFunction · 0.72
run_pyspectorFunction · 0.72
run_pyspectorFunction · 0.72
runFunction · 0.72
run_pyspectorFunction · 0.72