From 3d0ba4ad4a9dcb5ed134aff3d16a2fe31374d112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DOTTEL=20Ga=C3=ABl?= Date: Wed, 11 Mar 2026 23:37:54 +0100 Subject: [PATCH 1/3] Add a check for VideoSnapshot&& to ImageViewRGB32 conversion --- .../workflows/cpp-ci-serial-programs-base.yml | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cpp-ci-serial-programs-base.yml b/.github/workflows/cpp-ci-serial-programs-base.yml index d467c9db0..1da3c2b3d 100644 --- a/.github/workflows/cpp-ci-serial-programs-base.yml +++ b/.github/workflows/cpp-ci-serial-programs-base.yml @@ -86,7 +86,7 @@ jobs: mkdir bin cd bin cmake .. -DQT_MAJOR:STRING=6 ${{env.CMAKE_ADDITIONAL_FLAGS}} - cmake --build . --config RelWithDebInfo --parallel 10 + # cmake --build . --config RelWithDebInfo --parallel 10 - name: Prepare upload build if: inputs.upload-build @@ -132,18 +132,49 @@ jobs: cd Arduino-Source cat << 'EOF' > query.txt - set output dump - match invocation( + set output diag + match cxxConstructExpr( isExpansionInFileMatching("SerialPrograms/"), hasDeclaration(cxxConstructorDecl(ofClass(hasName("std::filesystem::path")))), hasArgument(0, hasType(asString("std::string"))) ) + + # match cxxConstructExpr( + # isExpansionInFileMatching("SerialPrograms/"), + # hasDeclaration(cxxConstructorDecl(ofClass(hasName("ImageViewRGB32")))), + # hasArgument(0, hasType(rValueReferenceType(pointee(hasType(hasName("VideoSnapshot")))))), + # unless(hasAncestor(functionDecl(isInline()))) + # ) + + match cxxConstructExpr( + isExpansionInFileMatching("SerialPrograms/"), + hasDeclaration(cxxConstructorDecl(ofClass(hasName("ImageViewRGB32")))), + hasArgument(0, hasType(asString("VideoSnapshot"))), + unless(hasAncestor(functionDecl(isInline()))) + ) EOF - files=$(jq -r '.[].file' SerialPrograms/bin/compile_commands.json) - echo "$files" | xargs --max-args=150 clang-query -p SerialPrograms/bin/ -f query.txt >> output.txt - cat output.txt - if grep --silent "Match #" output.txt; then - echo "::error Forbidden std::filesystem::path construction detected!" + # files=$(jq -r '.[].file' SerialPrograms/bin/compile_commands.json) + # echo "$files" | xargs --max-args=150 clang-query -p SerialPrograms/bin/ -f query.txt >> clang-query_output.txt + clang-query -p SerialPrograms/bin/ /home/runner/work/Arduino-Source/Arduino-Source/Arduino-Source/3rdParty/QtWavFile/WavFile.cpp -f query.txt >> clang-query_output.txt + + echo "Clang query output (begin)" + cat clang-query_output.txt + echo "Clang query output (end)" + + if grep --silent "Match #" clang-query_output.txt; then + echo "::error Forbidden code detected! It can be one of the following:" + echo "::error - std::filesystem::path created from std::string. More information https://discord.com/channels/695809740428673034/1462210406616531259/1462567541825339635" + echo "::error - ImageViewRGB32 created from VideoSnapshot&& that is stored. It is a dangling pointer as nothing hold the data anymore" + echo "::error You can read more about the exact error with the artifact below." exit 1 fi + + - name: Upload Clang query output + uses: actions/upload-artifact@v7 + if: inputs.run-clang-query && always() + with: + name: Clang query output (compiler=${{inputs.compiler}}) + path: | + Arduino-Source/SerialPrograms/bin/compile_commands.json + Arduino-Source/clang-query_output.txt \ No newline at end of file From 0175651b2652b81d3b39c0da2c23275ca839c570 Mon Sep 17 00:00:00 2001 From: pifopi Date: Sun, 29 Mar 2026 18:50:19 +0200 Subject: [PATCH 2/3] Iterate --- .github/workflows/cpp-ci-serial-programs-base.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp-ci-serial-programs-base.yml b/.github/workflows/cpp-ci-serial-programs-base.yml index 1da3c2b3d..00a6d8eb5 100644 --- a/.github/workflows/cpp-ci-serial-programs-base.yml +++ b/.github/workflows/cpp-ci-serial-programs-base.yml @@ -149,7 +149,7 @@ jobs: match cxxConstructExpr( isExpansionInFileMatching("SerialPrograms/"), hasDeclaration(cxxConstructorDecl(ofClass(hasName("ImageViewRGB32")))), - hasArgument(0, hasType(asString("VideoSnapshot"))), + hasArgument(0, hasType(rValueReferenceType(pointee(hasType(hasName("VideoSnapshot")))))), unless(hasAncestor(functionDecl(isInline()))) ) EOF From 0266acada629f1f16b24580460bd9563fe81c372 Mon Sep 17 00:00:00 2001 From: pifopi Date: Sun, 29 Mar 2026 20:22:22 +0200 Subject: [PATCH 3/3] clang-query --version --- .github/workflows/cpp-ci-serial-programs-base.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cpp-ci-serial-programs-base.yml b/.github/workflows/cpp-ci-serial-programs-base.yml index 00a6d8eb5..b9f82be61 100644 --- a/.github/workflows/cpp-ci-serial-programs-base.yml +++ b/.github/workflows/cpp-ci-serial-programs-base.yml @@ -131,6 +131,7 @@ jobs: run : | cd Arduino-Source + clang-query --version cat << 'EOF' > query.txt set output diag match cxxConstructExpr(