@@ -93,6 +93,41 @@ def test_mixed_typescript_declaration_and_runtime_stays_executable() -> None:
9393 assert is_executable_content ("evil.d.ts" , runtime )
9494
9595
96+ @pytest .mark .parametrize (
97+ "runtime" ,
98+ [
99+ b'type = console.log("runtime");\n ' ,
100+ b"namespace: { console.log('runtime'); }\n " ,
101+ ],
102+ )
103+ def test_ambiguous_typescript_keywords_stay_executable (runtime : bytes ) -> None :
104+ """Assignments and labels must not be mistaken for declarations."""
105+ assert is_executable_content ("evil.d.mts" , runtime )
106+
107+
108+ @pytest .mark .parametrize (
109+ "runtime" ,
110+ [
111+ b'type = console.log("runtime");\n ' ,
112+ b"namespace: { console.log('runtime'); }\n " ,
113+ ],
114+ )
115+ def test_ambiguous_typescript_keywords_in_hidden_documents_raise_sc9 (
116+ tmp_path : Path , runtime : bytes
117+ ) -> None :
118+ archive_path = tmp_path / ".types.docx.txt"
119+ _write_archive (archive_path , _document_members (** {"word/payload.d.mts" : runtime }))
120+ (tmp_path / "SKILL.md" ).write_text ("# Declaration container\n " , encoding = "utf-8" )
121+
122+ context = build_context ({"skill_path" : str (tmp_path )})
123+ virtual_path = ".types.docx.txt!/word/payload.d.mts"
124+ metadata = next (item for item in context ["component_metadata" ] if item ["path" ] == virtual_path )
125+ assert metadata ["executable" ] is True
126+ assert metadata ["concealed_executable" ] is True
127+ findings = _analyze_concealed_executables (context ["component_metadata" ])
128+ assert any (finding .rule_id == "SC9" and finding .file == virtual_path for finding in findings )
129+
130+
96131@pytest .mark .parametrize (
97132 ("path" , "payload" ),
98133 [
0 commit comments