Skip to content

Commit

Permalink
utils: add safety_macros codegen script (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft authored Mar 3, 2021
1 parent 27ff5d5 commit 6648c66
Show file tree
Hide file tree
Showing 17 changed files with 3,000 additions and 203 deletions.
6 changes: 3 additions & 3 deletions codebuild/bin/grep_simple_mistakes.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
Expand Down Expand Up @@ -65,14 +65,14 @@ for file in $S2N_FILES_ASSERT_NOTNULL_CHECK; do
# $line_one definitely contains an assignment from s2n_stuffer_raw_read(),
# because that's what we grepped for. So verify that either $line_one or
# $line_two contains a null check.
manual_null_check_regex="(.*(if|ENSURE_POSIX).*=\ NULL)|(ENSURE_REF)"
manual_null_check_regex="(.*(if|ENSURE_POSIX|POSIX_ENSURE).*=\ NULL)|(ENSURE_REF)"
if [[ $line_one == *"notnull_check("* ]] || [[ $line_one =~ $manual_null_check_regex ]] ||\
[[ $line_two == *"notnull_check("* ]] || [[ $line_two =~ $manual_null_check_regex ]]; then
# Found a notnull_check
continue
else
FAILED=1
printf "\e[1;34mFound a call to s2n_stuffer_raw_read without a notnull_check in $file:\e[0m\n$line_one\n\n"
printf "\e[1;34mFound a call to s2n_stuffer_raw_read without an ENSURE_REF in $file:\e[0m\n$line_one\n\n"
fi
done < <(grep -rnE -A 1 "=\ss2n_stuffer_raw_read\(.*\)" $file)
done
Expand Down
Loading

0 comments on commit 6648c66

Please sign in to comment.