-
Notifications
You must be signed in to change notification settings - Fork 318
Fix Mongo Query Sanitizing #152
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
Conversation
e6a9dce to
1e0d1e2
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.
I'd like some extra eyes on this section in particular. I ported over the behavior the instrumentation was attempting to apply, but I'm not 100% sure if the span tags are correct.
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.
Looks ok to me.
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.
Actually we need to set the service name somewhere:
span.setTag(DDTags.SERVICE_NAME, "mongo");
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 think we want to use mongo.query as the operation name.
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.
The method call to errorLogs can be replaced with:
span.log(Collections.singletonMap("error.object", throwable));
9d36973 to
c5c426a
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.
This kind of scares me a little... unbounded cache that relies on the behavior below for removal. What do you think @realark?
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'm okay with it because the monog CommandListener api guarantees the started event will generate a failed/success event.
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.
In other words, the mongo java driver itself would have to be buggy for the map to leak. We're not relying on good user code.
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 believe this method is no longer used and can be deleted.
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.
Yes we've to
tylerbenson
left a comment
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.
Once that unused method is deleted, I'm ok with this being merged.
palazzem
left a comment
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 think we should address Tyler's comments, especially unbounded cache issue
c5c426a to
b85b9b0
Compare
|
@palazzem I think the cache is ok for now since it was already being done that way with the existing mongo instrumentation. Certainly something we can look at in the future though. |
This fixes the bug which was capturing raw mongo queries with sensitive information.
The root cause was the byteman instrumentation was attempting to use a patched version of the TracingCommandListener. However, it was unable to do the bytecode patching because that class is not on the runtime classpath (because it is a dependency).
The fix is to create a new class, DDTracingCommandListener, inside of MongoHelper with the desired behavior. This is mostly the code from opentracing's TracingCommandListener. I will leave comments in sections where this PR will cause change.
In addition to the new unit tests, manual testing was done with the dropwizard-mongo sample app.