You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: troubleshooting/codeql-builds/compiled-languages-csharp.md
+34-4Lines changed: 34 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,22 @@ Using `dotnet` is best documented at: https://docs.github.com/en/actions/automat
55
55
#### NuGet Error NU1301
56
56
This can indicate your custom package server is not configured which may fail the `dotnet restore` command. For private package servers, the follwing guidance shows how to add package sources: [Setting up authentication for nuget feeds](https://github.com/actions/setup-dotnet#setting-up-authentication-for-nuget-feeds)
57
57
58
-
### .NET Framework Manual Build Steps on Windows Runners
58
+
#### NuGet.targets(132,5): warning : Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
59
+
60
+
Consider adding auth for your GitHub Packages hosted NuGet feed using the nuget CLI tooling. Add this before the `autobuild` / custom build steps in your workflow.
Utilize the [nuget/setup-nuget](https://github.com/nuget/setup-nuget#basic) action to pass package key/source to nuget exe.
72
+
73
+
#### Manual Build Steps on Windows Runners
59
74
NOTE: if you require windows OS to build, ensure you are using a windows runner.
60
75
61
76
Example using `windows-latest`:
@@ -118,6 +133,21 @@ Running low on disk using the default Actions runner? Try a few of these workaro
118
133
119
134
- See also: [Vertical Scaling](#vertical-scaling---throw-hardware-at-the-software-problem)
120
135
136
+
## MvcBuildViews target failures
137
+
138
+
This can manifest through a variety of errors
139
+
- `error ASPPARSE`
140
+
- `[error]C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config(113,0): Error ASPCONFIG: Could not load type`
141
+
- `Error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.`
142
+
- `(AfterBuildCompiler target) -> D:\a\Orchard\Orchard\src\Orchard.Web\Modules\Orchard.Glimpse\web.config(38): error ASPCONFIG: Could not load file or assembly 'System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)`
143
+
144
+
The CodeQL compiler tracer used for `csharp` will auto inject the /p:MvcBuildViews=true flag. This pre-compilation of Views gives us the ability to extract the generated code from those files, leading to (potentially) better error reporting and location information if a query does flag an issue. The lack of view information passing through CodeQL to the compiler will lead to an incomplete database, where important dataflow sources/sinks/taint-steps are not included in the analysis.
145
+
146
+
The recommendation here is to ensure that passing /p:MvcBuildViews=true to your CI build will compile even outside of CodeQL. Having a developer reivew this on their local machine is the best scenario. This can be on done on the specific web project by adding `<MvcBuildViews>true</MvcBuildViews>` to the local .csproj ( you will often find this defaulted to false). The MVC full framework steps are listed [here](https://learn.microsoft.com/en-us/archive/blogs/jimlamb/turn-on-compile-time-view-checking-for-asp-net-mvc-projects-in-tfs-build-2010). There are a few different reasons why this can cause your project to fail compilation.
147
+
148
+
For `Error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.`, change the locations of the obj and publish folder to not be located under the project folder of the website. If you have bin/obj files checked into source then this could be a likely culprit: https://gunnarpeipman.com/aspnet-mvc-allowdefinition-machinetoapplication/. You will find [various permutations of this recommendation](https://stackoverflow.com/questions/12778088/allowdefinition-machinetoapplication-error-setting-mvcbuildviewstrue-mvcbui) out there!
149
+
150
+
For `Error ASPCONFIG: Could not load type 'X.Y.Z'`, ensure that you do not have excluded `.cshtml`, `.ashx`, `.ashx.cs`, `.aspx` or `.aspx.cs` files on disk in existing `Views` folders or the Root folder of your project! You can show hidden files in your solution view to hunt these down and remove from these folders. MvcBuildViews does not observe the file include from the csproj when compiling the application. You may have to hunt these down one by one, so adding `<MvcBuildViews>true</MvcBuildViews>` to your local .csproj may help you get this done on your local machine with Visual Studio. The `Error List` view in Visual Studio will have a column that shows you the actual File name you need to delete.
121
151
122
152
# Speed up C# Analysis
123
153
@@ -126,10 +156,10 @@ Start here: [CodeQL Docs - The build takes too long](https://docs.github.com/en
126
156
## Optimization - Caching Dependencies
127
157
Depending on the number of dependencies, it may be faster to restore packages for your project using the Actions dependency cache. Projects with many large dependencies should see a performance increase as it cuts down the time required for downloading. Projects with fewer dependencies may not see a significant performance increase and may even see a slight decrease due to how NuGet installs cached dependencies. The performance varies from project to project. See [this article](https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net#caching-dependencies) for configuring the NuGet dependency cache.
128
158
129
-
## Optimization - Removing Unit Tests
130
-
CodeQL will extract and analyze any code that is passed through the compiler. Consider excluding any code you do not wish to include in a security scan to speed up and remove noise from this process.
159
+
## Optimization - Removing Code From Scans
160
+
CodeQL will extract and analyze any code that is passed through the compiler. Consider excluding any code you do not wish to include in a security scan to speed up and remove noise from this process. This is commonly employed for unit tests, demo code, or code that would not benefit from being scanned (ex: DacPacs).
131
161
132
-
With .NET we can employ a few mechanisms to remove test/demo code from CodeQL scans (e.g. you would want to run your unit test in another workflow ):
162
+
With .NET we can employ a few mechanisms to remove code from CodeQL scans (e.g. you would want to run your unit test in another workflow ):
133
163
- A [solution filter](https://docs.microsoft.com/en-us/visualstudio/msbuild/solution-filters?view=vs-2019) to only build required projects
134
164
- An explicit [solution file that excludes projects](https://docs.microsoft.com/en-us/visualstudio/ide/how-to-exclude-projects-from-a-build?view=vs-2022)
135
165
- example from the Open Source project: [Identity Server](https://github.com/DuendeSoftware/IdentityServer/)
Copy file name to clipboardExpand all lines: troubleshooting/codeql-builds/compiled-languages-java.md
+30-10Lines changed: 30 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
2
2
# Private Package Registries
3
3
4
-
## The codeql for java is failing when it tries to do mvn command and tries to access a artifactory repo where our pom.xml are stored.
5
-
6
-
Assuming the given package registry instance is publicly accessible:
4
+
## The autobuild for java is failing when running Maven build command and a private package registry is needed - `status: 401 Unauthorized `
5
+
- ex: artifactory where our pom.xml dependencies are stored
7
6
7
+
Assuming the given package registry instance is publicly accessible and needs credentials:
8
8
9
9
Option 1 - Pass credentials via environment variable from Actions secrets and configure Maven settings to utilize those credentials (see sample [here](https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#yaml-example))
10
10
@@ -24,7 +24,20 @@ ex `settings.xml`
24
24
</server>
25
25
```
26
26
27
-
Option 2 - Use the [maven-settings-action](https://github.com/s4u/maven-settings-action) to dynamically create/overrite a `settings.xml` that contains the credentials for your specified package manager.
27
+
Option 2 - Use the GitHub https://github.com/actions/setup-java#maven-options action to generate maven's settings.xml on the fly and pass the values to Apache Maven GPG Plugin as well as Apache Maven Toolchains.
28
+
29
+
```yml
30
+
- name: Set up Apache Maven Central
31
+
uses: actions/setup-java@v3
32
+
with:
33
+
distribution: 'temurin'
34
+
java-version: '11'
35
+
server-id: maven # Value of the distributionManagement/repository/id field of the pom.xml
36
+
server-username: MAVEN_USERNAME # env variable for username in deploy
37
+
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
38
+
```
39
+
40
+
Option 3 - Use the [maven-settings-action](https://github.com/s4u/maven-settings-action) to dynamically create/overrite a `settings.xml` that contains the credentials for your specified package manager.
28
41
29
42
```yml
30
43
- if: matrix.language == 'java'
@@ -34,6 +47,8 @@ Option 2 - Use the [maven-settings-action](https://github.com/s4u/maven-settings
Copy file name to clipboardExpand all lines: troubleshooting/codeql-builds/compiled-languages.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ See [language specific guidance](#language-specific-guidance) for common resolut
24
24
Ensure network access from GitHub runners to your private registry is open
25
25
- For IP Whitelisting, consider using [Larger Runners with Static IP](https://docs.github.com/en/actions/using-github-hosted-runners/using-larger-runners#networking-for-larger-runners)
26
26
- See Also: [Connecting Actions to a private network](https://docs.github.com/en/actions/using-github-hosted-runners/connecting-to-a-private-network)
27
+
- Alternatively, consider a self-hosted actions runner that will execute within your existing private network. See ["Hosting your own runners"](https://docs.github.com/en/actions/hosting-your-own-runners)
27
28
28
29
See [language specific guidance](#language-specific-guidance) for authentication options to popular package mangers
29
30
@@ -48,9 +49,9 @@ alternatively we can further define limits
48
49
- name: Perform CodeQL Analysis
49
50
uses: github/codeql-action/analyze@v2
50
51
with:
51
-
# Increase Values seen in logs:
52
+
# Increase Values seen in logs:
52
53
#2022-06-01T19:37:19.0200037Z CODEQL_RAM: 119741
53
-
#2022-06-01T19:37:19.0200307Z CODEQL_THREADS: 32
54
+
#2022-06-01T19:37:19.0200307Z CODEQL_THREADS: 32
54
55
ram: 64000
55
56
threads: 16
56
57
```
@@ -64,5 +65,6 @@ Helpful Articles to understand how to review, troubleshoot, and debug logs:
64
65
- [Adding artifacts on every CodeQL Run](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/troubleshooting-the-codeql-workflow#creating-codeql-debugging-artifacts-using-a-workflow-flag)
Copy file name to clipboardExpand all lines: troubleshooting/sarif-upload/troubleshooting.md
+31-2Lines changed: 31 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
-
### SARIF Upload Errors
1
+
## SARIF Upload Errors
2
+
* Test environment - GHES 3.2.1 + CodeQL CLI 2.7.2
2
3
3
4
:gift: wrong ref:
4
5
```
@@ -58,9 +59,37 @@ More information on the API can be found [here](https://docs.github.com/en/rest/
58
59
59
60
### Test environments
60
61
- GHES 3.2.1 + CodeQL CLI 2.7.2
62
+
=======
63
+
## SARIF Parsing Errors
61
64
65
+
### Code Scanning could not process the submitted SARIF file: rejecting SARIF, as there are more runs than allowed (123 > 15)
66
+
The GitHub api for accepting SARIF uploads has a limiter to prevent that number from being greater than specified (>15) for each upload.
62
67
63
-
### Tools to rewrite SARIF
68
+
See limits for various thresholds on the [REST API documentation](https://docs.github.com/en/rest/code-scanning?apiVersion=2022-11-28#upload-an-analysis-as-sarif-data)
69
+
* Runs per file
70
+
* Results per run
71
+
* Rules per run
72
+
* Tool extensions per run
73
+
* Thread Flow Locations per result
74
+
* Location per result
75
+
* Tags per rule
76
+
77
+
### A fatal error occurred: SARIF file is too large. The GitHub code scanning API accepts a max file size of 2000MB. This file is xxxxMB. File: "xyz.sarif"
78
+
- aleternatively - `failed decompressing file from the path: "upload /xyz.sarif.gz": maximum SARIF size exceeded`
79
+
80
+
First, review recommendedations per language to reduce the amount of code being scanned (e.g. removing test or demo code from the scan in an attempt to remove unwanted detections from SARIF). A detailed analysis of the SARIF file may indicate a massive number of a single rule, in this case [excluding a specific rule from the analysis](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning#excluding-specific-queries-from-analysis) would be the best solution. Alternatively, use a tool like [filter-sarif action](https://github.com/advanced-security/filter-sarif) to rewrite the SARIF file to exclude specific detections via an exclusion pattern.
81
+
82
+
If there are many deep code paths highlighted in the SARIF, use `--max-path=0` (or 1) passed into the analyze step or `database analyze` cli command to get rid of the dataflow paths and reduce the SARIF size that way (NOTE this will impact all rules).
0 commit comments