[apparmor] [patch] Add (abstract) get_clean method to baserule

Kshitij Gupta kgupta8592 at gmail.com
Wed Oct 28 19:49:42 UTC 2015


Hi,

On Fri, Oct 23, 2015 at 5:53 PM, Christian Boltz <apparmor at cboltz.de> wrote:

> Hello,
>
> $subject.
>
> Also add a test to ensure it raises an AppArmorBug.
>
>
> [ 05-baserule-add-abstract-get_clean.diff ]
>
> === modified file ./utils/apparmor/rule/__init__.py
> --- utils/apparmor/rule/__init__.py     2015-06-06 14:53:16.868029000 +0200
> +++ utils/apparmor/rule/__init__.py     2015-10-23 14:08:28.639214618 +0200
> @@ -81,6 +85,11 @@
>             required to be implemented by subclasses; raise exception if
> not'''
>          raise AppArmorBug("'%s' needs to implement _parse(), but didn't"
> % (str(cls)))
>
> +    # @abstractmethod  FIXME - uncomment when python3 only
> +    def get_clean(self, depth=0):
> +        '''return clean rule (with default formatting, and leading
> whitespace as specified in the depth parameter)'''
> +        raise AppArmorBug("'%s' needs to implement get_clean(), but
> didn't" % (str(self.__class__)))
>
Should be also give the class a detention? (Sorry couldn't resist)

> +

     def get_raw(self, depth=0):
>          '''return raw rule (with original formatting, and leading
> whitespace in the depth parameter)'''
>          if self.raw_rule:
> === modified file 'utils/test/test-baserule.py'
> --- utils/test/test-baserule.py 2015-06-06 12:04:11 +0000
> +++ utils/test/test-baserule.py 2015-10-23 12:17:53 +0000
> @@ -35,6 +35,11 @@
>          with self.assertRaises(AppArmorBug):
>              BaseRule.match('foo')
>
> +    def test_abstract_get_clean(self):
> +        obj = BaseRule()
> +        with self.assertRaises(AppArmorBug):
> +            obj.get_clean()
> +
>      def test_is_equal_localvars(self):
>          obj = BaseRule()
>          with self.assertRaises(AppArmorBug):
>
>
>
Thanks for the patch.

Acked-by: Kshitij Gupta <kgupta8592 at gmail.com>.

Regards,
>
> Christian Boltz
> --
> > Write the code like you are going to lose your memory in six months.
> Most people would say I write code like I've already lost my mind.
> Is that the same thing?   [Randal L. Schwartz]
>
haha... laughed out loud for real. :-)

>
>
> --
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/apparmor
>



-- 
Regards,

Kshitij Gupta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20151029/aea6367d/attachment.html>


More information about the AppArmor mailing list