From ca5084ece553b1831814c6b111b229b613484929 Mon Sep 17 00:00:00 2001 From: sarahCx Date: Mon, 28 Oct 2024 10:18:32 +0200 Subject: [PATCH] add .rs to include filters --- internal/commands/scan_test.go | 29 +++++++++++++++++++++++++++++ internal/params/filters.go | 1 + 2 files changed, 30 insertions(+) diff --git a/internal/commands/scan_test.go b/internal/commands/scan_test.go index 0659433ae..c27b24621 100644 --- a/internal/commands/scan_test.go +++ b/internal/commands/scan_test.go @@ -1178,3 +1178,32 @@ func TestValidateContainerImageFormat(t *testing.T) { }) } } + +func TestFilterMatched(t *testing.T) { + tests := []struct { + name string + filters []string + fileName string + expected bool + }{ + { + name: "whenFileMatchesInclusionFilter_shouldReturnTrue", + filters: []string{"*.go"}, + fileName: "main.go", + expected: true, + }, + { + name: "whenFileNoMatchesInclusionFilter_shouldReturnFalse", + filters: []string{"*.go"}, + fileName: "main.py", + expected: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := filterMatched(tt.filters, tt.fileName) + assert.Equal(t, tt.expected, result) + }) + } +} diff --git a/internal/params/filters.go b/internal/params/filters.go index 4e1e5d0cc..b34e20ce0 100644 --- a/internal/params/filters.go +++ b/internal/params/filters.go @@ -135,6 +135,7 @@ var BaseIncludeFilters = []string{ "Podfile.lock", "*.cmp", "Directory.Packages.props", + "*.rs", } var BaseExcludeFilters = []string{