-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i/builtin: add auditd-support interface #14811
base: master
Are you sure you want to change the base?
i/builtin: add auditd-support interface #14811
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #14811 +/- ##
==========================================
+ Coverage 78.20% 78.22% +0.01%
==========================================
Files 1151 1157 +6
Lines 151396 152850 +1454
==========================================
+ Hits 118402 119560 +1158
- Misses 25662 25905 +243
- Partials 7332 7385 +53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
7221942
to
ec2c000
Compare
The current This requires root and
Thus, so this should be an excellent way of probing whether we have access to The only hard part is that we need |
Shellcheck is flipping out about all the horribleness in the |
It may be helpful to add something which runs |
The netlink socket and network added in fd5b03b is needed for auditd to function, as shown here:
|
Once we settle on precisely what needs to be tested (perhaps |
Spread test is failing because apparently reading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the spread test, that is great. However, I do not think we should have the content of the snap with all its binaries, it would be better to simply have snapcraft.yaml
and files needed by the recipe in the repo and publish in the store the built snap, possibly registered by the [email protected]
user.
Otherwise I have a couple of minor comments.
run-checks
Outdated
@@ -242,6 +242,9 @@ if [ "$STATIC" = 1 ]; then | |||
|
|||
if command -v shellcheck >/dev/null; then | |||
exclude_tools_path=tests/lib/external/snapd-testing-tools | |||
exclude_test_snapd_audit_control_auditd=tests/main/interfaces-audit-control/test-snapd-audit-control/etc/init.d/auditd | |||
exclude_test_snapd_audit_control_augenrules=tests/main/interfaces-audit-control/test-snapd-audit-control/sbin/augenrules | |||
excluded="$exclude_tools_path $exclude_test_snapd_audit_control_auditd $exclude_test_snapd_audit_control_augenrules" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could consider using a bash array here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this, but it didn't work (shellcheck was mad about snapd-testing-tools
). Do you see what would be wrong?
diff --git a/run-checks b/run-checks
index c6b2c9d1e4..5b87c01778 100755
--- a/run-checks
+++ b/run-checks
@@ -242,9 +242,7 @@ if [ "$STATIC" = 1 ]; then
if command -v shellcheck >/dev/null; then
exclude_tools_path=tests/lib/external/snapd-testing-tools
- exclude_test_snapd_audit_control_auditd=tests/main/interfaces-audit-control/test-snapd-audit-control/etc/init.d/auditd
- exclude_test_snapd_audit_control_augenrules=tests/main/interfaces-audit-control/test-snapd-audit-control/sbin/augenrules
- excluded="$exclude_tools_path $exclude_test_snapd_audit_control_auditd $exclude_test_snapd_audit_control_augenrules"
+ excluded=("$exclude_tools_path" "tests/main/interfaces-audit-control/test-snapd-audit-control/etc/init.d/auditd" "tests/main/interfaces-audit-control/test-snapd-audit-control/sbin/augenrules")
echo "Checking shell scripts..."
if [ -n "$CHANGED_FILES" ]; then
echo "Checking just the changed bash files"
@@ -259,13 +257,7 @@ if [ "$STATIC" = 1 ]; then
echo "Filtering files"
FILTERED_FILES=
for file in $INITIAL_FILES; do
- include_file=true
- for excl in $excluded; do
- if echo "$file" | grep -q "$excl" ; then
- include_file=false
- fi
- done
- if [ "$include_file" = true ] ; then
+ if [[ ! "${excluded[*]}" =~ ${file} ]] ; then
FILTERED_FILES="$FILTERED_FILES $file"
fi
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will still need the inner for loop, something like this would work:
for excl in "${excluded[@]}"; do
if [ "$excl" = "$file" ]
then include_file=false
fi
done
I mentioned using [[...]]
as it supports regex but I think that here the match is actually exact.
run-checks
Outdated
if ! echo "$file" | grep -q "$exclude_tools_path"; then | ||
include_file=true | ||
for excl in $excluded; do | ||
if echo "$file" | grep -q "$excl" ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and compare here using globbing and [[ ... ]]
This sounds good to me, though is it possible to publish a snap to the store which plugs an interface which doesn't yet exist in snapd (or review tools)? My thought is I could strip out everything not strictly required for the minimal spread test (e.g. just keep the If there's a way to get a snap in the store which plugs the |
I suppose an alternative would be for us to build the snap inside the spread test, for now, but I think that's probably worse. |
4ef6ccb
to
86759ab
Compare
I fixed the spread test, by the way. It now tries to read loginuid and sessionid for all processes. This succeeds when the interface is connected and fails when it's not. |
The plan is to upload |
I've requested ownership of the The repo for the snap is (for now) here: https://github.com/olivercalder/test-snapd-audit-control |
58862e9
to
60db9c6
Compare
Rebased due to testing backend changes on master. |
Publishing of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! Looks good, my only comment is that I would really prefer to have sources for test-snapd-audit-control
under tests/lib/snaps/
, it is really just 5/6 text files and we would have more control this way, even if we use the one from the store.
Do you mean have a copy of the |
Yes, I refer to the file in the |
The plan is to transfer repo ownership to the Canonical org and then move snap ownership as well. Do you think there should be no external repo at all, and instead just have the snapcraft sources in the snapd repo? Also, I see most snaps which have |
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
…it-control Signed-off-by: Oliver Calder <[email protected]>
…ginuid,sessionid} Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
…e related names/comments Signed-off-by: Oliver Calder <[email protected]>
…id's loginuid and sessionid Signed-off-by: Oliver Calder <[email protected]>
…auditd.state Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
Signed-off-by: Oliver Calder <[email protected]>
…-support Signed-off-by: Oliver Calder <[email protected]>
For some reason, on Ubuntu 16.04, /proc/*/{loginuid,sessionid} are always readable when run in GitHub CI, whether or not the auditd-support interface is connected, so skip that check for permission denial on 16.04. Signed-off-by: Oliver Calder <[email protected]>
af2beeb
to
aafc359
Compare
Rebased to pull in test fixes. |
This PR is ready for re-review. |
Add an interface which grants the
audit_control
capability, along with some required paths forauditd
to function properly.This work is tracked internally by https://warthogs.atlassian.net/browse/SNAPDENG-34214