-
Notifications
You must be signed in to change notification settings - Fork 22
Fixes for security issues #61
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import subprocess, os, time, json,logging | ||
| import subprocess, os, time, json, logging, re | ||
| import psutil | ||
|
|
||
| from browserstack.local_binary import LocalBinary | ||
|
|
@@ -70,7 +70,16 @@ def start(self, **kwargs): | |
| del self.options['key'] | ||
|
|
||
| if 'binarypath' in self.options: | ||
| self.binary_path = self.options['binarypath'] | ||
| candidate = os.path.realpath(self.options['binarypath']) | ||
| if not os.path.isfile(candidate): | ||
| raise BrowserStackLocalError('binarypath does not point to a file') | ||
| try: | ||
| version_output = subprocess.check_output([candidate, '--version'], timeout=10).decode('utf-8') | ||
| except (subprocess.SubprocessError, OSError) as e: | ||
| raise BrowserStackLocalError('binarypath failed verification: {}'.format(e)) | ||
| if not re.match(LocalBinary.VERSION_REGEX, version_output): | ||
| raise BrowserStackLocalError('binarypath failed verification') | ||
| self.binary_path = candidate | ||
| del self.options['binarypath'] | ||
| else: | ||
| l = LocalBinary(self.key) | ||
|
|
@@ -90,10 +99,18 @@ def start(self, **kwargs): | |
| if 'source' in self.options: | ||
| del self.options['source'] | ||
|
|
||
| logfile_dir = os.path.dirname(self.local_logfile_path) | ||
|
Collaborator
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. This block truncates The truncation appears intended to clear stale output from a prior run — which it can't do here because by the time it runs, the current daemon has already written. This ordering is pre-existing (master had the same shape with Suggested fix: move the truncation up — right after Question: is the post-Popen position load-bearing for some reason? If not, recommend moving it up.
Collaborator
Author
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. fixed |
||
| if logfile_dir: | ||
| os.makedirs(logfile_dir, exist_ok=True) | ||
| try: | ||
| with open(self.local_logfile_path, 'w') as f: | ||
|
rounak610 marked this conversation as resolved.
|
||
| f.write('') | ||
| except OSError as e: | ||
| raise BrowserStackLocalError('Unable to open logfile: {}'.format(e)) | ||
|
|
||
| self.proc = subprocess.Popen(self._generate_cmd(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
| (out, err) = self.proc.communicate() | ||
|
|
||
| os.system('echo "" > "'+ self.local_logfile_path +'"') | ||
| try: | ||
| if out: | ||
| output_string = out.decode() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.