Skip to content

Commit 5c44475

Browse files
authored
fix: perform tls verification by default (#219)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 09b5067 commit 5c44475

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

output/webhook/options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ func WithLogger(logger plugin.Logger) WebhookOptionFunc {
2828
}
2929

3030
// WithUrl specifies the webhook URL
31-
func WithUrl(url string) WebhookOptionFunc {
31+
func WithUrl(url string, skipVerify bool) WebhookOptionFunc {
3232
return func(o *WebhookOutput) {
3333
o.url = url
34+
o.skipVerify = skipVerify
3435
}
3536
}
3637

output/webhook/plugin.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ import (
2020
)
2121

2222
var cmdlineOptions struct {
23-
format string
24-
url string
25-
username string
26-
password string
23+
format string
24+
url string
25+
username string
26+
password string
27+
skipVerify bool
2728
}
2829

2930
func init() {
@@ -48,6 +49,13 @@ func init() {
4849
DefaultValue: "http://localhost:3000",
4950
Dest: &(cmdlineOptions.url),
5051
},
52+
{
53+
Name: "tls-skip-verify",
54+
Type: plugin.PluginOptionTypeBool,
55+
Description: "skip tls verification (for self-signed certs)",
56+
DefaultValue: false,
57+
Dest: &(cmdlineOptions.skipVerify),
58+
},
5159
{
5260
Name: "username",
5361
Type: plugin.PluginOptionTypeString,
@@ -72,7 +80,7 @@ func NewFromCmdlineOptions() plugin.Plugin {
7280
WithLogger(
7381
logging.GetLogger().With("plugin", "output.webhook"),
7482
),
75-
WithUrl(cmdlineOptions.url),
83+
WithUrl(cmdlineOptions.url, cmdlineOptions.skipVerify),
7684
WithBasicAuth(cmdlineOptions.username, cmdlineOptions.password),
7785
WithFormat(cmdlineOptions.format),
7886
)

output/webhook/webhook.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,23 @@ const (
4141
)
4242

4343
type WebhookOutput struct {
44-
errorChan chan error
45-
eventChan chan event.Event
46-
logger plugin.Logger
47-
format string
48-
url string
49-
username string
50-
password string
44+
errorChan chan error
45+
eventChan chan event.Event
46+
logger plugin.Logger
47+
format string
48+
url string
49+
username string
50+
password string
51+
skipVerify bool
5152
}
5253

5354
func New(options ...WebhookOptionFunc) *WebhookOutput {
5455
w := &WebhookOutput{
55-
errorChan: make(chan error),
56-
eventChan: make(chan event.Event, 10),
57-
format: "adder",
58-
url: "http://localhost:3000",
56+
errorChan: make(chan error),
57+
eventChan: make(chan event.Event, 10),
58+
format: "adder",
59+
url: "http://localhost:3000",
60+
skipVerify: false,
5961
}
6062
for _, option := range options {
6163
option(w)
@@ -270,7 +272,7 @@ func (w *WebhookOutput) SendWebhook(e *event.Event) error {
270272
IdleConnTimeout: defaultTransport.IdleConnTimeout,
271273
ExpectContinueTimeout: defaultTransport.ExpectContinueTimeout,
272274
TLSHandshakeTimeout: defaultTransport.TLSHandshakeTimeout,
273-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
275+
TLSClientConfig: &tls.Config{InsecureSkipVerify: w.skipVerify},
274276
}
275277
client := &http.Client{Transport: customTransport}
276278
// Send payload

0 commit comments

Comments
 (0)