Skip to content

Commit

Permalink
Fix CR.
Browse files Browse the repository at this point in the history
  • Loading branch information
asafambar committed Oct 1, 2023
1 parent b26b6ea commit 6b2661c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
14 changes: 8 additions & 6 deletions xray/commands/audit/sca/npm/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ func BuildDependencyTree(params utils.AuditParams) (dependencyTrees []*xrayUtils
if err != nil {
return
}
treeDepsParam := biutils.NpmTreeDepListParam{
Args: addIgnoreScriptsFlag([]string{}),
}
if params != nil {
treeDepsParam = createTreeDepsParam(params)
}

treeDepsParam := createTreeDepsParam(params)

// Calculate npm dependencies
dependenciesMap, err := biutils.CalculateDependenciesMap(npmExecutablePath, currentDir, packageInfo.BuildInfoModuleId(), treeDepsParam, log.Logger)
if err != nil {
Expand All @@ -51,6 +48,11 @@ func BuildDependencyTree(params utils.AuditParams) (dependencyTrees []*xrayUtils
}

func createTreeDepsParam(params utils.AuditParams) biutils.NpmTreeDepListParam {
if params == nil {
return biutils.NpmTreeDepListParam{
Args: addIgnoreScriptsFlag([]string{}),
}
}
npmTreeDepParam := biutils.NpmTreeDepListParam{
Args: addIgnoreScriptsFlag(params.Args()),
}
Expand Down
3 changes: 1 addition & 2 deletions xray/commands/curation/curationaudit.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ func (ca *CurationAuditCommand) doCurateAudit(results map[string][]*PackageStatu

func (ca *CurationAuditCommand) getAuditParamsByTech(tech coreutils.Technology) utils.AuditParams {
if tech == coreutils.Npm {
return utils.AuditNpmParams{
AuditParams: ca.AuditParams}.
return utils.AuditNpmParams{AuditParams: ca.AuditParams}.
SetNpmIgnoreNodeModules(true).
SetNpmOverwritePackageLock(true)
}
Expand Down
25 changes: 25 additions & 0 deletions xray/utils/auditnpmparams.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package utils

type AuditNpmParams struct {
AuditParams
npmIgnoreNodeModules bool
npmOverwritePackageLock bool
}

func (anp AuditNpmParams) SetNpmIgnoreNodeModules(ignoreNpmNodeModules bool) AuditNpmParams {
anp.npmIgnoreNodeModules = ignoreNpmNodeModules
return anp
}

func (anp AuditNpmParams) SetNpmOverwritePackageLock(overwritePackageLock bool) AuditNpmParams {
anp.npmOverwritePackageLock = overwritePackageLock
return anp
}

func (anp AuditNpmParams) NpmIgnoreNodeModules() bool {
return anp.npmIgnoreNodeModules
}

func (anp AuditNpmParams) NpmOverwritePackageLock() bool {
return anp.npmOverwritePackageLock
}
25 changes: 0 additions & 25 deletions xray/utils/packageManagerAuditParams.go

This file was deleted.

0 comments on commit 6b2661c

Please sign in to comment.