Skip to content

Commit

Permalink
Modify qrexec-policy-graph for more flexibility
Browse files Browse the repository at this point in the history
Enable outputting more information about permissions/actions
Make output more flexible (can be provided as output parameter,
not just sys.stdout)
  • Loading branch information
marmarta committed Sep 25, 2023
1 parent b570f1f commit d587170
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions qrexec/tools/qrexec_policy_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
"connections.",
)

argparser.add_argument(
"--full-output",
action="store_true",
help="Output complete policy scheme, including detailed action "
"specifications.",
)


def handle_single_action(args, action):
"""Get single policy action and output (or not) a line to add"""
Expand All @@ -83,6 +90,9 @@ def handle_single_action(args, action):
target = action.rule.action.target
if args.target and target not in args.target:
return ""
if args.full_output:
return f' "{action.request.source}" -> "{target}" ' \
f'[label="{service} {action.rule.action}" color=orange];\n'
if isinstance(action, parser.AskResolution):
if args.include_ask:
return f' "{action.request.source}" -> "{target}" [label="{service}" color=orange];\n'
Expand All @@ -91,10 +101,9 @@ def handle_single_action(args, action):
return ""


def main(args=None):
def main(args=None, output=sys.stdout):
args = argparser.parse_args(args)

output = sys.stdout
if args.output:
# pylint: disable=consider-using-with
output = open(args.output, "w", encoding='utf-8')
Expand Down

0 comments on commit d587170

Please sign in to comment.