Mask the http target's destination URL in the UI (closes #115)
All checks were successful
check / check (push) Successful in 4m17s
All checks were successful
check / check (push) Successful in 4m17s
An http target's destination is frequently a Slack, Discord or Teams incoming-webhook endpoint whose path segments are the credential — the same property that made the Slack target's webhook URL a bearer token. The source detail page rendered it in full, so the leak closed for slack targets stayed reachable through a different target type. Render it through the existing MaskURL, which reduces a URL to scheme and host. The field accepts an arbitrary URL, so no path segment can be assumed non-secret and none is shown.
This commit is contained in:
@@ -131,6 +131,47 @@ func TestHandleSourceDetail_MasksSlackWebhookURL(t *testing.T) {
|
||||
assert.Contains(t, body, "https://hooks.slack.com/...")
|
||||
}
|
||||
|
||||
// TestHandleSourceDetail_MasksHTTPDestinationURL is the
|
||||
// regression test for the same leak reached through the http
|
||||
// target: its destination is routinely an incoming-webhook
|
||||
// endpoint whose path segments are the credential, so the
|
||||
// rendered page must not contain them.
|
||||
func TestHandleSourceDetail_MasksHTTPDestinationURL(
|
||||
t *testing.T,
|
||||
) {
|
||||
t.Parallel()
|
||||
|
||||
var (
|
||||
h *handlers.Handlers
|
||||
sess *session.Session
|
||||
db *database.Database
|
||||
)
|
||||
|
||||
app := newTestApp(t, &h, &sess, &db)
|
||||
app.RequireStart()
|
||||
|
||||
t.Cleanup(app.RequireStop)
|
||||
|
||||
wh := seedWebhook(t, db)
|
||||
seedConfiguredTarget(
|
||||
t, db, wh.ID,
|
||||
database.TargetTypeHTTP,
|
||||
`{"url":"`+slackWebhookURL+`"}`,
|
||||
)
|
||||
|
||||
body := renderSourceDetailPage(t, h, sess, wh.ID)
|
||||
|
||||
assert.NotContains(t, body, slackSecretPath)
|
||||
assert.NotContains(t, body, "T00000000")
|
||||
assert.NotContains(t, body, "B00000000")
|
||||
assert.NotContains(
|
||||
t, body, "XXXXXXXXXXXXXXXXXXXXXXXX",
|
||||
)
|
||||
|
||||
assert.Contains(t, body, "Destination URL")
|
||||
assert.Contains(t, body, "https://hooks.slack.com/...")
|
||||
}
|
||||
|
||||
// TestHandleSourceDetail_RendersNamedTargetFields proves the
|
||||
// other target types render labelled fields rather than the
|
||||
// stored blob.
|
||||
@@ -172,7 +213,7 @@ func TestHandleSourceDetail_RendersNamedTargetFields(
|
||||
body := renderSourceDetailPage(t, h, sess, wh.ID)
|
||||
|
||||
assert.Contains(t, body, "Destination URL")
|
||||
assert.Contains(t, body, "https://example.com/hook")
|
||||
assert.Contains(t, body, "https://example.com/...")
|
||||
assert.Contains(t, body, "Timeout")
|
||||
assert.Contains(t, body, "1 configured")
|
||||
assert.NotContains(t, body, "sekrit")
|
||||
|
||||
Reference in New Issue
Block a user