Skip to content

Commit

Permalink
Fix import cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Sep 13, 2023
1 parent f51094d commit 03a3707
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type scanConfiguration struct {
func (asm *ApplicabilityScanManager) createConfigFile(workingDir string) error {
skipDirs := jas.SkippedDirs
if asm.thirdPartyScan {
log.Debug("Including node modules in applicability scan")
log.Debug("Including node modules folder in applicability scan")
skipDirs = removeElementFromSlice(skipDirs, jas.NodeModulesPattern)
}
configFileContent := applicabilityScanConfig{
Expand Down
7 changes: 2 additions & 5 deletions xray/commands/audit/sca/yarn/yarn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import (
biUtils "github.com/jfrog/build-info-go/build/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/xray/commands/audit/sca"
"github.com/jfrog/jfrog-cli-core/v2/xray/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/log"
xrayUtils "github.com/jfrog/jfrog-client-go/xray/services/utils"
)

const (
NpmPackageTypeIdentifier = "npm://"
)

func BuildDependencyTree() (dependencyTrees []*xrayUtils.GraphNode, uniqueDeps []string, err error) {
currentDir, err := coreutils.GetWorkingDirectory()
if err != nil {
Expand Down Expand Up @@ -55,5 +52,5 @@ func parseYarnDependenciesMap(dependencies map[string]*biUtils.YarnDependency, r
}

func getXrayDependencyId(yarnDependency *biUtils.YarnDependency) string {
return NpmPackageTypeIdentifier + yarnDependency.Name() + ":" + yarnDependency.Details.Version
return utils.NpmPackageTypeIdentifier + yarnDependency.Name() + ":" + yarnDependency.Details.Version
}
6 changes: 3 additions & 3 deletions xray/utils/resultstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"fmt"
"github.com/jfrog/jfrog-cli-core/v2/xray/commands/audit/sca/yarn"
"os"
"path/filepath"
"sort"
Expand All @@ -29,6 +28,7 @@ const (
directDependencyIndex = 1
directDependencyPathLength = 2
nodeModules = "node_modules"
NpmPackageTypeIdentifier = "npm://"
)

// PrintViolationsTable prints the violations in 4 tables: security violations, license compliance violations, operational risk violations and ignore rule URLs.
Expand Down Expand Up @@ -1037,10 +1037,10 @@ func shouldDisqualifyEvidence(components map[string]services.Component, evidence
}

func extractNpmDependencyNameFromComponent(key string) (dependencyName string) {
if !strings.HasPrefix(key, yarn.NpmPackageTypeIdentifier) {
if !strings.HasPrefix(key, NpmPackageTypeIdentifier) {
return
}
packageAndVersion := strings.TrimPrefix(key, yarn.NpmPackageTypeIdentifier)
packageAndVersion := strings.TrimPrefix(key, NpmPackageTypeIdentifier)
split := strings.Split(packageAndVersion, ":")
if len(split) < 2 {
return
Expand Down

0 comments on commit 03a3707

Please sign in to comment.