Skip to content

Commit

Permalink
remove GetMatchFlagsFromPkgInput helper as it was not needed for isDe…
Browse files Browse the repository at this point in the history
…pendency (#1933)

* remove GetMatchFlagsFromPkgInput helper as it was not needed

Signed-off-by: pxp928 <parth.psu@gmail.com>

* fix unit tests

Signed-off-by: pxp928 <parth.psu@gmail.com>

---------

Signed-off-by: pxp928 <parth.psu@gmail.com>
  • Loading branch information
pxp928 authored Jul 10, 2024
1 parent 8a987bd commit 0c70002
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
14 changes: 7 additions & 7 deletions internal/testing/testdata/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ var (
{
Pkg: topLevelPack,
DepPkg: worldFilePack,
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeAllVersions},
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
VersionRange: "",
Expand All @@ -687,7 +687,7 @@ var (
{
Pkg: topLevelPack,
DepPkg: rootFilePack,
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeAllVersions},
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
VersionRange: "",
Expand All @@ -697,7 +697,7 @@ var (
{
Pkg: topLevelPack,
DepPkg: triggersFilePack,
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeAllVersions},
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
VersionRange: "",
Expand All @@ -707,7 +707,7 @@ var (
{
Pkg: topLevelPack,
DepPkg: rsaPubFilePack,
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeAllVersions},
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
VersionRange: "",
Expand All @@ -727,7 +727,7 @@ var (
{
Pkg: rootFilePack,
DepPkg: rsaPubFilePack,
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeAllVersions},
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
VersionRange: "",
Expand All @@ -737,7 +737,7 @@ var (
{
Pkg: baselayoutPack,
DepPkg: rootFilePack,
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeAllVersions},
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
VersionRange: "",
Expand All @@ -747,7 +747,7 @@ var (
{
Pkg: keysPack,
DepPkg: rsaPubFilePack,
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeAllVersions},
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
VersionRange: "",
Expand Down
16 changes: 4 additions & 12 deletions pkg/ingestor/parser/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func GetIsDep(foundNode *model.PkgInputSpec, relatedPackNodes []*model.PkgInputS
return &assembler.IsDependencyIngest{
Pkg: foundNode,
DepPkg: rfileNode,
DepPkgMatchFlag: GetMatchFlagsFromPkgInput(rfileNode),
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: dependency,
Justification: justification,
Expand All @@ -48,7 +48,7 @@ func GetIsDep(foundNode *model.PkgInputSpec, relatedPackNodes []*model.PkgInputS
return &assembler.IsDependencyIngest{
Pkg: foundNode,
DepPkg: rpackNode,
DepPkgMatchFlag: GetMatchFlagsFromPkgInput(rpackNode),
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: dependency,
Justification: justification,
Expand All @@ -70,7 +70,7 @@ func CreateTopLevelIsDeps(topLevel *model.PkgInputSpec, packages map[string][]*m
p := assembler.IsDependencyIngest{
Pkg: topLevel,
DepPkg: packNode,
DepPkgMatchFlag: GetMatchFlagsFromPkgInput(packNode),
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
Justification: justification,
Expand All @@ -87,7 +87,7 @@ func CreateTopLevelIsDeps(topLevel *model.PkgInputSpec, packages map[string][]*m
p := assembler.IsDependencyIngest{
Pkg: topLevel,
DepPkg: fileNode,
DepPkgMatchFlag: GetMatchFlagsFromPkgInput(fileNode),
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: &model.IsDependencyInputSpec{
DependencyType: model.DependencyTypeUnknown,
Justification: justification,
Expand Down Expand Up @@ -125,11 +125,3 @@ func createTopLevelHasSBOM(blob []byte, uri string, source string, timestamp tim
},
}
}

func GetMatchFlagsFromPkgInput(p *model.PkgInputSpec) model.MatchFlags {
matchFlags := model.MatchFlags{Pkg: model.PkgMatchTypeAllVersions}
if p.Version != nil && *p.Version != "" {
matchFlags = model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion}
}
return matchFlags
}
2 changes: 1 addition & 1 deletion pkg/ingestor/parser/deps_dev/deps_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (d *depsDevParser) GetPredicates(ctx context.Context) *assembler.IngestPred
preds.IsDependency = append(preds.IsDependency, assembler.IsDependencyIngest{
Pkg: isDepComp.CurrentPackageInput,
DepPkg: isDepComp.DepPackageInput,
DepPkgMatchFlag: common.GetMatchFlagsFromPkgInput(isDepComp.DepPackageInput),
DepPkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion},
IsDependency: isDepComp.IsDependency,
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingestor/parser/spdx/parse_spdx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func Test_spdxParser(t *testing.T) {
{
Pkg: pUrlToPkgDiscardError("pkg:guac/spdx/testsbom"),
DepPkg: pUrlToPkgDiscardError("pkg:guac/files/sha1:ba1c68d88439599dcca7594d610030a19eda4f63?filename=./include-file"),
DepPkgMatchFlag: generated.MatchFlags{Pkg: generated.PkgMatchTypeAllVersions},
DepPkgMatchFlag: generated.MatchFlags{Pkg: generated.PkgMatchTypeSpecificVersion},
IsDependency: &generated.IsDependencyInputSpec{
DependencyType: generated.DependencyTypeUnknown,
Justification: "top-level package GUAC heuristic connecting to each file/package",
Expand Down Expand Up @@ -780,7 +780,7 @@ func Test_spdxParser(t *testing.T) {
{
Pkg: pUrlToPkgDiscardError("pkg:guac/spdx/testsbom"),
DepPkg: pUrlToPkgDiscardError("pkg:guac/files/sha1:ba1c68d88439599dcca7594d610030a19eda4f63?filename=./include-file"),
DepPkgMatchFlag: generated.MatchFlags{Pkg: generated.PkgMatchTypeAllVersions},
DepPkgMatchFlag: generated.MatchFlags{Pkg: generated.PkgMatchTypeSpecificVersion},
IsDependency: &generated.IsDependencyInputSpec{
DependencyType: generated.DependencyTypeUnknown,
Justification: "top-level package GUAC heuristic connecting to each file/package",
Expand Down

0 comments on commit 0c70002

Please sign in to comment.