|
| 1 | +jobs: |
| 2 | + - job: APIScan |
| 3 | + variables: |
| 4 | + - name: runCodesignValidationInjection |
| 5 | + value : false |
| 6 | + - name: NugetSecurityAnalysisWarningLevel |
| 7 | + value: none |
| 8 | + - name: ReleaseTagVar |
| 9 | + value: fromBranch |
| 10 | + # Defines the variables APIScanClient, APIScanTenant and APIScanSecret |
| 11 | + - group: PS-PS-APIScan |
| 12 | + # PAT permissions NOTE: Declare a SymbolServerPAT variable in this group with a 'microsoft' organizanization scoped PAT with 'Symbols' Read permission. |
| 13 | + # A PAT in the wrong org will give a single Error 203. No PAT will give a single Error 401, and individual pdbs may be missing even if permissions are correct. |
| 14 | + - group: symbols |
| 15 | + |
| 16 | + pool: |
| 17 | + name: PowerShell1ES |
| 18 | + demands: |
| 19 | + - ImageOverride -equals PSMMS2019-Secure |
| 20 | + |
| 21 | + # APIScan can take a long time |
| 22 | + timeoutInMinutes: 180 |
| 23 | + |
| 24 | + steps: |
| 25 | + - template: ../SetVersionVariables.yml |
| 26 | + parameters: |
| 27 | + ReleaseTagVar: $(ReleaseTagVar) |
| 28 | + CreateJson: yes |
| 29 | + UseJson: no |
| 30 | + |
| 31 | + - pwsh: | |
| 32 | + Import-Module .\build.psm1 -force |
| 33 | + Start-PSBootstrap |
| 34 | + workingDirectory: '$(Build.SourcesDirectory)' |
| 35 | + retryCountOnTaskFailure: 2 |
| 36 | + displayName: 'Bootstrap' |
| 37 | +
|
| 38 | + - pwsh: | |
| 39 | + Import-Module .\build.psm1 -force |
| 40 | + Find-DotNet |
| 41 | + dotnet tool install dotnet-symbol --tool-path $(Agent.ToolsDirectory)\tools\dotnet-symbol |
| 42 | + $symbolToolPath = Get-ChildItem -Path $(Agent.ToolsDirectory)\tools\dotnet-symbol\dotnet-symbol.exe | Select-Object -First 1 -ExpandProperty FullName |
| 43 | + Write-Host "##vso[task.setvariable variable=symbolToolPath]$symbolToolPath" |
| 44 | + displayName: Install dotnet-symbol |
| 45 | + retryCountOnTaskFailure: 2 |
| 46 | +
|
| 47 | + - pwsh: | |
| 48 | + Import-Module .\build.psm1 -force |
| 49 | + Find-DotNet |
| 50 | + Start-PSBuild -Configuration StaticAnalysis -PSModuleRestore -Clean |
| 51 | +
|
| 52 | + $OutputFolder = Split-Path (Get-PSOutput) |
| 53 | + Write-Host "##vso[task.setvariable variable=BinDir]$OutputFolder" |
| 54 | + workingDirectory: '$(Build.SourcesDirectory)' |
| 55 | + displayName: 'Build PowerShell Source' |
| 56 | +
|
| 57 | + - pwsh: | |
| 58 | + Get-ChildItem -Path env: |
| 59 | + displayName: Capture Environment |
| 60 | + condition: succeededOrFailed() |
| 61 | +
|
| 62 | + # Explicitly download symbols for the drop since the SDL image doesn't have http://SymWeb access and APIScan cannot handle https yet. |
| 63 | + - pwsh: | |
| 64 | + Import-Module .\build.psm1 -force |
| 65 | + Find-DotNet |
| 66 | + $pat = '$(SymbolServerPAT)' |
| 67 | + if ($pat -like '*PAT*' -or $pat -eq '') |
| 68 | + { |
| 69 | + throw 'No PAT defined' |
| 70 | + } |
| 71 | + $url = 'https://microsoft.artifacts.visualstudio.com/defaultcollection/_apis/symbol/symsrv' |
| 72 | + $(symbolToolPath) --authenticated-server-path $(SymbolServerPAT) $url --symbols -d "$env:BinDir\*" --recurse-subdirectories |
| 73 | + displayName: 'Download Symbols for binaries' |
| 74 | + retryCountOnTaskFailure: 2 |
| 75 | + workingDirectory: '$(Build.SourcesDirectory)' |
| 76 | +
|
| 77 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-apiscan.APIScan@2 |
| 78 | + displayName: 'Run APIScan' |
| 79 | + inputs: |
| 80 | + softwareFolder: '$(BinDir)' |
| 81 | + softwareName: PowerShell |
| 82 | + softwareVersionNum: '$(ReleaseTagVar)' |
| 83 | + isLargeApp: false |
| 84 | + preserveTempFiles: false |
| 85 | + verbosityLevel: standard |
| 86 | + # write a status update every 5 minutes. Default is 1 minute |
| 87 | + statusUpdateInterval: '00:05:00' |
| 88 | + env: |
| 89 | + AzureServicesAuthConnectionString: RunAs=App;AppId=$(APIScanClient);TenantId=$(APIScanTenant);AppKey=$(APIScanSecret) |
| 90 | + |
| 91 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-report.SdtReport@2 |
| 92 | + continueOnError: true |
| 93 | + displayName: 'Guardian Export' |
| 94 | + inputs: |
| 95 | + GdnExportVstsConsole: true |
| 96 | + GdnExportSarifFile: true |
| 97 | + GdnExportHtmlFile: true |
| 98 | + GdnExportAllTools: false |
| 99 | + GdnExportGdnToolApiScan: true |
| 100 | + #this didn't do anything GdnExportCustomLogsFolder: '$(Build.ArtifactStagingDirectory)/Guardian' |
| 101 | + |
| 102 | + - pwsh: | |
| 103 | + Get-ChildItem -Path env: |
| 104 | + displayName: Capture Environment |
| 105 | + condition: succeededOrFailed() |
| 106 | +
|
| 107 | + - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@3 |
| 108 | + displayName: 'Publish Guardian Artifacts' |
| 109 | + inputs: |
| 110 | + AllTools: false |
| 111 | + APIScan: true |
| 112 | + ArtifactName: APIScan |
0 commit comments