You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
Malware scan metadata update (#1483)
This commit is contained in:
@@ -61,7 +61,7 @@ func runMalwareScan(config *malwareExecuteScanOptions, telemetryData *telemetry.
|
||||
}
|
||||
defer candidate.Close()
|
||||
|
||||
opts := piperhttp.ClientOptions{Username: config.User, Password: config.Password}
|
||||
opts := piperhttp.ClientOptions{Username: config.Username, Password: config.Password}
|
||||
httpClient.SetOptions(opts)
|
||||
|
||||
var scanResponse *malwareExecuteScanResponse
|
||||
|
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
type malwareExecuteScanOptions struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
File string `json:"file,omitempty"`
|
||||
}
|
||||
@@ -45,6 +45,8 @@ func MalwareExecuteScanCommand() *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.RegisterSecret(stepConfig.Username)
|
||||
log.RegisterSecret(stepConfig.Password)
|
||||
|
||||
if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 {
|
||||
sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID)
|
||||
@@ -74,13 +76,14 @@ func MalwareExecuteScanCommand() *cobra.Command {
|
||||
|
||||
func addMalwareExecuteScanFlags(cmd *cobra.Command, stepConfig *malwareExecuteScanOptions) {
|
||||
cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "malware scanning host.")
|
||||
cmd.Flags().StringVar(&stepConfig.User, "user", os.Getenv("PIPER_user"), "User")
|
||||
cmd.Flags().StringVar(&stepConfig.Username, "username", os.Getenv("PIPER_username"), "User")
|
||||
cmd.Flags().StringVar(&stepConfig.Password, "password", os.Getenv("PIPER_password"), "Password")
|
||||
cmd.Flags().StringVar(&stepConfig.File, "file", os.Getenv("PIPER_file"), "The file which is scanned for malware")
|
||||
|
||||
cmd.MarkFlagRequired("host")
|
||||
cmd.MarkFlagRequired("user")
|
||||
cmd.MarkFlagRequired("username")
|
||||
cmd.MarkFlagRequired("password")
|
||||
cmd.MarkFlagRequired("file")
|
||||
}
|
||||
|
||||
// retrieve step metadata
|
||||
@@ -102,7 +105,7 @@ func malwareExecuteScanMetadata() config.StepData {
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "user",
|
||||
Name: "username",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Type: "string",
|
||||
@@ -122,7 +125,7 @@ func malwareExecuteScanMetadata() config.StepData {
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Mandatory: true,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
},
|
||||
|
@@ -11,7 +11,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var malwareScanConfig = malwareExecuteScanOptions{Host: "https://example.org/malwarescanner", User: "me", Password: "********", File: "target/myFile"}
|
||||
var malwareScanConfig = malwareExecuteScanOptions{Host: "https://example.org/malwarescanner", Username: "me", Password: "********", File: "target/myFile"}
|
||||
|
||||
func TestMalwareScanTests(t *testing.T) {
|
||||
|
||||
|
@@ -5,6 +5,10 @@ metadata:
|
||||
Performs a malware scan
|
||||
spec:
|
||||
inputs:
|
||||
secrets:
|
||||
- name: malwareScanCredentialsId
|
||||
description: The technical user/password credential used to communicate with the malwarescanning service
|
||||
type: jenkins
|
||||
params:
|
||||
- name: host
|
||||
type: string
|
||||
@@ -14,7 +18,7 @@ spec:
|
||||
- STAGES
|
||||
- STEPS
|
||||
mandatory: true
|
||||
- name: user
|
||||
- name: username
|
||||
type: string
|
||||
description: "User"
|
||||
scope:
|
||||
@@ -22,6 +26,7 @@ spec:
|
||||
- STAGES
|
||||
- STEPS
|
||||
mandatory: true
|
||||
secret: true
|
||||
- name: password
|
||||
type: string
|
||||
description: "Password"
|
||||
@@ -30,6 +35,7 @@ spec:
|
||||
- STAGES
|
||||
- STEPS
|
||||
mandatory: true
|
||||
secret: true
|
||||
- name: file
|
||||
type: string
|
||||
description: "The file which is scanned for malware"
|
||||
@@ -37,4 +43,4 @@ spec:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
mandatory: false
|
||||
mandatory: true
|
||||
|
@@ -9,7 +9,7 @@ void call(Map parameters = [:]) {
|
||||
def cred = [
|
||||
type: 'usernamePassword',
|
||||
id: 'malwareScanCredentialsId',
|
||||
env: ['PIPER_user', 'PIPER_password']
|
||||
env: ['PIPER_username', 'PIPER_password']
|
||||
]
|
||||
|
||||
piperExecuteBin parameters, STEP_NAME, "metadata/${STEP_NAME}.yaml", [cred]
|
||||
|
Reference in New Issue
Block a user