@@ -122,6 +122,10 @@ def load_config() -> dict:
122122 logger .warning ("Invalid security.allow_any_original_host; using false" )
123123 security ["allow_any_original_host" ] = False
124124
125+ if not isinstance (security .get ("allow_local_resolved_hosts" , False ), bool ):
126+ logger .warning ("Invalid security.allow_local_resolved_hosts; using false" )
127+ security ["allow_local_resolved_hosts" ] = False
128+
125129 security ["post_process_action" ] = normalize_post_process_action (security .get ("post_process_action" ))
126130
127131 allowed_hosts = security .get ("allowed_hosts" , [])
@@ -312,6 +316,7 @@ def validate_remote_url(
312316 allow_any_original_host : bool ,
313317 allow_plain_http : bool ,
314318 check_allowlist : bool ,
319+ allow_local_resolved_hosts : bool ,
315320) -> None :
316321 parsed = urllib .parse .urlsplit (url )
317322 if not parsed .scheme or not parsed .netloc :
@@ -331,7 +336,8 @@ def validate_remote_url(
331336 if normalize_host (host ) not in allowed_hosts :
332337 raise BridgeError (f"Download host is not allow-listed: { host } " )
333338
334- assert_public_host (host )
339+ if not allow_local_resolved_hosts :
340+ assert_public_host (host )
335341
336342
337343def download_folder_from_config (config : dict ) -> Path | None :
@@ -410,6 +416,7 @@ def download_model(
410416 allowed_hosts : set [str ],
411417 allow_any_original_host : bool ,
412418 allow_plain_http : bool ,
419+ allow_local_resolved_hosts : bool ,
413420) -> Path :
414421 opener = urllib .request .build_opener (NoRedirectHandler ())
415422 current_url = initial_url
@@ -422,6 +429,7 @@ def download_model(
422429 allow_any_original_host = allow_any_original_host ,
423430 allow_plain_http = allow_plain_http ,
424431 check_allowlist = redirect_index == 0 ,
432+ allow_local_resolved_hosts = allow_local_resolved_hosts ,
425433 )
426434
427435 request = urllib .request .Request (
@@ -701,6 +709,7 @@ def main(argv: list[str] | None = None) -> int:
701709 config = load_config ()
702710 security = config ["security" ]
703711 allow_plain_http = security .get ("allow_plain_http" , False )
712+ allow_local_resolved_hosts = security .get ("allow_local_resolved_hosts" , False )
704713 allowed_extensions = security ["allowed_extensions" ]
705714 download_folder = download_folder_from_config (config )
706715
@@ -722,6 +731,7 @@ def main(argv: list[str] | None = None) -> int:
722731 allow_any_original_host = allow_any_original_host ,
723732 allow_plain_http = allow_plain_http ,
724733 check_allowlist = True ,
734+ allow_local_resolved_hosts = allow_local_resolved_hosts ,
725735 )
726736
727737 command = resolve_bambu_command (config )
@@ -734,6 +744,7 @@ def main(argv: list[str] | None = None) -> int:
734744 allowed_hosts = allowed_hosts ,
735745 allow_any_original_host = allow_any_original_host ,
736746 allow_plain_http = allow_plain_http ,
747+ allow_local_resolved_hosts = allow_local_resolved_hosts ,
737748 )
738749 validate_downloaded_file (local_path )
739750 check_3mf_post_process (local_path , security ["post_process_action" ])
0 commit comments