@@ -2142,6 +2142,22 @@ fn is_sensitive_context_path(path: &str) -> bool {
21422142 )
21432143}
21442144
2145+ fn is_context_pack_excluded_path ( path : & str ) -> bool {
2146+ let normalized = path. replace ( '\\' , "/" ) ;
2147+ let lower = normalized. to_ascii_lowercase ( ) ;
2148+ let excluded_extensions = [
2149+ ".exe" , ".dll" , ".pdb" , ".png" , ".jpg" , ".jpeg" , ".gif" , ".webp" , ".ico" , ".pdf" , ".zip" ,
2150+ ".gz" , ".tar" , ".tgz" , ".7z" , ".rar" , ".bin" , ".wasm" , ".so" , ".dylib" , ".class" , ".jar" ,
2151+ ".mp4" , ".mov" , ".avi" , ".mp3" , ".wav" , ".flac" , ".woff" , ".woff2" , ".ttf" , ".otf" ,
2152+ ] ;
2153+
2154+ lower == "cargo.lock"
2155+ || is_sensitive_context_path ( & normalized)
2156+ || excluded_extensions
2157+ . iter ( )
2158+ . any ( |extension| lower. ends_with ( extension) )
2159+ }
2160+
21452161fn ensure_provider_network_allowed (
21462162 config : & Config ,
21472163 profile : & ProviderProfile ,
@@ -2198,12 +2214,7 @@ fn build_context_pack(task: &str) -> Result<ContextPack, String> {
21982214
21992215 for file in files {
22002216 let rel_path = normalize_path ( & file) ;
2201- if rel_path. ends_with ( ".exe" )
2202- || rel_path. ends_with ( ".dll" )
2203- || rel_path. ends_with ( ".pdb" )
2204- || rel_path == "Cargo.lock"
2205- || is_sensitive_context_path ( & rel_path)
2206- {
2217+ if is_context_pack_excluded_path ( & rel_path) {
22072218 continue ;
22082219 }
22092220 let content = std:: fs:: read_to_string ( & file)
@@ -2235,6 +2246,39 @@ fn build_context_pack(task: &str) -> Result<ContextPack, String> {
22352246 "*.pfx" . to_string( ) ,
22362247 "*key*" . to_string( ) ,
22372248 "*credential*" . to_string( ) ,
2249+ "*.exe" . to_string( ) ,
2250+ "*.dll" . to_string( ) ,
2251+ "*.pdb" . to_string( ) ,
2252+ "*.png" . to_string( ) ,
2253+ "*.jpg" . to_string( ) ,
2254+ "*.jpeg" . to_string( ) ,
2255+ "*.gif" . to_string( ) ,
2256+ "*.webp" . to_string( ) ,
2257+ "*.ico" . to_string( ) ,
2258+ "*.pdf" . to_string( ) ,
2259+ "*.zip" . to_string( ) ,
2260+ "*.gz" . to_string( ) ,
2261+ "*.tar" . to_string( ) ,
2262+ "*.tgz" . to_string( ) ,
2263+ "*.7z" . to_string( ) ,
2264+ "*.rar" . to_string( ) ,
2265+ "*.bin" . to_string( ) ,
2266+ "*.wasm" . to_string( ) ,
2267+ "*.so" . to_string( ) ,
2268+ "*.dylib" . to_string( ) ,
2269+ "*.class" . to_string( ) ,
2270+ "*.jar" . to_string( ) ,
2271+ "*.mp4" . to_string( ) ,
2272+ "*.mov" . to_string( ) ,
2273+ "*.avi" . to_string( ) ,
2274+ "*.mp3" . to_string( ) ,
2275+ "*.wav" . to_string( ) ,
2276+ "*.flac" . to_string( ) ,
2277+ "*.woff" . to_string( ) ,
2278+ "*.woff2" . to_string( ) ,
2279+ "*.ttf" . to_string( ) ,
2280+ "*.otf" . to_string( ) ,
2281+ "Cargo.lock" . to_string( ) ,
22382282 ] ,
22392283 allowed_write_paths : vec ! [ ] ,
22402284 forbidden_actions : vec ! [ ] ,
@@ -5784,8 +5828,8 @@ fn handle_antigravity(subcommand: &str, action: Option<&str>) -> Result<(), Stri
57845828#[ cfg( test) ]
57855829mod tests {
57865830 use super :: {
5787- handle_benchmark, handle_validate, parse, BenchmarkArtifact , Command , Config , Defaults ,
5788- PolicyConfig , ProviderProfile ,
5831+ build_context_pack , handle_benchmark, handle_validate, parse, BenchmarkArtifact , Command ,
5832+ Config , Defaults , PolicyConfig , ProviderProfile ,
57895833 } ;
57905834 use std:: collections:: HashMap ;
57915835
@@ -6251,6 +6295,27 @@ mod tests {
62516295 assert_eq ! ( res, Ok ( 0 ) ) ;
62526296 }
62536297
6298+ #[ test]
6299+ fn test_context_pack_skips_binary_readme_assets ( ) {
6300+ let _guard = UNIT_TEST_LOCK . lock ( ) . unwrap ( ) ;
6301+ let asset_dir = std:: path:: Path :: new ( "assets/brand" ) ;
6302+ let asset_path = asset_dir. join ( "__ctxt_test_binary_asset.png" ) ;
6303+ let normalized_asset_path = "assets/brand/__ctxt_test_binary_asset.png" ;
6304+
6305+ let _ = std:: fs:: remove_file ( & asset_path) ;
6306+ std:: fs:: create_dir_all ( asset_dir) . unwrap ( ) ;
6307+ std:: fs:: write ( & asset_path, [ 0xff , 0xd8 , 0xff , 0x00 ] ) . unwrap ( ) ;
6308+
6309+ let result = build_context_pack ( "binary asset skip" ) ;
6310+ let _ = std:: fs:: remove_file ( & asset_path) ;
6311+
6312+ assert ! ( result. is_ok( ) ) ;
6313+ let context_pack = result. unwrap ( ) ;
6314+ assert ! ( !context_pack
6315+ . included_files
6316+ . contains( & normalized_asset_path. to_string( ) ) ) ;
6317+ }
6318+
62546319 #[ test]
62556320 fn test_dummy_benchmark_artifact_shape ( ) {
62566321 let providers = HashMap :: new ( ) ;
0 commit comments