@@ -3,19 +3,23 @@ package wrappers
33import (
44 "encoding/json"
55 "fmt"
6+ "github.com/checkmarx/ast-cli/internal/logger"
7+ "github.com/checkmarx/ast-cli/internal/wrappers/configuration"
68 "net/http"
79
810 commonParams "github.com/checkmarx/ast-cli/internal/params"
911 "github.com/pkg/errors"
1012 "github.com/spf13/viper"
1113)
1214
15+ const defaultPath = "api/micro-engines/read/scans/%s/scan-overview"
16+
1317type ScanOverviewHTTPWrapper struct {
1418 path string
1519}
1620
1721func NewHTTPScanOverviewWrapper (path string ) ScanOverviewWrapper {
18- validPath := setDefaultPath (path , commonParams . ScsScanOverviewPathKey , scanOverviewDefaultPath )
22+ validPath := setDefaultPath (path )
1923 return & ScanOverviewHTTPWrapper {
2024 path : validPath ,
2125 }
@@ -59,3 +63,18 @@ func (r *ScanOverviewHTTPWrapper) GetSCSOverviewByScanID(scanID string) (
5963 return nil , nil , errors .Errorf ("response status code %d" , resp .StatusCode )
6064 }
6165}
66+
67+ // setDefaultPath checks if the path is the default path, if not it writes the default path to the config file
68+ func setDefaultPath (path string ) string {
69+ if path != defaultPath {
70+ configFilePath , err := configuration .GetConfigFilePath ()
71+ if err != nil {
72+ logger .PrintfIfVerbose ("Error getting config file path: %v" , err )
73+ }
74+ err = configuration .SafeWriteSingleConfigKeyString (configFilePath , commonParams .ScsScanOverviewPathKey , defaultPath )
75+ if err != nil {
76+ logger .PrintfIfVerbose ("Error writing Scan Overview path to config file: %v" , err )
77+ }
78+ }
79+ return defaultPath
80+ }
0 commit comments