@@ -41,14 +41,16 @@ def verify_signing_hash(cert_hash: str) -> bool:
4141 bool: If the certificate is valid, returns True.
4242 """
4343
44- with tempfile .NamedTemporaryFile (mode = "w" , delete = True ) as in_file :
45- unsigned_tmp_file_path = in_file .name
46- in_file .write ("temporary file for signing" )
44+ with tempfile .NamedTemporaryFile (mode = "w" , delete = False ) as in_file :
45+ unsigned_tmp_file_path = Path ( in_file .name )
46+ in_file .write ("temporary file for signing\n " )
4747 in_file .flush ()
4848
49- cmd : str = f"security cms -SZ { cert_hash } -i { unsigned_tmp_file_path } "
49+ cmd : str = f"security cms -SZ { cert_hash } -i { unsigned_tmp_file_path } "
5050
51- stdout , error = run_command (cmd )
51+ stdout , error = run_command (cmd , text = False , check = False )
52+
53+ unsigned_tmp_file_path .unlink ()
5254
5355 if error :
5456 logger .error (f"Verification failed for hash { cert_hash } . Error: { error } " )
@@ -128,24 +130,15 @@ def generate_guidance(args: argparse.Namespace) -> None:
128130
129131 if args .profiles :
130132 logger .info ("Generating configuration profiles" )
131- if not signing :
132- generate_profiles (
133- build_path ,
134- baseline_name ,
135- baseline ,
136- consolidated = args .consolidated_profile ,
137- granular = args .granular_profiles ,
138- )
139- else :
140- generate_profiles (
141- build_path ,
142- baseline_name ,
143- baseline ,
144- signing ,
145- args .hash ,
146- consolidated = args .consolidated_profile ,
147- granular = args .granular_profiles ,
148- )
133+ generate_profiles (
134+ build_path ,
135+ baseline_name ,
136+ baseline ,
137+ signing ,
138+ args .hash ,
139+ consolidated = args .consolidated_profile ,
140+ granular = args .granular_profiles ,
141+ )
149142
150143 if args .ddm :
151144 logger .info ("Generating declarative components" )
@@ -188,6 +181,8 @@ def generate_guidance(args: argparse.Namespace) -> None:
188181 build_path ,
189182 baseline_name ,
190183 baseline ,
184+ signing ,
185+ args .hash ,
191186 consolidated = args .consolidated_profile ,
192187 granular = args .granular_profiles ,
193188 )
0 commit comments