[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xencons PATCH 2/3] Add support for CodeQL 2.20.1



CodeQL 2.20.1 uses a different query file to previous versions, and relies
on using different query packs, which need to be present on the system.

Adds CODEQL_QUERY_FILE environment variable to force a specific query file, if 
set.

Also adds "--threads=0" parameter, to use alll available CPUs.

https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/static-tools-and-codeql

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 msbuild.ps1 | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/msbuild.ps1 b/msbuild.ps1
index f258781..c8f65f4 100644
--- a/msbuild.ps1
+++ b/msbuild.ps1
@@ -109,7 +109,8 @@ Function Run-CodeQL {
                [string]$Name,
                [string]$Configuration,
                [string]$Platform,
-               [string]$SearchPath
+               [string]$SearchPath,
+               [string]$QueryFile
        )
 
        $projpath = Resolve-Path (Join-Path $SolutionPath $Name)
@@ -153,8 +154,10 @@ Function Run-CodeQL {
        $c += " database"
        $c += " analyze "
        $c += $database
-       $c += " windows_driver_recommended.qls"
+       $c += " "
+       $c += $QueryFile
        $c += " --format=sarifv2.1.0"
+       $c += " --threads=0"
        $c += " --output="
        $c += $sarif
        $c += " --search-path="
@@ -198,8 +201,22 @@ if ($Type -eq "codeql") {
        }
        New-Item -ItemType Directory "database" | Out-Null
 
+       $queryfile = "windows_driver_recommended.qls"
+       Try {
+               $ver = New-Object System.Version((& "codeql" 
"--version")[0].Split(" ")[-1] + "0")
+               Write-Host -ForegroundColor Cyan "INFO: CodeQL version " $ver
+               $minver = New-Object System.Version("2.20.1.0")
+               if ($ver -ge $minver) {
+                       $queryfile = "mustfix.qls"
+               }
+       } Catch {
+       }
+       if (-not [string]::IsNullOrEmpty($Env:CODEQL_QUERY_FILE)) {
+               $queryfile = $Env:CODEQL_QUERY_FILE
+               Write-Host -ForegroundColor Cyan "INFO: Overwriting codeql 
query file to " $queryfile
+       }
        ForEach ($project in $ProjectList) {
-               Run-CodeQL $solutionpath $project $configuration["codeql"] 
$platform[$Arch] $searchpath
+               Run-CodeQL $solutionpath $project $configuration["codeql"] 
$platform[$Arch] $searchpath $queryfile
        }
        Copy-Item -Path (Join-Path -Path $SolutionPath -ChildPath "*.sarif") 
-Destination $archivepath
 }
-- 
2.51.2.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.