[apparmor] internal layout of NetworkRule class / __init__() parameters
Christian Boltz
apparmor at cboltz.de
Fri Dec 19 23:57:05 UTC 2014
Hello,
how should the __init__() parameters for NetworkRule look like?
a) domain, type_or_protocol
b) domain, type, protocol
c) first_param, second_param (that's what the current code does, BTW)
d) ???
Feedback welcome - ideally before I start implementing the NetworkRule class ;-)
With methods a) and c) both parameters would be required (string or ALL),
which would make creating a NetworkRule object quite easy:
foo = NetworkRule('inet', 'tcp')
With method b) we'd probably have to make all 3 parameters optional to
avoid that we'll end up with something like
foo = NetworkRule ('inet', None, 'tcp')
but we'll need to use
foo = NetworkRule ('inet', protocol='tcp')
and I'm not sure if we really want that ;-)
Kshitij already answered on IRC:
<kshitij8> In lack of context I'd say b) seems better or maybe 2 constructors?
<cboltz> the syntax of a network rule is
<cboltz> NETWORK RULE = 'network' [ [ DOMAIN [ TYPE | PROTOCOL ] ] | [ PROTOCOL ] ] ','
<cboltz> (from the apparmor.d manpage fixed today ;-)
<cboltz> the reason for proposing a) is that having type and protocol in the same rule is impossible, so we could argue that separating it is useless work ;-)
<kshitij8> multiple constructor seems better.. would reflect the syntax clearly...
<kshitij8> even if they're just used as a wrapper
* kshitij8 wonders if default parameters are more pythonic
<cboltz> optional parameters could indeed be the way to go
<cboltz> but that still doesn't answer which parameter style we want ;-)
<kshitij8> I vote for style b)
<kshitij8> This is democratic voting right?
<cboltz> yes ;-)
<cboltz> but I still hope for an answer from sbeattie
<kshitij8> send it over to ml maybe if he's away.
<cboltz> I'll do that if he doesn't answer in the next hours
Regards,
Christian Boltz
--
Was hat ein Revolver mit Windows 98 gemeinsam?
Solange sie nicht geladen sind, sind sie harmlos.
More information about the AppArmor
mailing list