Skip to content

Commit b3facab

Browse files
committed
Add scripts
1 parent 9183e18 commit b3facab

File tree

3 files changed

+178
-0
lines changed

3 files changed

+178
-0
lines changed

NOTICE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
WebAuthn Swift project
2+
3+
----------------------------------------------------------------------
4+
5+
This source file is part of the WebAuthn Swift open source project
6+
7+
Copyright (c) 2022 the WebAuthn Swift project authors
8+
Licensed under Apache License v2.0
9+
10+
See LICENSE.txt for license information
11+
See CONTRIBUTORS.txt for the list of WebAuthn Swift project authors
12+
13+
SPDX-License-Identifier: Apache-2.0
14+
15+
----------------------------------------------------------------------
16+
17+
This product contains a derivation of various scripts from SwiftNIO.
18+
19+
* LICENSE (Apache License 2.0):
20+
* https://www.apache.org/licenses/LICENSE-2.0
21+
* HOMEPAGE:
22+
* https://github.com/apple/swift-nio
23+
24+
---

scripts/generate_contributors_list.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the WebAuthn Swift open source project
5+
##
6+
## Copyright (c) 2022 the WebAuthn Swift project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of WebAuthn Swift project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
set -eu
17+
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18+
contributors=$( cd "$here"/.. && git shortlog -es | cut -f2 | sed 's/^/- /' )
19+
20+
cat > "$here/../CONTRIBUTORS.txt" <<- EOF
21+
For the purpose of tracking copyright, this is the list of individuals and
22+
organizations who have contributed source code to the WebAuthn Swift extension.
23+
For employees of an organization/company where the copyright of work done
24+
by employees of that company is held by the company itself, only the company
25+
needs to be listed here.
26+
## COPYRIGHT HOLDERS
27+
- Swift Server Work Group
28+
### Contributors
29+
$contributors
30+
**Updating this list**
31+
Please do not edit this file manually. It is generated using \`./scripts/generate_contributors_list.sh\`. If a name is misspelled or appearing multiple times: add an entry in \`./.mailmap\`
32+
EOF

scripts/soundness.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the WebAuthn Swift open source project
5+
##
6+
## Copyright (c) 2022 the WebAuthn Swift project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of WebAuthn Swift project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
set -eu
17+
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18+
19+
function replace_acceptable_years() {
20+
# this needs to replace all acceptable forms with 'YEARS'
21+
sed -e 's/20[12][78901]-20[12][89012]/YEARS/' -e 's/20[12][89012]/YEARS/'
22+
}
23+
24+
printf "=> Checking for unacceptable language... "
25+
# This greps for unacceptable terminology. The square bracket[s] are so that
26+
# "git grep" doesn't find the lines that greps :).
27+
unacceptable_terms=(
28+
-e blacklis[t]
29+
-e whitelis[t]
30+
-e slav[e]
31+
-e sanit[y]
32+
)
33+
34+
# We have to exclude the code of conduct as it gives examples of unacceptable
35+
# language.
36+
if git grep --color=never -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md" > /dev/null; then
37+
printf "\033[0;31mUnacceptable language found.\033[0m\n"
38+
git grep -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md"
39+
exit 1
40+
fi
41+
printf "\033[0;32mokay.\033[0m\n"
42+
43+
printf "=> Checking license headers... "
44+
tmp=$(mktemp /tmp/.webauthn-swift-soundness_XXXXXX)
45+
46+
for language in swift bash; do
47+
declare -a matching_files
48+
declare -a exceptions
49+
expections=( )
50+
matching_files=( -name '*' )
51+
case "$language" in
52+
swift)
53+
exceptions=( -name Package.swift )
54+
matching_files=( -name '*.swift' )
55+
cat > "$tmp" <<"EOF"
56+
//===----------------------------------------------------------------------===//
57+
//
58+
// This source file is part of the WebAuthn Swift open source project
59+
//
60+
// Copyright (c) YEARS the WebAuthn Swift project authors
61+
// Licensed under Apache License v2.0
62+
//
63+
// See LICENSE.txt for license information
64+
// See CONTRIBUTORS.txt for the list of WebAuthn Swift project authors
65+
//
66+
// SPDX-License-Identifier: Apache-2.0
67+
//
68+
//===----------------------------------------------------------------------===//
69+
EOF
70+
;;
71+
bash)
72+
matching_files=( -name '*.sh' )
73+
cat > "$tmp" <<"EOF"
74+
#!/bin/bash
75+
##===----------------------------------------------------------------------===##
76+
##
77+
## This source file is part of the WebAuthn Swift open source project
78+
##
79+
## Copyright (c) 2022 the WebAuthn Swift project authors
80+
## Licensed under Apache License v2.0
81+
##
82+
## See LICENSE.txt for license information
83+
## See CONTRIBUTORS.txt for the list of WebAuthn Swift project authors
84+
##
85+
## SPDX-License-Identifier: Apache-2.0
86+
##
87+
##===----------------------------------------------------------------------===##
88+
EOF
89+
;;
90+
*)
91+
echo >&2 "ERROR: unknown language '$language'"
92+
;;
93+
esac
94+
95+
expected_lines=$(cat "$tmp" | wc -l)
96+
expected_sha=$(cat "$tmp" | shasum)
97+
98+
(
99+
cd "$here/.."
100+
{
101+
find . \
102+
\( \! -path './.build/*' -a \
103+
\( "${matching_files[@]}" \) -a \
104+
\( \! \( "${exceptions[@]}" \) \) \)
105+
106+
if [[ "$language" = bash ]]; then
107+
# add everything with a shell shebang too
108+
git grep --full-name -l '#!/bin/bash'
109+
git grep --full-name -l '#!/bin/sh'
110+
fi
111+
} | while read line; do
112+
if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then
113+
printf "\033[0;31mmissing headers in file '$line'!\033[0m\n"
114+
diff -u <(cat "$line" | replace_acceptable_years | head -n $expected_lines) "$tmp"
115+
exit 1
116+
fi
117+
done
118+
printf "\033[0;32mokay.\033[0m\n"
119+
)
120+
done
121+
122+
rm "$tmp"

0 commit comments

Comments
 (0)