Skip to content

Commit 70c87c3

Browse files
authored
Merge branch 'dev' into patch-OSV-2024-947
2 parents 6dadc4a + 5b6a51c commit 70c87c3

40 files changed

+793
-278
lines changed

.github/workflows/auto_update.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717
with:
1818
ref: dev
1919
- name: Setup Python
20-
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
20+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
2121
with:
2222
python-version: "3.8.x"
2323
- name: Run update
2424
run: |
2525
pip install pre-commit
2626
pre-commit autoupdate
2727
- name: Create Pull Request
28-
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
28+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
2929
with:
3030
token: ${{ secrets.PAT }}
3131
author: GitHub <[email protected]>
@@ -50,15 +50,15 @@ jobs:
5050
with:
5151
ref: dev
5252
- name: Setup Python
53-
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
53+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
5454
with:
5555
python-version: "3.9.x"
5656
- name: Run update
5757
run: |
5858
python3 3rdParty/OUIDataset/create_oui_data.py
5959
mv -f PCPP_OUIDataset.json 3rdParty/OUIDataset/PCPP_OUIDataset.json
6060
- name: Create Pull Request
61-
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
61+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
6262
with:
6363
token: ${{ secrets.PAT }}
6464
author: GitHub <[email protected]>

.github/workflows/build_and_test.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
BUILD_DIR: Dist
1212
GCOVR_FLAGS: --gcov-ignore-parse-errors --exclude-throw-branches --filter Common --filter Pcap --filter Packet --xml
1313
CCACHE_DIR: ${{ github.workspace }}/.ccache
14+
CPPCHECK_VERSION: 2.9
1415

1516
permissions:
1617
contents: read
@@ -33,7 +34,9 @@ jobs:
3334

3435
- name: Install dependencies
3536
run: |
36-
apk update && apk add cppcheck python3-dev
37+
apk update && apk add python3-dev
38+
git clone --branch $CPPCHECK_VERSION --single-branch https://github.com/danmar/cppcheck.git
39+
cd cppcheck && mkdir build && cd build && cmake .. && cmake --build . && cmake --install . && cd ../../ && rm -rf cppcheck
3740
python3 -m venv .venv
3841
. .venv/bin/activate
3942
python3 -m pip install pre-commit setuptools clang-format==19.1.6 clang-tidy==18.1.8
@@ -146,7 +149,7 @@ jobs:
146149
gcovr -v -r . ${{ matrix.additional-gcov-flags }} $GCOVR_FLAGS -o coverage.xml
147150
148151
- name: Upload Coverage Results
149-
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
152+
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
150153
with:
151154
files: ./coverage.xml
152155
flags: ${{ matrix.image }},unittest
@@ -321,7 +324,7 @@ jobs:
321324
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
322325

323326
- name: Setup Python
324-
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
327+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
325328
with:
326329
# support version: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
327330
python-version: "3.12"
@@ -394,7 +397,7 @@ jobs:
394397
gcovr -v -r . $GCOVR_FLAGS -o coverage.xml
395398
396399
- name: Upload Coverage Results
397-
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
400+
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
398401
if: ${{ matrix.host-arch == matrix.arch }}
399402
with:
400403
files: ./coverage.xml
@@ -425,7 +428,7 @@ jobs:
425428
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
426429

427430
- name: Setup MSYS2
428-
uses: msys2/setup-msys2@c52d1fa9c7492275e60fe763540fb601f5f232a1 # v2.25.0
431+
uses: msys2/setup-msys2@61f9e5e925871ba6c9e3e8da24ede83ea27fa91f # v2.27.0
429432
with:
430433
msystem: ${{matrix.sys}}
431434
install: >-
@@ -435,7 +438,7 @@ jobs:
435438
mingw-w64-${{matrix.env}}-make
436439
437440
- name: Setup Python
438-
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
441+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
439442
with:
440443
python-version: "3.12"
441444

@@ -483,7 +486,7 @@ jobs:
483486
run: gcovr -v -g -k -r . $env:GCOVR_FLAGS.split() -o coverage.xml
484487

485488
- name: Upload Coverage Results
486-
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
489+
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
487490
with:
488491
files: ./coverage.xml
489492
flags: ${{ matrix.sys }},unittest
@@ -519,7 +522,7 @@ jobs:
519522
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
520523

521524
- name: Setup Python
522-
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
525+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
523526
with:
524527
python-version: "3.12"
525528

@@ -574,7 +577,7 @@ jobs:
574577
python -m pytest --root-path=../../Dist/examples_bin
575578
576579
- name: Upload Coverage Results
577-
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
580+
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
578581
with:
579582
files: ./Tests/Pcap++Test/Pcap++Coverage.xml,./Tests/Packet++Test/Packet++Coverage.xml
580583
flags: ${{ matrix.os }},unittest,${{ matrix.pcap_lib }}
@@ -592,7 +595,7 @@ jobs:
592595
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
593596
- name: Test in FreeBSD
594597
id: test
595-
uses: vmactions/freebsd-vm@debf37ca7b7fa40e19c542ef7ba30d6054a706a4 # v1.1.5
598+
uses: vmactions/freebsd-vm@8873d98fd1413b5977cb2f7348fe329775159892 # v1.1.9
596599
with:
597600
release: ${{ matrix.version }}
598601
usesh: true
@@ -743,7 +746,7 @@ jobs:
743746
gcovr -v -r . $GCOVR_FLAGS -o coverage.xml
744747
745748
- name: Upload Coverage Results
746-
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
749+
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
747750
with:
748751
files: ./coverage.xml
749752
flags: xdp,unittest

.github/workflows/cifuzz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
dry-run: false
3636
sanitizer: ${{ matrix.sanitizer }}
3737
- name: Upload Crash
38-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
38+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
3939
if: failure() && steps.build.outcome == 'success'
4040
with:
4141
name: artifacts

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
# Initializes the CodeQL tools for scanning.
3131
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
32+
uses: github/codeql-action/init@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
3333
with:
3434
languages: ${{ matrix.language }}
3535
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -44,4 +44,4 @@ jobs:
4444
cmake --build build -j
4545
4646
- name: Perform CodeQL Analysis
47-
uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
47+
uses: github/codeql-action/analyze@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11

.github/workflows/package.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ jobs:
7272

7373
- name: Generate artifact attestation
7474
if: github.ref_type == 'tag'
75-
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
75+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
7676
with:
7777
subject-path: "${{ env.BUILD_DIR }}/*.tar.gz,${{ env.BUILD_DIR }}/*.deb,${{ env.BUILD_DIR }}/*.rpm"
7878

7979
- name: Upload binaries to release
8080
if: github.ref_type == 'tag'
81-
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
81+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
8282
with:
8383
draft: true
8484
allowUpdates: true
@@ -100,7 +100,7 @@ jobs:
100100
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
101101

102102
- name: Test in FreeBSD
103-
uses: vmactions/freebsd-vm@debf37ca7b7fa40e19c542ef7ba30d6054a706a4 # v1.1.5
103+
uses: vmactions/freebsd-vm@8873d98fd1413b5977cb2f7348fe329775159892 # v1.1.9
104104
with:
105105
release: ${{ matrix.version }}
106106
envs: 'BUILD_DIR'
@@ -114,13 +114,13 @@ jobs:
114114
115115
- name: Generate artifact attestation
116116
if: github.ref_type == 'tag'
117-
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
117+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
118118
with:
119119
subject-path: "${{ env.BUILD_DIR }}/*.tar.gz"
120120

121121
- name: Upload binaries to release
122122
if: github.ref_type == 'tag'
123-
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
123+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
124124
with:
125125
draft: true
126126
allowUpdates: true
@@ -169,13 +169,13 @@ jobs:
169169

170170
- name: Generate artifact attestation
171171
if: github.ref_type == 'tag'
172-
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
172+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
173173
with:
174174
subject-path: "${{ env.BUILD_DIR }}/*.tar.gz,${{ env.BUILD_DIR }}/*.pkg"
175175

176176
- name: Upload binaries to release
177177
if: github.ref_type == 'tag'
178-
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
178+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
179179
with:
180180
draft: true
181181
allowUpdates: true
@@ -201,7 +201,7 @@ jobs:
201201
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
202202

203203
- name: Setup MSYS2
204-
uses: msys2/setup-msys2@c52d1fa9c7492275e60fe763540fb601f5f232a1 # v2.25.0
204+
uses: msys2/setup-msys2@61f9e5e925871ba6c9e3e8da24ede83ea27fa91f # v2.27.0
205205
with:
206206
msystem: ${{matrix.sys}}
207207
update: true
@@ -240,13 +240,13 @@ jobs:
240240

241241
- name: Generate artifact attestation
242242
if: github.ref_type == 'tag'
243-
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
243+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
244244
with:
245245
subject-path: "${{ env.BUILD_DIR }}/*.zip"
246246

247247
- name: Upload binaries to release
248248
if: github.ref_type == 'tag'
249-
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
249+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
250250
with:
251251
draft: true
252252
allowUpdates: true
@@ -290,13 +290,13 @@ jobs:
290290

291291
- name: Generate artifact attestation
292292
if: github.ref_type == 'tag'
293-
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
293+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
294294
with:
295295
subject-path: "${{ env.BUILD_DIR }}/*.zip"
296296

297297
- name: Upload binaries to release
298298
if: github.ref_type == 'tag'
299-
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
299+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
300300
with:
301301
draft: true
302302
allowUpdates: true
@@ -353,7 +353,7 @@ jobs:
353353
mkdir -p "android-package"
354354
mv "${COMBINED_PACKAGE_DIR}" "android-package"
355355
356-
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
356+
- uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
357357
with:
358358
path: android-package
359359
name: android-package-${{ matrix.target }}-${{ matrix.api-version }}
@@ -368,7 +368,7 @@ jobs:
368368
id-token: write
369369

370370
steps:
371-
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
371+
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
372372
with:
373373
pattern: android-package-*
374374
merge-multiple: true
@@ -381,13 +381,13 @@ jobs:
381381
382382
- name: Generate artifact attestation
383383
if: github.ref_type == 'tag'
384-
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4
384+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
385385
with:
386386
subject-path: "${{ env.PACKAGE_DIR }}.tar.gz"
387387

388388
- name: Upload binaries to release
389389
if: github.ref_type == 'tag'
390-
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
390+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
391391
with:
392392
draft: true
393393
allowUpdates: true

.github/workflows/scorecards.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
persist-credentials: false
3737

3838
- name: "Run analysis"
39-
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
39+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
4040
with:
4141
results_file: results.sarif
4242
results_format: sarif
@@ -58,14 +58,14 @@ jobs:
5858
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
5959
# format to the repository Actions tab.
6060
- name: "Upload artifact"
61-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
61+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
6262
with:
6363
name: SARIF file
6464
path: results.sarif
6565
retention-days: 5
6666

6767
# Upload the results to GitHub's code scanning dashboard.
6868
- name: "Upload to code-scanning"
69-
uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
69+
uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
7070
with:
7171
sarif_file: results.sarif

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,31 @@ if(PCAPPP_USE_SANITIZER)
8585
endif()
8686
endif()
8787

88+
# Build options (Compile time log level)
89+
set(
90+
PCAPP_ALLOWED_LOG_LEVELS
91+
""
92+
"0"
93+
"1"
94+
"2"
95+
"3"
96+
)
97+
set(
98+
PCAPPP_LOG_LEVEL
99+
""
100+
CACHE STRING
101+
"Compile time log level (0 - Off, 1 - Error, 2 - Info, 3 - Debug) Default(empty): Debug"
102+
)
103+
set_property(CACHE PCAPPP_LOG_LEVEL PROPERTY STRINGS ${PCAPP_ALLOWED_LOG_LEVELS})
104+
105+
if(NOT PCAPPP_LOG_LEVEL IN_LIST PCAPP_ALLOWED_LOG_LEVELS)
106+
message(FATAL_ERROR "PCAPPP_LOG_LEVEL must be one of ${PCAPP_ALLOWED_LOG_LEVELS}")
107+
endif()
108+
109+
if(PCAPPP_LOG_LEVEL)
110+
add_compile_definitions("PCPP_ACTIVE_LOG_LEVEL=${PCAPPP_LOG_LEVEL}")
111+
endif()
112+
88113
# Build options (Turn on Examples and Tests if it's the main project)
89114
option(PCAPPP_BUILD_EXAMPLES "Build Examples" ${PCAPPP_MAIN_PROJECT})
90115
cmake_dependent_option(

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Every code contribution to this project is highly valued and appreciated. I enco
2424
- All new APIs are well documented using Doxygen (please use @ for keywords)
2525
- Make sure that pre-commit hooks are passing by using `pre-commit run --all-files`. For pre-commit hooks you need to install `cppcheck` and `clang-format` on your system. You can install them using the following commands:
2626
- `pre-commit`: `pip install pre-commit`
27-
- `cppcheck` (version 2.7 is recommended):
27+
- `cppcheck` (version 2.9 is recommended):
2828
- For Linux (apt) `sudo apt install cppcheck`
2929
- For Windows (using `choco`) `choco install cppcheck --version=2.7`
3030
- For Windows (MSI install): https://github.com/danmar/cppcheck/releases/download/2.7/cppcheck-2.7-x64-Setup.msi

Common++/header/SystemUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/// @file
1010

11+
// @todo Change to constexpr when C++17 is minimum supported version
1112
enum : uint8_t
1213
{
1314
MAX_NUM_OF_CORES = 32

Common++/src/SystemUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace
6060
/// A deleter that cleans up a FILE handle using pclose.
6161
struct PcloseDeleter
6262
{
63-
void operator()(FILE* ptr) const
63+
void operator()(FILE* ptr) const noexcept
6464
{
6565
PCLOSE(ptr);
6666
}

0 commit comments

Comments
 (0)