From 8a88e8ff674ff098cb0ed6666e6886cbd443e452 Mon Sep 17 00:00:00 2001 From: Dimitri Bouniol Date: Sat, 1 Feb 2025 13:30:57 -0800 Subject: [PATCH] Replaced soundness script with the official check Fixes #97 --- .github/workflows/pull_request.yml | 1 - .license_header_template | 12 +++ README.md | 7 ++ scripts/soundness.sh | 119 ----------------------------- 4 files changed, 19 insertions(+), 120 deletions(-) create mode 100644 .license_header_template delete mode 100755 scripts/soundness.sh diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f9492fc0..a09181e5 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,7 +12,6 @@ jobs: license_header_check_project_name: "Swift WebAuthn" shell_check_enabled: false format_check_enabled: false - license_header_check_enabled: false docs_check_enabled: false unit-tests: diff --git a/.license_header_template b/.license_header_template new file mode 100644 index 00000000..189471c3 --- /dev/null +++ b/.license_header_template @@ -0,0 +1,12 @@ +@@===----------------------------------------------------------------------===@@ +@@ +@@ This source file is part of the Swift WebAuthn open source project +@@ +@@ Copyright (c) YEARS the Swift WebAuthn project authors +@@ Licensed under Apache License v2.0 +@@ +@@ See LICENSE.txt for license information +@@ +@@ SPDX-License-Identifier: Apache-2.0 +@@ +@@===----------------------------------------------------------------------===@@ diff --git a/README.md b/README.md index f1297851..e1f604f1 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,13 @@ For an authentication ceremony use the following two methods: - `WebAuthnManager.beginAuthentication()` - `WebAuthnManager.finishAuthentication()` +## Contributing + +If you add any new files, please run the following command at the root of the repo to identify any missing license headers: +```bash +% PROJECTNAME="Swift WebAuthn" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-license-header.sh)" +``` + ## Credits Swift WebAuthn is heavily inspired by existing WebAuthn libraries like diff --git a/scripts/soundness.sh b/scripts/soundness.sh deleted file mode 100755 index aca40cdb..00000000 --- a/scripts/soundness.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -##===----------------------------------------------------------------------===## -## -## This source file is part of the Swift WebAuthn open source project -## -## Copyright (c) 2022 the Swift WebAuthn project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## - -set -eu -here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -function replace_acceptable_years() { - # this needs to replace all acceptable forms with 'YEARS' - sed -e 's/20[12][78901234]-20[12][8901234]/YEARS/' -e 's/20[12][8901234]/YEARS/' -} - -printf "=> Checking for unacceptable language... " -# This greps for unacceptable terminology. The square bracket[s] are so that -# "git grep" doesn't find the lines that greps :). -unacceptable_terms=( - -e blacklis[t] - -e whitelis[t] - -e slav[e] - -e sanit[y] -) - -# We have to exclude the code of conduct as it gives examples of unacceptable -# language. -if git grep --color=never -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md" > /dev/null; then - printf "\033[0;31mUnacceptable language found.\033[0m\n" - git grep -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md" - exit 1 -fi -printf "\033[0;32mokay.\033[0m\n" - -printf "=> Checking license headers... " -tmp=$(mktemp /tmp/.webauthn-swift-soundness_XXXXXX) - -for language in swift bash; do - declare -a matching_files - declare -a exceptions - expections=( ) - matching_files=( -name '*' ) - case "$language" in - swift) - exceptions=( -name Package.swift ) - matching_files=( -name '*.swift' ) - cat > "$tmp" <<"EOF" -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift WebAuthn open source project -// -// Copyright (c) YEARS the Swift WebAuthn project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// -EOF - ;; - bash) - matching_files=( -name '*.sh' ) - cat > "$tmp" <<"EOF" -#!/bin/bash -##===----------------------------------------------------------------------===## -## -## This source file is part of the Swift WebAuthn open source project -## -## Copyright (c) YEARS the Swift WebAuthn project authors -## Licensed under Apache License v2.0 -## -## See LICENSE.txt for license information -## -## SPDX-License-Identifier: Apache-2.0 -## -##===----------------------------------------------------------------------===## -EOF - ;; - *) - echo >&2 "ERROR: unknown language '$language'" - ;; - esac - - expected_lines=$(cat "$tmp" | wc -l) - expected_sha=$(cat "$tmp" | shasum) - - ( - cd "$here/.." - { - find . \ - \( \! -path './.build/*' -a \ - \( "${matching_files[@]}" \) -a \ - \( \! \( "${exceptions[@]}" \) \) \) - - if [[ "$language" = bash ]]; then - # add everything with a shell shebang too - git grep --full-name -l '#!/bin/bash' - git grep --full-name -l '#!/bin/sh' - fi - } | while read line; do - if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then - printf "\033[0;31mmissing headers in file '$line'!\033[0m\n" - diff -u <(cat "$line" | replace_acceptable_years | head -n $expected_lines) "$tmp" - exit 1 - fi - done - printf "\033[0;32mokay.\033[0m\n" - ) -done - -rm "$tmp"