diff --git a/.github/workflows/reusable_pull_request.yml b/.github/workflows/reusable_pull_request.yml index 4a4b05bc5e..e84c5c00f8 100644 --- a/.github/workflows/reusable_pull_request.yml +++ b/.github/workflows/reusable_pull_request.yml @@ -3,18 +3,26 @@ name: Pull Request on: workflow_call: inputs: - enable_unit_tests: + unit_tests_enabled: type: boolean description: "Boolean to enable the unit tests job. Defaults to true." default: true - enable_api_breakage_check: + api_breakage_check_enabled: type: boolean description: "Boolean to enable the API breakage check job. Defaults to true." default: true - enable_docs_check: + docs_check_enabled: type: boolean description: "Boolean to enable the docs check job. Defaults to true." default: true + acceptable_language_check_enabled: + type: boolean + description: "Boolean to enable the acceptable language check job. Defaults to true." + default: true + acceptable_language_check_word_list: + type: string + description: "List of unacceptable words. Defaults to a sensitive list of words." + default: "blacklist whitelist slave master sane sanity insane insanity kill killed killing hang hung hanged hanging" #ignore-unacceptable-language ## We are cancelling previously triggered workflow runs concurrency: @@ -24,7 +32,7 @@ concurrency: jobs: unit-tests: name: Unit tests - if: ${{ inputs.enable_unit_tests }} + if: ${{ inputs.unit_tests_enabled }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -46,7 +54,7 @@ jobs: api-breakage-check: name: API breakage check - if: ${{ inputs.enable_api_breakage_check }} + if: ${{ inputs.api_breakage_check_enabled }} runs-on: ubuntu-latest container: image: swift:5.10-noble @@ -65,7 +73,7 @@ jobs: docs-check: name: Documentation check - if: ${{ inputs.enable_docs_check }} + if: ${{ inputs.docs_check_enabled }} runs-on: ubuntu-latest container: image: swift:5.10-noble @@ -83,4 +91,17 @@ jobs: for target in "${targets[@]}"; do swift package plugin generate-documentation --target "$target" --warnings-as-errors --analyze --level detailed - done \ No newline at end of file + done + + acceptable-language-check: + name: Acceptable language check + if: ${{ inputs.acceptable_language_check_enabled }} + runs-on: ubuntu-latest + timeout-minutes: 1 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Run acceptable language check + env: + UNACCEPTABLE_LANGUAGE_PATTERNS: ${{ inputs.acceptable_language_check_word_list}} + run: ./scripts/acceptable_language_check.sh \ No newline at end of file diff --git a/IntegrationTests/run-tests.sh b/IntegrationTests/run-tests.sh index 9250b83ed9..3fcc18e82f 100755 --- a/IntegrationTests/run-tests.sh +++ b/IntegrationTests/run-tests.sh @@ -143,9 +143,9 @@ fi # report if [[ $cnt_fail > 0 ]]; then - # kill leftovers (the whole process group) + # terminate leftovers (the whole process group) trap '' TERM - kill 0 + kill 0 # ignore-unacceptable-language plugins_do summary_fail "$cnt_ok" "$cnt_fail" else diff --git a/IntegrationTests/tests_01_http/defines.sh b/IntegrationTests/tests_01_http/defines.sh index 8f4c287c25..46d967b002 100644 --- a/IntegrationTests/tests_01_http/defines.sh +++ b/IntegrationTests/tests_01_http/defines.sh @@ -141,17 +141,17 @@ function stop_server() { do_netstat "$token_type" assert_number_of_open_fds_for_pid_equals "$token_pid" "$token_open_fds" fi - kill -0 "$token_pid" # assert server is still running - ###kill -INT "$token_pid" # tell server to shut down gracefully - kill "$token_pid" # tell server to shut down gracefully + kill -0 "$token_pid" # assert server is still running ignore-unacceptable-language + ###kill -INT "$token_pid" # tell server to shut down gracefully ignore-unacceptable-language + kill "$token_pid" # tell server to shut down gracefully ignore-unacceptable-language for f in $(seq 20); do - if ! kill -0 "$token_pid" 2> /dev/null; then + if ! kill -0 "$token_pid" 2> /dev/null; then # ignore-unacceptable-language break # good, dead fi ps auxw | grep "$token_pid" || true sleep 0.1 done - if kill -0 "$token_pid" 2> /dev/null; then + if kill -0 "$token_pid" 2> /dev/null; then # ignore-unacceptable-language fail "server $token_pid still running" fi } diff --git a/IntegrationTests/tests_01_http/test_08_survive_signals.sh b/IntegrationTests/tests_01_http/test_08_survive_signals.sh index 33358cacc4..c906c879e0 100644 --- a/IntegrationTests/tests_01_http/test_08_survive_signals.sh +++ b/IntegrationTests/tests_01_http/test_08_survive_signals.sh @@ -23,15 +23,15 @@ echo FOO BAR > "$htdocs/some_file.txt" for f in $(seq 20); do # send some signals that are usually discarded - kill -CHLD "$server_pid" - kill -URG "$server_pid" - kill -CONT "$server_pid" - kill -WINCH "$server_pid" + kill -CHLD "$server_pid" # ignore-unacceptable-language + kill -URG "$server_pid" # ignore-unacceptable-language + kill -CONT "$server_pid" # ignore-unacceptable-language + kill -WINCH "$server_pid" # ignore-unacceptable-language do_curl "$token" "http://foobar.com/fileio/some_file.txt" > "$tmp/out.txt" & curl_pid=$! for g in $(seq 20); do - kill -URG "$server_pid" + kill -URG "$server_pid" # ignore-unacceptable-language done wait $curl_pid cmp "$htdocs/some_file.txt" "$tmp/out.txt" diff --git a/IntegrationTests/tests_01_http/test_10_connection_drop_in_body_ok.sh b/IntegrationTests/tests_01_http/test_10_connection_drop_in_body_ok.sh index 307a71d317..502e0b5864 100644 --- a/IntegrationTests/tests_01_http/test_10_connection_drop_in_body_ok.sh +++ b/IntegrationTests/tests_01_http/test_10_connection_drop_in_body_ok.sh @@ -21,7 +21,7 @@ htdocs=$(get_htdocs "$token") server_pid=$(get_server_pid "$token") socket=$(get_socket "$token") -kill -0 $server_pid +kill -0 $server_pid # ignore-unacceptable-language ( echo -e 'POST /dynamic/echo HTTP/1.1\r\nContent-Length: 400000\r\n\r\nsome_bytes' for f in $(seq 5); do @@ -30,5 +30,5 @@ kill -0 $server_pid done ) | do_nc -U "$socket" sleep 0.1 -kill -0 $server_pid +kill -0 $server_pid # ignore-unacceptable-language stop_server "$token" diff --git a/IntegrationTests/tests_01_http/test_13_http_pipelining.sh b/IntegrationTests/tests_01_http/test_13_http_pipelining.sh index 88c2d74a96..ad3d4330df 100644 --- a/IntegrationTests/tests_01_http/test_13_http_pipelining.sh +++ b/IntegrationTests/tests_01_http/test_13_http_pipelining.sh @@ -21,7 +21,7 @@ htdocs=$(get_htdocs "$token") server_pid=$(get_server_pid "$token") socket=$(get_socket "$token") -kill -0 $server_pid +kill -0 $server_pid # ignore-unacceptable-language echo -e 'GET /dynamic/count-to-ten HTTP/1.1\r\n\r\nGET /dynamic/count-to-ten HTTP/1.1\r\n\r\n' | \ do_nc -U "$socket" > "$tmp/actual" diff --git a/IntegrationTests/tests_01_http/test_18_close_with_no_keepalive.sh b/IntegrationTests/tests_01_http/test_18_close_with_no_keepalive.sh index 719c0c35f6..508e22a8fc 100644 --- a/IntegrationTests/tests_01_http/test_18_close_with_no_keepalive.sh +++ b/IntegrationTests/tests_01_http/test_18_close_with_no_keepalive.sh @@ -21,7 +21,7 @@ htdocs=$(get_htdocs "$token") server_pid=$(get_server_pid "$token") socket=$(get_socket "$token") -kill -0 $server_pid +kill -0 $server_pid # ignore-unacceptable-language echo -e 'GET /dynamic/count-to-ten HTTP/1.1\r\nConnection: close\r\n\r\n' | \ do_nc -U "$socket" > "$tmp/actual" diff --git a/IntegrationTests/tests_01_http/test_19_connection_drop_while_waiting_for_response_uds.sh b/IntegrationTests/tests_01_http/test_19_connection_drop_while_waiting_for_response_uds.sh index cc2e96c5c1..f4393dfcc7 100644 --- a/IntegrationTests/tests_01_http/test_19_connection_drop_while_waiting_for_response_uds.sh +++ b/IntegrationTests/tests_01_http/test_19_connection_drop_while_waiting_for_response_uds.sh @@ -20,7 +20,7 @@ start_server --disable-half-closure "$token" server_pid=$(get_server_pid "$token") socket=$(get_socket "$token") -kill -0 "$server_pid" +kill -0 "$server_pid" # ignore-unacceptable-language echo -e 'GET /dynamic/write-delay/10000 HTTP/1.1\r\n\r\n' | do_nc -w1 -U "$socket" sleep 0.2 diff --git a/IntegrationTests/tests_01_http/test_20_connection_drop_while_waiting_for_response_tcp.sh b/IntegrationTests/tests_01_http/test_20_connection_drop_while_waiting_for_response_tcp.sh index 202891dfd4..9a5e71de38 100644 --- a/IntegrationTests/tests_01_http/test_20_connection_drop_while_waiting_for_response_tcp.sh +++ b/IntegrationTests/tests_01_http/test_20_connection_drop_while_waiting_for_response_tcp.sh @@ -22,7 +22,7 @@ server_pid=$(get_server_pid "$token") ip=$(get_server_ip "$token") port=$(get_server_port "$token") -kill -0 $server_pid +kill -0 $server_pid # ignore-unacceptable-language echo -e 'GET /dynamic/write-delay/10000 HTTP/1.1\r\n\r\n' | do_nc -w1 "$ip" "$port" sleep 0.2 stop_server "$token" diff --git a/IntegrationTests/tests_01_http/test_21_connection_reset_tcp.sh b/IntegrationTests/tests_01_http/test_21_connection_reset_tcp.sh index 033fb7cce1..a380a7b28e 100644 --- a/IntegrationTests/tests_01_http/test_21_connection_reset_tcp.sh +++ b/IntegrationTests/tests_01_http/test_21_connection_reset_tcp.sh @@ -22,11 +22,11 @@ server_pid=$(get_server_pid "$token") ip=$(get_server_ip "$token") port=$(get_server_port "$token") -kill -0 $server_pid +kill -0 $server_pid # ignore-unacceptable-language # try to simulate a TCP connection reset, works really well on Darwin but not on # Linux over loopback. On Linux however # `test_19_connection_drop_while_waiting_for_response_uds.sh` tests a very # similar situation. -yes "$( echo -e 'GET /dynamic/write-delay HTTP/1.1\r\n\r\n')" | nc "$ip" "$port" > /dev/null & sleep 0.5; kill -9 $! +yes "$( echo -e 'GET /dynamic/write-delay HTTP/1.1\r\n\r\n')" | nc "$ip" "$port" > /dev/null & sleep 0.5; kill -9 $! # ignore-unacceptable-language sleep 0.2 stop_server "$token" diff --git a/NOTICE.txt b/NOTICE.txt index 6caf903044..ffe1623ca5 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -41,14 +41,14 @@ This product contains a derivation of the Tony Stone's 'process_test_files.rb'. * https://www.apache.org/licenses/LICENSE-2.0 * HOMEPAGE: * https://github.com/tonystone/build-tools/commit/6c417b7569df24597a48a9aa7b505b636e8f73a1 - * https://github.com/tonystone/build-tools/blob/master/source/xctest_tool.rb + * https://github.com/tonystone/build-tools/blob/cf3440f43bde2053430285b4ed0709c865892eb5/source/xctest_tool.rb --- This product contains NodeJS's llhttp. * LICENSE (MIT): - * https://github.com/nodejs/llhttp/blob/master/LICENSE-MIT + * https://github.com/nodejs/llhttp/blob/1e1c5b43326494e97cf8244ff57475eb72a1b62c/LICENSE-MIT * HOMEPAGE: * https://github.com/nodejs/llhttp @@ -57,7 +57,7 @@ This product contains NodeJS's llhttp. This product contains "cpp_magic.h" from Thomas Nixon & Jonathan Heathcote's uSHET * LICENSE (MIT): - * https://github.com/18sg/uSHET/blob/master/LICENSE + * https://github.com/18sg/uSHET/blob/c09e0acafd86720efe42dc15c63e0cc228244c32/lib/cpp_magic.h * HOMEPAGE: * https://github.com/18sg/uSHET @@ -68,14 +68,14 @@ This product contains "sha1.c" and "sha1.h" from FreeBSD (Copyright (C) 1995, 19 * LICENSE (BSD-3): * https://opensource.org/licenses/BSD-3-Clause * HOMEPAGE: - * https://github.com/freebsd/freebsd/tree/master/sys/crypto + * https://github.com/freebsd/freebsd-src/tree/adf1fc7dd99ad514455f3dd17d289cc59cbae217/sys/crypto --- This product contains a derivation of Fabian Fett's 'Base64.swift'. * LICENSE (Apache License 2.0): - * https://github.com/fabianfett/swift-base64-kit/blob/master/LICENSE + * https://github.com/swift-extras/swift-extras-base64/blob/b8af49699d59ad065b801715a5009619100245ca/LICENSE * HOMEPAGE: * https://github.com/fabianfett/swift-base64-kit diff --git a/README.md b/README.md index 889dd5a25b..39d2094975 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ One major difference between writing concurrent code and writing synchronous cod An [`EventLoopFuture`][elf] is essentially a container for the return value of a function that will be populated *at some time in the future*. Each [`EventLoopFuture`][elf] has a corresponding [`EventLoopPromise`][elp], which is the object that the result will be put into. When the promise is succeeded, the future will be fulfilled. -If you had to poll the future to detect when it completed that would be quite inefficient, so [`EventLoopFuture`][elf] is designed to have managed callbacks. Essentially, you can hang callbacks off the future that will be executed when a result is available. The [`EventLoopFuture`][elf] will even carefully arrange the scheduling to ensure that these callbacks always execute on the event loop that initially created the promise, which helps ensure that you don't need too much synchronization around [`EventLoopFuture`][elf] callbacks. +If you had to poll the future to detect when it completed that would be quite inefficient, so [`EventLoopFuture`][elf] is designed to have managed callbacks. Essentially, you can chain callbacks off the future that will be executed when a result is available. The [`EventLoopFuture`][elf] will even carefully arrange the scheduling to ensure that these callbacks always execute on the event loop that initially created the promise, which helps ensure that you don't need too much synchronization around [`EventLoopFuture`][elf] callbacks. Another important topic for consideration is the difference between how the promise passed to `close` works as opposed to `closeFuture` on a [`Channel`][c]. For example, the promise passed into `close` will succeed after the [`Channel`][c] is closed down but before the [`ChannelPipeline`][cp] is completely cleared out. This will allow you to take action on the [`ChannelPipeline`][cp] before it is completely cleared out, if needed. If it is desired to wait for the [`Channel`][c] to close down and the [`ChannelPipeline`][cp] to be cleared out without any further action, then the better option would be to wait for the `closeFuture` to succeed. diff --git a/Sources/CNIOAtomics/src/cpp_magic.h b/Sources/CNIOAtomics/src/cpp_magic.h index 66f9f7899e..62afcce3b6 100644 --- a/Sources/CNIOAtomics/src/cpp_magic.h +++ b/Sources/CNIOAtomics/src/cpp_magic.h @@ -1,5 +1,5 @@ // -// this is https://github.com/18sg/uSHET/blob/master/lib/cpp_magic.h +// this is https://github.com/18sg/uSHET/blob/c09e0acafd86720efe42dc15c63e0cc228244c32/lib/cpp_magic.h // LICENSE: MIT // // diff --git a/Sources/CNIOLinux/shim.c b/Sources/CNIOLinux/shim.c index 832cef739e..4187317bf0 100644 --- a/Sources/CNIOLinux/shim.c +++ b/Sources/CNIOLinux/shim.c @@ -63,7 +63,7 @@ int CNIOLinux_pthread_setname_np(pthread_t thread, const char *name) { int CNIOLinux_pthread_getname_np(pthread_t thread, char *name, size_t len) { #ifdef __ANDROID__ - // https://android.googlesource.com/platform/bionic/+/master/libc/bionic/pthread_setname_np.cpp#51 + // https://android.googlesource.com/platform/bionic/+/8a18af52d9b9344497758ed04907a314a083b204/libc/bionic/pthread_setname_np.cpp#51 if (thread == pthread_self()) { return TEMP_FAILURE_RETRY(prctl(PR_GET_NAME, name)) == -1 ? -1 : 0; } diff --git a/Sources/CNIOSHA1/update_and_patch_sha1.sh b/Sources/CNIOSHA1/update_and_patch_sha1.sh index 8557928a34..a730717d4a 100755 --- a/Sources/CNIOSHA1/update_and_patch_sha1.sh +++ b/Sources/CNIOSHA1/update_and_patch_sha1.sh @@ -35,7 +35,7 @@ for f in sha1.c sha1.h; do echo " - use welcoming language (soundness check)" echo " - ensure BYTE_ORDER is defined" echo "*/" - curl -Ls "https://raw.githubusercontent.com/freebsd/freebsd/master/sys/crypto/$f" + curl -Ls "https://raw.githubusercontent.com/freebsd/freebsd/master/sys/crypto/$f" # ignore-unacceptable-language ) > "$here/c_nio_$f" for func in sha1_init sha1_pad sha1_loop sha1_result; do diff --git a/Sources/NIO/Docs.docc/index.md b/Sources/NIO/Docs.docc/index.md index 90f318e0e4..481ce3cd78 100644 --- a/Sources/NIO/Docs.docc/index.md +++ b/Sources/NIO/Docs.docc/index.md @@ -128,7 +128,7 @@ One major difference between writing concurrent code and writing synchronous cod An [`EventLoopFuture`][elf] is essentially a container for the return value of a function that will be populated *at some time in the future*. Each [`EventLoopFuture`][elf] has a corresponding [`EventLoopPromise`][elp], which is the object that the result will be put into. When the promise is succeeded, the future will be fulfilled. -If you had to poll the future to detect when it completed that would be quite inefficient, so [`EventLoopFuture`][elf] is designed to have managed callbacks. Essentially, you can hang callbacks off the future that will be executed when a result is available. The [`EventLoopFuture`][elf] will even carefully arrange the scheduling to ensure that these callbacks always execute on the event loop that initially created the promise, which helps ensure that you don't need too much synchronization around [`EventLoopFuture`][elf] callbacks. +If you had to poll the future to detect when it completed that would be quite inefficient, so [`EventLoopFuture`][elf] is designed to have managed callbacks. Essentially, you can chain callbacks off the future that will be executed when a result is available. The [`EventLoopFuture`][elf] will even carefully arrange the scheduling to ensure that these callbacks always execute on the event loop that initially created the promise, which helps ensure that you don't need too much synchronization around [`EventLoopFuture`][elf] callbacks. Another important topic for consideration is the difference between how the promise passed to `close` works as opposed to `closeFuture` on a [`Channel`][c]. For example, the promise passed into `close` will succeed after the [`Channel`][c] is closed down but before the [`ChannelPipeline`][cp] is completely cleared out. This will allow you to take action on the [`ChannelPipeline`][cp] before it is completely cleared out, if needed. If it is desired to wait for the [`Channel`][c] to close down and the [`ChannelPipeline`][cp] to be cleared out without any further action, then the better option would be to wait for the `closeFuture` to succeed. diff --git a/Sources/NIOCore/SystemCallHelpers.swift b/Sources/NIOCore/SystemCallHelpers.swift index b74092a139..cbf3b53a0f 100644 --- a/Sources/NIOCore/SystemCallHelpers.swift +++ b/Sources/NIOCore/SystemCallHelpers.swift @@ -122,7 +122,7 @@ enum SystemCalls { let err = errno #endif - // There is really nothing "sane" we can do when EINTR was reported on close. + // There is really nothing "good" we can do when EINTR was reported on close. // So just ignore it and "assume" everything is fine == we closed the file descriptor. // // For more details see: diff --git a/Sources/NIOPosix/System.swift b/Sources/NIOPosix/System.swift index 6fea9a56f8..8a96793c02 100644 --- a/Sources/NIOPosix/System.swift +++ b/Sources/NIOPosix/System.swift @@ -463,7 +463,7 @@ internal enum Posix { let err = errno #endif - // There is really nothing "sane" we can do when EINTR was reported on close. + // There is really nothing "good" we can do when EINTR was reported on close. // So just ignore it and "assume" everything is fine == we closed the file descriptor. // // For more details see: diff --git a/Tests/NIOPosixTests/ChannelTests.swift b/Tests/NIOPosixTests/ChannelTests.swift index e987d6f8ca..f947ad14f3 100644 --- a/Tests/NIOPosixTests/ChannelTests.swift +++ b/Tests/NIOPosixTests/ChannelTests.swift @@ -2991,7 +2991,7 @@ final class ReentrantWritabilityChangingHandler: ChannelInboundHandler { func channelActive(context: ChannelHandlerContext) { // We want to enqueue at least two pending writes before flushing. Neither of which - // should cause writability to change. However, we'll hang a callback off the first + // should cause writability to change. However, we'll chain a callback off the first // write which will make the channel unwritable and a writability change to be // emitted. The flush for that write should result in the writability flipping back // again. diff --git a/scripts/acceptable_language_check.sh b/scripts/acceptable_language_check.sh new file mode 100755 index 0000000000..8133cf0192 --- /dev/null +++ b/scripts/acceptable_language_check.sh @@ -0,0 +1,37 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the SwiftNIO open source project +## +## Copyright (c) 2024 Apple Inc. and the SwiftNIO project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.txt for the list of SwiftNIO project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + +set -euo pipefail + +log() { printf -- "** %s\n" "$*" >&2; } +error() { printf -- "** ERROR: %s\n" "$*" >&2; } +fatal() { error "$@"; exit 1; } + +test -n "${UNACCEPTABLE_LANGUAGE_PATTERNS:-}" || fatal "UNACCEPTABLE_LANGUAGE_PATTERNS unset" + +log "Checking for unacceptable language..." +unacceptable_language_lines=$(git grep \ + -i -I -w \ + -H -n --column \ + -E "${UNACCEPTABLE_LANGUAGE_PATTERNS// /|}" | grep -v "ignore-unacceptable-language" +) || true | /usr/bin/paste -s -d " " - + +if [ -n "${unacceptable_language_lines}" ]; then + fatal " ❌ Found unacceptable language: +${unacceptable_language_lines} +" +fi + +log "✅ Found no unacceptable language." \ No newline at end of file diff --git a/scripts/nio-diagnose b/scripts/nio-diagnose index e5ab7c0c50..21e6d40cf2 100755 --- a/scripts/nio-diagnose +++ b/scripts/nio-diagnose @@ -355,7 +355,7 @@ function analyse_process() { output "## Analysing pid $pid" output - if ! kill -0 "$pid" 2> /dev/null; then + if ! kill -0 "$pid" 2> /dev/null; then # ignore-unacceptable-language output "pid $pid is dead, skipping" return 0 fi