Line 2:
sudo -u apache php foo.php > /tmp/out
^-- SC2024: sudo doesn't affect redirects. Use ..| sudo tee file
Here's what I wanted or expected to see:
No warnings.
My justification is that bash is a common language used in bootstrapping and provisioning, while doing these operations it's often necessary to start a script as root and ideal to run a script in another language as another user.
In the case of web apps to avoid accidentally creating files like logs as root, but we still want to capture the output somewhere temporarily for buffering (e.g check exit status and only pass up the output of the script if it exits non-zero).
The advice to use sudo tee file
is inappropriate here (which I'll admit is mentioned on the wiki page) but it seems like this warning would almost never be relevant to anyone sudoing to a user other than root.
Alternatively, perhaps the original check would be better to only display if the path was under /etc
?