I have a yaml pipeline to do code scanning and dependency scanning with Github Advanced Security for Azure devops:
pool:
vmImage: ubuntu-latest
steps:
- task: AdvancedSecurity-Codeql-Init@1
inputs:
languages: 'csharp'
- task: AdvancedSecurity-Codeql-Autobuild@1
- task: AdvancedSecurity-Dependency-Scanning@1
- task: AdvancedSecurity-Codeql-Analyze@1
I have a monorepo that contains 5 applications, all in the same repository.
How does the autobuild step work? What if I have multiple dotnet projects (multiple csproj and sln files). How does it know which one to build? Will it build all of them?
On the other hand, when I use a custom build to only build one of my monorepo projects:
- task: DotNetCoreCLI@2
displayName: '.NET Restore'
inputs:
command: restore
projects: ${{ variables.projectPath }}
vstsFeed: 'MyCorpFeed'
includeNuGetOrg: true
- task: DotNetCoreCLI@2
displayName: '.NET Build'
inputs:
command: build
projects: ${{ variables.projectPath }}
arguments: '--configuration release'
In the output I also notice alerts for other .NET projects (that were not included in the build). Am I doing something wrong? Or is this normal behavior ?
When dealing with a monorepo that contains multiple projects, the autobuild step attempts to build all the projects it can find. If you have multiple .NET projects (multiple csproj and sln files), the autobuild step will try to build all of them. This is because the autobuild step is designed to maximize the coverage of the CodeQL analysis.
This is expected behavior. The CodeQL analysis is not limited to just the projects that were built in the current pipeline run. It analyzes the entire codebase in the repository. Therefore, if there are issues in the other .NET projects in your repository, they will be flagged by the CodeQL analysis.
Please refer to the official doc Code Scanning for more detials.