@@ -383,7 +383,7 @@ def _cmd_install_model(args: argparse.Namespace) -> int:
383383 """
384384 import shutil
385385 import re
386- import subprocess # noqa: S404 — used with absolute paths from shutil.which + list args, never shell=True
386+ import subprocess # nosec B404 — used with absolute paths from shutil.which + list args, never shell=True
387387 import urllib .parse
388388 import urllib .request
389389
@@ -450,7 +450,7 @@ def _cmd_install_model(args: argparse.Namespace) -> int:
450450 expected_size = None
451451 req = urllib .request .Request (gguf_url , method = "HEAD" )
452452 try :
453- with urllib .request .urlopen (req , timeout = 30 ) as resp : # noqa: S310 — URL validated above
453+ with urllib .request .urlopen (req , timeout = 30 ) as resp : # nosec B310 — URL is parse- validated above (https + huggingface.co only)
454454 expected_size = int (resp .headers .get ("Content-Length" ) or 0 )
455455 except Exception as exc :
456456 output ["error" ] = f"could not query HF for { args .model } : { exc } "
@@ -463,7 +463,7 @@ def _cmd_install_model(args: argparse.Namespace) -> int:
463463 else :
464464 try :
465465 req = urllib .request .Request (gguf_url )
466- with urllib .request .urlopen (req , timeout = 600 ) as resp , open (dest , "wb" ) as fh : # noqa: S310 — URL validated above
466+ with urllib .request .urlopen (req , timeout = 600 ) as resp , open (dest , "wb" ) as fh : # nosec B310 — URL is parse- validated above (https + huggingface.co only)
467467 while chunk := resp .read (8 * 1024 * 1024 ):
468468 fh .write (chunk )
469469 output ["downloaded" ] = True
@@ -495,7 +495,7 @@ def _cmd_install_model(args: argparse.Namespace) -> int:
495495 print (json .dumps (output , indent = 2 ))
496496 return 2
497497 try :
498- result = subprocess .run ( # noqa: S603 — argv list, no shell, validated args
498+ result = subprocess .run ( # nosec B603 B607 — argv list w/ absolute path from shutil.which , no shell, validated args
499499 [ollama_bin , "create" , args .name , "-f" , modelfile ],
500500 capture_output = True ,
501501 text = True ,
@@ -515,7 +515,7 @@ def _cmd_install_model(args: argparse.Namespace) -> int:
515515 # 5. Smoke test (warm the model + keep-alive). Same safety profile
516516 # as step 4: absolute path + argv list + validated args, no shell.
517517 try :
518- smoke = subprocess .run ( # noqa: S603 — argv list, no shell, validated args
518+ smoke = subprocess .run ( # nosec B603 B607 — argv list w/ absolute path from shutil.which , no shell, validated args
519519 [ollama_bin , "run" , args .name , "test" ],
520520 input = "hi\n " ,
521521 capture_output = True ,
0 commit comments