-
Notifications
You must be signed in to change notification settings - Fork 77
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
Updates deploy to build API #454
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0784a3f
Updated build command, keeping old methods available
Cawllec 1d5bfe4
Apply fixes from StyleCI (#453)
kattrali fefd5af
Added buildername to build parameters
Cawllec a4e4f5e
Merge branch 'cawllec/update-build-api' of github.com:bugsnag/bugsnag…
Cawllec 1615d68
Added deprecated tags, added provider tests
Cawllec f26f6a1
Apply fixes from StyleCI (#455)
kattrali 3c6537c
Added build-tool param
Cawllec caea76f
Merge branch 'cawllec/update-build-api' of github.com:bugsnag/bugsnag…
Cawllec 2216988
Changes to api
Cawllec a34a51c
Added check on exec function
Cawllec a996030
Apply fixes from StyleCI (#456)
kattrali f62133b
Improved user detection, created static utils to avoid class pollution
Cawllec 0277fe4
Merge branch 'cawllec/update-build-api' of github.com:bugsnag/bugsnag…
Cawllec b910c53
Apply fixes from StyleCI (#457)
kattrali a47ac7d
Fixed param err
Cawllec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Bugsnag; | ||
|
||
class Utils | ||
{ | ||
/** | ||
* Checks whether the given function name is available. | ||
* | ||
* @param string $func the function name | ||
* | ||
* @return bool | ||
*/ | ||
public static function functionAvailable($func) | ||
{ | ||
$disabled = explode(',', ini_get('disable_functions')); | ||
|
||
return function_exists($func) && !in_array($func, $disabled); | ||
} | ||
|
||
/** | ||
* Gets the current user's identity for build reporting. | ||
* | ||
* @return string | ||
*/ | ||
public static function getBuilderName() | ||
{ | ||
$builderName = null; | ||
if (self::functionAvailable('exec')) { | ||
$output = []; | ||
$success = 0; | ||
exec('whoami', $output, $success); | ||
if ($success == 0) { | ||
$builderName = $output[0]; | ||
} | ||
} | ||
if (is_null($builderName)) { | ||
$builderName = get_current_user(); | ||
} | ||
|
||
return $builderName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 should default to
whoami
or a php cross platform equivalent.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 don't think we want to add shell calls in the base notifier, it's much safer to use wrapped commands in higher level libs.
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 not? If this isnt automated very few people will set it.
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.
You probably want:
get_current_user();
instead of shell executing
whoami
. That function will give you the owner of the file, which is maybe better than nothing.Something you could do if the user has installed and not disabled the functions from posix extension, is:
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.
whoami
works across all windows post server-2003 & unix-like systems. I'll add a check on the response to see if it returned correctly and fallback toget_current_user
if not.