Skip to content

Draft: Fix most Severe/High CodeQL issues #258

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

Draft
wants to merge 59 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8f430b5
Create codeql-config.yml
TheAssembler1 Apr 22, 2025
c4a2524
Create codeql.yml
TheAssembler1 Apr 22, 2025
c683a54
test
TheAssembler1 Apr 22, 2025
110deb7
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 22, 2025
a40bdfc
remvoe
TheAssembler1 Apr 22, 2025
4abc540
Update codeql.yml
TheAssembler1 Apr 22, 2025
21b7c27
Update codeql.yml
TheAssembler1 Apr 22, 2025
29a83f9
1
TheAssembler1 Apr 22, 2025
5faf45e
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 22, 2025
e05598f
Committing clang-format changes
github-actions[bot] Apr 22, 2025
281dacf
more
TheAssembler1 Apr 22, 2025
bd721c3
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 22, 2025
de0b04d
update
TheAssembler1 Apr 22, 2025
36b846f
another
TheAssembler1 Apr 22, 2025
3ba5647
Committing clang-format changes
github-actions[bot] Apr 22, 2025
cda18bc
another
TheAssembler1 Apr 22, 2025
8674438
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 22, 2025
1a846e5
Committing clang-format changes
github-actions[bot] Apr 22, 2025
7bfd764
another
TheAssembler1 Apr 22, 2025
e98841d
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 22, 2025
079f167
Committing clang-format changes
github-actions[bot] Apr 22, 2025
4d4964f
another
TheAssembler1 Apr 22, 2025
b192d87
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 22, 2025
2b35b58
another
TheAssembler1 Apr 22, 2025
0587c02
Committing clang-format changes
github-actions[bot] Apr 22, 2025
5bd9530
another
TheAssembler1 Apr 22, 2025
f8a257b
another
TheAssembler1 Apr 22, 2025
9ba1f23
Committing clang-format changes
github-actions[bot] Apr 22, 2025
f0a3c22
another
TheAssembler1 Apr 22, 2025
5f747e6
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 22, 2025
3a7453e
another
TheAssembler1 Apr 22, 2025
c1fb397
another
TheAssembler1 Apr 23, 2025
1cf5d30
Committing clang-format changes
github-actions[bot] Apr 23, 2025
1da939a
another
TheAssembler1 Apr 24, 2025
39648ac
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 24, 2025
30b8afd
Committing clang-format changes
github-actions[bot] Apr 24, 2025
0b3fd04
another
TheAssembler1 Apr 24, 2025
3fd4439
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 24, 2025
f499edc
Committing clang-format changes
github-actions[bot] Apr 24, 2025
4daf9d8
another
TheAssembler1 Apr 24, 2025
8458482
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 24, 2025
28f9380
Committing clang-format changes
github-actions[bot] Apr 24, 2025
962db67
another
TheAssembler1 Apr 24, 2025
98d3fca
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 24, 2025
c9398cb
another
TheAssembler1 Apr 24, 2025
8688af7
Committing clang-format changes
github-actions[bot] Apr 24, 2025
75460e9
another
TheAssembler1 Apr 24, 2025
5cc0837
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 Apr 24, 2025
e25e3ff
update
TheAssembler1 May 17, 2025
4115858
Committing clang-format changes
github-actions[bot] May 17, 2025
b19d91f
test
TheAssembler1 May 17, 2025
c899877
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 May 17, 2025
4852666
checkpoint
TheAssembler1 May 17, 2025
24ae499
Committing clang-format changes
github-actions[bot] May 17, 2025
068b633
update
TheAssembler1 May 17, 2025
5b5cb99
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 May 17, 2025
7171541
Committing clang-format changes
github-actions[bot] May 17, 2025
2df916a
fix
TheAssembler1 May 17, 2025
3cfec51
Merge branch 'pdc_codeql' of https://github.com/TheAssembler1/pdc int…
TheAssembler1 May 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Query filters to include or exclude specific queries
query-filters:
- exclude:
# See: https://codeql.github.com/codeql-query-help/cpp/cpp-short-global-name/
id: cpp/short-global-name
- exclude:
# See: https://codeql.github.com/codeql-query-help/cpp/cpp-commented-out-code/
id: cpp/commented-out-code
- exclude:
# See: https://codeql.github.com/codeql-query-help/cpp/cpp-poorly-documented-function/
id: cpp/poorly-documented-function
- exclude:
# See: https://codeql.github.com/codeql-query-help/cpp/cpp-trivial-switch/
id: cpp/trivial-switch
- exclude:
# See: https://codeql.github.com/codeql-query-help/cpp/cpp-irregular-enum-init/
id: cpp/irregular-enum-init
- exclude:
# See: https://codeql.github.com/codeql-query-help/cpp/cpp-guarded-free/
id: cpp/guarded-free

# Directories to scan for vulnerabilities
paths:
- src

# Directories and files to ignore during the scan
paths-ignore:
- scripts
- examples
- docs
- benchmark
119 changes: 119 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL Advanced"

env:
CMAKE_POLICY_VERSION_MINIMUM: 3.5

on:
push:
branches: [ "pdc_codeql" ]
pull_request:
branches: [ "pdc_codeql" ]
schedule:
- cron: '33 23 * * 2'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
- language: c-cpp
build-mode: manual
- language: python
build-mode: none
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Dependencies
run: |
sudo apt-get update
sudo apt-get install libopenmpi-dev libhdf5-dev uuid-dev cmake

- name: Build PDC Dependencies
run: |
# libfabric
wget https://github.com/ofiwg/libfabric/archive/refs/tags/v1.12.1.tar.gz
tar xf v1.12.1.tar.gz
cd libfabric-1.12.1
./autogen.sh
./configure --disable-usnic --disable-mrail --disable-rstream --disable-perf --disable-efa --disable-psm2 --disable-psm --disable-verbs --disable-shm --disable-static --disable-silent-rules
make -j2 && sudo make install
cd ..

# Mercury
git clone --recursive https://github.com/mercury-hpc/mercury.git
cd mercury
git checkout v2.2.0
mkdir build && cd build
cmake ../ -DCMAKE_C_COMPILER=gcc -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DNA_USE_OFI=ON -DNA_USE_SM=OFF -DMERCURY_USE_CHECKSUMS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5
make -j2 && sudo make install

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
config-file: ./.github/codeql-config.yml
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
- name: Build PDC
shell: bash
run: |
mkdir build && cd build
cmake ../ -DBUILD_MPI_TESTING=ON -DBUILD_SHARED_LIBS=ON -DPDC_SERVER_CACHE=ON -DBUILD_TESTING=ON -DPDC_ENABLE_MPI=ON -DCMAKE_C_COMPILER=mpicc -DCMAKE_POLICY_VERSION_MINIMUM=3.5
make -j2 && sudo make install

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
9 changes: 8 additions & 1 deletion examples/bdcats.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#include <inttypes.h>
#include "pdc.h"

#define NPARTICLES 8388608
#define NPARTICLES 8388608
#define MAX_PARTICLES (NPARTICLES * 2)

double
uniform_random_number()
Expand Down Expand Up @@ -82,6 +83,11 @@ main(int argc, char **argv)
LOG_INFO("Writing %" PRIu64 " number of particles with %d clients.\n", numparticles, size);
}

if (numparticles > MAX_PARTICLES) {
LOG_ERRROR("numparticles exceeds max size\n");
goto done;
}

x = (float *)malloc(numparticles * sizeof(float));
y = (float *)malloc(numparticles * sizeof(float));
z = (float *)malloc(numparticles * sizeof(float));
Expand Down Expand Up @@ -463,6 +469,7 @@ main(int argc, char **argv)
free(offset_remote);
free(mysize);

done:
#ifdef ENABLE_MPI
MPI_Finalize();
#endif
Expand Down
12 changes: 10 additions & 2 deletions examples/bdcats_batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
#include <inttypes.h>
#include "pdc.h"

#define NPARTICLES 8388608
#define N_OBJS 8
#define NPARTICLES 8388608
#define MAX_PARTICLES (NPARTICLES * 2)
#define N_OBJS 8

double
uniform_random_number()
Expand Down Expand Up @@ -115,6 +116,11 @@ main(int argc, char **argv)
sleep_time, timestep, numparticles, test_method);
}

if (numparticles > MAX_PARTICLES) {
LOG_ERRROR("numparticles exceeds max size\n");
goto done;
}

x = (float *)malloc(numparticles * sizeof(float));
y = (float *)malloc(numparticles * sizeof(float));
z = (float *)malloc(numparticles * sizeof(float));
Expand Down Expand Up @@ -710,6 +716,8 @@ main(int argc, char **argv)
free(pz);
free(id1);
free(id2);

done:
#ifdef ENABLE_MPI
MPI_Finalize();
#endif
Expand Down
4 changes: 3 additions & 1 deletion examples/bdcats_old.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
#include <inttypes.h>
#include "pdc.h"

#define NPARTICLES 8388608
#define NPARTICLES 8388608
#define MAX_PARTICLES (NPARTICLES * 2)

double
uniform_random_number()
Expand Down Expand Up @@ -390,6 +391,7 @@ main(int argc, char **argv)
free(offset_remote);
free(mysize);

done:
#ifdef ENABLE_MPI
MPI_Finalize();
#endif
Expand Down
Loading
Loading