Skip to content

Commit 70fb0e6

Browse files
authored
Update Xray lib to 1.3.0 (#707)
1 parent 214106d commit 70fb0e6

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

git_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/stretchr/testify/assert"
1010

1111
"github.com/jfrog/jfrog-cli-core/v2/common/format"
12+
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
1213
"github.com/jfrog/jfrog-cli-security/commands/git/contributors"
1314
"github.com/jfrog/jfrog-cli-security/policy"
1415
securityTests "github.com/jfrog/jfrog-cli-security/tests"
@@ -109,6 +110,10 @@ func TestGitAuditSimpleJson(t *testing.T) {
109110
func TestGitAuditStaticScaSimpleJson(t *testing.T) {
110111
// XRAY-136444 will be fixed in 3.141.7
111112
integration.InitAuditNewScaTests(t, "3.141.7")
113+
if coreutils.IsWindows() {
114+
// On windows tests are failing due to the bug in Xray Server, should be fixed at XRAY-138079
115+
securityTestUtils.SkipTestIfDurationNotPassed(t, "26-03-2026", 14, "Bug in Xray Server, should be fixed at XRAY-138079")
116+
}
112117

113118
xrayVersion := integration.GetAndValidateXrayVersion(t, securityUtils.StaticScanMinVersion)
114119

sca/bom/xrayplugin/plugin/plugin.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
const (
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

121122
func getPluginLogger() (writer io.Writer, logPath string, err error) {

sca/bom/xrayplugin/xraylibbom.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ func (sbg *XrayLibBomGenerator) GenerateSbom(target results.ScanTarget) (sbom *c
104104
log.Debug(fmt.Sprintf("Using Xray-Lib executable at: %s", binaryPath))
105105
startTime := time.Now()
106106
envVars := sbg.getPluginEnvVars()
107-
scanner, logPath, err := plugin.CreateScannerPluginClient(binaryPath, envVars)
107+
scanner, logPath, killPlugin, err := plugin.CreateScannerPluginClient(binaryPath, envVars)
108108
if err != nil {
109109
return nil, fmt.Errorf("failed to create Xray-Lib plugin client: %w", err)
110110
}
111+
defer killPlugin()
111112
startLog := "Generating SBOM"
112113
if sbg.totalTargets > 1 {
113114
startLog += fmt.Sprintf(" for target: %s", target.Target)

0 commit comments

Comments
 (0)