forked from greenbone/openvas-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_license_headers.bash
More file actions
executable file
·33 lines (27 loc) · 1 KB
/
check_license_headers.bash
File metadata and controls
executable file
·33 lines (27 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
function comment_string () {
ext=$1
if [[ $ext == "c" || $ext == "h" || $ext == "rs" ]]; then
echo "//"
elif [[ $ext == "nasl" || $ext == "cmake" ]]; then
echo "#"
fi
}
any_missing_headers=0
exts="c h nasl cmake"
for ext in $exts; do
find . -not -path "./rust/target/*" -not -path "./rust/crates/nasl-c-lib/tmp/*" -regex ".*\.\($ext\)" -print0 | while read -d $'\0' f; do
header=$(head -n 3 "$f")
if ! [[ "$header" =~ SPDX ]]; then
echo "File does not contain license header: $f"
any_missing_headers=1
if [[ "$1" == add_header ]]; then
tmpfile=$(mktemp)
cp "$f" "$tmpfile"
comment=$(comment_string $ext)
echo -e "$comment SPDX-FileCopyrightText: 2025 Greenbone AG\n$comment\n$comment SPDX-License-Identifier: GPL-2.0-or-later WITH x11vnc-openssl-exception\n" | cat - $tmpfile > "$f"
fi
fi
done
done
exit $any_missing_headers