From d3bbf92eba985ebfa8958490cc838f6f10f9f348 Mon Sep 17 00:00:00 2001 From: Stella Huang Date: Wed, 18 Nov 2026 15:21:51 -0800 Subject: [PATCH] Modernize DevDiv static analysis Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../devdiv/static-analysis.yml | 242 ++---------------- 1 file changed, 28 insertions(+), 214 deletions(-) diff --git a/build/azure-pipelines/devdiv/static-analysis.yml b/build/azure-pipelines/devdiv/static-analysis.yml index f5bc9f9025a0..ad21dccca6d0 100644 --- a/build/azure-pipelines/devdiv/static-analysis.yml +++ b/build/azure-pipelines/devdiv/static-analysis.yml @@ -36,19 +36,21 @@ extends: bandit: enabled: false antimalwareScan: - enabled: false + enabled: true componentgovernance: - enabled: false + enabled: true + ignoreDirectories: .github,build,news credscan: - enabled: false + enabled: true + verboseOutput: true eslint: enabled: false policheck: - enabled: false + enabled: true publishLogs: - enabled: false + enabled: true sdtReport: - enabled: false + enabled: true tsa: enabled: false pool: @@ -65,6 +67,15 @@ extends: jobs: - job: StaticAnalysis displayName: Static analysis + templateContext: + sdl: + publishLogs: + enabled: false + outputs: + - output: pipelineArtifact + targetPath: '$(Build.ArtifactStagingDirectory)\bandit' + artifactName: BanditResults + isProduction: false steps: - checkout: self clean: true @@ -84,15 +95,8 @@ extends: throw 'Bandit target contains no Python files.' } - $poliCheckExceptions = '$(Build.SourcesDirectory)\build\ci\static_analysis\policheck\exceptions.mdb' - if (-not (Test-Path -LiteralPath $poliCheckExceptions -PathType Leaf)) { - throw "PoliCheck exceptions file was not found: $poliCheckExceptions" - } - Write-Host "Bandit will scan $($pythonFiles.Count) Python files." - Write-Host "PoliCheck exceptions: $poliCheckExceptions" - Write-Host "AntiMalware and CredScan will scan $(Build.SourcesDirectory)." - displayName: Verify scan targets + displayName: Verify Bandit target - task: Bandit@1 continueOnError: true @@ -119,204 +123,14 @@ extends: verbose: false displayName: Run Bandit - - task: PoliCheck@1 - continueOnError: true - inputs: - EXGT: false - SOMEnabled: false - cmdLineArgs: '/F:$(Build.SourcesDirectory) /T:9 /O:PoliCheck.xml' - importEx: '' - inputType: Basic - optionsB1: '' - optionsB2: '' - optionsB3: '' - optionsCTGLEN: '' - optionsD: '' - optionsFC: none - optionsFTPATH: '' - optionsHMENABLE: none - optionsHPATH: '' - optionsHVER: '' - optionsOCDB: '' - optionsPE: 1|2 - optionsRule: '' - optionsRulesDBPath: '$(Build.SourcesDirectory)\build\ci\static_analysis\policheck\exceptions.mdb' - optionsSEV: '' - optionsTASKNAME: '' - optionsUEPATH: '' - optionsWORKINGDIRECTORY: '' - optionsXCLASS: '' - optionsXS: none - result: PoliCheck.xml - targetArgument: $(Build.SourcesDirectory) - targetType: F - termTypeK: '' - termTypeL: '' - termTypeT: 0029a9 - termTypeTCustom: 9 - toolVersion: Latest - uploadErrorLevel: Error - uploadToSOM: false - workspaceId: '' - displayName: Run PoliCheck - - - task: AntiMalware@3 - continueOnError: true - inputs: - Arguments: '-Scan -ScanType 3 -DisableRemediation -File "$(Build.SourcesDirectory)"' - BootSectorScan: false - DisableRemediation: true - EnableServices: true - FileDirPath: $(Build.SourcesDirectory) - InputType: Basic - ScanType: CustomScan - SignatureFreshness: UpToDate - SupportLogOnError: false - TreatSignatureUpdateFailureAs: Warning - TreatStaleSignatureAs: Error - displayName: Run AntiMalware - - - task: CredScan@2 - continueOnError: true - inputs: - batchSize: '' - debugMode: false - fileScanReadBufferSize: '' - folderSuppression: false - m365Version: Latest - maxFileScanReadBytes: '' - outputFormat: pre - regexMatchTimeoutInSeconds: '' - scanFolder: $(Build.SourcesDirectory) - searchersFile: '' - searchersFileType: Default - suppressAsError: false - suppressionsFile: '' - toolMajorVersion: V2 - toolVersion: Latest - toolVersionV2: Latest - verboseOutput: true - displayName: Run CredScan - - - task: AutoApplicability@1 - continueOnError: true - inputs: - ApplyRules: Microsoft.Security - DataSensitivity: none - ExternalRelease: true - InternalRelease: false - IsCertAuthority: false - IsCodeSigner: false - IsService: false - IsSoftware: true - UsesHSM: false - VerboseWriter: false - toolVersion: Latest - displayName: Run AutoApplicability - - - task: VulnerabilityAssessment@0 - continueOnError: true - displayName: Run Vulnerability Assessment - - - task: SdtReport@1 - continueOnError: true - inputs: - APIScan: false - AllTools: false - BinSkim: false - BinSkimBreakOn: Error - CodesignValidation: false - CodesignValidationBreakOn: Error - CredScan: true - CustomLogsFolder: '' - FortifySCA: false - FxCop: false - FxCopBreakOn: ErrorAbove - HtmlFile: true - MSRD: false - ModernCop: false - ModernCopBreakOn: Error - PoliCheck: true - PoliCheckBreakOn: Severity1 - RoslynAnalyzers: false - RoslynAnalyzersBreakOn: Error - SDLNativeRules: false - Semmle: false - SemmleBreakOn: Error - TSLint: false - TSLintBreakOn: Error - ToolLogsNotFoundAction: Standard - TsvFile: true - VstsConsole: true - displayName: Create Security Analysis Report - - - task: PublishSecurityAnalysisLogs@2 - inputs: - APIScan: false - AllTools: false - AntiMalware: true - ArtifactName: CodeAnalysisLogs - ArtifactType: Container - BinSkim: false - CodesignValidation: false - CredScan: true - FortifySCA: false - FxCop: false - MSRD: false - ModernCop: false - PoliCheck: true - RoslynAnalyzers: false - SDLNativeRules: false - Semmle: false - TSLint: false - ToolLogsNotFoundAction: Standard - UploadCustomResults: false - WebScout: false - displayName: Publish Security Analysis Logs - - - task: TSAUpload@1 - inputs: - areaPath: 'DevDiv\Python and AI Tools\Python\VS Code\Static Analysis' - codeBaseAdmins: '' - codeBaseName: vscode-python-main - codebase: NewOrUpdate - instanceUrlForTsaV2: DEVDIV - notificationAlias: brcan@microsoft.com,plseng@microsoft.com - notifyAlwaysV1: true - notifyAlwaysV2: false - projectNameDEVDIV: DevDiv - serviceTreeID: 6e6194bc-7baa-4486-86d0-9f5419626d46 - tsaEnvironment: PROD - tsaStamp: TSA - tsaVersion: TsaV2 - tsaWebApiUrl: $(TSAStamp) - uploadAPIScan: false - uploadAsync: true - uploadBinSkim: false - uploadCredScan: true - uploadFortifySCA: false - uploadFxCop: false - uploadModernCop: false - uploadPREfast: false - uploadPoliCheck: true - uploadRoslyn: false - uploadTSLint: false - validateCompatibility: Error - validateToolOutput: Warning - displayName: TSA Upload + - pwsh: | + $banditResults = '$(Pipeline.Workspace)\.gdn\.r\bandit' + if (-not (Test-Path -LiteralPath $banditResults -PathType Container)) { + throw "Bandit results directory was not found: $banditResults" + } + if (-not (Get-ChildItem -LiteralPath $banditResults -Filter '*.sarif' -Recurse -File)) { + throw "Bandit SARIF was not found: $banditResults" + } - - task: ComponentGovernanceComponentDetection@0 - inputs: - alertWarningLevel: High - autoInjected: false - detectorsFilter: '' - detectorsToRun: '' - dockerImagesToScan: '' - failOnAlert: false - ignoreDirectories: .github,build,news - scanType: Register - sourceScanPath: '' - useDefaultDetectors: true - verbosity: Verbose - whatif: false - displayName: Component Detection + Copy-Item -LiteralPath $banditResults -Destination '$(Build.ArtifactStagingDirectory)' -Recurse -Force + displayName: Stage Bandit results