Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Security Tasks to PR and CI Pipelines #590

Merged
merged 30 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
17712a4
WIP security additions
wsugarman Feb 22, 2021
febcb90
Add AntiMalware
wsugarman Feb 23, 2021
bdfc399
Fix typo for path
wsugarman Feb 23, 2021
46215ab
Fix pattern for Windows
wsugarman Feb 23, 2021
b22ff26
Enable security if disabled
wsugarman Feb 23, 2021
bdd520e
Add ARMory task
wsugarman Feb 23, 2021
39fb717
Add BinSkim
wsugarman Feb 23, 2021
5c0c4de
Fix BinSkim path and add CredScan
wsugarman Feb 23, 2021
f3bd390
Try using binskim guardian globs
wsugarman Feb 23, 2021
e86277e
Change BinSkim dir glob
wsugarman Feb 24, 2021
10fc380
Narrow BinSkim parameters
wsugarman Feb 24, 2021
bd6dd4f
Use guardian glob again
wsugarman Feb 24, 2021
81ddbc0
Make verbose and add v1 summaries
wsugarman Feb 24, 2021
beb0246
Add suppressions file
wsugarman Feb 24, 2021
12e76b7
Add inspector; use preview summary
wsugarman Feb 24, 2021
ac55497
Temporarily run CI tasks in PR
wsugarman Feb 24, 2021
03ce65c
Update summary tasks again
wsugarman Feb 24, 2021
fc2914e
First pass Semmle
wsugarman Feb 25, 2021
0d0ba5f
Fix expression
wsugarman Feb 25, 2021
e8fb46e
Change neq to ne
wsugarman Feb 25, 2021
513d148
Revert Semmle version
wsugarman Feb 25, 2021
3d5cccb
Change Semmle commands
wsugarman Feb 25, 2021
29d558f
Run required queries
wsugarman Feb 25, 2021
af5a56a
Add component governance
wsugarman Feb 25, 2021
592e527
Upload Semmle snapshot
wsugarman Feb 25, 2021
9552e29
Remove Semmle
wsugarman Feb 25, 2021
b2525cb
Remove parameter
wsugarman Feb 25, 2021
6f10253
Merge branch 'main' into users/wsugarman/SecurityPipelineTasks
wsugarman Feb 26, 2021
9ea247b
Remove extra line
wsugarman Feb 26, 2021
82a9615
Expand -c argument
wsugarman Feb 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CredScanSuppressions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"tool": "Credential Scanner",
"suppressions": [
{
"placeholder": "d8147077-d907-4551-8f40-90c6e86f3f0e",
"_justification": "This is an example value and does not represent a real credential."
},
{
"placeholder": "globalAdminServicePrincipal",
"_justification": "Service principal for local testing."
}
]
}
3 changes: 2 additions & 1 deletion build/.vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ stages:
- template: build.yml
parameters:
packageArtifacts: false
securityAnalysis: false

- stage: UpdateTestEnvironment
displayName: 'Update Test Environment'
Expand All @@ -63,7 +64,7 @@ stages:
downloadType: 'single'
downloadPath: '$(System.ArtifactsDirectory)'
artifactName: 'deploy'
- template: add-aad-test-environment.yml
- template: add-aad-test-environment.yml
- task: AzureRmWebAppDeployment@3
displayName: 'Azure app service deployment'
inputs:
Expand Down
7 changes: 4 additions & 3 deletions build/.vsts-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ stages:
pool:
vmImage: $(WindowsVmImage)
steps:
- template: ./update-semver.yml
- template: ./update-semver.yml
- powershell: |
$buildNumber = "$(GitVersion.semVer)" -replace "\.", ""
Write-Host "##vso[build.updatebuildnumber]$buildNumber"
$buildNumber = "$(GitVersion.semVer)" -replace "\.", ""
Write-Host "##vso[build.updatebuildnumber]$buildNumber"
Write-Host "Updated build number to '$buildNumber"
name: SetBuildVersion

Expand Down Expand Up @@ -47,6 +47,7 @@ stages:
- template: build.yml
parameters:
packageArtifacts: false
securityAnalysis: false

- stage: DeployTestEnvironment
displayName: 'Deploy Test Environment'
Expand Down
80 changes: 80 additions & 0 deletions build/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
steps:
- task: ComponentGovernanceComponentDetection@0
inputs:
scanType: 'Register'
verbosity: 'Verbose'
alertWarningLevel: 'High'
failOnAlert: true
ignoreDirectories: '$(Build.SourcesDirectory)\samples\Azurite'

- task: AntiMalware@4
inputs:
InputType: 'Basic'
ScanType: 'CustomScan'
FileDirPath: '$(Build.SourcesDirectory)'
EnableServices: true
TreatSignatureUpdateFailureAs: 'Standard'
SignatureFreshness: 'OneDay'
TreatStaleSignatureAs: 'Error'

- task: Armory@2
inputs:
targetDirectory: '$(Build.SourcesDirectory)\samples\templates'
targetFiles: 'f|*.json'
excludePassesFromLog: false

- task: BinSkim@4
inputs:
InputType: 'Basic'
Function: 'analyze'
AnalyzeTargetGlob: '+:file|$(Build.SourcesDirectory)\**\bin\**\Microsoft.Health.Dicom*.dll;+:file|$(Build.SourcesDirectory)\**\bin\**\Microsoft.Health.Dicom*.exe'
AnalyzeVerbose: true

- task: CredScan@3
inputs:
scanFolder: '$(Build.SourcesDirectory)'
outputFormat: 'sarif'
suppressionsFile: 'CredScanSuppressions.json'
verboseOutput: true

- task: SdtReport@2
inputs:
GdnExportAllTools: false
GdnExportGdnToolArmory: true
GdnExportGdnToolBinSkim: true
GdnExportGdnToolCredScan: true

- task: PublishSecurityAnalysisLogs@3
inputs:
ArtifactName: 'CodeAnalysisLogs'
ArtifactType: 'Container'
AllTools: false
AntiMalware: true
APIScan: false
Armory: true
Bandit: false
BinSkim: true
CodesignValidation: false
CredScan: true
CSRF: false
ESLint: false
Flawfinder: false
FortifySCA: false
FxCop: false
ModernCop: false
MSRD: false
PoliCheck: false
RoslynAnalyzers: false
SDLNativeRules: false
Semmle: false
SpotBugs: false
TSLint: false
WebScout: false
ToolLogsNotFoundAction: 'Error'

- task: PostAnalysis@2
inputs:
GdnBreakAllTools: false
GdnBreakGdnToolArmory: true
GdnBreakGdnToolBinSkim: true
GdnBreakGdnToolCredScan: true
10 changes: 7 additions & 3 deletions build/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
parameters:
packageArtifacts: true
analyzeSecurity: true

steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk (for sql generation)'
inputs:
version: '3.1.401'

- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
Expand All @@ -17,14 +18,17 @@ steps:
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration) -p:AssemblyVersion="$(assemblySemVer)" -p:FileVersion="$(assemblySemFileVer)" -p:InformationalVersion="$(informationalVersion)" -p:ContinuousIntegrationBuild=true'
arguments: '-c $(buildConfiguration) -p:AssemblyVersion="$(assemblySemVer)" -p:FileVersion="$(assemblySemFileVer)" -p:InformationalVersion="$(informationalVersion)" -p:ContinuousIntegrationBuild=true'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Generally, I think we should keep the full argument name in scripts like this for discoverability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense


- task: DotNetCoreCLI@2
displayName: 'dotnet test UnitTests'
inputs:
command: test
projects: '**/*UnitTests/*.csproj'
arguments: '--configuration $(buildConfiguration) --no-build'
arguments: '-c $(buildConfiguration) --no-build'

- ${{ if eq(parameters.packageArtifacts, 'true') }}:
- template: package.yml

- ${{ if eq(parameters.analyzeSecurity, 'true') }}:
- template: analyze.yml
2 changes: 1 addition & 1 deletion build/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ steps:
inputs:
command: pack
configuration: '$(buildConfiguration)'
packagesToPack: '**/*.csproj;!test/**/*.csproj;!**/*.UnitTests.csproj'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove the packing of test projects, and have removed the web tests and integration tests from the nuget artifact. The pipeline instead uses these projects from the IntegrationTests artifact, as they are built in a previous task.

packDirectory: '$(build.artifactStagingDirectory)/nupkgs'
versioningScheme: byEnvVar
versionEnvVar: 'nuget_version'
nobuild: true
zipAfterPublish: true
env:
nuget_version: $(nuGetVersion)

Expand Down