2022-06-24 09:04:24 +02:00
// Code generated by piper's step-generator. DO NOT EDIT.
package cmd
import (
"fmt"
"os"
2024-01-17 09:38:16 +01:00
"path/filepath"
2022-06-24 09:04:24 +02:00
"reflect"
"strings"
"time"
"github.com/SAP/jenkins-library/pkg/config"
2026-02-25 15:58:35 +02:00
"github.com/SAP/jenkins-library/pkg/eventing"
2022-06-24 09:04:24 +02:00
"github.com/SAP/jenkins-library/pkg/gcs"
"github.com/SAP/jenkins-library/pkg/log"
2024-01-17 09:38:16 +01:00
"github.com/SAP/jenkins-library/pkg/piperenv"
2022-06-24 09:04:24 +02:00
"github.com/SAP/jenkins-library/pkg/splunk"
"github.com/SAP/jenkins-library/pkg/telemetry"
"github.com/SAP/jenkins-library/pkg/validation"
"github.com/bmatcuk/doublestar"
"github.com/spf13/cobra"
)
type codeqlExecuteScanOptions struct {
2023-04-28 15:47:05 +02:00
GithubToken string `json:"githubToken,omitempty"`
BuildTool string `json:"buildTool,omitempty" validate:"possible-values=custom maven golang npm pip yarn"`
BuildCommand string `json:"buildCommand,omitempty"`
Language string `json:"language,omitempty"`
ModulePath string `json:"modulePath,omitempty"`
Database string `json:"database,omitempty"`
QuerySuite string `json:"querySuite,omitempty"`
UploadResults bool `json:"uploadResults,omitempty"`
2023-06-20 14:50:28 +02:00
SarifCheckMaxRetries int `json:"sarifCheckMaxRetries,omitempty"`
SarifCheckRetryInterval int `json:"sarifCheckRetryInterval,omitempty"`
2023-10-18 13:20:15 +02:00
TargetGithubRepoURL string `json:"targetGithubRepoURL,omitempty"`
TargetGithubBranchName string `json:"targetGithubBranchName,omitempty"`
2023-04-28 15:47:05 +02:00
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"`
VulnerabilityThresholdTotal int `json:"vulnerabilityThresholdTotal,omitempty"`
CheckForCompliance bool `json:"checkForCompliance,omitempty"`
2023-12-01 10:45:31 +01:00
ProjectSettingsFile string `json:"projectSettingsFile,omitempty"`
GlobalSettingsFile string `json:"globalSettingsFile,omitempty"`
2024-04-02 06:48:17 +02:00
DatabaseCreateFlags string `json:"databaseCreateFlags,omitempty"`
DatabaseAnalyzeFlags string `json:"databaseAnalyzeFlags,omitempty"`
2024-05-27 13:09:05 +02:00
CustomCommand string `json:"customCommand,omitempty"`
2024-06-06 14:14:03 +02:00
TransformQuerySuite string `json:"transformQuerySuite,omitempty"`
2025-09-12 19:37:30 +04:00
Paths string `json:"paths,omitempty"`
PathsIgnore string `json:"pathsIgnore,omitempty"`
2022-06-24 09:04:24 +02:00
}
2024-01-17 09:38:16 +01:00
type codeqlExecuteScanInflux struct {
step_data struct {
fields struct {
codeql bool
}
tags struct {
}
}
codeql_data struct {
fields struct {
repositoryURL string
repositoryReferenceURL string
codeScanningLink string
querySuite string
optionalTotal int
optionalAudited int
auditAllTotal int
auditAllAudited int
}
tags struct {
}
}
}
func ( i * codeqlExecuteScanInflux ) persist ( path , resourceName string ) {
measurementContent := [] struct {
measurement string
valType string
name string
value interface {}
}{
{ valType : config . InfluxField , measurement : "step_data" , name : "codeql" , value : i . step_data . fields . codeql },
{ valType : config . InfluxField , measurement : "codeql_data" , name : "repositoryUrl" , value : i . codeql_data . fields . repositoryURL },
{ valType : config . InfluxField , measurement : "codeql_data" , name : "repositoryReferenceUrl" , value : i . codeql_data . fields . repositoryReferenceURL },
{ valType : config . InfluxField , measurement : "codeql_data" , name : "codeScanningLink" , value : i . codeql_data . fields . codeScanningLink },
{ valType : config . InfluxField , measurement : "codeql_data" , name : "querySuite" , value : i . codeql_data . fields . querySuite },
{ valType : config . InfluxField , measurement : "codeql_data" , name : "optionalTotal" , value : i . codeql_data . fields . optionalTotal },
{ valType : config . InfluxField , measurement : "codeql_data" , name : "optionalAudited" , value : i . codeql_data . fields . optionalAudited },
{ valType : config . InfluxField , measurement : "codeql_data" , name : "auditAllTotal" , value : i . codeql_data . fields . auditAllTotal },
{ valType : config . InfluxField , measurement : "codeql_data" , name : "auditAllAudited" , value : i . codeql_data . fields . auditAllAudited },
}
errCount := 0
for _ , metric := range measurementContent {
err := piperenv . SetResourceParameter ( path , resourceName , filepath . Join ( metric . measurement , fmt . Sprintf ( "%vs" , metric . valType ), metric . name ), metric . value )
if err != nil {
log . Entry (). WithError ( err ). Error ( "Error persisting influx environment." )
errCount ++
}
}
if errCount > 0 {
log . Entry (). Error ( "failed to persist Influx environment" )
}
}
2022-06-24 09:04:24 +02:00
type codeqlExecuteScanReports struct {
}
func ( p * codeqlExecuteScanReports ) persist ( stepConfig codeqlExecuteScanOptions , gcpJsonKeyFilePath string , gcsBucketId string , gcsFolderPath string , gcsSubFolder string ) {
if gcsBucketId == "" {
log . Entry (). Info ( "persisting reports to GCS is disabled, because gcsBucketId is empty" )
return
}
log . Entry (). Info ( "Uploading reports to Google Cloud Storage..." )
content := [] gcs . ReportOutputParam {
{ FilePattern : "**/*.csv" , ParamRef : "" , StepResultType : "codeql" },
{ FilePattern : "**/*.sarif" , ParamRef : "" , StepResultType : "codeql" },
2023-02-22 20:00:53 +03:00
{ FilePattern : "**/toolrun_codeql_*.json" , ParamRef : "" , StepResultType : "codeql" },
2023-06-02 18:31:52 +05:30
{ FilePattern : "**/piper_codeql_report.json" , ParamRef : "" , StepResultType : "codeql" },
2022-06-24 09:04:24 +02:00
}
2025-03-07 13:27:14 +02:00
gcsClient , err := gcs . NewClient ( gcpJsonKeyFilePath , "" )
2022-06-24 09:04:24 +02:00
if err != nil {
log . Entry (). Errorf ( "creation of GCS client failed: %v" , err )
return
}
defer gcsClient . Close ()
structVal := reflect . ValueOf ( & stepConfig ). Elem ()
inputParameters := map [ string ] string {}
for i := 0 ; i < structVal . NumField (); i ++ {
field := structVal . Type (). Field ( i )
if field . Type . String () == "string" {
paramName := strings . Split ( field . Tag . Get ( "json" ), "," )
paramValue , _ := structVal . Field ( i ). Interface ().( string )
inputParameters [ paramName [ 0 ]] = paramValue
}
}
if err := gcs . PersistReportsToGCS ( gcsClient , content , inputParameters , gcsFolderPath , gcsBucketId , gcsSubFolder , doublestar . Glob , os . Stat ); err != nil {
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.
func CodeqlExecuteScanCommand () * cobra . Command {
const STEP_NAME = "codeqlExecuteScan"
metadata := codeqlExecuteScanMetadata ()
var stepConfig codeqlExecuteScanOptions
var startTime time . Time
2024-01-17 09:38:16 +01:00
var influx codeqlExecuteScanInflux
2022-06-24 09:04:24 +02:00
var reports codeqlExecuteScanReports
var logCollector * log . CollectorHook
var splunkClient * splunk . Splunk
telemetryClient := & telemetry . Telemetry {}
var createCodeqlExecuteScanCmd = & 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." ,
Long : `This step executes a codeql scan on the specified project to perform static code analysis and check the source code for security flaws.
The codeql step triggers a scan locally on your orchestrator (e.g. Jenkins) within a docker container so finally you have to supply a docker image with codeql
and Java plus Maven.` ,
PreRunE : func ( cmd * cobra . Command , _ [] string ) error {
startTime = time . Now ()
log . SetStepName ( STEP_NAME )
log . SetVerbose ( GeneralConfig . Verbose )
GeneralConfig . GitHubAccessTokens = ResolveAccessTokens ( GeneralConfig . GitHubTokens )
2024-11-04 14:20:37 +01:00
path , err := os . Getwd ()
if err != nil {
return err
}
2022-06-24 09:04:24 +02:00
fatalHook := & log . FatalHook { CorrelationID : GeneralConfig . CorrelationID , Path : path }
log . RegisterHook ( fatalHook )
2024-11-04 14:20:37 +01:00
err = PrepareConfig ( cmd , & metadata , STEP_NAME , & stepConfig , config . OpenPiperFile )
2022-06-24 09:04:24 +02:00
if err != nil {
log . SetErrorCategory ( log . ErrorConfiguration )
return err
}
2025-08-18 17:49:20 +03:00
// Set step error patterns for improved error detection
stepErrors := make ([] log . StepError , len ( metadata . Metadata . Errors ))
for i , err := range metadata . Metadata . Errors {
stepErrors [ i ] = log . StepError {
Pattern : err . Pattern ,
Message : err . Message ,
Category : err . Category ,
}
}
log . SetStepErrors ( stepErrors )
2022-06-24 09:04:24 +02:00
log . RegisterSecret ( stepConfig . GithubToken )
if len ( GeneralConfig . HookConfig . SentryConfig . Dsn ) > 0 {
sentryHook := log . NewSentryHook ( GeneralConfig . HookConfig . SentryConfig . Dsn , GeneralConfig . CorrelationID )
log . RegisterHook ( & sentryHook )
}
2023-11-06 14:25:13 +06:00
if len ( GeneralConfig . HookConfig . SplunkConfig . Dsn ) > 0 || len ( GeneralConfig . HookConfig . SplunkConfig . ProdCriblEndpoint ) > 0 {
2022-06-24 09:04:24 +02:00
splunkClient = & splunk . Splunk {}
logCollector = & log . CollectorHook { CorrelationID : GeneralConfig . CorrelationID }
log . RegisterHook ( logCollector )
}
if err = log . RegisterANSHookIfConfigured ( GeneralConfig . CorrelationID ); err != nil {
log . Entry (). WithError ( err ). Warn ( "failed to set up SAP Alert Notification Service log hook" )
}
validation , err := validation . New ( validation . WithJSONNamesForStructFields (), validation . WithPredefinedErrorMessages ())
if err != nil {
return err
}
if err = validation . ValidateStruct ( stepConfig ); err != nil {
log . SetErrorCategory ( log . ErrorConfiguration )
return err
}
return nil
},
Run : func ( _ * cobra . Command , _ [] string ) {
2024-10-11 14:55:39 +05:00
vaultClient := config . GlobalVaultClient ()
2026-02-25 15:58:35 +02:00
var oidcTokenProvider func ( string ) ( string , error )
2024-10-11 14:55:39 +05:00
if vaultClient != nil {
defer vaultClient . MustRevokeToken ()
2026-02-25 15:58:35 +02:00
oidcTokenProvider = vaultClient . GetOIDCTokenByValidation
2024-10-11 14:55:39 +05:00
}
2022-06-24 09:04:24 +02:00
stepTelemetryData := telemetry . CustomData {}
stepTelemetryData . ErrorCode = "1"
handler := func () {
2024-01-17 09:38:16 +01:00
influx . persist ( GeneralConfig . EnvRootPath , "influx" )
2022-06-24 09:04:24 +02:00
reports . persist ( stepConfig , GeneralConfig . GCPJsonKeyFilePath , GeneralConfig . GCSBucketId , GeneralConfig . GCSFolderPath , GeneralConfig . GCSSubFolder )
config . RemoveVaultSecretFiles ()
stepTelemetryData . Duration = fmt . Sprintf ( "%v" , time . Since ( startTime ). Milliseconds ())
stepTelemetryData . ErrorCategory = log . GetErrorCategory (). String ()
stepTelemetryData . PiperCommitHash = GitCommit
telemetryClient . SetData ( & stepTelemetryData )
2025-02-07 12:18:01 +01:00
telemetryClient . LogStepTelemetryData ()
2022-06-24 09:04:24 +02:00
if len ( GeneralConfig . HookConfig . SplunkConfig . Dsn ) > 0 {
2023-07-14 19:19:57 +06:00
splunkClient . Initialize ( GeneralConfig . CorrelationID ,
GeneralConfig . HookConfig . SplunkConfig . Dsn ,
GeneralConfig . HookConfig . SplunkConfig . Token ,
GeneralConfig . HookConfig . SplunkConfig . Index ,
GeneralConfig . HookConfig . SplunkConfig . SendLogs )
splunkClient . Send ( telemetryClient . GetData (), logCollector )
}
if len ( GeneralConfig . HookConfig . SplunkConfig . ProdCriblEndpoint ) > 0 {
splunkClient . Initialize ( GeneralConfig . CorrelationID ,
GeneralConfig . HookConfig . SplunkConfig . ProdCriblEndpoint ,
GeneralConfig . HookConfig . SplunkConfig . ProdCriblToken ,
GeneralConfig . HookConfig . SplunkConfig . ProdCriblIndex ,
GeneralConfig . HookConfig . SplunkConfig . SendLogs )
2022-06-24 09:04:24 +02:00
splunkClient . Send ( telemetryClient . GetData (), logCollector )
}
2026-04-20 08:39:33 +02:00
if len ( GeneralConfig . HookConfig . GCPPubSubConfig . ProjectNumber ) > 0 {
if err := eventing . PublishTaskRunFinishedEvent (
2026-02-25 15:58:35 +02:00
oidcTokenProvider ,
& GeneralConfig ,
eventing . EventContext {
2026-03-30 11:14:22 +02:00
StepName : STEP_NAME ,
StageName : telemetryClient . GetData (). StageName ,
ErrorCode : stepTelemetryData . ErrorCode ,
PipelineID : telemetryClient . GetBuildURL (),
2026-02-25 15:58:35 +02:00
},
); err != nil {
log . Entry (). WithError ( err ). Warn ( "failed to publish GCP Pub/Sub event" )
2024-10-11 14:55:39 +05:00
}
}
2022-06-24 09:04:24 +02:00
}
log . DeferExitHandler ( handler )
defer handler ()
2025-02-07 12:18:01 +01:00
telemetryClient . Initialize ( STEP_NAME )
2024-01-17 09:38:16 +01:00
codeqlExecuteScan ( stepConfig , & stepTelemetryData , & influx )
2022-06-24 09:04:24 +02:00
stepTelemetryData . ErrorCode = "0"
log . Entry (). Info ( "SUCCESS" )
},
}
addCodeqlExecuteScanFlags ( createCodeqlExecuteScanCmd , & stepConfig )
return createCodeqlExecuteScanCmd
}
func addCodeqlExecuteScanFlags ( cmd * cobra . Command , stepConfig * codeqlExecuteScanOptions ) {
2023-03-22 18:14:04 +05:30
cmd . Flags (). StringVar ( & stepConfig . GithubToken , "githubToken" , os . Getenv ( "PIPER_githubToken" ), "GitHub personal access token in plain text. NEVER set this parameter in a file commited to a source code repository. This parameter is intended to be used from the command line or set securely via the environment variable listed below. In most pipeline use-cases, you should instead either store the token in Vault (where it can be automatically retrieved by the step from one of the paths listed below) or store it as a Jenkins secret and configure the secret's id via the `githubTokenCredentialsId` parameter." )
2022-06-24 09:04:24 +02:00
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" )
2025-08-29 14:01:14 +04:00
cmd . Flags (). StringVar ( & stepConfig . Language , "language" , os . Getenv ( "PIPER_language" ), "The programming language used to analyze. Use coma separation and select custom build tool to analyze multiple languages" )
2022-06-24 09:04:24 +02:00
cmd . Flags (). StringVar ( & stepConfig . ModulePath , "modulePath" , `./` , "Allows providing the path for the module to scan" )
2022-07-20 10:07:57 +02:00
cmd . Flags (). StringVar ( & stepConfig . Database , "database" , `codeqlDB` , "Path to the CodeQL database to create. This directory will be created, and must not already exist." )
2022-06-24 09:04:24 +02:00
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." )
2023-07-11 18:32:54 +02:00
cmd . Flags (). IntVar ( & stepConfig . SarifCheckMaxRetries , "sarifCheckMaxRetries" , 10 , "Maximum number of retries when waiting for the server to finish processing the SARIF upload." )
cmd . Flags (). IntVar ( & stepConfig . SarifCheckRetryInterval , "sarifCheckRetryInterval" , 30 , "Interval in seconds between retries when waiting for the server to finish processing the SARIF upload." )
2024-02-05 11:24:49 +01:00
cmd . Flags (). StringVar ( & stepConfig . TargetGithubRepoURL , "targetGithubRepoURL" , os . Getenv ( "PIPER_targetGithubRepoURL" ), "Target github repo url. Only relevant, if project uses a combination of Piper and non-GitHub SCM." )
cmd . Flags (). StringVar ( & stepConfig . TargetGithubBranchName , "targetGithubBranchName" , os . Getenv ( "PIPER_targetGithubBranchName" ), "Target github branch name. Only relevant, if project uses a combination of Piper and non-GitHub SCM." )
2023-03-13 16:47:16 +03:00
cmd . Flags (). StringVar ( & stepConfig . Threads , "threads" , `0` , "Use this many threads for the codeql operations." )
2024-02-05 06:25:55 +01:00
cmd . Flags (). StringVar ( & stepConfig . Ram , "ram" , `4000` , "Use this much ram (MB) for the codeql operations." )
2022-06-24 09:04:24 +02:00
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." )
2023-04-28 15:47:05 +02:00
cmd . Flags (). IntVar ( & stepConfig . VulnerabilityThresholdTotal , "vulnerabilityThresholdTotal" , 0 , "Threashold for maximum number of allowed vulnerabilities." )
cmd . Flags (). BoolVar ( & stepConfig . CheckForCompliance , "checkForCompliance" , false , "If set to true, the piper step checks for compliance based on vulnerability threadholds. Example - If total vulnerabilites are 10 and vulnerabilityThresholdTotal is set as 0, then the steps throws an compliance error." )
2023-12-01 10:45:31 +01:00
cmd . Flags (). StringVar ( & stepConfig . ProjectSettingsFile , "projectSettingsFile" , os . Getenv ( "PIPER_projectSettingsFile" ), "Path to the mvn settings file that should be used as project settings file." )
cmd . Flags (). StringVar ( & stepConfig . GlobalSettingsFile , "globalSettingsFile" , os . Getenv ( "PIPER_globalSettingsFile" ), "Path to the mvn settings file that should be used as global settings file." )
2024-04-02 06:48:17 +02:00
cmd . Flags (). StringVar ( & stepConfig . DatabaseCreateFlags , "databaseCreateFlags" , os . Getenv ( "PIPER_databaseCreateFlags" ), "A space-separated string of flags for the 'codeql database create' command." )
cmd . Flags (). StringVar ( & stepConfig . DatabaseAnalyzeFlags , "databaseAnalyzeFlags" , os . Getenv ( "PIPER_databaseAnalyzeFlags" ), "A space-separated string of flags for the 'codeql database analyze' command." )
2024-05-27 13:09:05 +02:00
cmd . Flags (). StringVar ( & stepConfig . CustomCommand , "customCommand" , os . Getenv ( "PIPER_customCommand" ), "A custom user-defined command to run between codeql analysis and results upload." )
2024-06-06 14:14:03 +02:00
cmd . Flags (). StringVar ( & stepConfig . TransformQuerySuite , "transformQuerySuite" , os . Getenv ( "PIPER_transformQuerySuite" ), "A transform string that will be applied to the querySuite using the sed command." )
2025-09-12 19:37:30 +04:00
cmd . Flags (). StringVar ( & stepConfig . Paths , "paths" , os . Getenv ( "PIPER_paths" ), "List of file or directory patterns to include.\nEach entry must be on its own line, e.g.:\n src/**\n lib/**\nNote: This parameter is only applicable for interpreted languages.\n" )
cmd . Flags (). StringVar ( & stepConfig . PathsIgnore , "pathsIgnore" , os . Getenv ( "PIPER_pathsIgnore" ), "List of file or directory patterns to ignore.\nEach entry must be on its own line, e.g.:\n **/*.md\n docs/**\nNote: This parameter is only applicable for interpreted languages.\n" )
2022-06-24 09:04:24 +02:00
cmd . MarkFlagRequired ( "buildTool" )
}
// retrieve step metadata
func codeqlExecuteScanMetadata () config . StepData {
var theMetaData = 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" },
},
2023-01-23 11:39:08 +03:00
Resources : [] config . StepResources {
{ Name : "commonPipelineEnvironment" },
{ Name : "buildDescriptor" , Type : "stash" },
{ Name : "tests" , Type : "stash" },
},
2022-06-24 09:04:24 +02:00
Parameters : [] config . StepParameters {
{
Name : "githubToken" ,
ResourceRef : [] config . ResourceReference {
{
Name : "githubTokenCredentialsId" ,
Type : "secret" ,
},
{
Name : "githubVaultSecretName" ,
Type : "vaultSecret" ,
Default : "github" ,
},
},
Scope : [] string { "GENERAL" , "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {{ Name : "access_token" }},
Default : os . Getenv ( "PIPER_githubToken" ),
},
{
Name : "buildTool" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "GENERAL" , "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : true ,
Aliases : [] config . Alias {},
Default : `maven` ,
},
{
Name : "buildCommand" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_buildCommand" ),
},
{
Name : "language" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_language" ),
},
{
Name : "modulePath" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : `./` ,
},
2022-07-20 10:07:57 +02:00
{
Name : "database" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : `codeqlDB` ,
},
2022-06-24 09:04:24 +02:00
{
Name : "querySuite" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_querySuite" ),
},
{
Name : "uploadResults" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "bool" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : false ,
},
2023-06-20 14:50:28 +02:00
{
Name : "sarifCheckMaxRetries" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "int" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : 10 ,
},
{
Name : "sarifCheckRetryInterval" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "int" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : 30 ,
},
2023-10-18 13:20:15 +02:00
{
Name : "targetGithubRepoURL" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_targetGithubRepoURL" ),
},
{
Name : "targetGithubBranchName" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_targetGithubBranchName" ),
},
2023-03-13 16:47:16 +03:00
{
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 {},
2024-02-05 06:25:55 +01:00
Default : `4000` ,
2023-03-13 16:47:16 +03:00
},
2022-06-24 09:04:24 +02:00
{
Name : "analyzedRef" ,
ResourceRef : [] config . ResourceReference {
{
Name : "commonPipelineEnvironment" ,
Param : "git/ref" ,
},
},
Scope : [] string {},
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_analyzedRef" ),
},
{
Name : "repository" ,
ResourceRef : [] config . ResourceReference {
{
Name : "commonPipelineEnvironment" ,
Param : "git/httpsUrl" ,
},
},
Scope : [] string {},
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {{ Name : "githubRepo" }},
Default : os . Getenv ( "PIPER_repository" ),
},
{
Name : "commitId" ,
ResourceRef : [] config . ResourceReference {
{
Name : "commonPipelineEnvironment" ,
2022-07-12 10:25:17 +02:00
Param : "git/remoteCommitId" ,
2022-06-24 09:04:24 +02:00
},
},
Scope : [] string {},
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_commitId" ),
},
2023-04-28 15:47:05 +02:00
{
Name : "vulnerabilityThresholdTotal" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "int" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : 0 ,
},
{
Name : "checkForCompliance" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "PARAMETERS" , "STAGES" , "STEPS" },
Type : "bool" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : false ,
},
2023-12-01 10:45:31 +01:00
{
Name : "projectSettingsFile" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "GENERAL" , "STEPS" , "STAGES" , "PARAMETERS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {{ Name : "maven/projectSettingsFile" }},
Default : os . Getenv ( "PIPER_projectSettingsFile" ),
},
{
Name : "globalSettingsFile" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "GENERAL" , "STEPS" , "STAGES" , "PARAMETERS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {{ Name : "maven/globalSettingsFile" }},
Default : os . Getenv ( "PIPER_globalSettingsFile" ),
},
2024-04-02 06:48:17 +02:00
{
Name : "databaseCreateFlags" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "STEPS" , "STAGES" , "PARAMETERS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_databaseCreateFlags" ),
},
{
Name : "databaseAnalyzeFlags" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "STEPS" , "STAGES" , "PARAMETERS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_databaseAnalyzeFlags" ),
},
2024-05-27 13:09:05 +02:00
{
Name : "customCommand" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "STEPS" , "STAGES" , "PARAMETERS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_customCommand" ),
},
2024-06-06 14:14:03 +02:00
{
Name : "transformQuerySuite" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "STEPS" , "STAGES" , "PARAMETERS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_transformQuerySuite" ),
},
2025-09-12 19:37:30 +04:00
{
Name : "paths" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "STEPS" , "STAGES" , "PARAMETERS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_paths" ),
},
{
Name : "pathsIgnore" ,
ResourceRef : [] config . ResourceReference {},
Scope : [] string { "STEPS" , "STAGES" , "PARAMETERS" },
Type : "string" ,
Mandatory : false ,
Aliases : [] config . Alias {},
Default : os . Getenv ( "PIPER_pathsIgnore" ),
},
2022-06-24 09:04:24 +02:00
},
},
Containers : [] config . Container {
{},
},
Outputs : config . StepOutputs {
Resources : [] config . StepResources {
2024-01-17 09:38:16 +01:00
{
Name : "influx" ,
Type : "influx" ,
Parameters : [] map [ string ] interface {}{
{ "name" : "step_data" , "fields" : [] map [ string ] string {{ "name" : "codeql" }}},
{ "name" : "codeql_data" , "fields" : [] map [ string ] string {{ "name" : "repositoryUrl" }, { "name" : "repositoryReferenceUrl" }, { "name" : "codeScanningLink" }, { "name" : "querySuite" }, { "name" : "optionalTotal" }, { "name" : "optionalAudited" }, { "name" : "auditAllTotal" }, { "name" : "auditAllAudited" }}},
},
},
2022-06-24 09:04:24 +02:00
{
Name : "reports" ,
Type : "reports" ,
Parameters : [] map [ string ] interface {}{
{ "filePattern" : "**/*.csv" , "type" : "codeql" },
{ "filePattern" : "**/*.sarif" , "type" : "codeql" },
2023-02-22 20:00:53 +03:00
{ "filePattern" : "**/toolrun_codeql_*.json" , "type" : "codeql" },
2023-06-02 18:31:52 +05:30
{ "filePattern" : "**/piper_codeql_report.json" , "type" : "codeql" },
2022-06-24 09:04:24 +02:00
},
},
},
},
},
}
return theMetaData
}