PengZheng commented on code in PR #799:
URL: https://github.com/apache/celix/pull/799#discussion_r2358889819


##########
.github/workflows/fuzzing.yml:
##########
@@ -0,0 +1,59 @@
+name: Celix Fuzzing
+
+on:
+  push:
+  pull_request:
+  schedule:
+    - cron: '0 3 * * *'
+
+jobs:
+  fuzz-utils:
+    runs-on: ubuntu-22.04
+    timeout-minutes: 30
+    steps:
+      - name: Checkout source code
+        uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0
+      - name: Set up Python
+        uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c 
#v4.9.1
+        with:
+          python-version: '3.x'
+      - name: Set Compiler Environment Variables
+        run: |
+          echo "CC=clang" >> $GITHUB_ENV
+          echo "CXX=clang++" >> $GITHUB_ENV
+      - name: Install Conan
+        run: pip install conan
+      - name: Cache Conan
+        uses: actions/cache@v3
+        with:
+          path: ~/.conan2/p
+          key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.py', 
'libs/utils/**') }}
+          restore-keys: |
+            ${{ runner.os }}-conan-
+      - name: Setup Conan Profile
+        run: |
+          conan profile detect 
+      - name: Conan install
+        run: conan install . --output-folder=build --build=missing -o 
"celix/*:build_utils=True" -o "celix/*:enable_fuzzing=True"
+      - name: Conan build
+        run: conan build . --output-folder=build -o "celix/*:build_utils=True" 
-o "celix/*:enable_fuzzing=True" -o "celix/*:celix_err_buffer_size=5120"
+      - name: Set fuzzer run time
+        id: set-runtime
+        run: |
+          if [[ "${{ github.event_name }}" == "schedule" ]]; then
+            echo "FUZZ_TIME=600" >> ${GITHUB_ENV}
+          else
+            echo "FUZZ_TIME=30" >> ${GITHUB_ENV}
+          fi
+      - name: Run properties fuzzer
+        run: |
+          source build/conanrun.sh
+          ./build/libs/utils/fuzzing/celix_properties_fuzzer 
-max_total_time=$FUZZ_TIME ./build/libs/utils/fuzzing/properties_corpus

Review Comment:
   Shall we let corpus to be maintained by CI?
   1. Commit CI's addition
   2. Add `-merge=1`



##########
.github/workflows/fuzzing.yml:
##########
@@ -0,0 +1,59 @@
+name: Celix Fuzzing
+
+on:
+  push:
+  pull_request:
+  schedule:
+    - cron: '0 3 * * *'
+
+jobs:
+  fuzz-utils:
+    runs-on: ubuntu-22.04
+    timeout-minutes: 30
+    steps:
+      - name: Checkout source code
+        uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0
+      - name: Set up Python
+        uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c 
#v4.9.1
+        with:
+          python-version: '3.x'
+      - name: Set Compiler Environment Variables
+        run: |
+          echo "CC=clang" >> $GITHUB_ENV
+          echo "CXX=clang++" >> $GITHUB_ENV
+      - name: Install Conan
+        run: pip install conan
+      - name: Cache Conan
+        uses: actions/cache@v3
+        with:
+          path: ~/.conan2/p
+          key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.py', 
'libs/utils/**') }}
+          restore-keys: |
+            ${{ runner.os }}-conan-
+      - name: Setup Conan Profile
+        run: |
+          conan profile detect 
+      - name: Conan install
+        run: conan install . --output-folder=build --build=missing -o 
"celix/*:build_utils=True" -o "celix/*:enable_fuzzing=True"

Review Comment:
   IIRC, for conan 2, this step in superfluous. 
   If options appear in install step, they don't need to be repeated in the 
build step.



##########
libs/utils/fuzzing/src/FilterFuzz.cc:
##########
@@ -0,0 +1,23 @@
+#include <celix_filter.h>
+#include <celix_err.h>
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+
+int filterParseFuzzOneInput(const uint8_t* data, size_t size) {
+    char* buffer = static_cast<char*>(malloc(size + 1));
+    if (buffer == nullptr) {
+        return 0;
+    }
+    memcpy(buffer, data, size);
+    buffer[size] = '\0';
+
+    celix_filter_t* filter = celix_filter_create(buffer);

Review Comment:
   `celix_filter_match` seems another interesting fuzzing target.



##########
.github/workflows/fuzzing.yml:
##########
@@ -0,0 +1,59 @@
+name: Celix Fuzzing
+
+on:
+  push:
+  pull_request:
+  schedule:
+    - cron: '0 3 * * *'
+
+jobs:
+  fuzz-utils:
+    runs-on: ubuntu-22.04
+    timeout-minutes: 30
+    steps:
+      - name: Checkout source code
+        uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0
+      - name: Set up Python
+        uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c 
#v4.9.1
+        with:
+          python-version: '3.x'
+      - name: Set Compiler Environment Variables
+        run: |
+          echo "CC=clang" >> $GITHUB_ENV
+          echo "CXX=clang++" >> $GITHUB_ENV
+      - name: Install Conan
+        run: pip install conan
+      - name: Cache Conan
+        uses: actions/cache@v3
+        with:
+          path: ~/.conan2/p
+          key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.py', 
'libs/utils/**') }}
+          restore-keys: |
+            ${{ runner.os }}-conan-
+      - name: Setup Conan Profile
+        run: |
+          conan profile detect 
+      - name: Conan install
+        run: conan install . --output-folder=build --build=missing -o 
"celix/*:build_utils=True" -o "celix/*:enable_fuzzing=True"
+      - name: Conan build
+        run: conan build . --output-folder=build -o "celix/*:build_utils=True" 
-o "celix/*:enable_fuzzing=True" -o "celix/*:celix_err_buffer_size=5120"

Review Comment:
   How about enabling ASAN and UBSAN altogether?



##########
libs/utils/CMakeLists.txt:
##########
@@ -126,5 +126,24 @@ if (UTILS)
         add_subdirectory(gtest)
     endif ()
 
+
+    if (ENABLE_FUZZING)
+        add_library(utils_cuf STATIC ${UTILS_SRC})
+        target_compile_definitions(utils_cuf PRIVATE CELIX_UTILS_STATIC_DEFINE)
+        target_include_directories(utils_cuf PUBLIC
+                        ${CMAKE_CURRENT_LIST_DIR}/include
+                        ${CMAKE_CURRENT_LIST_DIR}/include_internal
+                        ${CMAKE_BINARY_DIR}/celix/gen/includes/utils
+                        ${CMAKE_BINARY_DIR}/celix/gen/src/utils
+                        include_deprecated
+                        )
+        target_link_libraries(utils_cuf PUBLIC ${UTILS_PUBLIC_DEPS} 
${UTILS_PRIVATE_DEPS})
+        target_compile_options(utils_cuf PRIVATE 
-fsanitize=fuzzer-no-link,address) 

Review Comment:
   Oh, I see ASAN is enabled separately. Note that we have 
`enable_xxx_sanitizer` conan options.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to