Skip to content

Commit

Permalink
secilc/secil2tree: Add option to write CIL AST after post processing
Browse files Browse the repository at this point in the history
This will show the resulting CIL AST after deny rules have been
processed.

Signed-off-by: James Carter <[email protected]>
Reviewed-by: Daniel Burgener <[email protected]>
Acked-by: Petr Lautrbach <[email protected]>
  • Loading branch information
jwcart2 committed Aug 16, 2023
1 parent 5d5a871 commit 409b4d3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion secilc/secil2tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum write_ast_phase {
WRITE_AST_PHASE_PARSE = 0,
WRITE_AST_PHASE_BUILD,
WRITE_AST_PHASE_RESOLVE,
WRITE_AST_PHASE_POST,
};

static __attribute__((__noreturn__)) void usage(const char *prog)
Expand All @@ -58,7 +59,7 @@ static __attribute__((__noreturn__)) void usage(const char *prog)
printf(" Blocks, blockinherits, blockabstracts, and\n");
printf(" in-statements will not be allowed.\n");
printf(" -A, --ast-phase=<phase> write AST of phase <phase>. Phase must be parse, \n");
printf(" build, or resolve. (default: resolve)\n");
printf(" build, resolve, or post. (default: resolve)\n");
printf(" -v, --verbose increment verbosity level\n");
printf(" -h, --help display usage information\n");
exit(1);
Expand Down Expand Up @@ -115,6 +116,8 @@ int main(int argc, char *argv[])
write_ast = WRITE_AST_PHASE_BUILD;
} else if (!strcasecmp(optarg, "resolve")) {
write_ast = WRITE_AST_PHASE_RESOLVE;
} else if (!strcasecmp(optarg, "post")) {
write_ast = WRITE_AST_PHASE_POST;
} else {
fprintf(stderr, "Invalid AST phase: %s\n", optarg);
usage(argv[0]);
Expand Down Expand Up @@ -203,6 +206,9 @@ int main(int argc, char *argv[])
case WRITE_AST_PHASE_RESOLVE:
rc = cil_write_resolve_ast(file, db);
break;
case WRITE_AST_PHASE_POST:
rc = cil_write_post_ast(file, db);
break;
}

if (rc != SEPOL_OK) {
Expand Down

0 comments on commit 409b4d3

Please sign in to comment.