Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/confcom/azext_confcom/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
validate_fragment_json,
validate_fragment_json_policy,
validate_image_target,
validate_stdio,
validate_upload_fragment,
validate_infrastructure_svn,
)
Expand Down Expand Up @@ -105,9 +106,15 @@ def load_arguments(self, _):
)
c.argument(
"disable_stdio",
options_list=("--disable-stdio",),
required=False,
action="store_true",
help="Disabling container stdio will disable the ability to see the output of the container in the terminal for Confidential ACI",
validator=validate_stdio,
)
c.argument(
"enable_stdio",
action="store_true",
help="Disabling container stdio will disable the ability to see the output of the container in the terminal for Confidential ACI",
Comment thread
DomAyre marked this conversation as resolved.
Outdated
validator=validate_stdio,
)
c.argument(
"diff",
Expand Down Expand Up @@ -290,9 +297,15 @@ def load_arguments(self, _):
)
c.argument(
"disable_stdio",
options_list=("--disable-stdio",),
required=False,
action="store_true",
help="Disabling container stdio will disable the ability to see the output of the container in the terminal for Confidential ACI",
validator=validate_stdio,
)
c.argument(
"enable_stdio",
action="store_true",
help="Disabling container stdio will disable the ability to see the output of the container in the terminal for Confidential ACI",
Comment thread
DomAyre marked this conversation as resolved.
Outdated
validator=validate_stdio,
)
c.argument(
"debug_mode",
Expand Down
4 changes: 4 additions & 0 deletions src/confcom/azext_confcom/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@ def validate_fragment_path(namespace):
def validate_fragment_json(namespace):
if namespace.fragments_json and not namespace.generate_import:
raise CLIError("Must provide --fragment-path to place a fragment import into a file")

def validate_stdio(namespace):
if namespace.enable_stdio and namespace.disable_stdio:
raise CLIError('Use only one of --enable-stdio or --disable-stdio.')
48 changes: 40 additions & 8 deletions src/confcom/azext_confcom/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os
import sys
from typing import Optional

from azext_confcom import oras_proxy, os_util, security_policy
from azext_confcom.config import (
Expand Down Expand Up @@ -43,7 +44,8 @@ def acipolicygen_confcom(
save_to_file: str = None,
debug_mode: bool = False,
print_policy_to_terminal: bool = False,
disable_stdio: bool = False,
disable_stdio: Optional[bool] = None,
enable_stdio: Optional[bool] = None,
print_existing_policy: bool = False,
faster_hashing: bool = False,
omit_id: bool = False,
Expand All @@ -61,6 +63,20 @@ def acipolicygen_confcom(
"For additional information, see http://aka.ms/clisecrets. \n",
)

stdio_enabled = True # Default value
Comment thread
DomAyre marked this conversation as resolved.
Outdated
if enable_stdio is None and disable_stdio is None:
logger.warning(
"WARNING: Using default stdio setting (Enabled)\n"
"For the most secure deployments, ensure stdio is disabled. "
"Default behaviour may change in the future, you can set stdio with:\n"
" --disable-stdio\n"
" --enable-stdio\n"
)
elif enable_stdio is not None:
stdio_enabled = enable_stdio
elif disable_stdio is not None:
stdio_enabled = not disable_stdio
Comment thread
DomAyre marked this conversation as resolved.
Outdated

if print_existing_policy and arm_template:
print_existing_policy_from_arm_template(arm_template, arm_template_parameters)
return
Expand Down Expand Up @@ -112,7 +128,7 @@ def acipolicygen_confcom(
input_path,
debug_mode=debug_mode,
infrastructure_svn=infrastructure_svn,
disable_stdio=disable_stdio,
disable_stdio=(not stdio_enabled),
exclude_default_fragments=exclude_default_fragments,
)
elif arm_template:
Expand All @@ -121,21 +137,21 @@ def acipolicygen_confcom(
arm_template,
arm_template_parameters,
debug_mode=debug_mode,
disable_stdio=disable_stdio,
disable_stdio=(not stdio_enabled),
approve_wildcards=approve_wildcards,
diff_mode=diff,
rego_imports=fragments_list,
exclude_default_fragments=exclude_default_fragments,
)
elif image_name:
container_group_policies = security_policy.load_policy_from_image_name(
image_name, debug_mode=debug_mode, disable_stdio=disable_stdio
image_name, debug_mode=debug_mode, disable_stdio=(not stdio_enabled)
)
elif virtual_node_yaml_path:
container_group_policies = security_policy.load_policy_from_virtual_node_yaml_file(
virtual_node_yaml_path=virtual_node_yaml_path,
debug_mode=debug_mode,
disable_stdio=disable_stdio,
disable_stdio=(not stdio_enabled),
approve_wildcards=approve_wildcards,
diff_mode=diff,
rego_imports=fragments_list,
Expand Down Expand Up @@ -227,14 +243,30 @@ def acifragmentgen_confcom(
fragment_path: str = None,
omit_id: bool = False,
generate_import: bool = False,
disable_stdio: bool = False,
disable_stdio: Optional[bool] = None,
enable_stdio: Optional[bool] = None,
debug_mode: bool = False,
output_filename: str = "",
outraw: bool = False,
upload_fragment: bool = False,
no_print: bool = False,
fragments_json: str = "",
):

stdio_enabled = True # Default value
Comment thread
DomAyre marked this conversation as resolved.
Outdated
if enable_stdio is None and disable_stdio is None:
logger.warning(
"WARNING: Using default stdio setting (Enabled)\n"
"For the most secure deployments, ensure stdio is disabled. "
"Default behaviour may change in the future, you can set stdio with:\n"
" --disable-stdio\n"
" --enable-stdio\n"
)
elif enable_stdio is not None:
stdio_enabled = enable_stdio
elif disable_stdio is not None:
stdio_enabled = not disable_stdio

output_type = get_fragment_output_type(outraw)

if generate_import:
Expand Down Expand Up @@ -288,14 +320,14 @@ def acifragmentgen_confcom(

if image_name:
policy = security_policy.load_policy_from_image_name(
image_name, debug_mode=debug_mode, disable_stdio=disable_stdio
image_name, debug_mode=debug_mode, disable_stdio=(not stdio_enabled)
)
else:
# this is using --input
if not tar_mapping:
tar_mapping = os_util.load_tar_mapping_from_config_file(input_path)
policy = security_policy.load_policy_from_json_file(
input_path, debug_mode=debug_mode, disable_stdio=disable_stdio
input_path, debug_mode=debug_mode, disable_stdio=(not stdio_enabled)
)
# get all of the fragments that are being used in the policy
# and associate them with each container group
Expand Down
Loading