Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
dbd9bbfd
Commit
dbd9bbfd
authored
Sep 23, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve raven header blacklisting
parent
0a5245e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
15 deletions
+47
-15
internal/helper/raven.go
internal/helper/raven.go
+12
-4
main.go
main.go
+0
-11
raven.go
raven.go
+35
-0
No files found.
internal/helper/raven.go
View file @
dbd9bbfd
...
...
@@ -3,11 +3,15 @@ package helper
import
(
"net/http"
"reflect"
"strings"
"github.com/getsentry/raven-go"
)
var
ravenHeaderBlacklist
=
[]
string
{
"Authorization"
,
"Private-Token"
,
}
func
captureRavenError
(
r
*
http
.
Request
,
err
error
)
{
client
:=
raven
.
DefaultClient
...
...
@@ -29,9 +33,13 @@ func captureRavenError(r *http.Request, err error) {
}
func
CleanHeadersForRaven
(
r
*
http
.
Request
)
{
if
auth
:=
r
.
Header
.
Get
(
"Authorization"
);
auth
!=
""
{
if
authSplit
:=
strings
.
Split
(
auth
,
" "
);
authSplit
!=
nil
{
r
.
Header
.
Set
(
"Authorization"
,
authSplit
[
0
]
+
" [redacted]"
)
if
r
==
nil
{
return
}
for
_
,
key
:=
range
ravenHeaderBlacklist
{
if
r
.
Header
.
Get
(
key
)
!=
""
{
r
.
Header
.
Set
(
key
,
"[redacted]"
)
}
}
}
main.go
View file @
dbd9bbfd
...
...
@@ -25,8 +25,6 @@ import (
"time"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/upstream"
"github.com/getsentry/raven-go"
)
// Current version of GitLab Workhorse
...
...
@@ -91,11 +89,6 @@ func main() {
}()
}
// Use a custom environment variable (not SENTRY_DSN) to prevent
// clashes with gitlab-rails.
raven
.
SetDSN
(
os
.
Getenv
(
"GITLAB_WORKHORSE_SENTRY_DSN"
))
raven
.
DefaultClient
.
SetRelease
(
Version
)
up
:=
wrapRaven
(
upstream
.
NewUpstream
(
backendURL
,
...
...
@@ -109,7 +102,3 @@ func main() {
log
.
Fatal
(
http
.
Serve
(
listener
,
up
))
}
func
wrapRaven
(
h
http
.
Handler
)
http
.
Handler
{
return
http
.
HandlerFunc
(
raven
.
RecoveryHandler
(
h
.
ServeHTTP
))
}
raven.go
0 → 100644
View file @
dbd9bbfd
package
main
import
(
"net/http"
"os"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"github.com/getsentry/raven-go"
)
func
wrapRaven
(
h
http
.
Handler
)
http
.
Handler
{
// Use a custom environment variable (not SENTRY_DSN) to prevent
// clashes with gitlab-rails.
sentryDSN
:=
os
.
Getenv
(
"GITLAB_WORKHORSE_SENTRY_DSN"
)
raven
.
SetDSN
(
sentryDSN
)
// sentryDSN may be empty
if
sentryDSN
==
""
{
return
h
}
raven
.
DefaultClient
.
SetRelease
(
Version
)
return
http
.
HandlerFunc
(
raven
.
RecoveryHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
defer
func
()
{
if
p
:=
recover
();
p
!=
nil
{
helper
.
CleanHeadersForRaven
(
r
)
panic
(
p
)
}
}()
h
.
ServeHTTP
(
w
,
r
)
}))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment