2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +00:00

8293 Commits

Author SHA1 Message Date
Julia Sarris
d9d1776579 add owner back to rule lines 2025-06-02 16:29:57 -04:00
Julia Sarris
edf42d4f79 nameservice strict 2025-06-02 09:58:53 -04:00
Julia Sarris
f382920950 private files strict 2025-06-02 09:50:44 -04:00
Julia Sarris
3356f5ea0a Merge branch apparmor:master into master 2025-06-02 13:50:13 +00:00
John Johansen
e80ebea43f Merge Allow noexec mounts in fusermount3 profile
The permissive flags should be revisited once we have rule delegation

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1704
Approved-by: John Johansen <john@jjmx.net>
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2025-06-01 05:24:31 +00:00
John Johansen
df41185eb2 profiles: provide backwards compat for hwctl profile
The hwctl profile is being carried upstream, so we can keep it in
sync, but is being packaged from the regular profile set so that it
can be part of a package that is SRUed (ubuntu stable release update)
separate from the rest of apparmor, and its profiles.

Provide backwards compat with older parser to reduce the amount of
distro patching that is needed.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-05-30 13:24:17 -07:00
John Johansen
421558041b Merge Add additional mount regression tests for options= options in combo
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1703
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2025-05-30 18:26:10 +00:00
Christian Boltz
d315f2b279 Merge logprof: improve LOGPROF-SUGGEST metadata for abstractions
Many profile MRs created with aa-logprof come with abstractions
unrelated to the confined application. This MR allow to restrict
proposed abstractions to related profiles.

Improve #LOGPROF-SUGGEST metadata to support a set of space-separated
regexes. If this tag is present, the abstraction is only proposed to
aa-logprof if one of the regexes is matched.

If this abstraction should not be proposed to any profile, it is
possible to tell #LOGPROF-SUGGEST: no

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1696
Approved-by: Christian Boltz <apparmor@cboltz.de>
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-05-28 15:52:35 +00:00
Maxime Bélair
e637884554 logprof: improve LOGPROF-SUGGEST metadata for abstractions
Improve #LOGPROF-SUGGEST metadata to support a set of space-separated
regexes. If this tag is present, the abstraction is only proposed to
aa-logprof if one of the regexes is matched.

If this abstraction should not be proposed to any profile, it is
possible to tell #LOGPROF-SUGGEST: no

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-28 15:47:03 +02:00
Ryan Lee
f826e1dbea Allow noexec mounts in fusermount3 profile
The permissive flags should be revisited once we have rule delegation

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-27 15:40:21 -04:00
Ryan Lee
6e16efe703 Add additional mount regression tests for options= options in combo
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-27 14:40:26 -04:00
Christian Boltz
0ee95d7e38 Merge utils: Introduce aa-show-usage for profile usage analysis
Introduce aa-show-usage, a new helper allowing to determine which
profiles on the system are used and which are not. A profile is marked as
used when at least one file installed in the machine matches the attach point
specified in the profile.

This tool supports filtering options, allowing users to, for example,
display only unconfined profiles that are currently in use. This can
notably help sysadmins to evaluate the security of their systems.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1612
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-05-26 20:46:56 +00:00
Maxime Bélair
b46f7a426c Add support for --show-matching-path and xattrs
The new option --show-matching-path shows a path that matches in the host
filesystem, to prove that the profile is indeed used.

Also, profiles' xattrs are now parsed into a dict and are taken in
consideration when looking for matching profiles.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-26 20:08:38 +00:00
Maxime Bélair
db376c0458 Refactor to use cmd everywhere
Many test provide their own implementation of cmd(). This commit makes
all of them rely on common.py implementation of cmd()

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-26 20:08:38 +00:00
Maxime Bélair
29b4716377 Add a manual entry for aa-show-usage
Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-26 20:08:38 +00:00
Maxime Bélair
229811de9a Add tests for aa-show-usage
Add new tests for aa-show-usage and regex.py, that is internally used by
aa-show-usage

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-26 20:08:38 +00:00
Maxime Bélair
b850f19622 utils: add aa-show-usage for profile usage analysis
Introduce aa-show-usage, a new helper allowing to determine which
profiles on the system are used and which are not. A profile is marked as
used when at least one file installed in the machine matches the attach point
specified in the profile.

This tool supports filtering options, allowing users to, for example,
display only unconfined profiles that are currently in use. This can
notably help sysadmins to evaluate the security of their systems.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-26 20:08:38 +00:00
Georgia Garcia
9f4dfdd57e Merge profiles: remove dpkg and lsb_release usage in usr.bin.hwctl
The [hardware-api client project](https://github.com/canonical/hardware-api/tree/main/client) has been simplified, so now we don't use `dpkg` and `lsb_release` there
This PR removes the sub-profiles for these executables.

Also, some denials were detected while running the `hwctl` binary in lxc, so the profile has been updated to fix it as well. See https://github.com/canonical/hardware-api/issues/319 for more

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1701
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-26 08:58:44 -03:00
Zygmunt Krynicki
2dacf287f2 Merge ci: build test images explicitly when requested
The recent change to make CI pipeline build test images on a manual
trigger masks the outcome of the pipeline. Let's use the new inputs [1]
feature to allow manually triggering the pipeline with an explicitly
built image instead.

[1] https://docs.gitlab.com/ci/inputs/

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1700
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: Zygmunt Krynicki <me@zygoon.pl>
2025-05-25 19:32:30 +02:00
Christian Kujau
34d889f6e9 Use @{int} instead of ranges
Thanks @cboltz for the hint!
2025-05-25 13:06:08 +00:00
Christian Kujau
1e74ae32ea Allow lsblk to access Xen PVH disk devices
For details, please see:
https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2111604
2025-05-23 22:37:45 +00:00
Nadzeya H
cd7586776c
remove dpkg and lsb_release usage in usr.bin.hwctl 2025-05-23 17:16:55 +02:00
Georgia Garcia
2e7da63183 utils: add support for multiple fstypes in mount rules
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-22 15:51:45 -03:00
Zygmunt Krynicki
5aed9e8a50 ci: build test images explicitly when requested
The recent change to make CI pipeline build test images on a manual
trigger masks the outcome of the pipeline. Let's use the new inputs [1]
feature to allow manually triggering the pipeline with an explicitly
built image instead.

[1] https://docs.gitlab.com/ci/inputs/

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-05-22 08:41:15 +02:00
Georgia Garcia
79f2ea72b0 utils: add support for multiple options in mount rules
The tools don't support having multiple options specified in mount
rules as it is allowed in the parser.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-21 17:55:54 -03:00
Maxime Bélair
97dc70606b Merge add apparmor profile for dig
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1525
Approved-by: Ryan Lee <rlee287@yahoo.com>
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-21 14:48:05 +00:00
Shishir Subedi
be143350fd add apparmor profile for dig 2025-05-21 14:48:05 +00:00
Christian Boltz
9fabe25a9f Merge libapparmor/test: avoid writing __pycache__
Having a `__pycache__` on check can result in all kinds of weird issues.
Notaby, the test environment is currently clearing all environment variables,
including those responsible for keeping a reproducible build.
This is not immediately a problem for functionality,
but complicates downstream distribution in systems such as nix, where it is considered a bug [1].

It might also be possible to force determinism by exporting env vars instead:
```
  DETERMINISTIC_BUILD=1
  PYTHONHASHSEED=0
```
This forces a special mode on the pycache, where instead of a `moddate`,
it will then store a hash of the outputs [2].
This would be an alternative fix, but considering apparmor upstream does
not (yet) test for bit-reproducibility, it is likely too fragile here.

[1] https://github.com/NixOS/nixpkgs/issues/409032
[2] https://peps.python.org/pep-0552/

I understand AppArmor might or might not care about deterministic builds.
I was writing this patch for nixpkgs anyways, so I might as well try to
contribute it - whether it gets merged or not.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1697
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-05-21 11:52:39 +00:00
Grimmauld
f584505ac3 libapparmor/test: avoid writing __pycache__
Having a __pycache__ on check can result in all kinds of weird issues.
Notaby, the test environment is currently clearing all environment variables,
including those responsible for keeping a reproducible build.
This is not immediately a problem for functionality,
but complicates downstream distribution in systems such as nix, where it is considered a bug [1].

It might also be possible to force determinism by exporting env vars instead:
```
  DETERMINISTIC_BUILD=1
  PYTHONHASHSEED=0
```
This forces a special mode on the pycache, where instead of a `moddate`,
it will then store a hash of the outputs [2].
This would be an alternative fix, but considering apparmor upstream does
not (yet) test for bit-reproducibility, it is likely too fragile here.

[1] https://github.com/NixOS/nixpkgs/issues/409032
[2] https://peps.python.org/pep-0552/
2025-05-21 11:33:23 +00:00
Julia Sarris
bef7b32d24 john update 2025-05-20 14:42:50 -04:00
Julia Sarris
bece53da7b Merge branch apparmor:master into master 2025-05-20 18:42:03 +00:00
Georgia Garcia
09330c63fa Merge ci: document the GitLab cache hack
We rely on a hack that avoids compressing and pushing the cache if it
has not really changed but it's worth adding links.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1695
Approved-by: Ryan Lee <rlee287@yahoo.com>
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-16 10:20:02 -03:00
Georgia Garcia
4b756c908c Merge ci: allow building the spread image in master
The current logic will only build spread images, for master (which uses
protected cache), when the .image-garden.mk or .gitlab-ci.yml files
change as compared to master. This is great IF they change and WHEN the
cache is hot but right now it seems that this is not the case and master
just has no protected cache.

Add a manual knob to run the one-off cache job whenever we want to.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1694
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-16 10:17:12 -03:00
Zygmunt Krynicki
f9ba11a91e ci: document the GitLab cache hack
We rely on a hack that avoids compressing and pushing the cache if it
has not really changed but it's worth adding links.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-05-16 12:02:59 +02:00
Zygmunt Krynicki
272ad36df8 ci: allow building the spread in master
The current logic will only build spread images, for master (which uses
protected cache), when the .image-garden.mk or .gitlab-ci.yml files
change as compared to master. This is great IF they change and WHEN the
cache is hot but right now it seems that this is not the case and master
just has no protected cache.

Add a manual knob to run the one-off cache job whenever we want to.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-05-16 11:42:13 +02:00
John Johansen
c0e27e0dcb Merge ci: optimise image-* job to skip cache upload if unchanged
This relies on a documented hack that makes GitLab cache machinery
skip the upload if all of the cached files are missing in the tree.

This saves about a minute per pull request CI/CD run times the number of
images required for testing.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1691
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-16 09:33:21 +00:00
John Johansen
559754c6a4 Merge ci: git restore-mtime .image-garden.mk
This fixes the long standing issue affecting caching of the image
between the image-* jobs and the spread-* jobs.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1690
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-16 09:31:09 +00:00
John Johansen
b15a74ed7a Merge ci: make all jobs interruptible
This way they can be automatically cancelled by GitLab when a new commit is pushed
to a merge request, this providing feedback to the tip of the branch or pull request
more rapidly.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1689
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-16 09:29:22 +00:00
Georgia Garcia
170315d35f Merge ci: exclude generated content from spread copy
This allows having a locally-built apparmor tree while using spread to
test against other distributions.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1692
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-16 05:57:17 -03:00
Zygmunt Krynicki
a5bae11cfd ci: exclude generated content from spread copy
This allows having a locally-built apparmor tree while using spread to
test against other distributions.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-05-16 00:26:05 +02:00
Zygmunt Krynicki
81c1b86373 ci: optimise image-* job to skip cache upload if unchanged
This relies on a documented hack that makes GitLab cache machinery
skip the upload if all of the cached files are missing in the tree.

This saves about a minute per pull request CI/CD run times the number of
images required for testing.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-05-15 23:20:27 +02:00
Zygmunt Krynicki
d2d0f36244 ci: git restore-mtime .image-garden.mk
This fixes the long standing issue affecting caching of the image
between the image-* jobs and the spread-* jobs.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-05-15 23:08:45 +02:00
Zygmunt Krynicki
50734c9689 ci: make all jobs interruptible
This way they can be automatically cancelled by GitLab when a new commit is pushed
to a merge request, this providing feedback to the tip of the branch or pull request
more rapidly.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-05-15 20:02:04 +02:00
John Johansen
e55646c41c Merge profiles: only include tests extras/abstractions/ if it exists
profiles make check was showing an error because
profiles/extras/abstractions didn't exist, so only include tests for
it if it exists. This commit also deduplicates the abstractions test.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1687
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-14 12:15:57 +00:00
Georgia Garcia
52da04d951 profiles: only include tests extras/abstractions/ if it exists
profiles make check was showing an error because
profiles/extras/abstractions didn't exist, so only include tests for
it if it exists. This commit also deduplicates the abstractions test.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-14 12:08:01 +02:00
Georgia Garcia
59a636b403 Merge profiles: give lsof network netlink dgram permissions
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1686
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-05-14 05:21:35 -03:00
Ryan Lee
e36b57857f profiles: give lsof network netlink dgram permissions
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-05-14 09:45:53 +02:00
John Johansen
84c3e629e4 Merge unix-chkpwd: Add read capability to profile
Following the Security Technical Implementation Guide, it is better to
set the permissions to 0000 for the shadow file.
However, since PAM version 1.6.0, after this change [0], unix-chkpwd
will unconditionnaly read the shadow file. And with the previous
restriction, the binary has an access denied to the shadow which
blocks user authentications. Moreover the PAM changes is needed to fix
the CVE-2024-10041.
Giving the read caability to the unix-chkpwd profile allows it to
function properly. See bug report [1].

[0] - https://github.com/linux-pam/linux-pam/pull/686
[1] - https://bugzilla.suse.com/show_bug.cgi?id=1241678

Signed-off-by: vlefebvre <valentin.lefebvre@suse.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1685
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-13 16:00:21 +00:00
Maxime Bélair
c8dc701666 Merge Add netcat-openbsd profile
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1327
Approved-by: Maxime Bélair <maxime.belair@canonical.com>
Merged-by: Maxime Bélair <maxime.belair@canonical.com>
2025-05-13 07:22:31 +00:00
John Johansen
527054e0ab Merge utils aa-notify: small tweaks to the merged rule interface
This is a set of small tweaks to the merged rule interface window

- don't specify, font or size when setting bold
- improve message around unknown profiles
- add a custom message for snap profile
- output tktheme missing message, to help users identify they can improve the interface when started manually

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1529
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-05-13 04:11:06 +00:00