[apparmor] [PATCH v2] json support for tools (logprof and genprof)
Seth Arnold
seth.arnold at canonical.com
Wed Mar 22 23:27:55 UTC 2017
On Wed, Mar 22, 2017 at 01:24:04PM -0500, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn at suse.com>
>
> This adds JSON support for tools in order to be able to talk to
> other utilities such as Yast.
>
> The json is one per line, in order to differentiate between multiple
> records. This is based on work presented by Christian Boltz some time
> back.
Hi Goldwyn, thanks for the update. It looks good to me with only the
tineist of concerns -- first, this "one per line" idea. It feels like it'd
be more resilient if instead of using multiple json documents, one per
line, it'd be one json document with an array if an array is needed, and
make the whitespace as unimportant as possible.
Of course I expect yast to be the only consumer of this interface for a
while, so if yast expects multiple json docs, then that's just what it
ought to be. But if this interface is more flexible then I'd suspect that
passing a single json document between processes would be more reliable.
> --- a/utils/aa-genprof
> +++ b/utils/aa-genprof
> @@ -61,8 +61,12 @@ parser = argparse.ArgumentParser(description=_('Generate profile for the given p
> parser.add_argument('-d', '--dir', type=str, help=_('path to profiles'))
> parser.add_argument('-f', '--file', type=str, help=_('path to logfile'))
> parser.add_argument('program', type=str, help=_('name of program to profile'))
> +parser.add_argument('-j', '--json', action="store_true", help=_('provide output in json format'))
> args = parser.parse_args()
> --- a/utils/aa-logprof
> +++ b/utils/aa-logprof
> @@ -16,6 +16,7 @@ import argparse
> import os
>
> import apparmor.aa as apparmor
> +import apparmor.ui as aaui
>
> # setup exception handling
> from apparmor.fail import enable_aa_exception_handler
> @@ -29,8 +30,12 @@ parser = argparse.ArgumentParser(description=_('Process log entries to generate
> parser.add_argument('-d', '--dir', type=str, help=_('path to profiles'))
> parser.add_argument('-f', '--file', type=str, help=_('path to logfile'))
> parser.add_argument('-m', '--mark', type=str, help=_('mark in the log to start processing after'))
> +parser.add_argument('-j', '--json', action='store_true', help=_('provide the output in json format'))
> args = parser.parse_args()
The other thing is that these two --help outputs are different; one is
"the output" and the other is "output'. I think having them identical
would make the tools feel more polished. (Every bit helps.)
Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20170322/74cfffb8/attachment.pgp>
More information about the AppArmor
mailing list