@@ -620,7 +620,7 @@ var _ = Describe("Analyzer", func() {
620
620
err = analyzer .Process (buildTags , nosecPackage .Path )
621
621
Expect (err ).ShouldNot (HaveOccurred ())
622
622
issues , _ , _ := analyzer .Report ()
623
- Expect (issues ).To (HaveLen (1 ))
623
+ Expect (issues ).To (HaveLen (sample . Errors ))
624
624
Expect (issues [0 ].Suppressions ).To (HaveLen (1 ))
625
625
Expect (issues [0 ].Suppressions [0 ].Kind ).To (Equal ("inSource" ))
626
626
Expect (issues [0 ].Suppressions [0 ].Justification ).To (Equal ("Justification" ))
@@ -640,12 +640,31 @@ var _ = Describe("Analyzer", func() {
640
640
err = analyzer .Process (buildTags , nosecPackage .Path )
641
641
Expect (err ).ShouldNot (HaveOccurred ())
642
642
issues , _ , _ := analyzer .Report ()
643
- Expect (issues ).To (HaveLen (1 ))
643
+ Expect (issues ).To (HaveLen (sample . Errors ))
644
644
Expect (issues [0 ].Suppressions ).To (HaveLen (1 ))
645
645
Expect (issues [0 ].Suppressions [0 ].Kind ).To (Equal ("inSource" ))
646
646
Expect (issues [0 ].Suppressions [0 ].Justification ).To (Equal ("" ))
647
647
})
648
648
649
+ It ("should track multiple suppressions if the violation is suppressed by both #nosec and #nosec RuleList" , func () {
650
+ sample := testutils .SampleCodeG101 [0 ]
651
+ source := sample .Code [0 ]
652
+ analyzer .LoadRules (rules .Generate (false , rules .NewRuleFilter (false , "G101" )).RulesInfo ())
653
+
654
+ nosecPackage := testutils .NewTestPackage ()
655
+ defer nosecPackage .Close ()
656
+ nosecSource := strings .Replace (source , "}" , "} //#nosec G101 -- Justification" , 1 )
657
+ nosecSource = strings .Replace (nosecSource , "func" , "//#nosec\n func" , 1 )
658
+ nosecPackage .AddFile ("pwd.go" , nosecSource )
659
+ err := nosecPackage .Build ()
660
+ Expect (err ).ShouldNot (HaveOccurred ())
661
+ err = analyzer .Process (buildTags , nosecPackage .Path )
662
+ Expect (err ).ShouldNot (HaveOccurred ())
663
+ issues , _ , _ := analyzer .Report ()
664
+ Expect (issues ).To (HaveLen (sample .Errors ))
665
+ Expect (issues [0 ].Suppressions ).To (HaveLen (2 ))
666
+ })
667
+
649
668
It ("should not report an error if the rule is not included" , func () {
650
669
sample := testutils .SampleCodeG101 [0 ]
651
670
source := sample .Code [0 ]
0 commit comments