@@ -69,10 +69,15 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
69
69
}
70
70
}
71
71
72
- token := match [0 ]
72
+ urlMatch := match [0 ]
73
73
password := match [1 ]
74
74
75
- parsedURL , err := url .Parse (token )
75
+ // Skip findings where the password starts with a `$` - it's almost certainly a variable.
76
+ if strings .HasPrefix (password , "$" ) {
77
+ continue
78
+ }
79
+
80
+ parsedURL , err := url .Parse (urlMatch )
76
81
if err != nil {
77
82
continue
78
83
}
@@ -83,11 +88,11 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
83
88
continue
84
89
}
85
90
86
- redact := strings .TrimSpace (strings .Replace (token , password , strings .Repeat ("*" , len (password )), - 1 ))
91
+ redact := strings .TrimSpace (strings .Replace (urlMatch , password , strings .Repeat ("*" , len (password )), - 1 ))
87
92
88
93
s := detectors.Result {
89
94
DetectorType : detectorspb .DetectorType_URI ,
90
- Raw : []byte (token ),
95
+ Raw : []byte (urlMatch ),
91
96
Redacted : redact ,
92
97
}
93
98
@@ -96,7 +101,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
96
101
// whitelist protocols
97
102
98
103
// Assume a 200 response is a valid credential
99
- postValues := map [string ]string {"protocol" : parsedURL .Scheme , "credentialed_uri" : token }
104
+ postValues := map [string ]string {"protocol" : parsedURL .Scheme , "credentialed_uri" : urlMatch }
100
105
jsonValue , _ := json .Marshal (postValues )
101
106
req , err := http .NewRequestWithContext (ctx , "POST" , ssrfProtectorURL , bytes .NewBuffer (jsonValue ))
102
107
if err != nil {
0 commit comments