-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add runcodeql.sh for "tox -e codeql" - Security check in python codes #105
Conversation
To me this is a false positive - it is saying that this assignment is unnecessary: https://github.com/linux-system-roles/nbde_server/blob/main/library/nbde_server_tang.py#L226 because |
# Run codeql against python codes in a role | ||
CODEQLACTIONDIR=${CODEQLACTIONDIR:-"${HOME}/github.com/github/codeql-action"} | ||
ROLE=${ROLE:-"$( basename $TOPDIR )"} | ||
WORKDIR=$( mktemp -d /var/tmp/CODEQL_DB_${ROLE}_XXX ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because this is running in tox, you already have a "working" directory .tox/codeql and a "temp" directory .tox/codeql/.tmp
https://github.com/linux-system-roles/tox-lsr#environment-variables-available-for-test-scripts
The codeql
command should be installed in $LSR_TOX_ENV_DIR/bin
which is in the PATH when running in tox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably make it idempotent:
if [ ! -f "$LSR_TOX_ENV_TMP_DIR/codeql-bundle-linux64.tar.gz" ]; then
curl -o "$LSR_TOX_ENV_TMP_DIR/codeql-bundle-linux64.tar.gz" "$CODEQLURL"
fi
if [ ! -f "$LSR_TOX_ENV_DIR/bin/codeql" ]; then
tar xfz "$LSR_TOX_ENV_TMP_DIR/codeql-bundle-linux64.tar.gz" -C "$LSR_TOX_ENV_TMP_DIR"
cp "$LSR_TOX_ENV_TMP_DIR/codeql" "$LSR_TOX_ENV_DIR/bin/codeql"
fi
if [ ! -d $GITHUBDIR ]; then | ||
mkdir -p $GITHUBDIR | ||
fi | ||
(cd $GITHUBDIR; gh repo clone github/codeql-action) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(cd $GITHUBDIR; gh repo clone github/codeql-action) | |
git clone https://github.com/github/codeql-action "$LSR_TOX_ENV_DIR/codeql-action" |
|
||
JQPATH=$( which jq 2> /dev/null ) | ||
if [ $? -ne 0 ]; then | ||
echo "WARNING: please install jq package" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this check to near the top so the script fails early if jq not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this check since you added it to the top
Ok. Thanks. Then, do you think we'd better find a way to skip testing on the line as |
Without using the UI in github, you can only exclude entire files. There isn't a comment mechanism - github/codeql#11427 |
@@ -226,6 +226,10 @@ commands = bash {lsr_scriptdir}/runansible-test.sh | |||
changedir = {toxinidir} | |||
commands = bash {lsr_scriptdir}/runwoke.sh | |||
|
|||
[testenv:codql] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[testenv:codql] | |
[testenv:codeql] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shame shame Thanks, @richm!
I pulled out
codeql
command lines from the codeql-action output and put them into theruncodeql.sh
script.This is the sample output of
tox -e codeql
run againstnbde_server
.To be honest, reading the code, I'm not convinced that "This assignment to 'rotate_result' is unnecessary"... Could someone understand this codeql result?
https://github.com/linux-system-roles/nbde_server/blob/main/library/nbde_server_tang.py#L258