# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2026 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{lib}/docker/cli-plugins/docker-buildx
@{att} = /att/docker-buildx/
profile docker-buildx /{,usr/}lib{,exec,32,64}/docker/cli-plugins/docker-buildx flags=(attach_disconnected,attach_disconnected.path=@{att}) {
  include <abstractions/attached/base>
  include <abstractions/attached/consoles>
  include <abstractions/attached/nameservice-strict>
  include <abstractions/ssl_certs>

  network inet dgram,
  network inet stream,
  network inet6 dgram,
  network inet6 stream,
  network netlink raw,

  unix (connect send receive) type=stream peer=(label=docker, addr=@docker_cli_@{hex32}),

  @{exec_path} mr,

  @{bin}/git px, # TODO: cx

  owner @{user_config_dirs}/docker/.token_seed rw,
  owner @{user_config_dirs}/docker/.token_seed.lock rwk,
  owner @{user_config_dirs}/docker/buildx/ rw,
  owner @{user_config_dirs}/docker/buildx/** rwk,

        /tmp/ r,
  owner /tmp/dockerfile@{int10}/{,**} rw,

  @{run}/docker.sock rw,

        @{PROC}/ r,
  owner @{PROC}/@{pid}/cgroup r,
  owner @{PROC}/@{pid}/mountinfo r,

  include if exists <local/docker-buildx>
}

# vim:syntax=apparmor
