Skip to content

Commit

Permalink
Add github workflow for license header check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Jan 7, 2025
1 parent 0c3adac commit 12d9ffe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ jobs:
- uses: actions/checkout@v4
- run: cargo install cargo-audit
- run: cargo audit
License-Headers:
runs-on: ubuntu-latest
steps:
- name: Check out openvas-scanner
uses: actions/checkout@v4
- name: Check license headers
run: bash ./check_license_headers.sh
Empty file modified check_license_header.sh
100755 → 100644
Empty file.
18 changes: 18 additions & 0 deletions check_license_headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
any_missing_headers=0

for folder in src misc rust/src; do
echo "Checking $folder"
for f in $(find $folder -regex ".*\.\(rs\|c\|h\)"); 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
echo -e "// SPDX-FileCopyrightText: 2025 Greenbone AG\n //\n// SPDX-License-Identifier: GPL-2.0-or-later WITH x11vnc-openssl-exception\n\n$(cat $f)" > $f
fi
fi
done
done

exit $any_missing_headers

0 comments on commit 12d9ffe

Please sign in to comment.