@@ -608,16 +608,16 @@ func stringMatrixEqual(a, b [][]string) bool {
608608
609609func TestBuildVulnDetails (t * testing.T ) {
610610 tests := []struct {
611- name string
612- pocDef * Poc
613- vulName string
614- params StrMap
615- wantKeys []string
616- wantNoKeys []string
617- wantVulnType string
618- wantVulnName string
619- wantParamVal string
620- wantParamKey string
611+ name string
612+ pocDef * Poc
613+ vulName string
614+ params StrMap
615+ wantKeys []string
616+ wantNoKeys []string
617+ wantVulnType string
618+ wantVulnName string
619+ wantParamVal string
620+ wantParamKey string
621621 }{
622622 {
623623 name : "最小Poc只有Name" ,
@@ -647,15 +647,15 @@ func TestBuildVulnDetails(t *testing.T) {
647647 wantVulnName : "Full Vuln" ,
648648 },
649649 {
650- name : "有params则details含parameters字段" ,
651- pocDef : & Poc {Name : "poc-yaml-params" },
650+ name : "有params则details含parameters字段" ,
651+ pocDef : & Poc {Name : "poc-yaml-params" },
652652 vulName : "Params Vuln" ,
653653 params : StrMap {
654654 {Key : "user" , Value : "admin" },
655655 {Key : "pass" , Value : "123456" },
656656 },
657- wantKeys : []string {"vulnerability_type" , "vulnerability_name" , "parameters" },
658- wantNoKeys : []string {"author" },
657+ wantKeys : []string {"vulnerability_type" , "vulnerability_name" , "parameters" },
658+ wantNoKeys : []string {"author" },
659659 wantParamKey : "user" ,
660660 wantParamVal : "admin" ,
661661 },
@@ -865,3 +865,33 @@ func TestCollectVarDeclarations(t *testing.T) {
865865 }
866866 })
867867}
868+
869+ func TestEvalSetTreatsEncodedValuesAsLiterals (t * testing.T ) {
870+ env := GetBaseEnv ()
871+ tests := []string {
872+ "fsHspZw/92PrS3XrPW+vxw==" ,
873+ "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyJ9.feetKmWoPnMkAebjkNnyuKo6c21_hzTgu0dfNqbdpZQ" ,
874+ }
875+
876+ for _ , value := range tests {
877+ variables := map [string ]interface {}{}
878+ got , err := evalset (env , variables , "token" , value )
879+ if err != nil {
880+ t .Fatalf ("evalset(%q) error = %v" , value , err )
881+ }
882+ if got != value || variables ["token" ] != value {
883+ t .Fatalf ("evalset(%q) = %q, stored %v" , value , got , variables ["token" ])
884+ }
885+ }
886+ }
887+
888+ func TestEvalSetStillEvaluatesExpressions (t * testing.T ) {
889+ variables := map [string ]interface {}{}
890+ got , err := evalset (GetBaseEnv (), variables , "token" , "randomLowercase(6)" )
891+ if err != nil {
892+ t .Fatal (err )
893+ }
894+ if len (got ) != 6 {
895+ t .Fatalf ("randomLowercase result length = %d, want 6" , len (got ))
896+ }
897+ }
0 commit comments