From a10aa383cb51ffd9d14b6da09771e1fdfe8de745 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Wed, 3 Jan 2024 12:00:02 -0800 Subject: [PATCH] Add ApiScan to nightly build (#8605) 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. --- .../automation/azure-pipelines-nightly.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/build-tools/automation/azure-pipelines-nightly.yaml b/build-tools/automation/azure-pipelines-nightly.yaml index 4370dc175d1..bbf13e27974 100644 --- a/build-tools/automation/azure-pipelines-nightly.yaml +++ b/build-tools/automation/azure-pipelines-nightly.yaml @@ -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'))