Skip to content

Commit

Permalink
test: Update ClusterFuzzLite github->action (#356)
Browse files Browse the repository at this point in the history
Update ClusterFuzzLite github->action

Signed-off-by: Taras Drozdovskyi <[email protected]>
  • Loading branch information
tdrozdovsky authored Dec 13, 2023
1 parent ce2f7ae commit 057b21d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 42 deletions.
7 changes: 4 additions & 3 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ MAVEN_ARGS="-Djavac.src.version=11 -Djavac.target.version=11 -Denforcer.skip=tru
(cd $PROJECT && $MVN install $MAVEN_ARGS -Dmaven.repo.local=$OUT/m2)

# build classpath
$MVN dependency:build-classpath -Dmdep.outputFile=cp.txt -Dmaven.repo.local=$OUT/m2
$MVN dependency:build-classpath -DskipTests -Dmdep.outputFile=cp.txt -Dmaven.repo.local=$OUT/m2

cp -r $SRC/lpvs/target/test-classes/ $OUT/
RUNTIME_CLASSPATH_ABSOLUTE="$(cat cp.txt):$OUT/test-classes"
cp -r $SRC/lpvs/target/classes/ $OUT/
RUNTIME_CLASSPATH_ABSOLUTE="$(cat cp.txt):$OUT/test-classes:$OUT/classes"
RUNTIME_CLASSPATH=$(echo $RUNTIME_CLASSPATH_ABSOLUTE | sed "s|$OUT|\$this_dir|g")

for fuzzer in $(find $SRC -name '*Fuzzer.java'); do
Expand All @@ -33,7 +34,7 @@ MAVEN_ARGS="-Djavac.src.version=11 -Djavac.target.version=11 -Denforcer.skip=tru
LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\":\$this_dir \
\$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \
--cp=$RUNTIME_CLASSPATH \
--target_class=com.lpvs.entity.$fuzzer_basename \
--target_class=com.lpvs.util.$fuzzer_basename \
--jvm_args=\"\$mem_settings\" \
--instrumentation_includes=\"com.**:org.**\" \
\$@" > $OUT/$fuzzer_basename
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cflite_batch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ClusterFuzzLite PR fuzzing
name: ClusterFuzzLite fuzzing

on:
push:
Expand All @@ -13,7 +13,7 @@ jobs:
group: ${{ github.workflow }}-${{ matrix.sanitizer }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
fail-fast: true
matrix:
sanitizer:
- address
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 60
mode: 'code-change'
mode: 'batch'
sanitizer: ${{ matrix.sanitizer }}
output-sarif: true
# Optional but recommended: used to download the corpus produced by
Expand Down
36 changes: 0 additions & 36 deletions src/test/java/com/lpvs/entity/LPVSFileTestFuzzer.java

This file was deleted.

41 changes: 41 additions & 0 deletions src/test/java/com/lpvs/util/LPVSWebhookUtilTestFuzzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2023, Samsung Electronics Co., Ltd. All rights reserved.
*
* Use of this source code is governed by a MIT license that can be
* found in the LICENSE file.
*/
package com.lpvs.util;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import com.code_intelligence.jazzer.junit.FuzzTest;
import com.lpvs.entity.LPVSQueue;
import org.junitpioneer.jupiter.SetEnvironmentVariable;

import static org.junit.jupiter.api.Assertions.*;

public class LPVSWebhookUtilTestFuzzer {

@FuzzTest(maxDuration = "60s")
@SetEnvironmentVariable(key = "JAZZER_FUZZ", value = "1")
public void fuzzTestGetPullRequestId(FuzzedDataProvider data) {
System.setProperty("JAZZER_FUZZ", "1");

LPVSQueue webhookConfig = new LPVSQueue();

// Fuzzing input data
webhookConfig.setRepositoryUrl(data.consumeRemainingAsString());
webhookConfig.setPullRequestUrl(data.consumeRemainingAsString());

// Perform the fuzz test
try {
String result = LPVSWebhookUtil.getPullRequestId(webhookConfig);

// Validate the result
assertNotNull(result);
} catch (Exception e) {
// Handle exceptions caused by unexpected inputs gracefully
// Log the exception or perform other actions
fail("| Unexpected exception: --- | " + e.getMessage());
}
}
}

0 comments on commit 057b21d

Please sign in to comment.