Skip to content

Commit a67f491

Browse files
committed
fix test and logic
1 parent f41fba9 commit a67f491

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

commands/audit/sca/conan/conan.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"os/exec"
8+
"path/filepath"
89

910
"github.com/jfrog/gofrog/datastructures"
1011
"github.com/jfrog/gofrog/io"
@@ -108,12 +109,16 @@ func calculateUniqueDependencies(nodes map[string]conanRef) []string {
108109
}
109110

110111
func calculateDependencies(executablePath, workingDir string, params utils.AuditParams) (dependencyTrees []*xrayUtils.GraphNode, uniqueDeps []string, err error) {
111-
graphInfo := append([]string{"info", ".", "--format=json"}, params.Args()...)
112+
graphInfo := []string{"info"}
112113
if params.PipRequirementsFile() != "" {
113-
// We allow passing a name for the descriptor file to be used in the 'graph info' command.
114+
// We allow passing a name for the descriptor file to be used in the 'graph info' command. If non has provided we execute the command on the current dir.
114115
// Since this ability already exists for python we leverage this ability
115-
graphInfo = append(graphInfo, "-f", params.PipRequirementsFile())
116+
graphInfo = append(graphInfo, filepath.Join(workingDir, params.PipRequirementsFile()))
117+
} else {
118+
graphInfo = append(graphInfo, ".")
116119
}
120+
graphInfo = append(graphInfo, "--format=json")
121+
graphInfo = append(graphInfo, params.Args()...)
117122
conanGraphInfoContent, err := getConanCmd(executablePath, workingDir, "graph", graphInfo...).RunWithOutput()
118123
if err != nil {
119124
return

commands/audit/sca/conan/conan_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func TestParseConanDependencyTree(t *testing.T) {
4343
}
4444
}
4545

46-
// TODO eran add a testcase with a provided descriptor name
4746
func TestBuildDependencyTree(t *testing.T) {
4847
testcases := []struct {
4948
name string
@@ -64,8 +63,7 @@ func TestBuildDependencyTree(t *testing.T) {
6463
params := &utils.AuditBasicParams{}
6564
if testcase.descriptorName != "" {
6665
// changing the name of the descriptor to verify the work with a non-default descriptor name
67-
changeNameCmd := exec.Command("mv", "conanfile.txt", testcase.descriptorName)
68-
changeNameCmd.Dir = dir
66+
changeNameCmd := exec.Command("mv", filepath.Join(dir, "conanfile.txt"), filepath.Join(dir, testcase.descriptorName))
6967
_, err := changeNameCmd.CombinedOutput()
7068
require.NoError(t, err)
7169
require.FileExists(t, filepath.Join(dir, testcase.descriptorName))

0 commit comments

Comments
 (0)