2017-11-28 17:06:32

by sven.vermeulen

[permalink] [raw]
Subject: [refpolicy] [PATCH 8/8] Fix regexp for templated boolean generation

In the previous patch set, logic was added to ignore XML comments in a
template when generating the template or interface documentation, and
when that XML comment is not attributable to the template or interface
itself. This was accomplished by matching for a templated boolean or
tunable generation statement.

Sadly, the regular expression for it did not include the necessary
backtick and (forward) tick detection which is part of such statements:

gen_tunable(`$1_something', false)
versus
gen_tunable(domain_something, false)

In this patch, the regular expression is updated to support this
situation.

Signed-off-by: Sven Vermeulen <[email protected]>
---
support/segenxml.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/support/segenxml.py b/support/segenxml.py
index 46a4a720..2ed4068a 100644
--- a/support/segenxml.py
+++ b/support/segenxml.py
@@ -44,7 +44,7 @@ INTERFACE = re.compile(r"^\s*(interface|template)\(`(\w*)'")
# "gen_tunable(allow_kerberos, false)"
# -> ("tunable", "allow_kerberos", "false")
BOOLEAN = re.compile(r"^\s*gen_(tunable|bool)\(\s*(\w*)\s*,\s*(true|false)\s*\)")
-TEMPLATE_BOOLEAN = re.compile(r"^\s*gen_(tunable|bool)\(\s*([\w\$]*)\s*,\s*(true|false)\s*\)")
+TEMPLATE_BOOLEAN = re.compile(r"^\s*gen_(tunable|bool)\(\s*\`?\s*([\w\$]*)\s*\'?\s*,\s*(true|false)\s*\)")

# Matches a XML comment in the policy, which is defined as any line starting
# with two # and at least one character of white space. Will give the single
--
2.13.6


2017-11-28 17:16:49

by sven.vermeulen

[permalink] [raw]
Subject: [refpolicy] [PATCH 8/8] Fix regexp for templated boolean generation

Wait with applying this one, I get other issues :-(

First dinner, then continue.

On Tue, Nov 28, 2017 at 6:06 PM, Sven Vermeulen
<[email protected]> wrote:
> In the previous patch set, logic was added to ignore XML comments in a
> template when generating the template or interface documentation, and
> when that XML comment is not attributable to the template or interface
> itself. This was accomplished by matching for a templated boolean or
> tunable generation statement.
>
> Sadly, the regular expression for it did not include the necessary
> backtick and (forward) tick detection which is part of such statements:
>
> gen_tunable(`$1_something', false)
> versus
> gen_tunable(domain_something, false)
>
> In this patch, the regular expression is updated to support this
> situation.
>
> Signed-off-by: Sven Vermeulen <[email protected]>
> ---
> support/segenxml.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/support/segenxml.py b/support/segenxml.py
> index 46a4a720..2ed4068a 100644
> --- a/support/segenxml.py
> +++ b/support/segenxml.py
> @@ -44,7 +44,7 @@ INTERFACE = re.compile(r"^\s*(interface|template)\(`(\w*)'")
> # "gen_tunable(allow_kerberos, false)"
> # -> ("tunable", "allow_kerberos", "false")
> BOOLEAN = re.compile(r"^\s*gen_(tunable|bool)\(\s*(\w*)\s*,\s*(true|false)\s*\)")
> -TEMPLATE_BOOLEAN = re.compile(r"^\s*gen_(tunable|bool)\(\s*([\w\$]*)\s*,\s*(true|false)\s*\)")
> +TEMPLATE_BOOLEAN = re.compile(r"^\s*gen_(tunable|bool)\(\s*\`?\s*([\w\$]*)\s*\'?\s*,\s*(true|false)\s*\)")
>
> # Matches a XML comment in the policy, which is defined as any line starting
> # with two # and at least one character of white space. Will give the single
> --
> 2.13.6
>