Skip to content

Commit c989616

Browse files
authored
Audit - Do not copy Visual Studio inner folder when building dependency tree (#205)
1 parent 1bb7dc8 commit c989616

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

commands/audit/sca/common.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import (
2121
xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils"
2222
)
2323

24+
const (
25+
// Visual Studio inner directory.
26+
DotVsRepoSuffix = ".vs"
27+
)
28+
2429
var CurationErrorMsgToUserTemplate = "Failed to retrieve the dependencies tree for the %s project. Please contact your " +
2530
"Artifactory administrator to verify pass-through for Curation audit is enabled for your project"
2631

commands/audit/sca/nuget/nuget.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ func BuildDependencyTree(params utils.AuditParams) (dependencyTree []*xrayUtils.
6565
err = errors.Join(err, fileutils.RemoveTempDir(tmpWd))
6666
}()
6767

68-
err = biutils.CopyDir(wd, tmpWd, true, nil)
68+
// Exclude Visual Studio inner directorty since it is not neccessary for the scan process and may cause race condition.
69+
err = biutils.CopyDir(wd, tmpWd, true, []string{sca.DotVsRepoSuffix})
6970
if err != nil {
7071
err = fmt.Errorf("failed copying project to temp dir: %w", err)
7172
return

commands/audit/sca/pnpm/pnpm.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"golang.org/x/exp/maps"
1414
"golang.org/x/exp/slices"
1515

16+
"github.com/jfrog/jfrog-cli-security/commands/audit/sca"
1617
"github.com/jfrog/jfrog-cli-security/commands/audit/sca/npm"
1718
"github.com/jfrog/jfrog-cli-security/utils"
1819
"github.com/jfrog/jfrog-cli-security/utils/techutils"
@@ -115,7 +116,9 @@ func installProjectIfNeeded(pnpmExecPath, workingDir string) (dirForDependencies
115116
err = errors.Join(err, fileutils.RemoveTempDir(dirForDependenciesCalculation))
116117
}
117118
}()
118-
err = biutils.CopyDir(workingDir, dirForDependenciesCalculation, true, nil)
119+
120+
// Exclude Visual Studio inner directorty since it is not neccessary for the scan process and may cause race condition.
121+
err = biutils.CopyDir(workingDir, dirForDependenciesCalculation, true, []string{sca.DotVsRepoSuffix})
119122
if err != nil {
120123
err = fmt.Errorf("failed copying project to temp dir: %w", err)
121124
return

commands/audit/sca/python/python.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ func getDependencies(auditPython *AuditPython) (dependenciesGraph map[string][]s
9494
)
9595
}()
9696

97-
err = biutils.CopyDir(wd, tempDirPath, true, nil)
97+
// Exclude Visual Studio inner directorty since it is not neccessary for the scan process and may cause race condition.
98+
err = biutils.CopyDir(wd, tempDirPath, true, []string{sca.DotVsRepoSuffix})
9899
if err != nil {
99100
return
100101
}
@@ -439,4 +440,4 @@ func populatePythonDependencyTree(currNode *xrayUtils.GraphNode, dependenciesGra
439440
currNode.Nodes = append(currNode.Nodes, childNode)
440441
populatePythonDependencyTree(childNode, dependenciesGraph, uniqueDepsSet)
441442
}
442-
}
443+
}

0 commit comments

Comments
 (0)