-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathshiftleftscan-pipeline.yml
90 lines (80 loc) · 2.97 KB
/
shiftleftscan-pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
trigger: none
pr: none
pool:
vmImage: 'ubuntu-20.04'
parameters:
- name: ShiftLeftOSS
displayName: Run ShiftLeft Open Source?
type: boolean
default: false
- name: ShiftLeftCI
displayName: Run ShiftLeft CI?
type: boolean
default: false
variables:
- group: SecureVariables
stages:
- stage: QualityCheckStage
displayName: Quality Check Stage
jobs:
- ${{ if eq(parameters.ShiftLeftOSS, true) }}:
- job: ShiftLeftJob
displayName: Run ShiftLeft Scan
steps:
- script: |
docker run \
-e SCAN_DEBUG_MODE=debug \
--volume "$(Build.SourcesDirectory):/app" \
--volume "$(Build.ArtifactStagingDirectory):/reports" \
shiftleft/sast-scan scan --src /app --build \
--out_dir /reports/CodeAnalysisLogs
displayName: "Perform ShiftLeft Scan"
continueOnError: "true"
- task: PublishBuildArtifacts@1
displayName: "Publish Analysis Logs"
inputs:
PathtoPublish: "$(Build.ArtifactStagingDirectory)/CodeAnalysisLogs"
ArtifactName: "CodeAnalysisLogs"
publishLocation: "Container"
- ${{ if eq(parameters.ShiftLeftCI, true) }}:
- job: windowsci
displayName: "ShiftLeft CI on Windows agent"
pool:
vmImage: windows-latest
steps:
- task: PowerShell@2
displayName: Download ShiftLeft cli
inputs:
targetType: 'inline'
script: |
Invoke-WebRequest -Uri 'https://cdn.shiftleft.io/download/sl-latest-windows-x64.zip' -OutFile $(Agent.HomeDirectory)\sl.zip
Expand-Archive -Path $(Agent.HomeDirectory)\sl.zip -DestinationPath $(Agent.HomeDirectory)\
- task: CmdLine@2
displayName: Analyze with Inspect
inputs:
script: |
$(Agent.HomeDirectory)\sl.exe analyze --force --app eShopOnWeb --tag branch=$(Build.SourceBranchName) --csharp --cpg $(System.DefaultWorkingDirectory)/Application-Source-Code/eShopOnWeb.sln
workingDirectory: '$(Build.SourcesDirectory)'
env:
SHIFTLEFT_ORG_ID: $(SHIFTLEFT_ORG_ID)
SHIFTLEFT_ACCESS_TOKEN: $(SHIFTLEFT_ACCESS_TOKEN)
- job: linuxci
displayName: "ShiftLeft CI on Linux agent"
pool:
vmImage: ubuntu-latest
steps:
- task: CmdLine@2
displayName: Download ShiftLeft cli
inputs:
targetType: 'inline'
script: |
curl https://cdn.shiftleft.io/download/sl > $(Agent.HomeDirectory)/sl && chmod a+rx $(Agent.HomeDirectory)/sl
- task: CmdLine@2
displayName: Analyze with Inspect
inputs:
script: |
$(Agent.HomeDirectory)\sl.exe analyze --force --app eShopOnWeb --tag branch=$(Build.SourceBranchName) --csharp --cpg $(System.DefaultWorkingDirectory)/Application-Source-Code/eShopOnWeb.sln
workingDirectory: '$(Build.SourcesDirectory)'
env:
SHIFTLEFT_ORG_ID: $(SHIFTLEFT_ORG_ID)
SHIFTLEFT_ACCESS_TOKEN: $(SHIFTLEFT_ACCESS_TOKEN)