Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup OneFuzz for CI #10431

Merged
46 commits merged into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f39b092
Setup OneFuzz
carlos-zamora Jun 8, 2021
284a4a7
Fix pipeline syntax issues
carlos-zamora Jun 8, 2021
6e6a6ed
fix platform
carlos-zamora Jun 8, 2021
f2f188f
fix configs --> fix build
carlos-zamora Jun 11, 2021
e8266b1
add some conditions to the build template
carlos-zamora Jun 11, 2021
da864ed
test: print variable to see if it's populated
carlos-zamora Jun 11, 2021
d4ae5f9
or --> and (bad logic)
carlos-zamora Jun 11, 2021
e3f64b9
BUILD PLATFORM --> CONFIGURATION
carlos-zamora Jun 11, 2021
bda579d
remove useless build step; try fix onefuzz cmd
carlos-zamora Jun 11, 2021
02af781
fix syntax error
carlos-zamora Jun 11, 2021
ce26d64
escape the slasher
carlos-zamora Jun 11, 2021
aa644e9
fix onefuxx call (this one should work)
carlos-zamora Jun 11, 2021
74bcb1c
stages don't preserve file system changes
carlos-zamora Jun 11, 2021
7611c6c
apparently you NEED a stage
carlos-zamora Jun 12, 2021
745728a
3rd time's the charm?
carlos-zamora Jun 12, 2021
db0fdd6
pointed at the wrong thing
carlos-zamora Jun 12, 2021
153971a
bring back stages; fiz path
carlos-zamora Jun 14, 2021
dc9fd55
actually download the artifacts
carlos-zamora Jun 14, 2021
facdf77
added an extra slash
carlos-zamora Jun 14, 2021
35c9967
don't forget the _drop_
carlos-zamora Jun 14, 2021
1030c06
fix up those slashes
carlos-zamora Jun 14, 2021
7719b1f
add a variable for SHA1, just to get going
carlos-zamora Jun 14, 2021
83ea5f3
fix fuzz.yml; add doc
carlos-zamora Jun 15, 2021
a8c905d
Migrate spelling-0.0.19 changes from main
DHowett Jun 15, 2021
4e3a1ba
Merge branch 'main' into dev/cazamor/onefuzz/setup
carlos-zamora Jun 23, 2021
c91e078
address PR feedback
carlos-zamora Jun 23, 2021
16d226a
apply PR feedback; add notifications
carlos-zamora Jun 23, 2021
1268cc1
Merge branch 'main' into dev/cazamor/onefuzz/setup
carlos-zamora Nov 18, 2021
a578d87
Merge branch 'dev/cazamor/onefuzz/setup' of https://github.com/micros…
carlos-zamora Nov 18, 2021
c32524a
spelling
carlos-zamora Nov 18, 2021
541b25c
fix indents
carlos-zamora Nov 18, 2021
4bd3095
change build pool & remove unused PGO steps
carlos-zamora Nov 22, 2021
c97787f
copy over relevant missing steps from build-console-steps (broken sin…
carlos-zamora Nov 22, 2021
ce52098
fix build
carlos-zamora Nov 22, 2021
8303728
couldn't find fuzzer lib, add MT to help
carlos-zamora Nov 22, 2021
d5c7ceb
set up notifications; ready for review
carlos-zamora Nov 23, 2021
d8d0cc9
spellcheck
carlos-zamora Nov 23, 2021
e15f639
fix path to json
carlos-zamora Nov 23, 2021
158d242
fix env var references
carlos-zamora Nov 23, 2021
1a2da08
add client secret
carlos-zamora Nov 23, 2021
9c56cdf
fix pool name
carlos-zamora Nov 30, 2021
bbbe99a
fix pool name for notifications version too
carlos-zamora Nov 30, 2021
c3fd708
Update doc/fuzzing.md
carlos-zamora Dec 8, 2021
78dd57b
polish fuzzing pipeline; update docs; add load bearing comment
carlos-zamora Jan 4, 2022
a5cc2ff
Merge branch 'main' into dev/cazamor/onefuzz/setup
carlos-zamora Jan 21, 2022
4084c62
enable notifications
carlos-zamora Jan 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/spelling/allow/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apc
Apc
bsd
calt
CMMI
ccmp
changelog
clickable
Expand Down Expand Up @@ -37,6 +38,7 @@ img
inlined
It'd
kje
libfuzzer
liga
lje
Llast
Expand All @@ -48,11 +50,13 @@ maxed
mkmk
mnt
mru
noreply
nje
noreply
ogonek
ok'd
overlined
pipeline
postmodern
ptys
qof
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/spelling/allow/apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DERR
dlldata
DONTADDTORECENT
DWORDLONG
endfor
enumset
environstrings
EXPCMDFLAGS
Expand Down Expand Up @@ -120,6 +121,7 @@ oaidl
ocidl
ODR
offsetof
onefuzz
osver
OSVERSIONINFOEXW
otms
Expand Down
1 change: 1 addition & 0 deletions .github/actions/spelling/allow/microsoft.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ MSVC
muxc
netcore
osgvsowi
Onefuzz
PFILETIME
pgc
pgo
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/spelling/allow/names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dhowett
Diviness
dsafa
duhowett
DXP
ekg
eryksun
ethanschoonover
Expand Down Expand Up @@ -69,6 +70,7 @@ sonpham
stakx
thereses
Walisch
WDX
Wellons
Wirt
Wojciech
Expand Down
1 change: 1 addition & 0 deletions .github/actions/spelling/expect/web.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mdtauk
cppreference
gfycat
Guake
azurewebsites
askubuntu
dostips
viewtopic
Expand Down
1 change: 1 addition & 0 deletions .vsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"Microsoft.VisualStudio.Component.VC.ASAN",
"Microsoft.VisualStudio.Component.VC.v142.x86.x64",
"Microsoft.VisualStudio.Component.VC.v142.ARM64",
"Microsoft.VisualStudio.ComponentGroup.UWP.VC",
Expand Down
11 changes: 3 additions & 8 deletions OpenConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1200,11 +1200,11 @@ Global
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Debug|x86.Build.0 = Debug|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|Any CPU.ActiveCfg = Debug|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|ARM.ActiveCfg = Debug|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|ARM64.ActiveCfg = Fuzzing|ARM64
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|DotNet_x64Test.ActiveCfg = Fuzzing|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|ARM64.ActiveCfg = Debug|ARM64
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|DotNet_x64Test.ActiveCfg = Debug|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|DotNet_x86Test.ActiveCfg = Debug|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|x64.ActiveCfg = Debug|x64
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|x86.ActiveCfg = Fuzzing|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Fuzzing|x86.ActiveCfg = Debug|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Release|Any CPU.ActiveCfg = Release|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Release|ARM.ActiveCfg = Release|Win32
{099193A0-1E43-4BBC-BA7F-7B351E1342DF}.Release|ARM64.ActiveCfg = Release|ARM64
Expand Down Expand Up @@ -1271,7 +1271,6 @@ Global
{919544AC-D39B-463F-8414-3C3C67CF727C}.Fuzzing|DotNet_x64Test.ActiveCfg = Fuzzing|Win32
{919544AC-D39B-463F-8414-3C3C67CF727C}.Fuzzing|DotNet_x86Test.ActiveCfg = Fuzzing|Win32
{919544AC-D39B-463F-8414-3C3C67CF727C}.Fuzzing|x64.ActiveCfg = Fuzzing|x64
{919544AC-D39B-463F-8414-3C3C67CF727C}.Fuzzing|x64.Build.0 = Fuzzing|x64
{919544AC-D39B-463F-8414-3C3C67CF727C}.Fuzzing|x86.ActiveCfg = Fuzzing|Win32
{919544AC-D39B-463F-8414-3C3C67CF727C}.Release|Any CPU.ActiveCfg = Release|Win32
{919544AC-D39B-463F-8414-3C3C67CF727C}.Release|ARM.ActiveCfg = Release|Win32
Expand Down Expand Up @@ -3241,13 +3240,10 @@ Global
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|Any CPU.ActiveCfg = Fuzzing|Win32
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|ARM.ActiveCfg = Fuzzing|Win32
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|ARM64.ActiveCfg = Fuzzing|ARM64
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|ARM64.Build.0 = Fuzzing|ARM64
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|DotNet_x64Test.ActiveCfg = Fuzzing|Win32
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|DotNet_x86Test.ActiveCfg = Fuzzing|Win32
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|x64.ActiveCfg = Fuzzing|x64
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|x64.Build.0 = Fuzzing|x64
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|x86.ActiveCfg = Fuzzing|Win32
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Fuzzing|x86.Build.0 = Fuzzing|Win32
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Release|Any CPU.ActiveCfg = Release|Win32
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Release|ARM.ActiveCfg = Release|Win32
{C323DAEE-B307-4C7B-ACE5-7293CBEFCB5B}.Release|ARM64.ActiveCfg = Release|ARM64
Expand Down Expand Up @@ -3321,7 +3317,6 @@ Global
{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Fuzzing|DotNet_x64Test.ActiveCfg = Fuzzing|Win32
{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Fuzzing|DotNet_x86Test.ActiveCfg = Fuzzing|Win32
{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Fuzzing|x64.ActiveCfg = Fuzzing|x64
{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Fuzzing|x64.Build.0 = Fuzzing|x64
{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Fuzzing|x86.ActiveCfg = Fuzzing|Win32
{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Fuzzing|x86.Build.0 = Fuzzing|Win32
{9CF74355-F018-4C19-81AD-9DC6B7F2C6F5}.Release|Any CPU.ActiveCfg = Release|Win32
Expand Down
34 changes: 34 additions & 0 deletions build/Fuzz/notifications-ado.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"config": {
"base_url": "https://dev.azure.com/microsoft/os",
"auth_token": "INSERT_PAT_HERE",
"project": "OpenConsole",
"type": "Bug",
"unique_fields": [
"Microsoft.VSTS.Common.CustomString03"
],
"comment": "<a href='{{ input_url }}'>This input</a> caused the <a href='{{ target_url }}'>fuzz target</a> {{ report.executable }} to crash. The faulting input SHA256 hash is {{ report.input_sha256 }} <br>",
"ado_fields": {
"System.AssignedTo": "INSERT_ASSIGNED_HERE",
"System.Tags": "OneFuzz",
"System.AreaPath": "OS\\WDX\\DXP\\WinDev\\Terminal",
"OSG.Watson.Telemetry14DaysInMarketHits": "1",
"System.IterationPath": "OS\\Future",
"Microsoft.VSTS.Common.CustomString01": "{{ job.project }}",
"Microsoft.VSTS.Common.CustomString02": "{{ job.name }}",
"Microsoft.VSTS.Common.CustomString03": "{{ report.minimized_stack_function_lines_sha256}}",
"System.Title": "[Fuzzing] - {{ report.crash_site }}",
"Microsoft.VSTS.CMMI.HowFound": "Security: Fuzzing",
"OSG.SecurityImpact": "Security Triage Requested",
"OSG.SDLSeverity": "Moderate",
"Microsoft.VSTS.TCM.ReproSteps": "The fuzzing target ({{ job.project }} {{ job.name }} {{ job.build }}) reported a crash. <br> {%if report.asan_log %} AddressSanitizer reported the following details: <br> <pre> {{ report.asan_log }} </pre> {% else %} Faulting call stack: <ul> {% for item in report.call_stack %} <li> {{ item }} </li> {% endfor %} </ul> <br> {% endif %} You can reproduce the issue remotely in OneFuzz by running the following command: <pre> {{ repro_cmd }} </pre>"
},
"on_duplicate": {
"set_state": {"Resolved": "Active", "Closed": "Active"},
"ado_fields": {
"System.IterationPath": "OS\\Future"
},
"increment": ["OSG.Watson.Telemetry14DaysInMarketHits"]
}
}
}
59 changes: 59 additions & 0 deletions build/pipelines/fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
trigger:
batch: true
branches:
include:
- main
paths:
exclude:
- docs/*
- samples/*
- tools/*

pr: none

# 0.0.yyMM.dd##
# 0.0.1904.0900
name: 0.0.$(Date:yyMM).$(Date:dd)$(Rev:rr)

stages:
- stage: Build_Fuzz_Config
displayName: Build Fuzzers
dependsOn: []
condition: succeeded()
jobs:
- template: ./templates/build-console-fuzzing.yml
parameters:
platform: x64
Comment on lines +24 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own edification - I get that this calls the build in build-console-fuzzing. I don't get how this tells that build to only build the Fuzzing config (and therefore only build conhost)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the top of build-console-fuzzing.yml, there's some predefined parameters:

parameters:
  configuration: 'Fuzzing'
  platform: ''
  additionalBuildArguments: ''

I think you'd be able to override the configuration parameter from here, but like, that would be a bad thing to do haha. The pipeline was designed to run in the fuzzing config so something would 100% fail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: in that case, it probably should not be configurable 😉

- stage: OneFuzz
displayName: Submit OneFuzz Job
dependsOn: ['Build_Fuzz_Config']
condition: succeeded()
pool:
vmImage: 'ubuntu-latest'
variables:
artifactName: fuzzingBuildOutput
jobs:
- job:
steps:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: $(artifactName)
downloadPath: $(Build.ArtifactStagingDirectory)
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
addToPath: true
architecture: 'x64'
- bash: |
set -ex
pip -q install onefuzz
onefuzz config --endpoint $(endpoint) --client_id $(client_id) --authority $(authority) --tenant_domain $(tenant_domain) --client_secret $(client_secret)
sed -i s/INSERT_PAT_HERE/$(ado_pat)/ build/Fuzz/notifications-ado.json
sed -i s/INSERT_ASSIGNED_HERE/$(ado_assigned_to)/ build/Fuzz/notifications-ado.json
displayName: Configure OneFuzz
- bash: |
onefuzz template libfuzzer basic --colocate_all_tasks --vm_count 1 --target_exe $target_exe_path --notification_config build/Fuzz/notifications-ado.json OpenConsole $test_name $(Build.SourceVersion) default
displayName: Submit OneFuzz Job
env:
target_exe_path: $(Build.ArtifactStagingDirectory)/$(artifactName)/Fuzzing/x64/test/OpenConsoleFuzzer.exe
test_name: WriteCharsLegacy
114 changes: 114 additions & 0 deletions build/pipelines/templates/build-console-fuzzing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
parameters:
configuration: 'Fuzzing'
platform: ''
additionalBuildArguments: ''

jobs:
- job: Build${{ parameters.platform }}${{ parameters.configuration }}
displayName: Build ${{ parameters.platform }} ${{ parameters.configuration }}
variables:
BuildConfiguration: ${{ parameters.configuration }}
BuildPlatform: ${{ parameters.platform }}
pool:
${{ if eq(variables['System.CollectionUri'], 'https://dev.azure.com/ms/') }}:
name: WinDevPoolOSS-L
${{ if ne(variables['System.CollectionUri'], 'https://dev.azure.com/ms/') }}:
name: WinDevPool-L
demands: ImageOverride -equals WinDevVS16-latest

steps:
- checkout: self
submodules: true
clean: true

- task: NuGetToolInstaller@0
displayName: 'Use NuGet 5.2.0'
inputs:
versionSpec: 5.2.0

# In the Microsoft Azure DevOps tenant, NuGetCommand is ambiguous.
# This should be `task: NuGetCommand@2`
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages for solution
inputs:
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: OpenConsole.sln
restoreDirectory: '$(Build.SourcesDirectory)\packages'

- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages for extraneous build actions
inputs:
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: build/packages.config
restoreDirectory: '$(Build.SourcesDirectory)\packages'

# The environment variable VCToolsInstallDir isn't defined on lab machines, so we need to retrieve it ourselves.
- script: |
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -Latest -requires Microsoft.Component.MSBuild -property InstallationPath > %TEMP%\vsinstalldir.txt
set /p _VSINSTALLDIR15=<%TEMP%\vsinstalldir.txt
del %TEMP%\vsinstalldir.txt
call "%_VSINSTALLDIR15%\Common7\Tools\VsDevCmd.bat"
echo VCToolsInstallDir = %VCToolsInstallDir%
echo ##vso[task.setvariable variable=VCToolsInstallDir]%VCToolsInstallDir%
displayName: 'Retrieve VC tools directory'

- task: VSBuild@1
displayName: 'Build solution **\OpenConsole.sln'
inputs:
solution: '**\OpenConsole.sln'
vsVersion: 16.0
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArgs: "${{ parameters.additionalBuildArguments }}"
clean: true
maximumCpuCount: true

- task: PowerShell@2
displayName: 'Rationalize build platform'
inputs:
targetType: inline
script: |
$Arch = "$(BuildPlatform)"
If ($Arch -Eq "x86") { $Arch = "Win32" }
Write-Host "##vso[task.setvariable variable=RationalizedBuildPlatform]${Arch}"

- task: CopyFiles@2
displayName: 'Copy result logs to Artifacts'
inputs:
Contents: |
**/*.wtl
**/*onBuildMachineResults.xml
${{ parameters.testLogPath }}
TargetFolder: '$(Build.ArtifactStagingDirectory)/$(BuildConfiguration)/$(BuildPlatform)/test'
OverWrite: true
flattenFolders: true

- task: CopyFiles@2
displayName: 'Copy outputs needed for test runs to Artifacts'
inputs:
Contents: |
$(Build.SourcesDirectory)/bin/$(RationalizedBuildPlatform)/$(BuildConfiguration)/*.exe
$(Build.SourcesDirectory)/bin/$(RationalizedBuildPlatform)/$(BuildConfiguration)/*.dll
$(Build.SourcesDirectory)/bin/$(RationalizedBuildPlatform)/$(BuildConfiguration)/*.xml
**/Microsoft.VCLibs.*.appx
**/TestHostApp/*.exe
**/TestHostApp/*.dll
**/TestHostApp/*.xml
!**/*.pdb
!**/*.ipdb
!**/*.obj
!**/*.pch
TargetFolder: '$(Build.ArtifactStagingDirectory)/$(BuildConfiguration)/$(BuildPlatform)/test'
OverWrite: true
flattenFolders: true
condition: succeeded()

- task: PublishBuildArtifacts@1
displayName: 'Publish All Build Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'fuzzingBuildOutput'
2 changes: 1 addition & 1 deletion build/pipelines/templates/build-console-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ steps:
displayName: 'Publish All Build Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
ArtifactName: 'drop'

- task: CopyFiles@2
displayName: 'Copy PGO databases needed for PGO instrumentation run'
Expand Down
Loading