commit bea7539148006f40938fffd71e953077c38247c1 parent 7afbb20817bc463d82f4941cfdbf01c1210aa239 Author: JohnMcPMS <johnmcp@microsoft.com> Date: Tue, 20 Apr 2021 14:10:36 -0700 Fix YAML fuzzer (#879) This change fixes the YAML fuzzer, at least enough to run it productively. It still is difficult to build, but the details are contained in the README.md file in the project. Diffstat:
17 files changed, 179 insertions(+), 28 deletions(-)
diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt @@ -41,6 +41,7 @@ chrono cin cla CLSCTX +cmake cmp CNG cnt @@ -198,6 +199,8 @@ junit langutil lastwritetime Linux +LLVM +llvmorg LOCALAPPDATA localtime LOGPATH @@ -215,11 +218,13 @@ MANIFESTSCHEMA MANIFESTVERSION MBs mday +memset metadata microsoft mimetype Minimatch MINORVERSION +mkdir monostate motw msbuild @@ -335,6 +340,7 @@ ruleset runsettings runtimes safecast +SANITIZERS savepoint screenshots SCROLLER @@ -473,6 +479,7 @@ utf uuidof validator valijson +vcvars vcxitems vcxproj vdproj diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt @@ -36,6 +36,7 @@ bomgar BOMs brk Buf +BUILTINS casemap casemappings cch diff --git a/.github/actions/spelling/patterns.txt b/.github/actions/spelling/patterns.txt @@ -28,6 +28,9 @@ El proyecto .* diferentes /NPH(?![a-z]) /td(?![a-z]) +# compile flags + -[TD] + # URLs -- Added here instead of allow.txt to facilitate wildcarding them as more are added http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer diff --git a/src/AppInstallerCLI.sln b/src/AppInstallerCLI.sln @@ -408,7 +408,8 @@ Global {82B39FDA-E86B-4713-A873-9D56DE00247A}.Debug|x86.Build.0 = Debug|Win32 {82B39FDA-E86B-4713-A873-9D56DE00247A}.Fuzzing|ARM.ActiveCfg = Release|ARM {82B39FDA-E86B-4713-A873-9D56DE00247A}.Fuzzing|ARM64.ActiveCfg = Release|ARM64 - {82B39FDA-E86B-4713-A873-9D56DE00247A}.Fuzzing|x64.ActiveCfg = Release|x64 + {82B39FDA-E86B-4713-A873-9D56DE00247A}.Fuzzing|x64.ActiveCfg = Fuzzing|x64 + {82B39FDA-E86B-4713-A873-9D56DE00247A}.Fuzzing|x64.Build.0 = Fuzzing|x64 {82B39FDA-E86B-4713-A873-9D56DE00247A}.Fuzzing|x86.ActiveCfg = Release|Win32 {82B39FDA-E86B-4713-A873-9D56DE00247A}.Release|ARM.ActiveCfg = Release|ARM {82B39FDA-E86B-4713-A873-9D56DE00247A}.Release|ARM.Build.0 = Release|ARM @@ -420,7 +421,8 @@ Global {82B39FDA-E86B-4713-A873-9D56DE00247A}.Release|x86.Build.0 = Release|Win32 {1622DA16-914F-4F57-A259-D5169003CC8C}.Debug|ARM.ActiveCfg = Fuzzing|x64 {1622DA16-914F-4F57-A259-D5169003CC8C}.Debug|ARM64.ActiveCfg = Fuzzing|x64 - {1622DA16-914F-4F57-A259-D5169003CC8C}.Debug|x64.ActiveCfg = Fuzzing|x64 + {1622DA16-914F-4F57-A259-D5169003CC8C}.Debug|x64.ActiveCfg = Debug|x64 + {1622DA16-914F-4F57-A259-D5169003CC8C}.Debug|x64.Build.0 = Debug|x64 {1622DA16-914F-4F57-A259-D5169003CC8C}.Debug|x86.ActiveCfg = Fuzzing|x64 {1622DA16-914F-4F57-A259-D5169003CC8C}.Fuzzing|ARM.ActiveCfg = Fuzzing|x64 {1622DA16-914F-4F57-A259-D5169003CC8C}.Fuzzing|ARM64.ActiveCfg = Fuzzing|x64 diff --git a/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj b/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj @@ -69,8 +69,7 @@ <ConfigurationType>StaticLibrary</ConfigurationType> <PlatformToolset>v140</PlatformToolset> <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0' And '$(Configuration)'!='Fuzzing'">v142</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0' And '$(Configuration)'=='Fuzzing'">ClangCL</PlatformToolset> + <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> @@ -86,6 +85,7 @@ <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <LinkIncremental>false</LinkIncremental> + <EnableASAN>true</EnableASAN> </PropertyGroup> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <SpectreMitigation>Spectre</SpectreMitigation> @@ -283,7 +283,7 @@ <LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Fuzzing|ARM64'">stdcpp17</LanguageStandard> <LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Fuzzing|Win32'">stdcpp17</LanguageStandard> <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'">MultiThreaded</RuntimeLibrary> - <AdditionalOptions>%(AdditionalOptions) -fsanitize=fuzzer,address</AdditionalOptions> + <AdditionalOptions>%(AdditionalOptions) /fsanitize-coverage=inline-8bit-counters /fsanitize-coverage=edge /fsanitize-coverage=trace-cmp /fsanitize-coverage=trace-div</AdditionalOptions> </ClCompile> <Link> <EnableCOMDATFolding>true</EnableCOMDATFolding> @@ -343,7 +343,9 @@ <ClInclude Include="YamlWrapper.h" /> </ItemGroup> <ItemGroup> - <ClCompile Include="GroupPolicy.cpp" /> + <ClCompile Include="GroupPolicy.cpp"> + <ExcludedFromBuild Condition="'$(Configuration)'=='Fuzzing'">true</ExcludedFromBuild> + </ClCompile> <ClCompile Include="AppInstallerLogging.cpp" /> <ClCompile Include="AppInstallerStrings.cpp" /> <ClCompile Include="DateTime.cpp" /> diff --git a/src/AppInstallerCommonCore/Manifest/ManifestCommon.cpp b/src/AppInstallerCommonCore/Manifest/ManifestCommon.cpp @@ -258,7 +258,7 @@ namespace AppInstaller::Manifest } else { - THROW_HR_MSG(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), "Unsupported ManifestType: %s", in.c_str()); + THROW_HR_MSG(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), "Unsupported ManifestType: %hs", in.c_str()); } } diff --git a/src/AppInstallerCommonCore/Public/AppInstallerLanguageUtilities.h b/src/AppInstallerCommonCore/Public/AppInstallerLanguageUtilities.h @@ -45,6 +45,7 @@ namespace AppInstaller }; // Enables a bool to be used as a destruction indicator. + // Default construction *sets the value to false!* using DestructionToken = ResetWhenMovedFrom<bool>; // Enable use of folding to execute functions across parameter packs. diff --git a/src/AppInstallerCommonCore/Public/winget/ManifestLocalization.h b/src/AppInstallerCommonCore/Public/winget/ManifestLocalization.h @@ -44,7 +44,7 @@ namespace AppInstaller::Manifest // Used to deduce the LocalizationVariant type; making a variant that includes std::monostate and all LocalizationMapping types. template <size_t... I> - inline auto Deduce(std::index_sequence<I...>) { return std::variant<std::monostate, LocalizationMapping<static_cast<Localization>(I)>::value_t...>{}; } + inline auto Deduce(std::index_sequence<I...>) { return std::variant<std::monostate, typename LocalizationMapping<static_cast<Localization>(I)>::value_t...>{}; } // Holds data of any type listed in a LocalizationMapping. using LocalizationVariant = decltype(Deduce(std::make_index_sequence<static_cast<size_t>(Localization::Max)>())); diff --git a/src/AppInstallerCommonCore/Regex.cpp b/src/AppInstallerCommonCore/Regex.cpp @@ -57,6 +57,7 @@ namespace AppInstaller::Regex impl& operator=(const impl& other) { *this = impl{ other }; + return *this; } impl(impl&&) = default; diff --git a/src/AppInstallerCommonCore/Runtime.cpp b/src/AppInstallerCommonCore/Runtime.cpp @@ -5,6 +5,8 @@ #include "Public/AppInstallerRuntime.h" #include "Public/AppInstallerStrings.h" +#include <optional> + #define WINGET_DEFAULT_LOG_DIRECTORY "DiagOutputDir" namespace AppInstaller::Runtime diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp @@ -65,7 +65,7 @@ namespace AppInstaller::Settings } return {}; - } + } template <Setting S> std::optional<typename details::SettingMapping<S>::json_t> GetValueFromPolicy() @@ -150,15 +150,8 @@ namespace AppInstaller::Settings std::vector<UserSettings::Warning>& warnings, std::index_sequence<S...>) { -#ifdef WINGET_DISABLE_FOR_FUZZING -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-value" -#endif // Use folding to call each setting validate function. (FoldHelper{}, ..., Validate<static_cast<Setting>(S)>(root, settings, warnings)); -#ifdef WINGET_DISABLE_FOR_FUZZING -#pragma clang diagnostic pop -#endif } } diff --git a/src/AppInstallerCommonCore/YamlWrapper.cpp b/src/AppInstallerCommonCore/YamlWrapper.cpp @@ -78,7 +78,7 @@ namespace AppInstaller::YAML::Wrapper } Document::Document(bool init) : - m_token(init), m_document{} + m_token(true) { if (init) { @@ -88,6 +88,10 @@ namespace AppInstaller::YAML::Wrapper THROW_HR(APPINSTALLER_CLI_ERROR_YAML_DOC_BUILD_FAILED); } } + else + { + memset(&m_document, 0, sizeof(m_document)); + } } Document::~Document() @@ -364,6 +368,7 @@ namespace AppInstaller::YAML::Wrapper { Event result; THROW_HR_IF(APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED, !yaml_stream_start_event_initialize(&result, YAML_UTF8_ENCODING)); + result.m_token = true; return result; } @@ -371,6 +376,7 @@ namespace AppInstaller::YAML::Wrapper { Event result; THROW_HR_IF(APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED, !yaml_stream_end_event_initialize(&result)); + result.m_token = true; return result; } @@ -378,6 +384,7 @@ namespace AppInstaller::YAML::Wrapper { Event result; THROW_HR_IF(APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED, !yaml_document_start_event_initialize(&result, NULL, NULL, NULL, 1)); + result.m_token = true; return result; } @@ -385,6 +392,7 @@ namespace AppInstaller::YAML::Wrapper { Event result; THROW_HR_IF(APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED, !yaml_document_end_event_initialize(&result, 1)); + result.m_token = true; return result; } @@ -392,6 +400,7 @@ namespace AppInstaller::YAML::Wrapper { Event result; THROW_HR_IF(APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED, !yaml_sequence_start_event_initialize(&result, NULL, NULL, 1, YAML_ANY_SEQUENCE_STYLE)); + result.m_token = true; return result; } @@ -399,6 +408,7 @@ namespace AppInstaller::YAML::Wrapper { Event result; THROW_HR_IF(APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED, !yaml_sequence_end_event_initialize(&result)); + result.m_token = true; return result; } @@ -406,6 +416,7 @@ namespace AppInstaller::YAML::Wrapper { Event result; THROW_HR_IF(APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED, !yaml_mapping_start_event_initialize(&result, NULL, NULL, 1, YAML_ANY_MAPPING_STYLE)); + result.m_token = true; return result; } @@ -413,6 +424,7 @@ namespace AppInstaller::YAML::Wrapper { Event result; THROW_HR_IF(APPINSTALLER_CLI_ERROR_YAML_INIT_FAILED, !yaml_mapping_end_event_initialize(&result)); + result.m_token = true; return result; } diff --git a/src/JsonCppLib/JsonCppLib.vcxproj b/src/JsonCppLib/JsonCppLib.vcxproj @@ -13,6 +13,10 @@ <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> + <ProjectConfiguration Include="Fuzzing|x64"> + <Configuration>Fuzzing</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="Release|ARM"> <Configuration>Release</Configuration> <Platform>ARM</Platform> @@ -73,6 +77,12 @@ <PlatformToolset>v142</PlatformToolset> <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + <EnableASAN>true</EnableASAN> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> @@ -108,6 +118,9 @@ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> @@ -126,6 +139,9 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'"> + <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir> + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\</OutDir> </PropertyGroup> @@ -181,6 +197,15 @@ <WarningLevel>Level3</WarningLevel> </ClCompile> </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'"> + <ClCompile> + <LanguageStandard>stdcpp17</LanguageStandard> + <AdditionalIncludeDirectories>json</AdditionalIncludeDirectories> + <WarningLevel>Level3</WarningLevel> + <AdditionalOptions>/fsanitize-coverage=inline-8bit-counters /fsanitize-coverage=edge /fsanitize-coverage=trace-cmp /fsanitize-coverage=trace-div %(AdditionalOptions)</AdditionalOptions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + </ClCompile> + </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <ClCompile> <LanguageStandard>stdcpp17</LanguageStandard> diff --git a/src/WinGetYamlFuzzing/README.md b/src/WinGetYamlFuzzing/README.md @@ -1,11 +1,30 @@ # WinGetYamlFuzzing -The goal of this project is to create a [libFuzzer](http://llvm.org/docs/LibFuzzer.html) based fuzzer for our YAML manifest loading. +The goal of this project is to create a [libFuzzer](http://llvm.org/docs/LibFuzzer.html) based fuzzer for our YAML manifest parsing. ## Issues -Currently the fuzzer crashes when exceptions are thrown (built using the VS clang 10 package). This is suspected to be caused by the issue mentioned [here](https://github.com/google/oss-fuzz/issues/2328), -which while fixed, was also regressed. While investigation continues, the fuzzer is of little value. +There is a known issue that is fixed in LLVM 12 for running on Windows, and the only known method to build a successful fuzzer is to manually build a local copy of libFuzzer and link it in to this project. + +## Building + +First, clone https://github.com/llvm/llvm-project/tree/llvmorg-12.0.0-rc4 (last known working). + +From the local clone, run these commands in `cmd` (modifying VS install location as needed): +``` +mkdir build +cd build +set verbose=1 +call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" +cmake -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" -DCOMPILER_RT_BUILD_BUILTINS=OFF -DCOMPILER_RT_BUILD_CRT=OFF -DCOMPILER_RT_BUILD_SANITIZERS=OFF -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_PROFILE=OFF -DLLVM_TARGETS_TO_BUILD=X86 -Thost=x64 ../llvm +cmake --build . --target fuzzer --config Release +mkdir ..\install +powershell -Command "$file = 'projects\compiler-rt\lib\fuzzer\cmake_install.cmake'; (Get-Content $file) -replace '\$\(Configuration\)', 'Release' | Out-File -Encoding utf8 $file" +cmake --install . --component fuzzer --config Release -v --prefix ../install +tree /F ..\install +``` + +Once this has built, update the project's Linker>Input settings to change the placeholder lib to the location of the `clang_rt.fuzzer-x86_64.lib` file under the install directory. ## Running -A script will be added when the issues are resolved and the fuzzer functions. In order to run it I have been doing the following: +A script will be added when the issues are resolved and the fuzzer functions out of the box. In order to run it I have been doing the following: 1. Copy the CLITests TestData YAML files to a new corpus directory. 2. Run the following command: `WinGetYamlFuzzing.exe -dict=<full path to dictionary.txt in project> <path to corpus directory>` \ No newline at end of file diff --git a/src/WinGetYamlFuzzing/WinGetYamlFuzzing.cpp b/src/WinGetYamlFuzzing/WinGetYamlFuzzing.cpp @@ -10,9 +10,50 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) try { - AppInstaller::Manifest::Manifest manifest = AppInstaller::Manifest::YamlParser::Create(input, true); + AppInstaller::Manifest::Manifest manifest = AppInstaller::Manifest::YamlParser::Create(input, false); } catch (...) {} return 0; } + +#ifndef WINGET_DISABLE_FOR_FUZZING + +#include <filesystem> +#include <AppInstallerStrings.h> + +// Emulate libFuzzer main by just sending all files in the corpus (last arg) to the fuzzer. +int main(int argc, char** argv) +{ + if (argc <= 1) + { + return 1; + } + + std::filesystem::path corpus = argv[argc - 1]; + + if (std::filesystem::is_directory(corpus)) + { + for (auto& file : std::filesystem::directory_iterator{ corpus }) + { + if (!file.is_directory()) + { + std::ifstream stream{ file.path(), std::ios_base::in | std::ios_base::binary }; + std::string contents = AppInstaller::Utility::ReadEntireStream(stream); + + LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t*>(contents.data()), contents.size()); + } + } + } + else + { + std::ifstream stream{ corpus, std::ios_base::in | std::ios_base::binary }; + std::string contents = AppInstaller::Utility::ReadEntireStream(stream); + + LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t*>(contents.data()), contents.size()); + } + + return 0; +} + +#endif diff --git a/src/WinGetYamlFuzzing/WinGetYamlFuzzing.vcxproj b/src/WinGetYamlFuzzing/WinGetYamlFuzzing.vcxproj @@ -1,6 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="Fuzzing|x64"> <Configuration>Fuzzing</Configuration> <Platform>x64</Platform> @@ -17,7 +21,15 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>ClangCL</PlatformToolset> + <PlatformToolset>v142</PlatformToolset> + <WholeProgramOptimization>false</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <EnableASAN>true</EnableASAN> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> @@ -30,10 +42,16 @@ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'"> <LinkIncremental>false</LinkIncremental> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Fuzzing|x64'"> <ClCompile> <WarningLevel>Level3</WarningLevel> @@ -45,14 +63,35 @@ <LanguageStandard>stdcpp17</LanguageStandard> <AdditionalIncludeDirectories>$(ProjectDir)..\AppInstallerCommonCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <AdditionalOptions>-fsanitize=fuzzer,address %(AdditionalOptions)</AdditionalOptions> + <AdditionalOptions>/fsanitize-coverage=inline-8bit-counters /fsanitize-coverage=edge /fsanitize-coverage=trace-cmp /fsanitize-coverage=trace-div %(AdditionalOptions)</AdditionalOptions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalDependencies>YOUR_LLVM_BUILT_LIBFUZZER.lib;legacy_stdio_definitions.lib;libsancov.lib;icuuc.lib;icuin.lib;urlmon.lib;Bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <LanguageStandard>stdcpp17</LanguageStandard> + <AdditionalIncludeDirectories>$(ProjectDir)..\AppInstallerCommonCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <Optimization>Disabled</Optimization> </ClCompile> <Link> <SubSystem>Console</SubSystem> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>$(LLVMInstallDir)\lib\clang\10.0.0\lib\windows\clang_rt.asan-preinit-x86_64.lib;$(LLVMInstallDir)\lib\clang\10.0.0\lib\windows\clang_rt.asan-x86_64.lib;$(LLVMInstallDir)\lib\clang\10.0.0\lib\windows\clang_rt.asan_cxx-x86_64.lib;$(LLVMInstallDir)\lib\clang\10.0.0\lib\windows\clang_rt.fuzzer-x86_64.lib;icuuc.lib;icuin.lib;urlmon.lib;Bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies> + <AdditionalDependencies>icuuc.lib;icuin.lib;urlmon.lib;Bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemGroup> @@ -62,6 +101,9 @@ <ProjectReference Include="..\AppInstallerCommonCore\AppInstallerCommonCore.vcxproj"> <Project>{5890d6ed-7c3b-40f3-b436-b54f640d9e65}</Project> </ProjectReference> + <ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj"> + <Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project> + </ProjectReference> <ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj"> <Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project> </ProjectReference> diff --git a/src/YamlCppLib/YamlCppLib.vcxproj b/src/YamlCppLib/YamlCppLib.vcxproj @@ -81,8 +81,7 @@ <ConfigurationType>StaticLibrary</ConfigurationType> <PlatformToolset>v140</PlatformToolset> <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0' And '$(Configuration)'!='Fuzzing'">v142</PlatformToolset> - <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0' And '$(Configuration)'=='Fuzzing'">ClangCL</PlatformToolset> + <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> @@ -103,6 +102,7 @@ <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <LinkIncremental>false</LinkIncremental> + <EnableASAN>true</EnableASAN> </PropertyGroup> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <SpectreMitigation>Spectre</SpectreMitigation> @@ -257,7 +257,7 @@ <AdditionalIncludeDirectories>libyaml\include;$(ProjectDir)</AdditionalIncludeDirectories> <LanguageStandard>Default</LanguageStandard> <WarningLevel>Level3</WarningLevel> - <AdditionalOptions>/D YAML_DECLARE_STATIC /D HAVE_CONFIG_H -fsanitize=fuzzer,address %(AdditionalOptions)</AdditionalOptions> + <AdditionalOptions>/D YAML_DECLARE_STATIC /D HAVE_CONFIG_H /fsanitize-coverage=inline-8bit-counters /fsanitize-coverage=edge /fsanitize-coverage=trace-cmp /fsanitize-coverage=trace-div %(AdditionalOptions)</AdditionalOptions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> </ClCompile> </ItemDefinitionGroup>