Skip to content

Commit e171362

Browse files
committed
Add PreBuildCheck stage (PoliCheck + CredScan) to shared template, mirroring MSAL.NET
1 parent d342947 commit e171362

File tree

2 files changed

+59
-10
lines changed

2 files changed

+59
-10
lines changed

.Pipelines/ADO-PUBLISH-SETUP.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Every publish requires explicitly entering a version and selecting a destination
2020

2121
| Stage | Trigger | Target |
2222
|-------|---------|--------|
23+
| **PreBuildCheck** (PoliCheck + CredScan) | always | SDL security scans |
2324
| **Validate** | release runs only (`runPublish: true`) | asserts `packageVersion` matches `msal/sku.py` |
2425
| **CI** (tests on Py 3.9–3.14) | after Validate (or immediately on PR/merge runs) ||
2526
| **Build** (sdist + wheel) | after CI, release runs only | dist artifact |
@@ -189,12 +190,15 @@ This pipeline is **always manually queued**. Both fields are required — the Va
189190

190191
```
191192
Manual queue (publishTarget = test.pypi.org (Preview / RC))
192-
└─► Validate ─► CI ─► Build ─► PublishMSALPython
193-
(test.pypi.org (Preview / RC), auto)
193+
└─► PreBuildCheck ─► Validate ─► CI ─► Build ─► PublishMSALPython
194+
(test.pypi.org (Preview / RC), auto)
194195
195196
Manual queue (publishTarget = pypi.org (Production))
196-
└─► Validate ─► CI ─► Build ─► PublishPyPI
197-
(pypi.org (Production), requires approval)
197+
└─► PreBuildCheck ─► Validate ─► CI ─► Build ─► PublishPyPI
198+
(pypi.org (Production), requires approval)
199+
200+
PR / merge build (runPublish: false)
201+
└─► PreBuildCheck ─► CI
198202
```
199203

200204
---

.Pipelines/template-pipeline-stages.yml

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#
1818
# Stage flow:
1919
#
20-
# runPublish: true → Validate ─► CI ─► Build ─► PublishMSALPython
21-
# └─► PublishPyPI
22-
# runPublish: false → CI (Validate / Build / Publish are skipped)
20+
# runPublish: true → PreBuildCheck ─► Validate ─► CI ─► Build ─► PublishMSALPython
21+
# └─► PublishPyPI
22+
# runPublish: false → PreBuildCheck ─► CI (Validate / Build / Publish are skipped)
2323

2424
parameters:
2525
- name: packageVersion
@@ -34,13 +34,52 @@ parameters:
3434

3535
stages:
3636

37+
# ══════════════════════════════════════════════════════════════════════════════
38+
# Stage 0 · PreBuildCheck — SDL security scans (PoliCheck + CredScan)
39+
# Always runs, mirrors MSAL.NET pre-build analysis.
40+
# ══════════════════════════════════════════════════════════════════════════════
41+
- stage: PreBuildCheck
42+
displayName: 'Pre-build security checks'
43+
jobs:
44+
- job: SecurityScan
45+
displayName: 'PoliCheck + CredScan'
46+
pool:
47+
vmImage: windows-latest
48+
variables:
49+
Codeql.SkipTaskAutoInjection: true
50+
steps:
51+
- task: NodeTool@0
52+
displayName: 'Install NPM'
53+
inputs:
54+
versionSpec: '16.x'
55+
56+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@2
57+
displayName: 'Run PoliCheck'
58+
inputs:
59+
targetType: F
60+
optionsUEPATH: '$(Build.SourcesDirectory)/build/policheck_exclusion.xml'
61+
continueOnError: true
62+
63+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
64+
displayName: 'Run CredScan'
65+
inputs:
66+
toolMajorVersion: V2
67+
debugMode: false
68+
69+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2
70+
displayName: 'Post Analysis'
71+
inputs:
72+
GdnBreakGdnToolCredScan: true
73+
GdnBreakGdnToolPoliCheck: true
74+
3775
# ══════════════════════════════════════════════════════════════════════════════
3876
# Stage 1 · Validate — verify packageVersion matches msal/sku.py __version__
3977
# Skipped when runPublish is false (PR / merge builds).
4078
# ══════════════════════════════════════════════════════════════════════════════
4179
- stage: Validate
4280
displayName: 'Validate version'
43-
condition: ${{ parameters.runPublish }}
81+
dependsOn: PreBuildCheck
82+
condition: and(${{ parameters.runPublish }}, eq(dependencies.PreBuildCheck.result, 'Succeeded'))
4483
jobs:
4584
- job: ValidateVersion
4685
displayName: 'Check version matches source'
@@ -75,8 +114,14 @@ stages:
75114
# ══════════════════════════════════════════════════════════════════════════════
76115
- stage: CI
77116
displayName: 'Run tests'
78-
dependsOn: Validate
79-
condition: in(dependencies.Validate.result, 'Succeeded', 'Skipped')
117+
dependsOn:
118+
- PreBuildCheck
119+
- Validate
120+
condition: |
121+
and(
122+
eq(dependencies.PreBuildCheck.result, 'Succeeded'),
123+
in(dependencies.Validate.result, 'Succeeded', 'Skipped')
124+
)
80125
jobs:
81126
- job: Test
82127
displayName: 'Run unit tests'

0 commit comments

Comments
 (0)