Skip to content

Commit 11600e7

Browse files
G-Rathanother-rex
andauthored
chore: remove deprecated internal functions (google#1369)
There's no reason for us to retain these in the internal packages, so they can just go Co-authored-by: Rex P <[email protected]>
1 parent 94c12b5 commit 11600e7

File tree

2 files changed

+0
-255
lines changed

2 files changed

+0
-255
lines changed

internal/config/config.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,6 @@ func (c *Config) ShouldIgnorePackage(pkg models.PackageVulns) (bool, PackageOver
112112
})
113113
}
114114

115-
// Deprecated: Use ShouldIgnorePackage instead
116-
func (c *Config) ShouldIgnorePackageVersion(name, version, ecosystem string) (bool, PackageOverrideEntry) {
117-
return c.ShouldIgnorePackage(models.PackageVulns{
118-
Package: models.PackageInfo{
119-
Name: name,
120-
Version: version,
121-
Ecosystem: ecosystem,
122-
},
123-
})
124-
}
125-
126115
// ShouldIgnorePackageVulnerabilities determines if the given package should have its vulnerabilities ignored based on override entries in the config
127116
func (c *Config) ShouldIgnorePackageVulnerabilities(pkg models.PackageVulns) bool {
128117
overrides, _ := c.filterPackageVersionEntries(pkg, func(e PackageOverrideEntry) bool {
@@ -139,17 +128,6 @@ func (c *Config) ShouldOverridePackageLicense(pkg models.PackageVulns) (bool, Pa
139128
})
140129
}
141130

142-
// Deprecated: Use ShouldOverridePackageLicense instead
143-
func (c *Config) ShouldOverridePackageVersionLicense(name, version, ecosystem string) (bool, PackageOverrideEntry) {
144-
return c.ShouldOverridePackageLicense(models.PackageVulns{
145-
Package: models.PackageInfo{
146-
Name: name,
147-
Version: version,
148-
Ecosystem: ecosystem,
149-
},
150-
})
151-
}
152-
153131
func shouldIgnoreTimestamp(ignoreUntil time.Time) bool {
154132
if ignoreUntil.IsZero() {
155133
// If IgnoreUntil is not set, should ignore.

internal/config/config_internal_test.go

Lines changed: 0 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -787,124 +787,6 @@ func TestConfig_ShouldIgnorePackage(t *testing.T) {
787787
}
788788
}
789789

790-
func TestConfig_ShouldIgnorePackageVersion(t *testing.T) {
791-
t.Parallel()
792-
793-
type args struct {
794-
name string
795-
version string
796-
ecosystem string
797-
}
798-
tests := []struct {
799-
name string
800-
config Config
801-
args args
802-
wantOk bool
803-
wantEntry PackageOverrideEntry
804-
}{
805-
{
806-
name: "Version-level entry exists",
807-
config: Config{
808-
PackageOverrides: []PackageOverrideEntry{
809-
{
810-
Name: "lib1",
811-
Version: "1.0.0",
812-
Ecosystem: "Go",
813-
Ignore: true,
814-
EffectiveUntil: time.Time{},
815-
Reason: "abc",
816-
},
817-
},
818-
},
819-
args: args{
820-
name: "lib1",
821-
version: "1.0.0",
822-
ecosystem: "Go",
823-
},
824-
wantOk: true,
825-
wantEntry: PackageOverrideEntry{
826-
Name: "lib1",
827-
Version: "1.0.0",
828-
Ecosystem: "Go",
829-
Ignore: true,
830-
EffectiveUntil: time.Time{},
831-
Reason: "abc",
832-
},
833-
},
834-
{
835-
name: "Package-level entry exists",
836-
config: Config{
837-
PackageOverrides: []PackageOverrideEntry{
838-
{
839-
Name: "lib1",
840-
Ecosystem: "Go",
841-
Ignore: true,
842-
EffectiveUntil: time.Time{},
843-
Reason: "abc",
844-
},
845-
},
846-
},
847-
args: args{
848-
name: "lib1",
849-
version: "1.0.0",
850-
ecosystem: "Go",
851-
},
852-
wantOk: true,
853-
wantEntry: PackageOverrideEntry{
854-
Name: "lib1",
855-
Ecosystem: "Go",
856-
Ignore: true,
857-
EffectiveUntil: time.Time{},
858-
Reason: "abc",
859-
},
860-
},
861-
{
862-
name: "Entry doesn't exist",
863-
config: Config{
864-
PackageOverrides: []PackageOverrideEntry{
865-
{
866-
Name: "lib1",
867-
Version: "2.0.0",
868-
Ecosystem: "Go",
869-
Ignore: false,
870-
EffectiveUntil: time.Time{},
871-
Reason: "abc",
872-
},
873-
{
874-
Name: "lib2",
875-
Version: "2.0.0",
876-
Ignore: true,
877-
Ecosystem: "Go",
878-
EffectiveUntil: time.Time{},
879-
Reason: "abc",
880-
},
881-
},
882-
},
883-
args: args{
884-
name: "lib1",
885-
version: "2.0.0",
886-
ecosystem: "Go",
887-
},
888-
wantOk: false,
889-
wantEntry: PackageOverrideEntry{},
890-
},
891-
}
892-
893-
for _, tt := range tests {
894-
t.Run(tt.name, func(t *testing.T) {
895-
t.Parallel()
896-
897-
gotOk, gotEntry := tt.config.ShouldIgnorePackageVersion(tt.args.name, tt.args.version, tt.args.ecosystem)
898-
if gotOk != tt.wantOk {
899-
t.Errorf("ShouldIgnorePackageVersion() gotOk = %v, wantOk %v", gotOk, tt.wantOk)
900-
}
901-
if !reflect.DeepEqual(gotEntry, tt.wantEntry) {
902-
t.Errorf("ShouldIgnorePackageVersion() gotEntry = %v, wantEntry %v", gotEntry, tt.wantEntry)
903-
}
904-
})
905-
}
906-
}
907-
908790
func TestConfig_ShouldIgnorePackageVulnerabilities(t *testing.T) {
909791
t.Parallel()
910792

@@ -1203,118 +1085,3 @@ func TestConfig_ShouldOverridePackageLicense(t *testing.T) {
12031085
})
12041086
}
12051087
}
1206-
1207-
func TestConfig_ShouldOverridePackageVersionLicense(t *testing.T) {
1208-
t.Parallel()
1209-
1210-
type args struct {
1211-
name string
1212-
version string
1213-
ecosystem string
1214-
}
1215-
tests := []struct {
1216-
name string
1217-
config Config
1218-
args args
1219-
wantOk bool
1220-
wantEntry PackageOverrideEntry
1221-
}{
1222-
{
1223-
name: "Exact version entry exists",
1224-
config: Config{
1225-
PackageOverrides: []PackageOverrideEntry{
1226-
{
1227-
Name: "lib1",
1228-
Version: "1.0.0",
1229-
Ecosystem: "Go",
1230-
License: License{
1231-
Override: []string{"mit"},
1232-
},
1233-
Reason: "abc",
1234-
},
1235-
},
1236-
},
1237-
args: args{
1238-
name: "lib1",
1239-
version: "1.0.0",
1240-
ecosystem: "Go",
1241-
},
1242-
wantOk: true,
1243-
wantEntry: PackageOverrideEntry{
1244-
Name: "lib1",
1245-
Version: "1.0.0",
1246-
Ecosystem: "Go",
1247-
License: License{
1248-
Override: []string{"mit"},
1249-
},
1250-
Reason: "abc",
1251-
},
1252-
},
1253-
{
1254-
name: "Version entry doesn't exist",
1255-
config: Config{
1256-
PackageOverrides: []PackageOverrideEntry{
1257-
{
1258-
Name: "lib1",
1259-
Version: "1.0.0",
1260-
Ecosystem: "Go",
1261-
License: License{
1262-
Override: []string{"mit"},
1263-
},
1264-
Reason: "abc",
1265-
},
1266-
},
1267-
},
1268-
args: args{
1269-
name: "lib1",
1270-
version: "1.0.1",
1271-
ecosystem: "Go",
1272-
},
1273-
wantOk: false,
1274-
wantEntry: PackageOverrideEntry{},
1275-
},
1276-
{
1277-
name: "Name matches",
1278-
config: Config{
1279-
PackageOverrides: []PackageOverrideEntry{
1280-
{
1281-
Name: "lib1",
1282-
Ecosystem: "Go",
1283-
License: License{
1284-
Override: []string{"mit"},
1285-
},
1286-
Reason: "abc",
1287-
},
1288-
},
1289-
},
1290-
args: args{
1291-
name: "lib1",
1292-
version: "1.0.1",
1293-
ecosystem: "Go",
1294-
},
1295-
wantOk: true,
1296-
wantEntry: PackageOverrideEntry{
1297-
Name: "lib1",
1298-
Ecosystem: "Go",
1299-
License: License{
1300-
Override: []string{"mit"},
1301-
},
1302-
Reason: "abc",
1303-
},
1304-
},
1305-
}
1306-
1307-
for _, tt := range tests {
1308-
t.Run(tt.name, func(t *testing.T) {
1309-
t.Parallel()
1310-
1311-
gotOk, gotEntry := tt.config.ShouldOverridePackageVersionLicense(tt.args.name, tt.args.version, tt.args.ecosystem)
1312-
if gotOk != tt.wantOk {
1313-
t.Errorf("ShouldOverridePackageVersionLicense() gotOk = %v, wantOk %v", gotOk, tt.wantOk)
1314-
}
1315-
if !reflect.DeepEqual(gotEntry, tt.wantEntry) {
1316-
t.Errorf("ShouldOverridePackageVersionLicense() gotEntry = %v, wantEntry %v", gotEntry, tt.wantEntry)
1317-
}
1318-
})
1319-
}
1320-
}

0 commit comments

Comments
 (0)