File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,12 +126,12 @@ class Finding:
126126 match : str
127127
128128 def __str__ (self ) -> str :
129- # Redact the match in output — don't print real PII to terminal
130129 redacted = self .match [:4 ] + "***" if len (self .match ) > 4 else "***"
130+ safe_line = self .line .replace (self .match , redacted ) # ← scrub match from line
131131 return (
132132 f" { self .file .name } :{ self .line_number } "
133133 f"[{ self .pattern } ] { redacted } "
134- f"— { self . line .strip ()[:80 ]} "
134+ f"— { safe_line .strip ()[:80 ]} "
135135 )
136136
137137
Original file line number Diff line number Diff line change @@ -74,9 +74,9 @@ def _record(
7474 serializer = SnapfixSerializer (max_depth = effective_depth , max_size_bytes = effective_size )
7575 scrubber = SnapfixScrubber (scrub_fields )
7676 codegen = SnapfixCodegen ()
77- store = SnapfixStore (cfg .output_dir )
7877
7978 try :
79+ store = SnapfixStore (cfg .output_dir ) # ← now inside try, error is caught
8080 serialized = serializer .serialize (obj )
8181 scrubbed , scrubbed_keys = scrubber .scrub (serialized )
8282 source = codegen .generate (
Original file line number Diff line number Diff line change 2121# Stub pytest.fixture so the generated file can be imported in tests
2222_fake_pytest = types .ModuleType ("pytest" )
2323_fake_pytest .fixture = lambda f : f # type: ignore
24- sys .modules .setdefault ("pytest" , _fake_pytest )
24+ # sys.modules.setdefault("pytest", _fake_pytest)
2525
2626
2727def _reload_snapfix ():
2828 for m in list (sys .modules ):
2929 if "snapfix" in m :
3030 del sys .modules [m ]
3131
32-
3332def _import_fixture_file (path : pathlib .Path ):
34- spec = importlib .util .spec_from_file_location ("_fx_tmp" , path )
35- mod = importlib .util .module_from_spec (spec ) # type: ignore
36- sys .modules ["_fx_tmp" ] = mod
37- spec .loader .exec_module (mod ) # type: ignore
38- return mod
33+ real_pytest = sys .modules .get ("pytest" )
34+ sys .modules ["pytest" ] = _fake_pytest # ← force replace
35+ try :
36+ spec = importlib .util .spec_from_file_location ("_fx_tmp" , path )
37+ mod = importlib .util .module_from_spec (spec )
38+ sys .modules ["_fx_tmp" ] = mod
39+ spec .loader .exec_module (mod )
40+ return mod
41+ finally :
42+ if real_pytest is not None :
43+ sys .modules ["pytest" ] = real_pytest
3944
4045
4146def test_full_pipeline_simple_dict (tmp_path ):
You can’t perform that action at this time.
0 commit comments