DevSecOps With Microsoft Security Code Analysis Extension
DevSecOps With Microsoft Security Code Analysis Extension
Extension
Available tools
BinSkim
Roslyn Analyzers
TSLint
Analysis results
You can publish the log files to Azure Artifacts as a .zip file.
You can also copy them to an accessible file share from your
private build agent.
Security Report
The Security Report build task parses the log files. These files
are created by the security tools that run during the build.
The build task then creates a single summary report file. This
file shows all issues found by the analysis tools.
You can configure this task to report results for specific tools
or for all tools. You can also choose what issue level to report,
like errors only or both errors and warnings.
With the Post-Analysis build task, you can inject a build break
that purposely causes a build to fail. You inject a build break if
one or more analysis tools report issues in the code.
You can configure this task to break the build for issues found
by specific tools or all tools. You can also configure it based
on the severity of issues found, such as errors or warnings.
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
displayName: 'Restore project dependencies'
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: MSBuild@1
inputs:
solution: '**/*.sln'
- task: CredScan@2
- task: RoslynAnalyzers@2
inputs:
userProvideBuildInfo: 'auto'
- task: SdtReport@1
inputs:
TsvFile: false
AllTools: false
BinSkim: false
CredScan: true
MSRD: false
RoslynAnalyzers: true
RoslynAnalyzersBreakOn: 'WarningAbove'
TSLint: false
ToolLogsNotFoundAction: 'Standard'
- task: PublishSecurityAnalysisLogs@2
inputs:
ArtifactName: 'CodeAnalysisLogs'
ArtifactType: 'Container'
AllTools: true
ToolLogsNotFoundAction: 'Standard'
- task: PostAnalysis@1
inputs:
AllTools: false
BinSkim: false
CredScan: true
RoslynAnalyzers: true
RoslynAnalyzersBreakOn: 'Error'
TSLint: false
ToolLogsNotFoundAction: 'Standard'
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration $(BuildConfiguration) --output
$(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
- task: PublishBuildArtifacts@1
displayName: 'publish artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
You will notice that there is also “Roslyn Analyzers” task which
I added to do some static code analysis.
Summary
In this article I presented Microsoft Security Code Analysis
Extension which enables security scanning in the CI pipelines.
This extension is important part of DevSecOps flow and
definitely will be worth trying once it is generally available. If
you would like to read more about Security Engineering I
recommend to visit Microsoft Security Development Lifecycle
(SDL) website. If you would like to read more about the
extension, there is official documentation available.