-
Notifications
You must be signed in to change notification settings - Fork 32
Security changes whitelisting #22
base: master
Are you sure you want to change the base?
Changes from 7 commits
e0a0ac9
c8dde1b
64c0afc
e1b90a2
8d05ea4
796829f
616ff46
8d5061f
9b8b46f
cd02f9e
60cd81d
f7548f6
cb9f24b
1f1ba3b
34f71e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ influxdb: | |
# Acceptable version are: '0.8' and '0.9' | ||
version: '0.9' | ||
|
||
useWhitelistedKeys: false | ||
|
||
modules: | ||
# The modules just get require'd in, so they don't have to be in the Bucky project. | ||
|
@@ -36,3 +37,21 @@ modules: | |
# - ./modules/statsd | ||
# - ./modules/openTSDB | ||
# - ./modules/influxdb | ||
|
||
whitelistedKeys: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In trying to run this, it looks like this file is invalid YAML in this current form. I think you need to fix the indentation perhaps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uncommenting atleast 1 of the keys should fix that issue. This is similar to having to uncomment atleast 1 collectors. |
||
# Uncomment the keys that you'd like to whitelist | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A note here would be helpful. "The example below are timing metrics that Bucky includes by default. You will need to whitelist these if you use the default configuration of Bucky and enable whitelisting" |
||
# - file.page.navigationStart | ||
# - file.page.unloadEventStart | ||
# - file.page.unloadEventEnd | ||
# - file.page.fetchStart | ||
# - file.page.domainLookupStart | ||
# - file.page.domainLookupEnd | ||
# - file.page.connectStart | ||
# - file.page.connectEnd | ||
# - file.page.requestStart | ||
# - file.page.responseStart | ||
# - file.page.responseEnd | ||
# - file.page.domLoading | ||
# - file.page.domInteractive | ||
# - file.page.domContentLoadedEventStart | ||
# - file.page.toJSON |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,29 @@ _ = require 'underscore' | |
|
||
load = require "../lib/load" | ||
modules = require("config").modules | ||
useWhitelistedKeys = require("config").useWhitelistedKeys | ||
whitelistedkeys = '' | ||
|
||
module.exports = ({app, logger, config}, next) -> | ||
collectorHandler = (collectors) -> | ||
arrOfVals = [] | ||
return (req, res) -> | ||
res.send(204, '') | ||
if useWhitelistedKeys | ||
for fields of req.body | ||
if (arrOfVals.indexOf( fields ) == -1) | ||
arrOfVals.push( fields ) | ||
if arrayEqual(arrOfVals, whitelistedkeys) | ||
res.send(204, '') | ||
else | ||
res.send(406, '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably respond with a meaningful error message here. I'm also not sure if it wouldn't make sense to accept the keys which do match the whitelist, rather than returning an error, in the interest of being able to use the BuckyClient software which automatically generates keys. |
||
else | ||
res.send(204, '') | ||
|
||
for coll in collectors | ||
coll(req.body, {req, res}) | ||
|
||
logger.log "Loading collectors: #{ modules.collectors.join(', ') }" | ||
whitelistedkeys = "#{modules.whitelistedKeys}".split(',') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its a comma separated list. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The values are coming from the YAML parser as an array: https://github.com/HubSpot/BuckyServer/pull/22/files#diff-fe7044f2ecd69c76ce484ad03fabc12fR41 They will only become a comma separated list if you cast them into a string, as you're doing with the string interpolation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if I do modules.whitelistedKeys, the output I get is, [ [Getter/Setter], [Getter/Setter] ] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The console will log it like that, but if you try There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know. Changes done. |
||
|
||
collectors = {} | ||
collPromises = [] | ||
|
@@ -38,3 +51,6 @@ module.exports = ({app, logger, config}, next) -> | |
collector[path] = collectorHandler(hls) | ||
|
||
next collector | ||
|
||
arrayEqual = (a, b) -> | ||
a.length is b.length and a.every (elem, i) -> elem is b[i] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename this
onlyAcceptWhitelistedKeys
.