@@ -33,6 +33,7 @@ type AscaScanParams struct {
3333 ASCAUpdateVersion bool
3434 IsDefaultAgent bool
3535 IgnoredFilePath string
36+ VorpalLocation string
3637}
3738
3839type AscaWrappersParam struct {
@@ -59,24 +60,24 @@ func validateVorpalDirExist(dirPath string) error {
5960
6061func ValidateCustomASCAInstallation (vorpalLocation string ) error {
6162 if err := validateVorpalDirExist (vorpalLocation ); err != nil {
62- return errors .Wrap (err , "Failed to validate ASCA location" )
63+ return errors .Wrap (err , "Failed to validate ASCA custom location" )
6364 }
64- ascaconfig .Params .SetVorpalCustomPath (vorpalLocation )
65- ASCAInstalled , _ := osinstaller .FileExists (ascaconfig .Params .ExecutableFilePath ())
65+ ASCAInstalled , _ := osinstaller .FileExists (filepath .Join (vorpalLocation , ascaconfig .Params .ExecutableFile ))
6666 if ! ASCAInstalled {
6767 return errors .Errorf ("No ASCA executable found in provided location: %s" , vorpalLocation )
6868 }
69+ logger .PrintIfVerbose ("Using custom ASCA engine installed at: " + vorpalLocation )
6970 return nil
7071}
7172
72- func CreateASCAScanRequest (ascaParams AscaScanParams , wrapperParams AscaWrappersParam , vorpalLocation string ) (* grpcs.ScanResult , error ) {
73+ func CreateASCAScanRequest (ascaParams AscaScanParams , wrapperParams AscaWrappersParam ) (* grpcs.ScanResult , error ) {
7374 var err error
74- if vorpalLocation == "" {
75+ if ascaParams . VorpalLocation == "" {
7576 err = manageASCAInstallation (ascaParams , wrapperParams )
7677 if err != nil {
7778 return nil , err
7879 }
79- } else if err := ValidateCustomASCAInstallation (vorpalLocation ); err != nil {
80+ } else if err := ValidateCustomASCAInstallation (ascaParams . VorpalLocation ); err != nil {
8081 return nil , err
8182 }
8283 err = ensureASCAServiceRunning (wrapperParams , ascaParams )
@@ -254,7 +255,7 @@ func ensureASCAServiceRunning(wrappersParam AscaWrappersParam, ascaParams AscaSc
254255 if err != nil {
255256 return err
256257 }
257- if err := RunASCAEngine (wrappersParam .ASCAWrapper .GetPort ()); err != nil {
258+ if err := RunASCAEngine (wrappersParam .ASCAWrapper .GetPort (), ascaParams . VorpalLocation ); err != nil {
258259 return err
259260 }
260261
@@ -281,16 +282,21 @@ func readSourceCode(filePath string) (string, error) {
281282 return string (data ), nil
282283}
283284
284- func RunASCAEngine (port int ) error {
285+ func RunASCAEngine (port int , vorpalLocation string ) error {
285286 dialTimeout := 5 * time .Second
286287 args := []string {
287288 "-listen" ,
288289 fmt .Sprintf ("%d" , port ),
289290 }
290291
291292 logger .PrintIfVerbose (fmt .Sprintf ("Running ASCA engine with args: %v \n " , args ))
293+ var cmd * exec.Cmd
292294
293- cmd := exec .Command (ascaconfig .Params .ExecutableFilePath (), args ... )
295+ if vorpalLocation != "" {
296+ cmd = exec .Command (filepath .Join (vorpalLocation , ascaconfig .Params .ExecutableFile ), args ... )
297+ } else {
298+ cmd = exec .Command (ascaconfig .Params .ExecutableFilePath (), args ... )
299+ }
294300
295301 osinstaller .ConfigureIndependentProcess (cmd )
296302
0 commit comments