[apparmor] Skippable files

John Johansen john.johansen at canonical.com
Mon May 28 19:52:19 UTC 2012


On 05/28/2012 11:07 AM, Nicolas Valcárcel wrote:
> Oh you meant using parser's is_skippable instead of own function, sorry, read it quite distracted. I'm not complete familiar with the parser code, but i can take a look to see if i can.
> 
Its C, C++ so no you really don't want to, but we will be able to provide one via the library soon.
Just use yours for now and when the library routine is in place then we can drop that in its place.
 
> On Mon, May 28, 2012 at 1:03 PM, Nicolas Valcárcel <nvalcarcel at corpb2c.com <mailto:nvalcarcel at corpb2c.com>> wrote:
> 
>     yes, i'm writing it, here is the code i'm using, last regexp is the one i'm asking for, it seems to be working, but i'll test it further before using it in production:
> 
>     def is_skippable_file(filename):
>         '''Returns True if file is skippable'''
> 
>         regexps = ['.*\.rpm(save|new)$',
>                    '.*\.dpkg-(old|new)$',
>                    '.*\.swp$',
>                    '.*~$',
>                    '(^|.*/)\.(?!.*\/.*)']
> 
>         for regexp in regexps:
>             if re.match(regexp, filename):
>                 return True
> 
>         return False
> 
> 
>     On Mon, May 28, 2012 at 12:53 PM, Seth Arnold <seth.arnold at gmail.com <mailto:seth.arnold at gmail.com>> wrote:
> 
>         I'd love to see the tools and parser using the exact same code to figure out which files to skip. Is there an exported library call that could be used in the tools to replace this function?
> 
>         -----Original Message-----
>         From: John Johansen <john.johansen at canonical.com <mailto:john.johansen at canonical.com>>
>         Sender: apparmor-bounces at lists.ubuntu.com <mailto:apparmor-bounces at lists.ubuntu.com>
>         Date: Mon, 28 May 2012 10:19:29
>         To: Nicolas Valcárcel<nvalcarcel at corpb2c.com <mailto:nvalcarcel at corpb2c.com>>
>         Cc: <apparmor at lists.ubuntu.com <mailto:apparmor at lists.ubuntu.com>>
>         Subject: Re: [apparmor] Skippable files
> 
>         On 05/28/2012 09:23 AM, Nicolas Valcárcel wrote:
>         > Hi, i'm working on rewriting to python3 some apparmor tools, but i'm not a perl expert, nor know apparmor in deep, so i got a stopper here that i hope you can help me with.
>         >
>         hey Nicolas
> 
>         > In Immunix/AppArmor.pm there is a function isSkippableFile which has a regexp i don't understand:
>         > $path =~ /(^|\/)\.[^\/]*$/               <--- this one i don't understand
>         dot files, but looking at it, it has an issue
>          '.' followed by anything that is not a path
>         or
>          '/.' followed by anything that is not a path, note the leading '/' is not anchored
> 
>         so
> 
>          .
>          ..
>          .foo
>          /.
>          /..
>          /.foo
>          bar/.foo
>          /bar/.foo
> 
>          but not
> 
>          ./
>          .foo/
>          .foo/bar
>          /.foo/
>          /.foo/bar
> 
>         now for where it has a problem, since the leading '/' is unanchored
>          /.foo/.bar
> 
>         will match
> 
> 
>         > $path =~ /\.rpm(save|new)$/       <--- this would be anything ending in .rpmsave or .rpmnew?
>         yes
> 
>         > $path =~ /\.dpkg-(old|new)$/       <--- this would be anything ending in .dpkg-old or .dpkg-new?
>         yes
> 
>         > $path =~ /\.swp$/                      <--- this would be anything ending in .swp?
>         yes
> 
>         > $path =~ /\~$/);                         <--- this would be anything ending in ~?
>         >
>         yes
> 
>         --
>         AppArmor mailing list
>         AppArmor at lists.ubuntu.com <mailto:AppArmor at lists.ubuntu.com>
>         Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
> 
> 
> 
> 
>     -- 
>     Nicolas Valcárcel
>     Gerente IT / CTO
>     Celular: (511) 976 330 707
> 
> 
> 
> 
> -- 
> Nicolas Valcárcel
> Gerente IT / CTO
> Celular: (511) 976 330 707
> 




More information about the AppArmor mailing list