Skip to content

Commit 33cb483

Browse files
authored
Revert conan use of PipRequirementsFile (jfrog#451)
1 parent 0999d71 commit 33cb483

File tree

3 files changed

+10
-48
lines changed

3 files changed

+10
-48
lines changed

commands/audit/sca/conan/conan.go

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

109
"github.com/jfrog/gofrog/datastructures"
1110
"github.com/jfrog/gofrog/io"
@@ -109,16 +108,7 @@ func calculateUniqueDependencies(nodes map[string]conanRef) []string {
109108
}
110109

111110
func calculateDependencies(executablePath, workingDir string, params utils.AuditParams) (dependencyTrees []*xrayUtils.GraphNode, uniqueDeps []string, err error) {
112-
graphInfo := []string{"info"}
113-
if params.PipRequirementsFile() != "" {
114-
// We allow passing a custom 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.
115-
// Since this ability already exists for python we leverage this ability
116-
graphInfo = append(graphInfo, filepath.Join(workingDir, params.PipRequirementsFile()))
117-
} else {
118-
graphInfo = append(graphInfo, ".")
119-
}
120-
graphInfo = append(graphInfo, "--format=json")
121-
graphInfo = append(graphInfo, params.Args()...)
111+
graphInfo := append([]string{"info", ".", "--format=json"}, params.Args()...)
122112
conanGraphInfoContent, err := getConanCmd(executablePath, workingDir, "graph", graphInfo...).RunWithOutput()
123113
if err != nil {
124114
return

commands/audit/sca/conan/conan_test.go

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package conan
22

33
import (
44
"encoding/json"
5-
"github.com/stretchr/testify/require"
65
"os"
7-
"os/exec"
86
"path/filepath"
97
"testing"
108

@@ -44,40 +42,16 @@ func TestParseConanDependencyTree(t *testing.T) {
4442
}
4543

4644
func TestBuildDependencyTree(t *testing.T) {
47-
testcases := []struct {
48-
name string
49-
descriptorName string
50-
}{
51-
{
52-
name: "default descriptor file",
53-
},
54-
{
55-
name: "custom descriptor file",
56-
descriptorName: "conanfile-system.txt",
57-
},
58-
}
59-
for _, testcase := range testcases {
60-
t.Run(testcase.name, func(t *testing.T) {
61-
dir, cleanUp := sca.CreateTestWorkspace(t, filepath.Join("projects", "package-managers", "conan"))
62-
defer cleanUp()
63-
params := &utils.AuditBasicParams{}
64-
if testcase.descriptorName != "" {
65-
// changing the name of the descriptor to verify the work with a non-default descriptor name
66-
changeNameCmd := exec.Command("mv", filepath.Join(dir, "conanfile.txt"), filepath.Join(dir, testcase.descriptorName))
67-
_, err := changeNameCmd.CombinedOutput()
68-
require.NoError(t, err)
69-
require.FileExists(t, filepath.Join(dir, testcase.descriptorName))
70-
params.SetPipRequirementsFile(testcase.descriptorName)
71-
}
72-
params.SetConanProfile(filepath.Join(dir, "profile"))
73-
graph, uniqueDeps, err := BuildDependencyTree(params)
74-
assert.NoError(t, err)
75-
if !tests.CompareTree(expectedResult, graph[0]) {
76-
t.Errorf("expected %+v, got: %+v", expectedResult.Nodes, graph)
77-
}
78-
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps, "First is actual, Second is Expected")
79-
})
45+
dir, cleanUp := sca.CreateTestWorkspace(t, filepath.Join("projects", "package-managers", "conan"))
46+
defer cleanUp()
47+
params := &utils.AuditBasicParams{}
48+
params.SetConanProfile(filepath.Join(dir, "profile"))
49+
graph, uniqueDeps, err := BuildDependencyTree(params)
50+
assert.NoError(t, err)
51+
if !tests.CompareTree(expectedResult, graph[0]) {
52+
t.Errorf("expected %+v, got: %+v", expectedResult.Nodes, graph)
8053
}
54+
assert.ElementsMatch(t, uniqueDeps, expectedUniqueDeps, "First is actual, Second is Expected")
8155
}
8256

8357
func TestCalculateUniqueDeps(t *testing.T) {

commands/audit/scarunner.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ func getRequestedDescriptors(params *AuditParams) map[techutils.Technology][]str
117117
requestedDescriptors := map[techutils.Technology][]string{}
118118
if params.PipRequirementsFile() != "" {
119119
requestedDescriptors[techutils.Pip] = []string{params.PipRequirementsFile()}
120-
// We leverage the ability to pass a custom descriptor name for Conan through PipRequirementsFile as well, therefore we set also Conan with the provided descriptor name.
121-
requestedDescriptors[techutils.Conan] = []string{params.PipRequirementsFile()}
122120
}
123121
return requestedDescriptors
124122
}

0 commit comments

Comments
 (0)