@@ -186,6 +186,27 @@ func TestFilter(t *testing.T) {
186186 Category : "restricted" ,
187187 Confidence : 1 ,
188188 }
189+ license3 = types.DetectedLicense {
190+ Name : "mit AND GPL-2.0-or-later" ,
191+ Severity : dbTypes .SeverityLow .String (),
192+ FilePath : "usr/share/gcc/python/libstdcxx/v6/__init__.py" ,
193+ Category : "restricted" ,
194+ Confidence : 1 ,
195+ }
196+ license4 = types.DetectedLicense {
197+ Name : "Apache-2.0 WITH LLVM-exception" ,
198+ Severity : dbTypes .SeverityLow .String (),
199+ FilePath : "usr/share/llvm/LICENSE.txt" ,
200+ Category : "restricted" ,
201+ Confidence : 1 ,
202+ }
203+ license5 = types.DetectedLicense {
204+ Name : "GPL-3.0 WITH GCC-exception-3.1" ,
205+ Severity : dbTypes .SeverityLow .String (),
206+ FilePath : "usr/share/gcc/LICENSE.txt" ,
207+ Category : "restricted" ,
208+ Confidence : 1 ,
209+ }
189210 )
190211 type args struct {
191212 report types.Report
@@ -360,6 +381,13 @@ func TestFilter(t *testing.T) {
360381 secret2 ,
361382 },
362383 },
384+ {
385+ Target : "LICENSE.txt" ,
386+ Licenses : []types.DetectedLicense {
387+ license1 , // ignored
388+ license3 ,
389+ },
390+ },
363391 },
364392 },
365393 severities : []dbTypes.Severity {
@@ -431,6 +459,20 @@ func TestFilter(t *testing.T) {
431459 },
432460 },
433461 },
462+ {
463+ Target : "LICENSE.txt" ,
464+ Licenses : []types.DetectedLicense {
465+ license3 ,
466+ },
467+ ModifiedFindings : []types.ModifiedFinding {
468+ {
469+ Type : types .FindingTypeLicense ,
470+ Status : types .FindingStatusIgnored ,
471+ Source : "testdata/.trivyignore" ,
472+ Finding : license1 ,
473+ },
474+ },
475+ },
434476 },
435477 },
436478 },
@@ -472,6 +514,9 @@ func TestFilter(t *testing.T) {
472514 Licenses : []types.DetectedLicense {
473515 license1 , // ignored
474516 license2 ,
517+ license3 , // ignored by combination for 2 licenses
518+ license4 , // ignored by WITH operator
519+ license5 , // not ignored (different exception)
475520 },
476521 },
477522 },
@@ -565,6 +610,7 @@ func TestFilter(t *testing.T) {
565610 Target : "LICENSE.txt" ,
566611 Licenses : []types.DetectedLicense {
567612 license2 ,
613+ license5 , // not ignored (different exception)
568614 },
569615 ModifiedFindings : []types.ModifiedFinding {
570616 {
@@ -573,6 +619,19 @@ func TestFilter(t *testing.T) {
573619 Source : "testdata/.trivyignore.yaml" ,
574620 Finding : license1 ,
575621 },
622+ {
623+ Type : types .FindingTypeLicense ,
624+ Status : types .FindingStatusIgnored ,
625+ Source : "testdata/.trivyignore.yaml" ,
626+ Statement : "All license components are individually ignored" ,
627+ Finding : license3 ,
628+ },
629+ {
630+ Type : types .FindingTypeLicense ,
631+ Status : types .FindingStatusIgnored ,
632+ Source : "testdata/.trivyignore.yaml" ,
633+ Finding : license4 ,
634+ },
576635 },
577636 },
578637 },
0 commit comments