summaryrefslogtreecommitdiff
path: root/maint/check-instrument-macros
blob: f434d68c3fb9216ef3958a3c32b6cd5ada4a5598 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
#
# The following scripts checks whether our invocations of the #[instrument] macro
# use skip_all and are at trace level. It's okay to have instrument macros that
# don't skip_all if the security implications have been thought through. All of
# our instrument macros should be at trace, level, however.

set -euo pipefail

if grep -oPr --include \*.rs "#\[(tracing::)?instrument[(][^\]]+\].*" ./crates | grep -v skip_all; then
    echo "Instrument macro is missing skip_all!"
    echo "If you have thought through the security implication and this is intentional, add a comment like the following:"
    echo ""
    echo "#[instrument] // Intentionally omitting skip_all"
    exit 1
fi

if grep -oPr --include \*.rs "#\[(tracing::)?instrument[(][^\]]+\].*" ./crates | grep -v trace; then
    echo "Instrument macro is not at trace level!"

    exit 1
fi