Skip to content

Commit

Permalink
Add ApiScan to nightly build (#8605)
Browse files Browse the repository at this point in the history
Context: https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/25351/APIScan-step-by-step-guide-to-setting-up-a-Pipeline

The ApiScan task has been added to the nightly build and test run.  This
task should help us identify related issues earlier, rather than having
to wait for a full scan of VS.  The task can take a long time to execute
so it has been added to the nightly job rather than the PR or CI jobs.
  • Loading branch information
pjcollins authored Jan 3, 2024
1 parent 0356ba6 commit a10aa38
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions build-tools/automation/azure-pipelines-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,80 @@ stages:
artifactName: Test Results - Localization With Emulator - macOS-$(System.JobPositionInPhase)

- template: yaml-templates/fail-on-issue.yaml


- stage: compliance_scan
displayName: Compliance
dependsOn: mac_build
jobs:
- job: api_scan
displayName: API Scan
pool:
name: Azure Pipelines
vmImage: windows-2022
timeoutInMinutes: 480
workspace:
clean: all
variables:
- name: ApiScan.Enabled
value: true
steps:
- template: yaml-templates/setup-test-environment.yaml
parameters:
installApkDiff: false
installLegacyDotNet: false
restoreNUnitConsole: false
updateMono: false

### Copy .dll and .pdb files for APIScan
- task: CopyFiles@2
displayName: Collect Files for APIScan
inputs:
Contents: $(System.DefaultWorkingDirectory)\bin\$(XA.Build.Configuration)\dotnet\packs\Microsoft.Android*\**\?(*.dll|*.pdb)
TargetFolder: $(Build.StagingDirectory)\apiscan
OverWrite: true
flattenFolders: true
condition: and(succeeded(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

- pwsh: Get-ChildItem -Path "$(Build.StagingDirectory)\apiscan" -Recurse
displayName: List Files for APIScan
condition: and(succeeded(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

### Run latest version of APIScan listed at https://www.1eswiki.com/wiki/APIScan_Build_Task
- task: APIScan@2
displayName: Run APIScan
inputs:
softwareFolder: $(Build.StagingDirectory)\apiscan
symbolsFolder: 'SRV*http://symweb;$(Build.StagingDirectory)\apiscan'
softwareName: $(ApiScanName)
softwareVersionNum: $(Build.SourceBranchName)-$(Build.SourceVersion)-$(Rev:r)
isLargeApp: true
toolVersion: Latest
condition: and(succeeded(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
env:
AzureServicesAuthConnectionString: runAs=App;AppId=$(ApiScanClientId);TenantId=$(ApiScanTenant);AppKey=$(ApiScanSecret)

- task: SdtReport@2
displayName: Guardian Export - Security Report
inputs:
GdnExportAllTools: false
GdnExportGdnToolApiScan: true
GdnExportOutputSuppressionFile: source.gdnsuppress
condition: and(succeededOrFailed(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

- task: PublishSecurityAnalysisLogs@3
displayName: Publish Guardian Artifacts
inputs:
ArtifactName: APIScan Logs
ArtifactType: Container
AllTools: false
APIScan: true
ToolLogsNotFoundAction: Warning
condition: and(succeededOrFailed(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

- task: PostAnalysis@2
displayName: Fail Build on Guardian Issues
inputs:
GdnBreakAllTools: false
GdnBreakGdnToolApiScan: true
condition: and(succeededOrFailed(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

0 comments on commit a10aa38

Please sign in to comment.