From b555b2f86b6a8ee951d868d9ca12dfba33842521 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Wed, 8 Sep 2021 17:47:48 -0700 Subject: [PATCH] Teach our check-DNS script to ignore temporary files (#27285) A plain `grep` was occasionally attempting to grep temporaary files that were being created and deleted concurrently by other sanity check scripts, leading to TOCTOU problems. This now only searches indexed files (thanks for the suggestion, @ctiller!). We still need to exclude `third_party` since upb is not a submodule. `git grep` will ignore all submodules by default, so the other third_party subfolders were already excluded. --- tools/run_tests/sanity/check_do_not_submit.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/run_tests/sanity/check_do_not_submit.sh b/tools/run_tests/sanity/check_do_not_submit.sh index 3f7c6e64f94..6e0438cd5cb 100755 --- a/tools/run_tests/sanity/check_do_not_submit.sh +++ b/tools/run_tests/sanity/check_do_not_submit.sh @@ -16,9 +16,8 @@ # Checks if any file contains "DO NOT SUBMIT" cd "$(dirname "$0")/../../.." || exit 1 -grep -Irn \ - --exclude='check_do_not_submit.sh' \ - --exclude-dir='.git/' \ - --exclude-dir='third_party/' \ - 'DO NOT SUBMIT' +git grep -Irn 'DO NOT SUBMIT' -- \ + './*' \ + ':!*check_do_not_submit.sh' \ + ':!third_party/' test $? -eq 1 || exit 1