Skip to content

Commit

Permalink
Merge pull request #89 from marcransome/codeql
Browse files Browse the repository at this point in the history
Add CodeQL helper scripts
  • Loading branch information
marcransome authored Apr 1, 2023
2 parents a9714a2 + 2f0728d commit 6decefe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
._*
build/
codeql-database/
codeql-analysis.sarif
16 changes: 16 additions & 0 deletions tool/codeql-analyse-database
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

parent_dir="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
codeql_db_dir="codeql-database"
codeql_sarif_file="codeql-analysis.sarif"

cd "${parent_dir}/.."

[[ -f "${codeql_sarif_file}" ]] && rm -f "${codeql_sarif_file}"

if [[ ! -d "${codeql_db_dir}" ]]; then
echo "No such CodeQL database directory: $(pwd)/${codeql_db_dir}"
exit 1
fi

codeql database analyze "${codeql_db_dir}" --format="sarif-latest" --output="${codeql_sarif_file}" "codeql/cpp-queries:codeql-suites/cpp-security-and-quality.qls"
12 changes: 12 additions & 0 deletions tool/codeql-create-database
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

parent_dir="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
codeql_db_dir="codeql-database"
build_dir="build"

cd "${parent_dir}/.."

[[ -d "${build_dir}" ]] && rm -rf "${build_dir}"
[[ -d "${codeql_db_dir}" ]] && rm -rf "${codeql_db_dir}"

codeql database create "${codeql_db_dir}" --source-root="./src" --language="cpp" --command="cmake -S .. -B ../${build_dir}" --command="cmake --build ../build"

0 comments on commit 6decefe

Please sign in to comment.