@@ -690,6 +690,71 @@ func TestSecretScanner(t *testing.T) {
690
690
},
691
691
}
692
692
693
+ wantFindingGrafanaQuoted := types.SecretFinding {
694
+ RuleID : "grafana-api-token" ,
695
+ Category : secret .CategoryGrafana ,
696
+ Title : "Grafana API token" ,
697
+ Severity : "MEDIUM" ,
698
+ StartLine : 1 ,
699
+ EndLine : 1 ,
700
+ Match : "GRAFANA_TOKEN=**********************************************************************************************" ,
701
+ Code : types.Code {
702
+ Lines : []types.Line {
703
+ {
704
+ Number : 1 ,
705
+ Content : "GRAFANA_TOKEN=**********************************************************************************************" ,
706
+ Highlighted : "GRAFANA_TOKEN=**********************************************************************************************" ,
707
+ IsCause : true ,
708
+ FirstCause : true ,
709
+ LastCause : true ,
710
+ },
711
+ {
712
+ Number : 2 ,
713
+ Content : "GRAFANA_TOKEN=**************************************************************************************" ,
714
+ Highlighted : "GRAFANA_TOKEN=**************************************************************************************" ,
715
+ IsCause : false ,
716
+ FirstCause : false ,
717
+ LastCause : false ,
718
+ },
719
+ },
720
+ },
721
+ }
722
+
723
+ wantFindingGrafanaUnquoted := types.SecretFinding {
724
+ RuleID : "grafana-api-token" ,
725
+ Category : secret .CategoryGrafana ,
726
+ Title : "Grafana API token" ,
727
+ Severity : "MEDIUM" ,
728
+ StartLine : 2 ,
729
+ EndLine : 2 ,
730
+ Match : "GRAFANA_TOKEN=********************************************************************************************" ,
731
+ Code : types.Code {
732
+ Lines : []types.Line {
733
+ {
734
+ Number : 1 ,
735
+ Content : "GRAFANA_TOKEN=**************************************************************************************" ,
736
+ Highlighted : "GRAFANA_TOKEN=**************************************************************************************" ,
737
+ IsCause : false ,
738
+ FirstCause : false ,
739
+ LastCause : false ,
740
+ },
741
+ {
742
+ Number : 2 ,
743
+ Content : "GRAFANA_TOKEN=********************************************************************************************" ,
744
+ Highlighted : "GRAFANA_TOKEN=********************************************************************************************" ,
745
+ IsCause : true ,
746
+ FirstCause : true ,
747
+ LastCause : true ,
748
+ },
749
+ {
750
+ Number : 3 ,
751
+ Content : "" ,
752
+ Highlighted : "" ,
753
+ },
754
+ },
755
+ },
756
+ }
757
+
693
758
wantMultiLine := types.SecretFinding {
694
759
RuleID : "multi-line-secret" ,
695
760
Category : "general" ,
@@ -858,6 +923,15 @@ func TestSecretScanner(t *testing.T) {
858
923
Findings : []types.SecretFinding {wantFindingHuggingFace },
859
924
},
860
925
},
926
+ {
927
+ name : "find grafana secret" ,
928
+ configPath : filepath .Join ("testdata" , "config.yaml" ),
929
+ inputFilePath : filepath .Join ("testdata" , "grafana-env.txt" ),
930
+ want : types.Secret {
931
+ FilePath : filepath .Join ("testdata" , "grafana-env.txt" ),
932
+ Findings : []types.SecretFinding {wantFindingGrafanaUnquoted , wantFindingGrafanaQuoted },
933
+ },
934
+ },
861
935
{
862
936
name : "find JWT token" ,
863
937
configPath : filepath .Join ("testdata" , "config.yaml" ),
0 commit comments