log.Entry().Errorf("failed to persist reports: %v",err)
}
}
// CodeqlExecuteScanCommand This step executes a codeql scan on the specified project to perform static code analysis and check the source code for security flaws.
funcCodeqlExecuteScanCommand()*cobra.Command{
constSTEP_NAME="codeqlExecuteScan"
metadata:=codeqlExecuteScanMetadata()
varstepConfigcodeqlExecuteScanOptions
varstartTimetime.Time
varreportscodeqlExecuteScanReports
varlogCollector*log.CollectorHook
varsplunkClient*splunk.Splunk
telemetryClient:=&telemetry.Telemetry{}
varcreateCodeqlExecuteScanCmd=&cobra.Command{
Use:STEP_NAME,
Short:"This step executes a codeql scan on the specified project to perform static code analysis and check the source code for security flaws.",
cmd.Flags().StringVar(&stepConfig.GithubToken,"githubToken",os.Getenv("PIPER_githubToken"),"GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line")
cmd.Flags().StringVar(&stepConfig.BuildTool,"buildTool",`maven`,"Defines the build tool which is used for building the project.")
cmd.Flags().StringVar(&stepConfig.BuildCommand,"buildCommand",os.Getenv("PIPER_buildCommand"),"Command to build the project")
cmd.Flags().StringVar(&stepConfig.Language,"language",os.Getenv("PIPER_language"),"The programming language used to analyze.")
cmd.Flags().StringVar(&stepConfig.ModulePath,"modulePath",`./`,"Allows providing the path for the module to scan")
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.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.")
cmd.MarkFlagRequired("buildTool")
}
// retrieve step metadata
funccodeqlExecuteScanMetadata()config.StepData{
vartheMetaData=config.StepData{
Metadata:config.StepMetadata{
Name:"codeqlExecuteScan",
Aliases:[]config.Alias{},
Description:"This step executes a codeql scan on the specified project to perform static code analysis and check the source code for security flaws.",
},
Spec:config.StepSpec{
Inputs:config.StepInputs{
Secrets:[]config.StepSecrets{
{Name:"githubTokenCredentialsId",Description:"Jenkins 'Secret text' credentials ID containing token to authenticate to GitHub.",Type:"jenkins"},