Skip to content

Commit 7583626

Browse files
Add PoliCheck (Azure#22651)
* Add PoliCheck to Aggregate Report Pipeline * Add per service run of policheck * Add step for filtering PoliCheck Results * Add PoliChheck Filtering * Condition PoliCheck oon ServiceDirectoryName * Add Allow List for core * Install PowerShell-Yaml * Remove sdk/core/PoliCheckAllowList.yml * Clone build tools, read allow list from build tools * Add reference to AddPoliCheckFilter build tools branch * Move PoliCheck to it own stage * Remove dependence ServiceDirectoryname * Remove step for filtering PoliCheck result * Add RulesDBPath * Add guardian break step for policheck, with special folder for guardian tools * Publish baseline results * Consume baseline file from downloaded artifacts * switch to DownloadPipelien Artifacts task * Add poliCheck baseline control * add baseline source parameter * Stage baseline output for publishing * Remove baseline * Update publishing of Guardian tools * Copy all the related files for guardian tools * Add files for PoliCheck exclusion * Switch to vanila PoliCheck Run * Download and used PoliCheck.mdb file for Exclusions * Update Exclusionfilename * Fix up poliCheck issue * Move Cred Scan into Compliance stage * Add space betweeem yaml steps * Fix up policheck issues in sdk\eventhub\Azure.Messaging.EventHubs.Shared\src\Testing\EventHubsTestEnvironment.cs * Move PoliCheck before CredScan
1 parent 0282984 commit 7583626

File tree

4 files changed

+197
-143
lines changed

4 files changed

+197
-143
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<PoliCheckExclusions>
2+
<!-- All strings must be UPPER CASE -->
3+
<!-- Each of these exclusions is a folder name - if \[name]\ exists in the file path, it will be skipped -->
4+
<!--<Exclusion Type="FolderPathFull">ABC|XYZ</Exclusion>-->
5+
<!-- Each of these exclusions is a folder name - if any folder or file starts with "\[name]", it will be
6+
skipped -->
7+
<!--<Exclusion Type="FolderPathStart">ABC|XYZ</Exclusion>-->
8+
<!-- Each of these file types will be completely skipped for the entire scan -->
9+
<!--<Exclusion Type="FileType">.ABC|.XYZ</Exclusion>-->
10+
<!-- The specified file names will be skipped during the scan regardless which folder they are in -->
11+
<!--<Exclusion Type="FileName">ABC.TXT|XYZ.CS</Exclusion>-->
12+
</PoliCheckExclusions>

eng/pipelines/aggregate-reports.yml

Lines changed: 181 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -17,142 +17,184 @@ pr:
1717
include:
1818
- eng/pipelines/aggregate-reports.yml
1919

20-
jobs:
21-
- job: GenerateReports
22-
23-
variables:
24-
- template: templates/variables/globals.yml
25-
26-
pool:
27-
vmImage: 'windows-2019'
28-
29-
timeoutInMinutes: 120
30-
steps:
31-
- download: net-core
32-
artifact: packages
33-
patterns: '*'
34-
35-
- pwsh: |
36-
npx cspell lint `
37-
--config ./.vscode/cspell.json `
38-
--no-must-find-files `
39-
'sdk/*/*/api/*.cs'
40-
displayName: Check spelling of public API surface
41-
# Spelling errors in public api surface are not blockers yet but will
42-
# become blockers when this is rolled out to all services. For now, turn
43-
# the pipeline yellow if spelling errors are detected but do not block.
44-
continueOnError: true
45-
46-
- template: /eng/common/pipelines/templates/steps/verify-links.yml
47-
parameters:
48-
Directory: ""
49-
CheckLinkGuidance: $true
50-
51-
- pwsh: |
52-
mkdir "$(System.ArtifactsDirectory)/BuildArtifacts"
53-
ls "$(PIPELINE.WORKSPACE)/net-core/packages"
54-
Copy-Item -Path "$(PIPELINE.WORKSPACE)/net-core/packages/*" -Destination "$(System.ArtifactsDirectory)/BuildArtifacts"
55-
displayName: Create Artifact Directory
56-
57-
58-
- pwsh: |
59-
mkdir '$(System.ArtifactsDirectory)/Packages'
60-
Move-Item -Path '$(System.ArtifactsDirectory)/BuildArtifacts/*' -Destination '$(System.ArtifactsDirectory)/Packages/' -Include Azure.*.nupkg -Exclude *.symbols.nupkg
61-
displayName: Isolate packages to process
62-
63-
- pwsh: |
64-
mkdir '$(Build.ArtifactStagingDirectory)/reports'
65-
Copy-Item -Path '$(Build.SourcesDirectory)/eng/common/InterdependencyGraph.html' -Destination '$(Build.ArtifactStagingDirectory)/reports/InterdependencyGraph.html'
66-
displayName: Setup reports directory
67-
68-
- task: PowerShell@2
69-
displayName: Generate Dependency Report
70-
inputs:
71-
pwsh: true
72-
filePath: 'eng/scripts/dependencies/AnalyzeDeps.ps1'
73-
arguments: >
74-
-PackagesPath '$(System.ArtifactsDirectory)/Packages/'
75-
-LockfilePath '$(Build.SourcesDirectory)/eng/Packages.Data.props'
76-
-OutPath '$(Build.ArtifactStagingDirectory)/reports/dependencies.html'
77-
-DumpPath '$(Build.ArtifactStagingDirectory)/reports/data.js'
78-
79-
- task: PowerShell@2
80-
displayName: 'Generate azure-sdk.deps.json'
81-
inputs:
82-
pwsh: true
83-
filePath: 'eng/scripts/dependencies/generate-deps.ps1'
84-
arguments: >
85-
-PackagesPath '$(System.ArtifactsDirectory)/Packages/'
86-
-DepsOutputFile '$(Build.ArtifactStagingDirectory)/reports/azure-sdk.deps.json'
87-
-ProjectRefPath '$(Build.ArtifactStagingDirectory)/reports'
88-
89-
- task: PowerShell@2
90-
displayName: 'Validate dependencies with pwsh servicing'
91-
inputs:
92-
pwsh: true
93-
filePath: 'eng/scripts/dependencies/compare-deps-files.ps1'
94-
arguments: >
95-
-PSDepsFile 'https://aka.ms/ps-deps-servicing'
96-
-AzSdkDepsFile '$(Build.ArtifactStagingDirectory)/reports/azure-sdk.deps.json'
97-
98-
- task: PowerShell@2
99-
displayName: 'Validate dependencies with pwsh stable'
100-
inputs:
101-
pwsh: true
102-
filePath: 'eng/scripts/dependencies/compare-deps-files.ps1'
103-
arguments: >
104-
-PSDepsFile 'https://aka.ms/ps-deps-stable'
105-
-AzSdkDepsFile '$(Build.ArtifactStagingDirectory)/reports/azure-sdk.deps.json'
106-
107-
- task: PowerShell@2
108-
displayName: 'Validate dependencies with pwsh preview'
109-
inputs:
110-
pwsh: true
111-
filePath: 'eng/scripts/dependencies/compare-deps-files.ps1'
112-
arguments: >
113-
-PSDepsFile 'https://aka.ms/ps-deps-preview'
114-
-AzSdkDepsFile '$(Build.ArtifactStagingDirectory)/reports/azure-sdk.deps.json'
115-
116-
- task: PublishPipelineArtifact@1
117-
displayName: 'Publish Report Artifacts'
118-
inputs:
119-
artifactName: reports
120-
path: '$(Build.ArtifactStagingDirectory)/reports'
121-
122-
- task: AzureFileCopy@2
123-
displayName: 'Upload dependency report'
124-
inputs:
125-
sourcePath: '$(Build.ArtifactStagingDirectory)/reports'
126-
azureSubscription: 'Azure SDK Artifacts'
127-
destination: AzureBlob
128-
storage: azuresdkartifacts
129-
containerName: 'azure-sdk-for-net'
130-
blobPrefix: dependencies
131-
132-
- task: PowerShell@2
133-
displayName: "Verify Repository Resource Refs"
134-
inputs:
135-
pwsh: true
136-
workingDirectory: $(Build.SourcesDirectory)
137-
filePath: eng/common/scripts/Verify-Resource-Ref.ps1
138-
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
139-
displayName: 'Run CredScan'
140-
inputs:
141-
suppressionsFile: 'eng\CredScanSuppression.json'
142-
condition: succeededOrFailed()
143-
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2
144-
displayName: 'Post Analysis'
145-
inputs:
146-
GdnBreakAllTools: false
147-
GdnBreakGdnToolCredScan: true
148-
GdnBreakGdnToolCredScanSeverity: Error
149-
GdnBreakBaselineFiles: $(Build.SourcesDirectory)\eng\dotnet.gdnbaselines
150-
GdnBreakBaselines: baseline
151-
# Used for generating baseline file
152-
# GdnBreakOutputBaselineFile: dotnet
153-
# GdnBreakOutputBaseline: baseline
154-
condition: succeededOrFailed()
155-
continueOnError: true
156-
- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@3
157-
displayName: 'Publish Security Analysis Logs'
158-
condition: succeededOrFailed()
20+
pool:
21+
vmImage: 'windows-2019'
22+
23+
variables:
24+
- template: templates/variables/globals.yml
25+
26+
stages:
27+
- stage: AggregateReports
28+
displayName: Aggregate Reports
29+
30+
jobs:
31+
- job: GenerateReports
32+
timeoutInMinutes: 120
33+
steps:
34+
- download: net-core
35+
artifact: packages
36+
patterns: '*'
37+
displayName: "Download packages artifacts from 'net - core' pipeline "
38+
39+
- pwsh: |
40+
npx cspell lint `
41+
--config ./.vscode/cspell.json `
42+
--no-must-find-files `
43+
'sdk/*/*/api/*.cs'
44+
displayName: Check spelling of public API surface
45+
# Spelling errors in public api surface are not blockers yet but will
46+
# become blockers when this is rolled out to all services. For now, turn
47+
# the pipeline yellow if spelling errors are detected but do not block.
48+
continueOnError: true
49+
50+
- template: /eng/common/pipelines/templates/steps/verify-links.yml
51+
parameters:
52+
Directory: ""
53+
CheckLinkGuidance: $true
54+
55+
- pwsh: |
56+
mkdir "$(System.ArtifactsDirectory)/BuildArtifacts"
57+
ls "$(PIPELINE.WORKSPACE)/net-core/packages"
58+
Copy-Item -Path "$(PIPELINE.WORKSPACE)/net-core/packages/*" -Destination "$(System.ArtifactsDirectory)/BuildArtifacts"
59+
displayName: Create Artifact Directory
60+
61+
- pwsh: |
62+
mkdir '$(System.ArtifactsDirectory)/Packages'
63+
Move-Item -Path '$(System.ArtifactsDirectory)/BuildArtifacts/*' -Destination '$(System.ArtifactsDirectory)/Packages/' -Include Azure.*.nupkg -Exclude *.symbols.nupkg
64+
displayName: Isolate packages to process
65+
66+
- pwsh: |
67+
mkdir '$(Build.ArtifactStagingDirectory)/reports'
68+
Copy-Item -Path '$(Build.SourcesDirectory)/eng/common/InterdependencyGraph.html' -Destination '$(Build.ArtifactStagingDirectory)/reports/InterdependencyGraph.html'
69+
displayName: Setup reports directory
70+
71+
- task: PowerShell@2
72+
displayName: Generate Dependency Report
73+
inputs:
74+
pwsh: true
75+
filePath: 'eng/scripts/dependencies/AnalyzeDeps.ps1'
76+
arguments: >
77+
-PackagesPath '$(System.ArtifactsDirectory)/Packages/'
78+
-LockfilePath '$(Build.SourcesDirectory)/eng/Packages.Data.props'
79+
-OutPath '$(Build.ArtifactStagingDirectory)/reports/dependencies.html'
80+
-DumpPath '$(Build.ArtifactStagingDirectory)/reports/data.js'
81+
82+
- task: PowerShell@2
83+
displayName: 'Generate azure-sdk.deps.json'
84+
inputs:
85+
pwsh: true
86+
filePath: 'eng/scripts/dependencies/generate-deps.ps1'
87+
arguments: >
88+
-PackagesPath '$(System.ArtifactsDirectory)/Packages/'
89+
-DepsOutputFile '$(Build.ArtifactStagingDirectory)/reports/azure-sdk.deps.json'
90+
-ProjectRefPath '$(Build.ArtifactStagingDirectory)/reports'
91+
92+
- task: PowerShell@2
93+
displayName: 'Validate dependencies with pwsh servicing'
94+
inputs:
95+
pwsh: true
96+
filePath: 'eng/scripts/dependencies/compare-deps-files.ps1'
97+
arguments: >
98+
-PSDepsFile 'https://aka.ms/ps-deps-servicing'
99+
-AzSdkDepsFile '$(Build.ArtifactStagingDirectory)/reports/azure-sdk.deps.json'
100+
101+
- task: PowerShell@2
102+
displayName: 'Validate dependencies with pwsh stable'
103+
inputs:
104+
pwsh: true
105+
filePath: 'eng/scripts/dependencies/compare-deps-files.ps1'
106+
arguments: >
107+
-PSDepsFile 'https://aka.ms/ps-deps-stable'
108+
-AzSdkDepsFile '$(Build.ArtifactStagingDirectory)/reports/azure-sdk.deps.json'
109+
110+
- task: PowerShell@2
111+
displayName: 'Validate dependencies with pwsh preview'
112+
inputs:
113+
pwsh: true
114+
filePath: 'eng/scripts/dependencies/compare-deps-files.ps1'
115+
arguments: >
116+
-PSDepsFile 'https://aka.ms/ps-deps-preview'
117+
-AzSdkDepsFile '$(Build.ArtifactStagingDirectory)/reports/azure-sdk.deps.json'
118+
119+
- task: PublishPipelineArtifact@1
120+
displayName: 'Publish Report Artifacts'
121+
inputs:
122+
artifactName: reports
123+
path: '$(Build.ArtifactStagingDirectory)/reports'
124+
125+
- task: AzureFileCopy@2
126+
displayName: 'Upload dependency report'
127+
inputs:
128+
sourcePath: '$(Build.ArtifactStagingDirectory)/reports'
129+
azureSubscription: 'Azure SDK Artifacts'
130+
destination: AzureBlob
131+
storage: azuresdkartifacts
132+
containerName: 'azure-sdk-for-net'
133+
blobPrefix: dependencies
134+
135+
- task: PowerShell@2
136+
displayName: "Verify Repository Resource Refs"
137+
inputs:
138+
pwsh: true
139+
workingDirectory: $(Build.SourcesDirectory)
140+
filePath: eng/common/scripts/Verify-Resource-Ref.ps1
141+
142+
- stage: ComplianceTools
143+
displayName: Compliance Tools
144+
dependsOn: []
145+
146+
jobs:
147+
- job: ComplianceTools
148+
timeoutInMinutes: 120
149+
steps:
150+
- pwsh: |
151+
azcopy copy "https://azuresdkartifacts.blob.core.windows.net/policheck/DotNetPoliCheckExclusion.mdb?$(azuresdk-policheck-blob-SAS)" `
152+
"$(Build.BinariesDirectory)"
153+
displayName: 'Download PoliCheck Exclusion Database'
154+
condition: succeededOrFailed()
155+
156+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@2
157+
displayName: 'Run PoliCheck'
158+
inputs:
159+
targetType: F
160+
targetArgument: '$(Build.SourcesDirectory)'
161+
result: PoliCheck.sarif
162+
optionsFC: 0
163+
optionsXS: 1
164+
optionsPE: 1|2|3|4
165+
optionsRulesDBPath: "$(Build.BinariesDirectory)/DotNetPoliCheckExclusion.mdb"
166+
optionsUEPATH: "$(Build.SourcesDirectory)/eng/guardian-tools/policheck/PolicheckExclusions.xml"
167+
condition: succeededOrFailed()
168+
169+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2
170+
displayName: 'Post Analysis (PoliCheck)'
171+
inputs:
172+
GdnBreakAllTools: false
173+
GdnBreakGdnToolPoliCheck: true
174+
GdnBreakGdnToolPoliCheckSeverity: Warning
175+
condition: succeededOrFailed()
176+
continueOnError: true
177+
178+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
179+
displayName: 'Run CredScan'
180+
inputs:
181+
suppressionsFile: 'eng\CredScanSuppression.json'
182+
condition: succeededOrFailed()
183+
184+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2
185+
displayName: 'Post Analysis (CredScan)'
186+
inputs:
187+
GdnBreakAllTools: false
188+
GdnBreakGdnToolCredScan: true
189+
GdnBreakGdnToolCredScanSeverity: Error
190+
GdnBreakBaselineFiles: $(Build.SourcesDirectory)\eng\dotnet.gdnbaselines
191+
GdnBreakBaselines: baseline
192+
# Used for generating baseline file
193+
# GdnBreakOutputBaselineFile: dotnet
194+
# GdnBreakOutputBaseline: baseline
195+
condition: succeededOrFailed()
196+
continueOnError: true
197+
198+
- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@3
199+
displayName: 'Publish Security Analysis Logs'
200+
condition: succeededOrFailed()

sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/Testing/EventHubsTestEnvironment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public sealed class EventHubsTestEnvironment : TestEnvironment
2828
/// <summary>The name of the environment variable used to specify an override for the Event Hub instance to use for all tests.</summary>
2929
private const string EventHubNameOverrideEnvironmentVariable = "EVENTHUB_OVERRIDE_EVENT_HUB_NAME";
3030

31-
/// <summary>The default value for the maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk for being hung.</summary>
31+
/// <summary>The default value for the maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk of not responding.</summary>
3232
private const int DefaultPerTestExecutionLimitMinutes = 5;
3333

3434
/// <summary>The singleton instance of the <see cref="EventHubsTestEnvironment" />, lazily created.</summary>
@@ -37,7 +37,7 @@ public sealed class EventHubsTestEnvironment : TestEnvironment
3737
/// <summary>The active Event Hubs namespace for this test run, lazily created.</summary>
3838
private readonly Lazy<NamespaceProperties> ActiveEventHubsNamespace;
3939

40-
/// <summary> The environment variable value, or default, for the maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk for being hung, lazily evaluated.</summary>
40+
/// <summary>The environment variable value, or default, for the maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk of not responding, lazily evaluated.</summary>
4141
private readonly Lazy<TimeSpan> ActivePerTestExecutionLimit;
4242

4343
/// <summary>The connection string for the active Event Hubs namespace for this test run, lazily created.</summary>
@@ -59,7 +59,7 @@ public sealed class EventHubsTestEnvironment : TestEnvironment
5959

6060
/// <summary>
6161
/// The environment variable value, or default, for the maximum duration, in minutes,
62-
/// that a single test is permitted to run before it is considered at-risk for being hung.
62+
/// that a single test is permitted to run before it is considered at-risk of not responding.
6363
/// </summary>
6464
///
6565
public TimeSpan TestExecutionTimeLimit => ActivePerTestExecutionLimit.Value;

sdk/eventhub/Azure.Messaging.EventHubs/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ The Event Hubs Live tests read information from the following environment variab
112112
The client secret (password) of the Azure Active Directory application that is associated with the service principal
113113

114114
- `EVENTHUB_PER_TEST_LIMIT_MINUTES`
115-
The maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk for being hung. If not provided, a default suitable for most local development environment runs is assumed.
115+
The maximum duration, in minutes, that a single test is permitted to run before it is considered at-risk of not responding. If not provided, a default suitable for most local development environment runs is assumed.
116116

117117
- `EVENTHUB_NAMESPACE_CONNECTION_STRING`
118118
The connection string to an Event Hubs namespace to use for testing. Tests will each create an ephemeral Event Hub instance in this namespace when executing, in order to ensure isolation. When the run is complete, the namespace will be left in the state that it was in before the test run took place.

0 commit comments

Comments
 (0)