Skip to content

Commit

Permalink
test: remove the unnecessary case and test
Browse files Browse the repository at this point in the history
  • Loading branch information
knqyf263 committed Sep 22, 2021
1 parent 25d1cf7 commit a39b834
Showing 1 changed file with 0 additions and 157 deletions.
157 changes: 0 additions & 157 deletions pkg/scanner/local/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,95 +631,6 @@ func TestScanner_Scan(t *testing.T) {
Name: "3.11",
},
},
{
name: "happy path with skip directories",
args: args{
target: "alpine:latest",
layerIDs: []string{"sha256:5216338b40a7b96416b8b9858974bbe4acc3096ee60acbc4dfb1ee02aecceb10"},
options: types.ScanOptions{
VulnType: []string{types.VulnTypeLibrary},
SecurityChecks: []string{types.SecurityCheckVulnerability, types.SecurityCheckConfig},
SkipDirs: []string{"/usr/lib/ruby/gems", "/app/k8s"},
},
},
fixtures: []string{"testdata/fixtures/happy.yaml"},
applyLayersExpectation: ApplierApplyLayersExpectation{
Args: ApplierApplyLayersArgs{
BlobIDs: []string{"sha256:5216338b40a7b96416b8b9858974bbe4acc3096ee60acbc4dfb1ee02aecceb10"},
},
Returns: ApplierApplyLayersReturns{
Detail: ftypes.ArtifactDetail{
OS: &ftypes.OS{
Family: "alpine",
Name: "3.11",
},
Packages: []ftypes.Package{
{Name: "musl", Version: "1.2.3"},
},
Applications: []ftypes.Application{
{
Type: "bundler",
FilePath: "usr/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/Gemfile.lock",
Libraries: []ftypes.LibraryInfo{
{
Library: dtypes.Library{Name: "rails", Version: "5.1"},
Layer: ftypes.Layer{
DiffID: "sha256:5cb2a5009179b1e78ecfef81a19756328bb266456cf9a9dbbcf9af8b83b735f0",
},
},
},
},
{
Type: "composer",
FilePath: "app/composer-lock.json",
Libraries: []ftypes.LibraryInfo{
{
Library: dtypes.Library{Name: "laravel/framework", Version: "6.0.0"},
Layer: ftypes.Layer{
DiffID: "sha256:9922bc15eeefe1637b803ef2106f178152ce19a391f24aec838cbe2e48e73303",
},
},
},
},
},
Misconfigurations: []ftypes.Misconfiguration{
{
FileType: ftypes.Kubernetes,
FilePath: "/app/k8s/deployment.yaml",
Failures: ftypes.MisconfResults{
{
Namespace: "appshield.kubernetes.id100",
Message: "something bad",
},
},
},
},
},
},
},
wantResults: report.Results{
{
Target: "app/composer-lock.json",
Vulnerabilities: []types.DetectedVulnerability{
{
VulnerabilityID: "CVE-2021-21263",
PkgName: "laravel/framework",
InstalledVersion: "6.0.0",
FixedVersion: "8.22.1, 7.30.3, 6.20.12",
Layer: ftypes.Layer{
DiffID: "sha256:9922bc15eeefe1637b803ef2106f178152ce19a391f24aec838cbe2e48e73303",
},
},
},
Class: report.ClassLangPkg,
Type: ftypes.Composer,
},
},
wantOS: &ftypes.OS{
Family: "alpine",
Name: "3.11",
},
},
{
name: "happy path with misconfigurations",
args: args{
Expand Down Expand Up @@ -1025,71 +936,3 @@ func TestScanner_Scan(t *testing.T) {
})
}
}

func Test_skipped(t *testing.T) {
type args struct {
filePath string
skipFiles []string
skipDirs []string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "no skip directory",
args: args{
filePath: "app/Gemfile.lock",
skipDirs: []string{},
},
want: false,
},
{
name: "skip directory with the leading slash",
args: args{
filePath: "app/Gemfile.lock",
skipDirs: []string{"/app"},
},
want: true,
},
{
name: "skip directory without a slash",
args: args{
filePath: "usr/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/Gemfile.lock",
skipDirs: []string{"/usr/lib/ruby"},
},
want: true,
},
{
name: "skip file with the leading slash",
args: args{
filePath: "Gemfile.lock",
skipFiles: []string{"/Gemfile.lock"},
},
want: true,
},
{
name: "skip file without a slash",
args: args{
filePath: "Gemfile.lock",
skipFiles: []string{"Gemfile.lock"},
},
want: true,
},
{
name: "not skipped",
args: args{
filePath: "usr/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/Gemfile.lock",
skipDirs: []string{"lib/ruby"},
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := skipped(tt.args.filePath, tt.args.skipFiles, tt.args.skipDirs)
assert.Equal(t, tt.want, got)
})
}
}

0 comments on commit a39b834

Please sign in to comment.