22
33import subprocess
44
5+ from pydantic import SecretStr
6+
57from ..contracts import ExecutionSpecification , ProcessOutcome
68from ..errors import ExecutionError
79
@@ -13,14 +15,18 @@ def execute(
1315 self , specification : ExecutionSpecification
1416 ) -> ProcessOutcome | ExecutionError :
1517 """Capture exact bytes and envelope startup and timeout failures."""
18+ environment = {
19+ name : value .get_secret_value () if isinstance (value , SecretStr ) else value
20+ for name , value in specification .environment
21+ }
1622 try :
1723 completed = subprocess .run ( # noqa: S603 - policy-approved structured argv
1824 specification .argv ,
1925 input = specification .input_bytes ,
2026 stdout = subprocess .PIPE ,
2127 stderr = subprocess .PIPE ,
2228 cwd = specification .working_directory ,
23- env = dict ( specification . environment ) ,
29+ env = environment ,
2430 timeout = specification .timeout_seconds ,
2531 shell = False ,
2632 check = False ,
@@ -37,6 +43,6 @@ def execute(
3743 return ExecutionError (
3844 "process could not be started" ,
3945 kind = "process_start_failed" ,
40- cause = f" { type (error ).__name__ } : { error } " ,
46+ cause = type (error ).__name__ ,
4147 )
4248 return ProcessOutcome (completed .returncode , completed .stdout , completed .stderr )
0 commit comments