[apparmor] [patch] move regexes from aa.py to regex.py

Steve Beattie steve at nxnw.org
Wed Nov 12 22:42:58 UTC 2014


On Wed, Nov 12, 2014 at 12:30:11AM +0100, Christian Boltz wrote:
> Hello,
> 
> Am Mittwoch, 12. November 2014 schrieb Kshitij Gupta:
> > On Wed, Nov 12, 2014 at 1:06 AM, Christian Boltz wrote:
> > > this patch moves the profile parsing regexes from aa.py to a new
> > > file, regex.py, and adds an "import" line so that they are still
> > > available in aa.py.
> > > 
> > > This is needed to avoid circular dependencies in the rule classes
> > > (aa.py will need to import the rule classes, which also means they
> > > can't import something from aa.py)
> > > 
> > > 
> > Its actually a good thing, the rule classes should be as stand-alone 
> > as possible (specially not dependent on the aa.py, which is arguably 
> > the most unstable piece of code in there).
> 
> Indeed, that's a nice side effect ;-)
> 
> > > === modified file 'utils/apparmor/aa.py'
> > > --- utils/apparmor/aa.py        2014-11-09 00:33:40 +0000
> > > +++ utils/apparmor/aa.py        2014-11-10 23:27:53 +0000
> > > @@ -40,8 +41,9 @@
> > > 
> > >                               mode_to_str_user, mode_contains,
> > >                               AA_OTHER,
> > >                               flatten_mode, owner_flatten_mode)
> > > 
> > > +from apparmor.regex import *
> > 
> > Hmm would it be better to import the regex's in a seperate namespace?
> 
> I wanted to make this patch as small and simple as possible and 
> therefore decided to import the regexes into the main namespace.
>
> Using another namespace would be another patch (with _lots of_ little 
> changes). However, I'm more focusing on the rule classes currently so I 
> won't do this in the next weeks.

Another alternative would be explicitly name all the regex
symbols, rather than glob them in (which also makes pyflakes cry,
I believe). Ugly, but doesn't require modifying things all over the
place except for the import statement, and also drives the point home
that these regexs really ought to be hidden away as an implementation
detail inside a Parser class, not global symbols.

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20141112/20462f2f/attachment.pgp>


More information about the AppArmor mailing list