mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2024-11-14 23:43:56 +01:00
tests(check): also checks files header.
This commit is contained in:
parent
04df705272
commit
3a6844c8ce
@ -10,6 +10,21 @@ set -eu -o pipefail
|
|||||||
|
|
||||||
readonly APPARMORD="apparmor.d"
|
readonly APPARMORD="apparmor.d"
|
||||||
|
|
||||||
|
_ensure_header() {
|
||||||
|
local file="$1"
|
||||||
|
headers=(
|
||||||
|
"# apparmor.d - Full set of apparmor profiles"
|
||||||
|
"# Copyright (C) "
|
||||||
|
"# SPDX-License-Identifier: GPL-2.0-only"
|
||||||
|
)
|
||||||
|
for header in "${headers[@]}"; do
|
||||||
|
if ! grep -q "^$header" "$file"; then
|
||||||
|
echo "$file does not contain '$header'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
_ensure_include() {
|
_ensure_include() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local include="$2"
|
local include="$2"
|
||||||
@ -37,6 +52,7 @@ _ensure_vim() {
|
|||||||
|
|
||||||
check_profiles() {
|
check_profiles() {
|
||||||
echo "⋅ Checking if all profiles contain:"
|
echo "⋅ Checking if all profiles contain:"
|
||||||
|
echo " - apparmor.d header & license"
|
||||||
echo " - 'abi <abi/4.0>,'"
|
echo " - 'abi <abi/4.0>,'"
|
||||||
echo " - 'profile <profile_name>'"
|
echo " - 'profile <profile_name>'"
|
||||||
echo " - 'include if exists <local/*>'"
|
echo " - 'include if exists <local/*>'"
|
||||||
@ -50,6 +66,7 @@ check_profiles() {
|
|||||||
name="$(basename "$file")"
|
name="$(basename "$file")"
|
||||||
name="${name/.apparmor.d/}"
|
name="${name/.apparmor.d/}"
|
||||||
include="include if exists <local/$name>"
|
include="include if exists <local/$name>"
|
||||||
|
_ensure_header "$file"
|
||||||
_ensure_include "$file" "$include"
|
_ensure_include "$file" "$include"
|
||||||
_ensure_abi "$file"
|
_ensure_abi "$file"
|
||||||
_ensure_vim "$file"
|
_ensure_vim "$file"
|
||||||
@ -71,11 +88,13 @@ check_profiles() {
|
|||||||
|
|
||||||
check_abstractions() {
|
check_abstractions() {
|
||||||
echo "⋅ Checking if all abstractions contain:"
|
echo "⋅ Checking if all abstractions contain:"
|
||||||
|
echo " - apparmor.d header & license"
|
||||||
echo " - 'abi <abi/4.0>,'"
|
echo " - 'abi <abi/4.0>,'"
|
||||||
echo " - 'include if exists <abstractions/*.d>'"
|
echo " - 'include if exists <abstractions/*.d>'"
|
||||||
echo " - vim:syntax=apparmor"
|
echo " - vim:syntax=apparmor"
|
||||||
directories=(
|
directories=(
|
||||||
"$APPARMORD/abstractions/" "$APPARMORD/abstractions/app/"
|
"$APPARMORD/abstractions/" "$APPARMORD/abstractions/app/"
|
||||||
|
"$APPARMORD/abstractions/attached/"
|
||||||
"$APPARMORD/abstractions/bus/" "$APPARMORD/abstractions/common/"
|
"$APPARMORD/abstractions/bus/" "$APPARMORD/abstractions/common/"
|
||||||
)
|
)
|
||||||
for dir in "${directories[@]}"; do
|
for dir in "${directories[@]}"; do
|
||||||
@ -83,6 +102,7 @@ check_abstractions() {
|
|||||||
name="$(basename "$file")"
|
name="$(basename "$file")"
|
||||||
root="${dir/${APPARMORD}\/abstractions\//}"
|
root="${dir/${APPARMORD}\/abstractions\//}"
|
||||||
include="include if exists <abstractions/${root}${name}.d>"
|
include="include if exists <abstractions/${root}${name}.d>"
|
||||||
|
_ensure_header "$file"
|
||||||
_ensure_include "$file" "$include"
|
_ensure_include "$file" "$include"
|
||||||
_ensure_abi "$file"
|
_ensure_abi "$file"
|
||||||
_ensure_vim "$file"
|
_ensure_vim "$file"
|
||||||
|
Loading…
Reference in New Issue
Block a user