Our company is using Travis CI and our team want to add a
yarn audit check to my test script for HIGH or CRITICAL vulnerabilities. When calling
yarn audit Travis returned status code of a bitmask of vulnerability levels, so that for example if you have moderate (4) and critical (16) levels, you get 20 back. And I want to fail my script if there are at least any high alerts, so if status >= 8.
Travis is setup so that a list of commands are run in sequence, aborting when there’s a non-zero status code, so basically a
set -e setup I guess.
My current attempt at this is the following:
yarn audit || (mask=$? && [ $mask -lt 8 ])
it doesn’t exactly say “run this command and fail if the status code was >=8” For example, is there a way of avoiding the
$? syntax when all you need to do is condition the status code once? I’m thinking along the lines of a single bracket expression such as
[ $(yarn audit)].
for bracket expression is there anything I can do cleaner? need help thank you…