Skip to content

Commit

Permalink
chore: linting
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Rulleau <[email protected]>
  • Loading branch information
Leiyks committed Dec 11, 2024
1 parent 3a0d934 commit ef44aac
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 30 deletions.
9 changes: 3 additions & 6 deletions src/DDTrace/Integrations/Symfony/SymfonyIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ function ($This, $scope, $args) {

$commandName = $this->getName();

if (
\dd_trace_env_config('DD_TRACE_REMOVE_ROOT_SPAN_SYMFONY_MESSENGER')
if (\dd_trace_env_config('DD_TRACE_REMOVE_ROOT_SPAN_SYMFONY_MESSENGER')
&& $commandName === 'messenger:consume'
) {
\DDTrace\set_priority_sampling(DD_TRACE_PRIORITY_SAMPLING_AUTO_REJECT);
Expand Down Expand Up @@ -400,11 +399,9 @@ function (SpanData $span, $args, $response) use ($integration) {
}

$parameters = $request->get('_route_params');
if (
!empty($parameters) &&
if (!empty($parameters) &&
is_array($parameters) &&
function_exists('\datadog\appsec\push_address')
) {
function_exists('\datadog\appsec\push_address')) {
\datadog\appsec\push_address("server.request.path_params", $parameters);
}

Expand Down
7 changes: 2 additions & 5 deletions src/DDTrace/Integrations/WordPress/WordPressIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ public function init(): int

\DDTrace\hook_method('WP', 'main', null, function ($This, $scope, $args) {
if (\property_exists($This, 'did_permalink') && $This->did_permalink === true) {
if (
function_exists('\datadog\appsec\push_address') &&
if (function_exists('\datadog\appsec\push_address') &&
\property_exists($This, 'query_vars') &&
function_exists('is_404') && is_404() === false
) {
function_exists('is_404') && is_404() === false) {
$parameters = $This->query_vars;
if (count($parameters) > 0) {
\datadog\appsec\push_address("server.request.path_params", $parameters);
Expand All @@ -75,7 +73,6 @@ function ($args, $retval) {
$userClass = '\WP_User';

$username = null;

if (isset($args[0])) {
$username = $args[0];
}
Expand Down
22 changes: 9 additions & 13 deletions tests/Appsec/Mock.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace datadog\appsec;

if (!class_exists('datadog\appsec\AppsecStatus')) {
class AppsecStatus
{
class AppsecStatus {

private static $instance = null;
private $connection;

protected function __construct() {}
protected function __construct() {
}

public static function getInstance()
{
Expand All @@ -31,8 +31,8 @@ protected function getDbPdo()
}

/**
* Not all test are interested on events but frameworks are instrumented so this check is to avoid errors
*/
* Not all test are interested on events but frameworks are instrumented so this check is to avoid errors
*/
private function initiated()
{
return $this->getDbPdo()
Expand Down Expand Up @@ -75,10 +75,8 @@ public function getEvents(array $names = [], array $addresses = [])

foreach ($events as $event) {
$new = json_decode($event['event'], true);
if (
empty($names) || in_array($new['eventName'], $names) &&
(empty($addresses) || !empty(array_intersect($addresses, array_keys($new))))
) {
if (empty($names) || in_array($new['eventName'], $names) &&
(empty($addresses) || !empty(array_intersect($addresses, array_keys($new))))) {
$result[] = $new;
}
}
Expand All @@ -89,8 +87,7 @@ public function getEvents(array $names = [], array $addresses = [])
}

if (!function_exists('datadog\appsec\appsecMockEnabled')) {
function appsecMockEnabled()
{
function appsecMockEnabled() {
return getenv('APPSEC_MOCK_ENABLED') === "true";
}
}
Expand Down Expand Up @@ -212,8 +209,7 @@ function track_user_signup_event($userId, $metadata)
* This function is exposed by appsec but here we are mocking it for tests
* @param array $params
*/
function push_address($key, $value)
{
function push_address($key, $value) {
if (!appsecMockEnabled()) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Integrations/Laravel/AutomatedLoginEventsTestSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ protected function ddSetUp()
protected function login($email)
{
$this->call(
GetSpec::create('Login success event', '/login/auth?email=' . $email)
GetSpec::create('Login success event', '/login/auth?email='.$email)
);
}

protected function createUser($id, $name, $email)
{
//Password is password
$this->connection()->exec("insert into users (id, name, email, password) VALUES (" . $id . ", '" . $name . "', '" . $email . "', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi')");
$this->connection()->exec("insert into users (id, name, email, password) VALUES (".$id.", '".$name."', '".$email."', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi')");
}

public function testUserLoginSuccessEvent()
Expand Down Expand Up @@ -73,7 +73,7 @@ public function testUserSignUp()
GetSpec::create('Signup', sprintf('/login/signup?email=%s&name=%s&password=%s', $email, $name, $password))
);

$users = $this->connection()->query("SELECT * FROM users where email='" . $email . "'")->fetchAll();
$users = $this->connection()->query("SELECT * FROM users where email='".$email."'")->fetchAll();

$this->assertEquals(1, count($users));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testUserLoginSuccessEvent()
$name = 'some name';
//Password is test
$this->connection()->exec(
'INSERT INTO ' . $this->users_table . ' VALUES (' . $id . ',"test","$P$BDzpK1XXL9P2cYWggPMUbN87GQSiI80","test","' . $email . '","","2020-10-22 16:31:15","",0,"' . $name . '")'
'INSERT INTO '.$this->users_table.' VALUES ('.$id.',"test","$P$BDzpK1XXL9P2cYWggPMUbN87GQSiI80","test","'.$email.'","","2020-10-22 16:31:15","",0,"'.$name.'")'
);

$spec = PostSpec::create('request', '/wp-login.php', [
Expand Down Expand Up @@ -71,7 +71,7 @@ public function testUserLoginFailureEventWhenUserDoesExists()
$name = 'some name';
//Password is test
$this->connection()->exec(
'INSERT INTO ' . $this->users_table . ' VALUES (' . $id . ',"test","$P$BDzpK1XXL9P2cYWggPMUbN87GQSiI80","test","' . $email . '","","2020-10-22 16:31:15","",0,"' . $name . '")'
'INSERT INTO '.$this->users_table.' VALUES ('.$id.',"test","$P$BDzpK1XXL9P2cYWggPMUbN87GQSiI80","test","'.$email.'","","2020-10-22 16:31:15","",0,"'.$name.'")'
);

$spec = PostSpec::create('request', '/wp-login.php', [
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testUserSignUp()
], "user_login=$username&user_email=$email&wp-submit=Register&redirect_to=")
);

$users = $this->connection()->query("SELECT * FROM " . $this->users_table . " where user_email='" . $email . "'")->fetchAll();
$users = $this->connection()->query("SELECT * FROM ".$this->users_table." where user_email='".$email."'")->fetchAll();

$this->assertEquals(1, count($users));

Expand Down

0 comments on commit ef44aac

Please sign in to comment.