@@ -116,35 +116,31 @@ fn e2e_scan_vulnerable_examples() {
116116// ============================================================================
117117
118118/// E2E test: Scan single Python file
119+ ///
120+ /// The fixture is written to a tempdir at test time so no `.py` source
121+ /// is committed to the tree — the estate-wide Python ban is governance-
122+ /// enforced (see .github/workflows/governance.yml), and a committed
123+ /// `.py` fixture would fail that gate even though its purpose here is
124+ /// to exercise Python-pattern detection.
119125#[ test]
120126fn e2e_scan_python_file ( ) {
121- let py_file = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "tests/fixtures/example.py" ) ;
122-
123- // Create temp Python file if it doesn't exist
124- if !py_file. exists ( ) {
125- use std:: fs;
126- let _ = fs:: create_dir_all ( py_file. parent ( ) . unwrap_or ( std:: path:: Path :: new ( "." ) ) ) ;
127- let _ = fs:: write (
128- & py_file,
129- r#"
130- import pickle
131- import subprocess
132-
133- def unsafe_deserialization(data):
134- return pickle.loads(data) # Unsafe!
135-
136- def command_injection(user_input):
137- subprocess.call("echo " + user_input, shell=True) # Unsafe!
138- "# ,
139- ) ;
140- }
141-
142- if py_file. exists ( ) {
143- let report = assail:: analyze ( & py_file) . expect ( "Python analysis should succeed" ) ;
144-
145- assert_eq ! ( report. language, Language :: Python ) ;
146- // Should detect unsafe patterns in Python code
147- }
127+ let tmp = tempfile:: tempdir ( ) . expect ( "create tempdir" ) ;
128+ let py_file = tmp. path ( ) . join ( "example.py" ) ;
129+ std:: fs:: write (
130+ & py_file,
131+ "import pickle\n \
132+ import subprocess\n \
133+ \n \
134+ def unsafe_deserialization(data):\n \
135+ return pickle.loads(data) # Unsafe!\n \
136+ \n \
137+ def command_injection(user_input):\n \
138+ subprocess.call(\" echo \" + user_input, shell=True) # Unsafe!\n ",
139+ )
140+ . expect ( "write python fixture" ) ;
141+
142+ let report = assail:: analyze ( & py_file) . expect ( "Python analysis should succeed" ) ;
143+ assert_eq ! ( report. language, Language :: Python ) ;
148144}
149145
150146// ============================================================================
0 commit comments