55
66import os
77import sys
8+ from typing import Optional
89
910from azext_confcom import oras_proxy , os_util , security_policy
11+ from azext_confcom ._validators import resolve_stdio
1012from azext_confcom .config import (
1113 DEFAULT_REGO_FRAGMENTS , POLICY_FIELD_CONTAINERS_ELEMENTS_REGO_FRAGMENTS ,
1214 REGO_IMPORT_FILE_STRUCTURE )
@@ -43,7 +45,8 @@ def acipolicygen_confcom(
4345 save_to_file : str = None ,
4446 debug_mode : bool = False ,
4547 print_policy_to_terminal : bool = False ,
46- disable_stdio : bool = False ,
48+ disable_stdio : Optional [bool ] = None ,
49+ enable_stdio : Optional [bool ] = None ,
4750 print_existing_policy : bool = False ,
4851 faster_hashing : bool = False ,
4952 omit_id : bool = False ,
@@ -61,6 +64,8 @@ def acipolicygen_confcom(
6164 "For additional information, see http://aka.ms/clisecrets. \n " ,
6265 )
6366
67+ stdio_enabled = resolve_stdio (enable_stdio , disable_stdio )
68+
6469 if print_existing_policy and arm_template :
6570 print_existing_policy_from_arm_template (arm_template , arm_template_parameters )
6671 return
@@ -112,7 +117,7 @@ def acipolicygen_confcom(
112117 input_path ,
113118 debug_mode = debug_mode ,
114119 infrastructure_svn = infrastructure_svn ,
115- disable_stdio = disable_stdio ,
120+ disable_stdio = ( not stdio_enabled ) ,
116121 exclude_default_fragments = exclude_default_fragments ,
117122 )
118123 elif arm_template :
@@ -121,21 +126,21 @@ def acipolicygen_confcom(
121126 arm_template ,
122127 arm_template_parameters ,
123128 debug_mode = debug_mode ,
124- disable_stdio = disable_stdio ,
129+ disable_stdio = ( not stdio_enabled ) ,
125130 approve_wildcards = approve_wildcards ,
126131 diff_mode = diff ,
127132 rego_imports = fragments_list ,
128133 exclude_default_fragments = exclude_default_fragments ,
129134 )
130135 elif image_name :
131136 container_group_policies = security_policy .load_policy_from_image_name (
132- image_name , debug_mode = debug_mode , disable_stdio = disable_stdio
137+ image_name , debug_mode = debug_mode , disable_stdio = ( not stdio_enabled )
133138 )
134139 elif virtual_node_yaml_path :
135140 container_group_policies = security_policy .load_policy_from_virtual_node_yaml_file (
136141 virtual_node_yaml_path = virtual_node_yaml_path ,
137142 debug_mode = debug_mode ,
138- disable_stdio = disable_stdio ,
143+ disable_stdio = ( not stdio_enabled ) ,
139144 approve_wildcards = approve_wildcards ,
140145 diff_mode = diff ,
141146 rego_imports = fragments_list ,
@@ -227,14 +232,18 @@ def acifragmentgen_confcom(
227232 fragment_path : str = None ,
228233 omit_id : bool = False ,
229234 generate_import : bool = False ,
230- disable_stdio : bool = False ,
235+ disable_stdio : Optional [bool ] = None ,
236+ enable_stdio : Optional [bool ] = None ,
231237 debug_mode : bool = False ,
232238 output_filename : str = "" ,
233239 outraw : bool = False ,
234240 upload_fragment : bool = False ,
235241 no_print : bool = False ,
236242 fragments_json : str = "" ,
237243):
244+
245+ stdio_enabled = resolve_stdio (enable_stdio , disable_stdio )
246+
238247 output_type = get_fragment_output_type (outraw )
239248
240249 if generate_import :
@@ -288,14 +297,14 @@ def acifragmentgen_confcom(
288297
289298 if image_name :
290299 policy = security_policy .load_policy_from_image_name (
291- image_name , debug_mode = debug_mode , disable_stdio = disable_stdio
300+ image_name , debug_mode = debug_mode , disable_stdio = ( not stdio_enabled )
292301 )
293302 else :
294303 # this is using --input
295304 if not tar_mapping :
296305 tar_mapping = os_util .load_tar_mapping_from_config_file (input_path )
297306 policy = security_policy .load_policy_from_json_file (
298- input_path , debug_mode = debug_mode , disable_stdio = disable_stdio
307+ input_path , debug_mode = debug_mode , disable_stdio = ( not stdio_enabled )
299308 )
300309 # get all of the fragments that are being used in the policy
301310 # and associate them with each container group
0 commit comments