mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-30 05:59:39 +02:00
fix(codeqlExecuteScan): added parameters threads and ram (#4269)
This commit is contained in:
parent
8084ce1a94
commit
9774eaab86
@ -187,10 +187,18 @@ func runCodeqlExecuteScan(config *codeqlExecuteScanOptions, telemetryData *telem
|
||||
|
||||
if len(language) > 0 {
|
||||
cmd = append(cmd, "--language="+language)
|
||||
} else if len(config.Language) > 0 {
|
||||
} else {
|
||||
cmd = append(cmd, "--language="+config.Language)
|
||||
}
|
||||
|
||||
if len(config.Threads) > 0 {
|
||||
cmd = append(cmd, "--threads="+config.Threads)
|
||||
}
|
||||
|
||||
if len(config.Ram) > 0 {
|
||||
cmd = append(cmd, "--ram="+config.Ram)
|
||||
}
|
||||
|
||||
//codeql has an autobuilder which tries to build the project based on specified programming language
|
||||
if len(config.BuildCommand) > 0 {
|
||||
cmd = append(cmd, "--command="+config.BuildCommand)
|
||||
@ -209,6 +217,12 @@ func runCodeqlExecuteScan(config *codeqlExecuteScanOptions, telemetryData *telem
|
||||
|
||||
cmd = nil
|
||||
cmd = append(cmd, "database", "analyze", "--format=sarif-latest", fmt.Sprintf("--output=%vtarget/codeqlReport.sarif", config.ModulePath), config.Database)
|
||||
if len(config.Threads) > 0 {
|
||||
cmd = append(cmd, "--threads="+config.Threads)
|
||||
}
|
||||
if len(config.Ram) > 0 {
|
||||
cmd = append(cmd, "--ram="+config.Ram)
|
||||
}
|
||||
cmd = codeqlQuery(cmd, config.QuerySuite)
|
||||
err = execute(utils, cmd, GeneralConfig.Verbose)
|
||||
if err != nil {
|
||||
@ -220,6 +234,12 @@ func runCodeqlExecuteScan(config *codeqlExecuteScanOptions, telemetryData *telem
|
||||
|
||||
cmd = nil
|
||||
cmd = append(cmd, "database", "analyze", "--format=csv", fmt.Sprintf("--output=%vtarget/codeqlReport.csv", config.ModulePath), config.Database)
|
||||
if len(config.Threads) > 0 {
|
||||
cmd = append(cmd, "--threads="+config.Threads)
|
||||
}
|
||||
if len(config.Ram) > 0 {
|
||||
cmd = append(cmd, "--ram="+config.Ram)
|
||||
}
|
||||
cmd = codeqlQuery(cmd, config.QuerySuite)
|
||||
err = execute(utils, cmd, GeneralConfig.Verbose)
|
||||
if err != nil {
|
||||
|
@ -28,6 +28,8 @@ type codeqlExecuteScanOptions struct {
|
||||
Database string `json:"database,omitempty"`
|
||||
QuerySuite string `json:"querySuite,omitempty"`
|
||||
UploadResults bool `json:"uploadResults,omitempty"`
|
||||
Threads string `json:"threads,omitempty"`
|
||||
Ram string `json:"ram,omitempty"`
|
||||
AnalyzedRef string `json:"analyzedRef,omitempty"`
|
||||
Repository string `json:"repository,omitempty"`
|
||||
CommitID string `json:"commitId,omitempty"`
|
||||
@ -178,6 +180,8 @@ func addCodeqlExecuteScanFlags(cmd *cobra.Command, stepConfig *codeqlExecuteScan
|
||||
cmd.Flags().StringVar(&stepConfig.Database, "database", `codeqlDB`, "Path to the CodeQL database to create. This directory will be created, and must not already exist.")
|
||||
cmd.Flags().StringVar(&stepConfig.QuerySuite, "querySuite", os.Getenv("PIPER_querySuite"), "The name of a CodeQL query suite. If omitted, the default query suite for the language of the database being analyzed will be used.")
|
||||
cmd.Flags().BoolVar(&stepConfig.UploadResults, "uploadResults", false, "Allows you to upload codeql SARIF results to your github project. You will need to set githubToken for this.")
|
||||
cmd.Flags().StringVar(&stepConfig.Threads, "threads", `0`, "Use this many threads for the codeql operations.")
|
||||
cmd.Flags().StringVar(&stepConfig.Ram, "ram", os.Getenv("PIPER_ram"), "Use this much ram (MB) for the codeql operations.")
|
||||
cmd.Flags().StringVar(&stepConfig.AnalyzedRef, "analyzedRef", os.Getenv("PIPER_analyzedRef"), "Name of the ref that was analyzed.")
|
||||
cmd.Flags().StringVar(&stepConfig.Repository, "repository", os.Getenv("PIPER_repository"), "URL of the GitHub instance")
|
||||
cmd.Flags().StringVar(&stepConfig.CommitID, "commitId", os.Getenv("PIPER_commitId"), "SHA of commit that was analyzed.")
|
||||
@ -287,6 +291,24 @@ func codeqlExecuteScanMetadata() config.StepData {
|
||||
Aliases: []config.Alias{},
|
||||
Default: false,
|
||||
},
|
||||
{
|
||||
Name: "threads",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Default: `0`,
|
||||
},
|
||||
{
|
||||
Name: "ram",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Default: os.Getenv("PIPER_ram"),
|
||||
},
|
||||
{
|
||||
Name: "analyzedRef",
|
||||
ResourceRef: []config.ResourceReference{
|
||||
|
@ -105,6 +105,21 @@ spec:
|
||||
- STAGES
|
||||
- STEPS
|
||||
default: false
|
||||
- name: threads
|
||||
type: string
|
||||
description: "Use this many threads for the codeql operations."
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
default: "0"
|
||||
- name: ram
|
||||
type: string
|
||||
description: "Use this much ram (MB) for the codeql operations."
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- name: analyzedRef
|
||||
type: string
|
||||
description: "Name of the ref that was analyzed."
|
||||
|
Loading…
x
Reference in New Issue
Block a user