Skip to content

Commit

Permalink
Alleged fix for docker-compose
Browse files Browse the repository at this point in the history
Refs #47
  • Loading branch information
bviktor committed Apr 1, 2020
1 parent 07c6634 commit 2cbfc58
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions ansible/roles/docker/files/authz.rego
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,35 @@ unconfined
# prohibit access to the host file system outside /home
# which would essentially grant root privileges to the user

valid_host_path_prefixes = {"home/", "proc/", "tmp/.X11-unix", "dev/shm"}
valid_host_path_prefixes = {"/home/", "/proc/", "/tmp/.X11-unix", "/dev/shm"}

# binds
# `docker run -v /:/host-root`

host_bind_paths[trimmed]
{
# run example:
# /:/host-root
#
# compose example:
# dockertest_shared_vol:/:rw

input.Body.HostConfig.Binds[_] = bind
split(bind, ":", parts)
trim(parts[0], "/", trimmed)

# find the first / occurence, it is guaranteed to exist
slashindex := indexof(bind, "/")

# take the remainder, '/:/host-root' or '/:rw'
afterslash := substring(bind, slashindex, -1)

# split into array via ':' delimiter
parts := split(afterslash, ":")

# '/' in both cases, magic!
trimmed := parts[0]

# TODO why did they trim leading slashes?
#trim(parts[0], "/", trimmed)
}

valid_host_bind_paths[host_path]
Expand All @@ -50,7 +69,10 @@ valid_bind_mapping_whitelist
host_mount_paths[trimmed]
{
input.Body.HostConfig.Mounts[_] = mount
trim(mount.Source, "/", trimmed)
trimmed := mount.Source

# TODO why did they trim leading slashes?
#trim(mount.Source, "/", trimmed)
}

valid_host_mount_paths[host_path]
Expand Down

0 comments on commit 2cbfc58

Please sign in to comment.