mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-20 00:31:32 +08:00
7a04a4b396
- Add a solution to provide fuzzer support for afl-fuzz and libfuzzer. - Add fuzz targets for Binary, Json and Xml encoder and decoder fuzzing. For afl-fuzz and libfuzzer. - Fix issues in encoders and decoders when unexpected exceptions are returned. The expectation is to return only ServiceResultException with BadDecodingError, BadEncodingError or BadEncodingLimitsExceeded. - Add a tool to create Testcases. - Add a tool to playback crashes and timeouts. - Solution is extensible with common files to discover new fuzz targets by reflection. New fuzz projects can share many files with the first project. - Breaking change: Fix how BinaryDecoder is used: Previously, calling close on the BinaryDecoder implicitly disposed the stream. Change behavior so that `using` pattern can be applied across the board.
68 lines
1.7 KiB
PowerShell
68 lines
1.7 KiB
PowerShell
param (
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$project,
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$i,
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$fuzztarget,
|
|
[string]$x = $null,
|
|
[int]$t = 10000,
|
|
[string]$command = "sharpfuzz"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
|
|
$outputDir = "bin"
|
|
$findingsDir = "findings"
|
|
|
|
if (Test-Path $outputDir) {
|
|
Remove-Item -Recurse -Force $outputDir
|
|
}
|
|
|
|
if (Test-Path $findingsDir) {
|
|
Remove-Item -Recurse -Force $findingsDir
|
|
}
|
|
|
|
dotnet publish $project --force -c release -o $outputDir
|
|
|
|
$projectName = (Get-Item $project).BaseName
|
|
$projectDll = "$projectName.dll"
|
|
$project = Join-Path $outputDir $projectDll
|
|
|
|
$exclusions = @(
|
|
"dnlib.dll",
|
|
"SharpFuzz.dll",
|
|
"SharpFuzz.Common.dll",
|
|
$projectDll
|
|
)
|
|
|
|
$fuzzingTargets = Get-ChildItem $outputDir -Filter *.dll `
|
|
| Where-Object { $_.Name -notin $exclusions } `
|
|
| Where-Object { $_.Name -notlike "System.*.dll" }
|
|
|
|
if (($fuzzingTargets | Measure-Object).Count -eq 0) {
|
|
Write-Error "No fuzzing targets found"
|
|
exit 1
|
|
}
|
|
|
|
foreach ($fuzzingTarget in $fuzzingTargets) {
|
|
Write-Output "Instrumenting $fuzzingTarget"
|
|
& $command $fuzzingTarget
|
|
|
|
if ($LastExitCode -ne 0) {
|
|
Write-Error "An error occurred while instrumenting $fuzzingTarget"
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
$env:AFL_SKIP_BIN_CHECK = 1
|
|
|
|
if ($x) {
|
|
Write-Output "afl-fuzz -i $i -o $findingsDir -t $t -m none -x $x dotnet $project $fuzztarget"
|
|
afl-fuzz -i $i -o $findingsDir -t $t -m none -x $x dotnet $project $fuzztarget
|
|
}
|
|
else {
|
|
Write-Output "afl-fuzz -i $i -o $findingsDir -t $t -m none dotnet $project $fuzztarget"
|
|
afl-fuzz -i $i -o $findingsDir -t $t -m none dotnet $project $fuzztarget
|
|
}
|