@@ -24,7 +24,7 @@ import (
2424
2525const (
2626 xrayLibPluginVersionEnvVariable = "JFROG_CLI_XRAY_LIB_PLUGIN_VERSION"
27- defaultXrayLibPluginVersion = "1.2 .0"
27+ defaultXrayLibPluginVersion = "1.3 .0"
2828
2929 SnippetDetectionEnvVariable = "JFROG_XRAY_SNIPPET_SCAN_ENABLE"
3030
@@ -76,11 +76,12 @@ type ScannerRPCServer struct {
7676}
7777
7878// CreateScannerPluginClient creates a plugin client. When not in CI and log level is DEBUG, plugin stderr is written
79- // to a log file under JFrog home (logs/xrayPluginLogs/)
80- func CreateScannerPluginClient (scangBinary string , envVars map [string ]string ) (scanner Scanner , logPath string , err error ) {
79+ // to a log file under JFrog home (logs/xrayPluginLogs/).
80+ // The returned cleanup function must be called when the scanner is no longer needed to terminate the plugin subprocess.
81+ func CreateScannerPluginClient (scangBinary string , envVars map [string ]string ) (scanner Scanner , logPath string , cleanup func (), err error ) {
8182 stderrWriter , logPath , err := getPluginLogger ()
8283 if err != nil {
83- return nil , "" , err
84+ return nil , "" , nil , err
8485 }
8586 clientConfig := & goplugin.ClientConfig {
8687 HandshakeConfig : PluginHandshakeConfig ,
@@ -103,19 +104,19 @@ func CreateScannerPluginClient(scangBinary string, envVars map[string]string) (s
103104 }()
104105 rpcClient , err := client .Client ()
105106 if err != nil {
106- return nil , "" , err
107+ return nil , "" , nil , err
107108 }
108109 // Wait for the plugin to complete the handshake
109110 raw , err := rpcClient .Dispense (pluginName )
110111 if err != nil {
111- return nil , "" , err
112+ return nil , "" , nil , err
112113 }
113114 // Assert that the plugin is of type Scanner
114115 scanPlugin , ok := raw .(Scanner )
115116 if ! ok {
116- return nil , "" , fmt .Errorf ("plugin is not of type of Xray-Lib plugin, expected Scanner, got %T" , raw )
117+ return nil , "" , nil , fmt .Errorf ("plugin is not of type of Xray-Lib plugin, expected Scanner, got %T" , raw )
117118 }
118- return scanPlugin , logPath , nil
119+ return scanPlugin , logPath , client . Kill , nil
119120}
120121
121122func getPluginLogger () (writer io.Writer , logPath string , err error ) {
0 commit comments