@@ -290,7 +290,7 @@ func (t *HubTestItem) RunWithNucleiTemplate() error {
290
290
return fmt .Errorf ("test '%s' doesn't exist in '%s', exiting" , t .Name , t .HubTestPath )
291
291
}
292
292
293
- crowdsecLogFile := fmt . Sprintf ( "%s/ log/crowdsec.log " , t . RuntimePath )
293
+ crowdsecLogFile := filepath . Join ( t . RuntimePath , " log" , "crowdsec.log" )
294
294
295
295
// machine add
296
296
cmdArgs := []string {"-c" , t .RuntimeConfigFilePath , "machines" , "add" , "testMachine" , "--force" , "--auto" }
@@ -363,7 +363,10 @@ func (t *HubTestItem) RunWithNucleiTemplate() error {
363
363
},
364
364
}
365
365
366
- err = nucleiConfig .RunNucleiTemplate (t .Name , t .Config .NucleiTemplate , t .NucleiTargetHost )
366
+ // the value in config is relative
367
+ nucleiTemplate := filepath .Join (t .Path , t .Config .NucleiTemplate )
368
+
369
+ err = nucleiConfig .RunNucleiTemplate (t .Name , nucleiTemplate , t .NucleiTargetHost )
367
370
if t .Config .ExpectedNucleiFailure {
368
371
if err != nil && errors .Is (err , ErrNucleiTemplateFail ) {
369
372
log .Infof ("Appsec test %s failed as expected" , t .Name )
@@ -381,7 +384,6 @@ func (t *HubTestItem) RunWithNucleiTemplate() error {
381
384
}
382
385
} else {
383
386
if err == nil {
384
- log .Infof ("Appsec test %s succeeded" , t .Name )
385
387
t .Success = true
386
388
} else {
387
389
log .Errorf ("Appsec test %s failed: %s" , t .Name , err )
@@ -419,7 +421,7 @@ func (t *HubTestItem) RunWithLogFile() error {
419
421
420
422
logFile := filepath .Join (testPath , t .Config .LogFile )
421
423
logType := t .Config .LogType
422
- dsn := fmt . Sprintf ( "file://%s" , logFile )
424
+ dsn := "file://" + logFile
423
425
424
426
logFileStat , err := os .Stat (logFile )
425
427
if err != nil {
@@ -441,7 +443,7 @@ func (t *HubTestItem) RunWithLogFile() error {
441
443
if err != nil {
442
444
if ! strings .Contains (string (output ), "unable to create machine: user 'testMachine': user already exist" ) {
443
445
fmt .Println (string (output ))
444
- return fmt .Errorf ("fail to run '%s' for test '%s': %v " , cscliRegisterCmd .String (), t .Name , err )
446
+ return fmt .Errorf ("fail to run '%s' for test '%s': %w " , cscliRegisterCmd .String (), t .Name , err )
445
447
}
446
448
}
447
449
@@ -464,7 +466,7 @@ func (t *HubTestItem) RunWithLogFile() error {
464
466
}
465
467
466
468
if err != nil {
467
- return fmt .Errorf ("fail to run '%s' for test '%s': %v " , crowdsecCmd .String (), t .Name , err )
469
+ return fmt .Errorf ("fail to run '%s' for test '%s': %w " , crowdsecCmd .String (), t .Name , err )
468
470
}
469
471
470
472
// assert parsers
@@ -570,17 +572,17 @@ func (t *HubTestItem) Run(ctx context.Context, patternDir string) error {
570
572
571
573
// copy template config file to runtime folder
572
574
if err = Copy (t .TemplateConfigPath , t .RuntimeConfigFilePath ); err != nil {
573
- return fmt .Errorf ("unable to copy '%s' to '%s': %v " , t .TemplateConfigPath , t .RuntimeConfigFilePath , err )
575
+ return fmt .Errorf ("unable to copy '%s' to '%s': %w " , t .TemplateConfigPath , t .RuntimeConfigFilePath , err )
574
576
}
575
577
576
578
// copy template profile file to runtime folder
577
579
if err = Copy (t .TemplateProfilePath , t .RuntimeProfileFilePath ); err != nil {
578
- return fmt .Errorf ("unable to copy '%s' to '%s': %v " , t .TemplateProfilePath , t .RuntimeProfileFilePath , err )
580
+ return fmt .Errorf ("unable to copy '%s' to '%s': %w " , t .TemplateProfilePath , t .RuntimeProfileFilePath , err )
579
581
}
580
582
581
583
// copy template simulation file to runtime folder
582
584
if err = Copy (t .TemplateSimulationPath , t .RuntimeSimulationFilePath ); err != nil {
583
- return fmt .Errorf ("unable to copy '%s' to '%s': %v " , t .TemplateSimulationPath , t .RuntimeSimulationFilePath , err )
585
+ return fmt .Errorf ("unable to copy '%s' to '%s': %w " , t .TemplateSimulationPath , t .RuntimeSimulationFilePath , err )
584
586
}
585
587
586
588
// copy template patterns folder to runtime folder
@@ -590,7 +592,7 @@ func (t *HubTestItem) Run(ctx context.Context, patternDir string) error {
590
592
591
593
// create the appsec-configs dir
592
594
if err = os .MkdirAll (filepath .Join (t .RuntimePath , "appsec-configs" ), os .ModePerm ); err != nil {
593
- return fmt .Errorf ("unable to create folder '%s': %+v " , t .RuntimePath , err )
595
+ return fmt .Errorf ("unable to create folder '%s': %w " , t .RuntimePath , err )
594
596
}
595
597
596
598
// if it's an appsec rule test, we need acquis and appsec profile
@@ -599,13 +601,13 @@ func (t *HubTestItem) Run(ctx context.Context, patternDir string) error {
599
601
log .Debugf ("copying %s to %s" , t .TemplateAcquisPath , t .RuntimeAcquisFilePath )
600
602
601
603
if err = Copy (t .TemplateAcquisPath , t .RuntimeAcquisFilePath ); err != nil {
602
- return fmt .Errorf ("unable to copy '%s' to '%s': %v " , t .TemplateAcquisPath , t .RuntimeAcquisFilePath , err )
604
+ return fmt .Errorf ("unable to copy '%s' to '%s': %w " , t .TemplateAcquisPath , t .RuntimeAcquisFilePath , err )
603
605
}
604
606
605
607
log .Debugf ("copying %s to %s" , t .TemplateAppsecProfilePath , filepath .Join (t .RuntimePath , "appsec-configs" , "config.yaml" ))
606
608
// copy template appsec-config file to runtime folder
607
609
if err = Copy (t .TemplateAppsecProfilePath , filepath .Join (t .RuntimePath , "appsec-configs" , "config.yaml" )); err != nil {
608
- return fmt .Errorf ("unable to copy '%s' to '%s': %v " , t .TemplateAppsecProfilePath , filepath .Join (t .RuntimePath , "appsec-configs" , "config.yaml" ), err )
610
+ return fmt .Errorf ("unable to copy '%s' to '%s': %w " , t .TemplateAppsecProfilePath , filepath .Join (t .RuntimePath , "appsec-configs" , "config.yaml" ), err )
609
611
}
610
612
} else { // otherwise we drop a blank acquis file
611
613
if err = os .WriteFile (t .RuntimeAcquisFilePath , []byte ("" ), os .ModePerm ); err != nil {
0 commit comments