|
| 1 | +abi <abi/3.0>, |
| 2 | +#include <tunables/global> |
| 3 | +profile apparmor_profile /home/sandbox/codejail_sandbox-python{3.[0-9],3.[1-9][0-9]}/bin/python { |
| 4 | + #include <abstractions/base> |
| 5 | + #include <abstractions/python> |
| 6 | + |
| 7 | + # Deny network access and socket operations |
| 8 | + # Note: If this profile is being run on a docker container |
| 9 | + # then this directive might not be sufficient. Docker network |
| 10 | + # interfaces are created in a different namespace from the one that |
| 11 | + # apparmor can monitor and manage and so apparmor can't always deny |
| 12 | + # network access to the container. Please be sure to test |
| 13 | + # network access from within your container for the jailed process |
| 14 | + # to be sure that everything is secure. |
| 15 | + deny network, |
| 16 | + |
| 17 | + /usr/{local/,}lib{,32,64}/python{2.[4-7],3,3.[0-9],3.[1-9][0-9]}/**.{pyc,so,so.*[0-9]} mr, |
| 18 | + /usr/{local/,}lib{,32,64}/python{2.[4-7],3,3.[0-9],3.[1-9][0-9]}/**.{egg,py,pth} r, |
| 19 | + /usr/{local/,}lib{,32,64}/python{2.[4-7],3,3.[0-9],3.[1-9][0-9]}/{site,dist}-packages/ r, |
| 20 | + /usr/{local/,}lib{,32,64}/python{2.[4-7],3,3.[0-9],3.[1-9][0-9]}/{site,dist}-packages/**/ r, |
| 21 | + /usr/{local/,}lib{,32,64}/python{2.[4-7],3,3.[0-9],3.[1-9][0-9]}/{site,dist}-packages/*.dist-info/{METADATA,namespace_packages.txt} r, |
| 22 | + /usr/{local/,}lib{,32,64}/python{2.[4-7],3,3.[0-9],3.[1-9][0-9]}/{site,dist}-packages/*.VERSION r, |
| 23 | + /usr/{local/,}lib{,32,64}/python{2.[4-7],3,3.[0-9],3.[1-9][0-9]}/{site,dist}-packages/*.egg-info/PKG-INFO r, |
| 24 | + /usr/{local/,}lib{,32,64}/python3.{1,}[0-9]/lib-dynload/*.so mr, |
| 25 | + |
| 26 | + # Site-wide configuration |
| 27 | + /etc/python{2.[4-7],3.[0-9],3.[1-9][0-9]}/** r, |
| 28 | + |
| 29 | + # shared python paths |
| 30 | + /usr/share/{pyshared,pycentral,python-support}/** r, |
| 31 | + /{var,usr}/lib/{pyshared,pycentral,python-support}/** r, |
| 32 | + /usr/lib/{pyshared,pycentral,python-support}/**.so mr, |
| 33 | + /var/lib/{pyshared,pycentral,python-support}/**.pyc mr, |
| 34 | + /usr/lib/python3/dist-packages/**.so mr, |
| 35 | + |
| 36 | + # wx paths |
| 37 | + /usr/lib/wx/python/*.pth r, |
| 38 | + |
| 39 | + # python build configuration and headers |
| 40 | + /usr/include/python{2.[4-7],3.[0-9],3.[1-9][0-9]}*/pyconfig.h r, |
| 41 | + |
| 42 | + # Include additions to the abstraction |
| 43 | + include if exists <abstractions/python.d> |
| 44 | + |
| 45 | + /home/sandbox/codejail_sandbox-python{3.[0-9],3.[1-9][0-9]}/** mr, |
| 46 | + /tmp/codejail-*/ rix, |
| 47 | + /tmp/codejail-*/** wrix, |
| 48 | + |
| 49 | + # Whitelist particiclar shared objects from the system |
| 50 | + # python installation |
| 51 | + # |
| 52 | + /usr/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/_json.so mr, |
| 53 | + /usr/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/_ctypes.so mr, |
| 54 | + /usr/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/_heapq.so mr, |
| 55 | + /usr/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/_io.so mr, |
| 56 | + /usr/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/_csv.so mr, |
| 57 | + /usr/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/datetime.so mr, |
| 58 | + /usr/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/_elementtree.so mr, |
| 59 | + /usr/lib/python{3.[0-9],3.[1-9][0-9]}/lib-dynload/pyexpat.so mr, |
| 60 | + # |
| 61 | + # Allow access to selections from /proc |
| 62 | + # |
| 63 | + /proc/*/mounts r, |
| 64 | +} |
0 commit comments