Skip to content

Commit 7c157c2

Browse files
committed
Update Code Scanning
1 parent 7e658cf commit 7c157c2

File tree

3 files changed

+52
-62
lines changed

3 files changed

+52
-62
lines changed

.github/workflows/code_scanning.yml

Lines changed: 45 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
# Initializes the CodeQL tools for scanning.
3232
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@v2
33+
uses: github/codeql-action/init@v3
3434
with:
3535
languages: 'c-cpp'
3636
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -44,20 +44,10 @@ jobs:
4444
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
4545
# If this step fails, then you should remove it and run the build manually (see below)
4646
- name: Autobuild
47-
uses: github/codeql-action/autobuild@v2
48-
49-
# ℹ️ Command-line programs to run using the OS shell.
50-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
51-
52-
# If the Autobuild fails above, remove it and uncomment the following three lines.
53-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
54-
55-
# - run: |
56-
# echo "Run, Build Application using script"
57-
# ./location_of_script_within_repo/buildscript.sh
47+
uses: github/codeql-action/autobuild@v3
5848

5949
- name: Perform CodeQL Analysis
60-
uses: github/codeql-action/analyze@v2
50+
uses: github/codeql-action/analyze@v3
6151
with:
6252
category: "/language:c-cpp"
6353

@@ -73,53 +63,53 @@ jobs:
7363
uses: actions/checkout@v3
7464

7565
- name: flawfinder_scan
76-
uses: david-a-wheeler/flawfinder@8e4a779ad59dbfaee5da586aa9210853b701959c
66+
uses: david-a-wheeler/flawfinder@2.0.19
7767
with:
7868
arguments: '--sarif ./'
7969
output: 'flawfinder_results.sarif'
8070

8171
- name: Upload analysis results to GitHub Security tab
82-
uses: github/codeql-action/upload-sarif@v2
72+
uses: github/codeql-action/upload-sarif@v3
8373
with:
8474
sarif_file: ${{github.workspace}}/flawfinder_results.sarif
8575

86-
# microsoft-analyze:
87-
# permissions:
88-
# contents: read # for actions/checkout to fetch code
89-
# security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
90-
# actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
91-
# name: Microsoft Analyze
92-
# runs-on: windows-latest
93-
94-
# steps:
95-
# - name: Checkout repository
96-
# uses: actions/checkout@v3
97-
98-
# - name: Configure CMake
99-
# run: cmake -B ./build
100-
101-
# # Build is not required unless generated source files are used
102-
# # - name: Build CMake
103-
# # run: cmake --build ./build
104-
105-
# - name: Initialize MSVC Code Analysis
106-
# uses: microsoft/msvc-code-analysis-action@04825f6d9e00f87422d6bf04e1a38b1f3ed60d99
107-
# # Provide a unique ID to access the sarif output path
108-
# id: run-analysis
109-
# with:
110-
# cmakeBuildDirectory: ${{ env.build }}
111-
# # Ruleset file that will determine what checks will be run
112-
# ruleset: NativeRecommendedRules.ruleset
113-
114-
# # Upload SARIF file to GitHub Code Scanning Alerts
115-
# - name: Upload SARIF to GitHub
116-
# uses: github/codeql-action/upload-sarif@v2
117-
# with:
118-
# sarif_file: ${{ steps.run-analysis.outputs.sarif }}
119-
120-
# # Upload SARIF file as an Artifact to download and view
121-
# # - name: Upload SARIF as an Artifact
122-
# # uses: actions/upload-artifact@v3
123-
# # with:
124-
# # name: sarif-file
125-
# # path: ${{ steps.run-analysis.outputs.sarif }}
76+
microsoft-analyze:
77+
permissions:
78+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
79+
contents: read # for actions/checkout to fetch code
80+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
81+
name: Microsoft Analyze
82+
runs-on: windows-latest
83+
84+
steps:
85+
- name: Checkout repository
86+
uses: actions/checkout@v3
87+
88+
- name: Configure CMake
89+
run: cmake -B ./build
90+
91+
# Build is not required unless generated source files are used
92+
# - name: Build CMake
93+
# run: cmake --build ./build
94+
95+
- name: Initialize MSVC Code Analysis
96+
uses: microsoft/msvc-code-analysis-action@04825f6d9e00f87422d6bf04e1a38b1f3ed60d99
97+
# Provide a unique ID to access the sarif output path
98+
id: run-analysis
99+
with:
100+
cmakeBuildDirectory: ./build
101+
# Ruleset file that will determine what checks will be run
102+
ruleset: NativeRecommendedRules.ruleset
103+
104+
# Upload SARIF file to GitHub Code Scanning Alerts
105+
- name: Upload SARIF to GitHub
106+
uses: github/codeql-action/upload-sarif@v3
107+
with:
108+
sarif_file: ${{ steps.run-analysis.outputs.sarif }}
109+
110+
# Upload SARIF file as an Artifact to download and view
111+
# - name: Upload SARIF as an Artifact
112+
# uses: actions/upload-artifact@v3
113+
# with:
114+
# name: sarif-file
115+
# path: ${{ steps.run-analysis.outputs.sarif }}

source/Socket.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
** Author Francois Michaut
55
**
66
** Started on Sat Jan 15 01:27:40 2022 Francois Michaut
7-
** Last update Tue Aug 5 00:04:25 2025 Francois Michaut
7+
** Last update Tue Aug 5 13:40:49 2025 Francois Michaut
88
**
99
** Socket.cpp : Protable C++ socket class implementation
1010
*/
@@ -46,7 +46,7 @@ namespace CppSockets {
4646
{
4747
socklen_t len = sizeof(int);
4848

49-
Socket::getsockopt(sockfd, SOL_SOCKET, SO_TYPE, (SockOptType *)&m_type, &len);
49+
Socket::getsockopt(sockfd, SOL_SOCKET, SO_TYPE, static_cast<SockOptType *>(&m_type), &len);
5050
#ifdef OS_LINUX
5151
Socket::getsockopt(sockfd, SOL_SOCKET, SO_DOMAIN, &m_domain, &len);
5252
Socket::getsockopt(sockfd, SOL_SOCKET, SO_PROTOCOL, &m_protocol, &len);
@@ -128,7 +128,7 @@ namespace CppSockets {
128128
std::size_t nb = 1;
129129

130130
while (nb != 0 && (len == -1 || total < len)) {
131-
nb = this->read(buff.data(), BUFF_SIZE);
131+
nb = this->read(buff.data(), buff.size());
132132
if (nb > 0) {
133133
res << std::string(buff.data(), nb);
134134
}
@@ -168,7 +168,7 @@ namespace CppSockets {
168168
auto Socket::set_reuseaddr(bool value) -> int {
169169
int val = static_cast<int>(value);
170170

171-
return this->setsockopt(SOL_SOCKET, SO_REUSEADDR, (SockOptType *)&val, sizeof(val));
171+
return this->setsockopt(SOL_SOCKET, SO_REUSEADDR, static_cast<SockOptType *>(&val), sizeof(val));
172172
}
173173

174174
auto Socket::getsockopt(int level, int optname, SockOptType *optval, socklen_t *optlen) -> int { // NOLINT(readability-make-member-function-const)

source/TlsSocket.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
** Author Francois Michaut
55
**
66
** Started on Wed Sep 14 21:04:42 2022 Francois Michaut
7-
** Last update Sun Aug 3 22:18:06 2025 Francois Michaut
7+
** Last update Tue Aug 5 13:49:19 2025 Francois Michaut
88
**
99
** SecureSocket.cpp : TLS socket wrapper implementation
1010
*/
@@ -154,13 +154,13 @@ namespace CppSockets {
154154
std::size_t nb = 0;
155155
std::size_t total;
156156

157-
if (SSL_peek(m_ssl.get(), buff.data(), BUFF_SIZE) <= 0) {
157+
if (SSL_peek(m_ssl.get(), buff.data(), buff.size()) <= 0) {
158158
set_connected(false); // TODO: we should replace this with check_for_error
159159
}
160160
check_for_error("Failed to read from socket", 1); // Do not raise an error if peek failed
161161
total = SSL_pending(m_ssl.get());
162162
while (total != 0 && len != 0) {
163-
nb = this->read(buff.data(), (BUFF_SIZE > len ? len : BUFF_SIZE));
163+
nb = this->read(buff.data(), (buff.size() > len ? len : buff.size()));
164164
res << std::string(buff.data(), nb);
165165
total -= nb;
166166
if (len != -1)

0 commit comments

Comments
 (0)