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

add path_prefix_from_file option, adding security by obscurity. This … #5541

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tensorboard/plugins/core/core_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,18 @@ def define_flags(self, parser):
optional and has no effect. The path_prefix can be leveraged for path
based routing of an ELB when the website base_url is not available e.g.
"example.site.com/path/to/tensorboard/".\
""",
)

parser.add_argument(
"--path_prefix_from_file",
metavar="PATH",
type=str,
default="",
help="""\
Read the path_prefix from the specified file; avoids the path being
visible by ps or top - and, thus, is useful to improve security on
multi-user systems.\
""",
)

Expand Down Expand Up @@ -711,6 +723,16 @@ def fix_flags(self, flags):
"--detect_file_replacement=true"
)

if flags.path_prefix_from_file and flags.path_prefix is None:
try:
with open(flags.path_prefix_from_file, 'r') as f:
flags.path_prefix = (f.read()).rstrip()
print("NOTE: using path_prefix=" + flags.path_prefix + " as read from file")
except IOError:
raise FlagsError("Cannot read prefix_from_file")
elif:
print("NOTE: Skipping prefix_from_file input due to overwrite by path_prefix")

flags.path_prefix = flags.path_prefix.rstrip("/")
if flags.path_prefix and not flags.path_prefix.startswith("/"):
raise FlagsError(
Expand Down