Skip to content
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

Added ability to hide sensative logs #825

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions splash/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ def _write_expired_args(self, request, expired_args):
return self._write_error(request, 498, ex)

def _log_stats(self, request, options, error=None):

if self.hide_passed_json_and_lua_source:
if 'posted_json' in options:
del options['posted_json']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be hard-coding specific keys. I can see two ways of handling it:

  1. dont_log argument, which can disable logging of specific fields per-request (posted_json and lua_source in this case);
  2. --log-args 0 startup argument, which disables logging of args completely

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I didn't think this was necessarily the best way to go about it. I was more so trying to get the idea out and we can go from there.

--log-args 0 would be great as long as it only stops the logging of this startup/shutdown args and not stops the logging from within the script (e.x. print())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking --log-args 0 disables logs only for Splash arguments, nothing else - i.e. "args" value in the log you've pasted

if 'lua_source' in options:
del options['lua_source']

msg = {
# Anything we retrieve from Twisted request object contains bytes.
# We have to convert it to unicode first for json.dump to succeed.
Expand Down Expand Up @@ -280,6 +287,9 @@ def __init__(self, pool, sandboxed,
self.strict = strict
self.implicit_main = implicit_main

# This is hardcoded, but should be set via the command line arg. Not sure where that would be...
self.hide_passed_json_and_lua_source = True

def _get_render(self, request, options):
params = dict(
proxy=options.get_proxy(),
Expand Down
6 changes: 5 additions & 1 deletion splash/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def parse_opts(jupyter=False, argv=sys.argv):
help="print Splash version number and exit")

if not jupyter:
# This options are specific of splash server and not used in splash-jupyter
# These options are specific to splash server and not used in splash-jupyter
op.add_option("-p", "--port", type="int", default=defaults.SPLASH_PORT,
help="port to listen to (default: %default)")
op.add_option("-i", "--ip", type="string", default=defaults.SPLASH_IP,
Expand All @@ -82,6 +82,10 @@ def parse_opts(jupyter=False, argv=sys.argv):
op.add_option("--argument-cache-max-entries", type="int",
default=defaults.ARGUMENT_CACHE_MAX_ENTRIES,
help="maximum number of entries in arguments cache (default: %default)")
op.add_option("--hide_passed_json_and_lua_source",
action="store_true",
default=False,
help="Hides `posted_json` and `lua_source` from final logs. Added security measure as you're not logging passwords, emails, etc.")

opts, args = op.parse_args(argv)

Expand Down