-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix blacklistIPs JS configuration #1004
Conversation
Net.IPNet does not support JSON unmarshalling, causing the blacklistIPs configuration to fail when set through JS. Fixed by wrapping net.IPNet for the purpose of JSON unmarshalling. Fixes grafana#973
Codecov Report
@@ Coverage Diff @@
## master #1004 +/- ##
==========================================
- Coverage 72.31% 72.16% -0.16%
==========================================
Files 132 131 -1
Lines 9703 9635 -68
==========================================
- Hits 7017 6953 -64
+ Misses 2272 2268 -4
Partials 414 414
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1004 +/- ##
==========================================
- Coverage 72.31% 72.11% -0.21%
==========================================
Files 132 131 -1
Lines 9703 9640 -63
==========================================
- Hits 7017 6952 -65
+ Misses 2272 2271 -1
- Partials 414 417 +3
Continue to review full report at Codecov.
|
2 similar comments
Codecov Report
@@ Coverage Diff @@
## master #1004 +/- ##
==========================================
- Coverage 72.31% 72.11% -0.21%
==========================================
Files 132 131 -1
Lines 9703 9640 -63
==========================================
- Hits 7017 6952 -65
+ Misses 2272 2271 -1
- Partials 414 417 +3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1004 +/- ##
==========================================
- Coverage 72.31% 72.11% -0.21%
==========================================
Files 132 131 -1
Lines 9703 9640 -63
==========================================
- Hits 7017 6952 -65
+ Misses 2272 2271 -1
- Partials 414 417 +3
Continue to review full report at Codecov.
|
af2100f
to
9ec56c8
Compare
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.
Thanks very much for this PR.
It looks awesome and I just have a comment about the not using "ipnet" directly in ParseCIDR
.
I was also wondering if we shouldn't be a little bit more backwards compatible as previously ipnet was definitely marshallable and unmarshalable it was just very inconvenient. although I don't know if anyone has actually used it and whether it is worth it. @na-- ?
lib/options.go
Outdated
} | ||
|
||
return &IPNet{ | ||
IPNet: net.IPNet{ |
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.
Why is this not just ipnet
?
@mstoykov I'm not sure if we need to support the previous (unintentional) ways of encoding and decoding values... I'm not sure if anyone used it, since this bug wasn't reported before I accidentally found it. And in the docs we clearly state that blacklisted IPs have the following JS config format: export let options = {
blacklistIPs: ["10.0.0.0/8"]
}; So that was definitely a bug. My only concern is that someone could have used the CLI {
// ...
blacklistIPs: [
{"IP":"10.0.0.0","Mask":"/wAAAA=="}
],
//...
} Which could have actually worked: https://play.golang.org/p/ZHq6_Rs6YsZ |
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.
Thanks for this fix, LGTM, besides that minor simplification of having IPNet
be directly type IPNet net.IPNet
.
As mentioned in the main thread, we might have to expand the UnmarshalJSON()
function a little, to support both strings like "10.0.0.0/8"
and JS objects like {"IP":"10.0.0.0","Mask":"/wAAAA=="}
, if it turns out that a lot of users used the --blacklist-ip
CLI flag before this. However, I think we can do that in a separate PR later, after we find out how many users used this in the cloud execution.
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.
LGTM
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.
LGTM
Net.IPNet does not support JSON unmarshalling, causing the blacklistIPs
configuration to fail when set through JS.
Fixed by wrapping net.IPNet for the purpose of JSON unmarshalling.
Fixes #973