Skip to content

Commit f3548d1

Browse files
authored
fix(executor/http): check if the file path provided is an absolute path (#814)
* Check if the filepath provided is an absoulte path, else use default workdir #778 Signed-off-by: Ivan Velasco <[email protected]> * TLSRootCA updated also Signed-off-by: Ivan Velasco <[email protected]> --------- Signed-off-by: Ivan Velasco <[email protected]>
1 parent aae6f3a commit f3548d1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

executors/http/http.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ func (e Executor) TLSOptions(ctx context.Context) ([]func(*http.Transport) error
431431
workdir := venom.StringVarFromCtx(ctx, "venom.testsuite.workdir")
432432

433433
if e.TLSRootCA != "" {
434-
TLSRootCAFilepath := filepath.Join(workdir, e.TLSRootCA)
434+
TLSRootCAFilepath := e.TLSRootCA
435+
if !filepath.IsAbs(e.TLSRootCA) {
436+
TLSRootCAFilepath = filepath.Join(workdir, e.TLSRootCA)
437+
}
435438
var TLSRootCA []byte
436439
if _, err := os.Stat(TLSRootCAFilepath); err == nil {
437440
TLSRootCA, err = os.ReadFile(TLSRootCAFilepath)
@@ -446,7 +449,10 @@ func (e Executor) TLSOptions(ctx context.Context) ([]func(*http.Transport) error
446449

447450
var TLSClientCert, TLSClientKey []byte
448451
if e.TLSClientCert != "" {
449-
TLSClientCertFilepath := filepath.Join(workdir, e.TLSClientCert)
452+
TLSClientCertFilepath := e.TLSClientCert
453+
if !filepath.IsAbs(e.TLSClientCert) {
454+
TLSClientCertFilepath = filepath.Join(workdir, e.TLSClientCert)
455+
}
450456
if _, err := os.Stat(TLSClientCertFilepath); err == nil {
451457
TLSClientCert, err = os.ReadFile(TLSClientCertFilepath)
452458
if err != nil {
@@ -458,7 +464,10 @@ func (e Executor) TLSOptions(ctx context.Context) ([]func(*http.Transport) error
458464
}
459465

460466
if e.TLSClientKey != "" {
461-
TLSClientKeyFilepath := filepath.Join(workdir, e.TLSClientKey)
467+
TLSClientKeyFilepath := e.TLSClientKey
468+
if !filepath.IsAbs(e.TLSClientKey) {
469+
TLSClientKeyFilepath = filepath.Join(workdir, e.TLSClientKey)
470+
}
462471
if _, err := os.Stat(TLSClientKeyFilepath); err == nil {
463472
TLSClientKey, err = os.ReadFile(TLSClientKeyFilepath)
464473
if err != nil {

0 commit comments

Comments
 (0)