@@ -120,23 +120,44 @@ func WithInsecureSkipVerify(b bool) Option {
120
120
}
121
121
122
122
// WithAllowlist sets the hostnames that we are allowed to connect to via
123
- // HTTP. Additionally, http response status metrics are tagged for each of
124
- // these hosts.
123
+ // HTTP.
125
124
func WithAllowlist (hosts []string ) Option {
126
125
return func (net * Network ) {
127
126
log .Infof ("HTTP retrieval allowlist: %s" , strings .Join (hosts , ", " ))
128
127
net .allowlist = make (map [string ]struct {})
129
128
for _ , h := range hosts {
129
+ h = strings .TrimSpace (h )
130
+ if h == "" {
131
+ log .Error ("empty string in allowlist. Ignoring..." )
132
+ continue
133
+ }
134
+ if strings .Contains (h , " " ) {
135
+ log .Errorf ("allowlist item '%s' contains a whitespace. Ignoring..." )
136
+ continue
137
+ }
138
+
130
139
net .allowlist [h ] = struct {}{}
131
140
}
132
141
}
133
142
}
134
143
144
+ // WithDenylist sets the hostnames that we are prohibited to connect to via
145
+ // HTTP.
135
146
func WithDenylist (hosts []string ) Option {
136
147
return func (net * Network ) {
137
148
log .Infof ("HTTP retrieval denylist: %s" , strings .Join (hosts , ", " ))
138
149
net .denylist = make (map [string ]struct {})
139
150
for _ , h := range hosts {
151
+ h = strings .TrimSpace (h )
152
+ if h == "" {
153
+ log .Error ("empty string in denylist. Ignoring..." )
154
+ continue
155
+ }
156
+ if strings .Contains (h , " " ) {
157
+ log .Errorf ("denylist item '%s' contains a whitespace. Ignoring..." )
158
+ continue
159
+ }
160
+
140
161
net .denylist [h ] = struct {}{}
141
162
}
142
163
}
0 commit comments