Issues (64)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Http/Controllers/GoogleAppsUsersController.php (10 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Acacha\Users\Http\Controllers;
4
5
use Acacha\Users\Services\GoogleApps\GoogleAppsService;
6
7
use Acacha\Users\Traits\HasPaginator;
8
use Google;
9
use Illuminate\Http\Request;
10
use Illuminate\Pagination\LengthAwarePaginator;
11
12
/**
13
 * Class GoogleAppsUsersController.
14
 *
15
 * @package Acacha\Users\Http\Controllers
16
 */
17
class GoogleAppsUsersController extends Controller
18
{
19
20
    use HasPaginator;
21
22
    /**
23
     * Google apps service.
24
     *
25
     * @var
26
     */
27
    public $service;
28
29
    /**
30
     * GoogleAppsUsersController constructor.
31
     *
32
     * @param $service
33
     */
34
    public function __construct(GoogleAppsService $service)
35
    {
36
        $this->service = $service;
37
    }
38
39
40
    /**
41
     * Show Google apps users.
42
     */
43
    public function index()
44
    {
45
        $this->authorize('see-google-apps-users');
46
        $data = [];
47
48
        return view('acacha_users::googleApps.google', $data);
49
    }
50
51
    /**
52
     * Sync local database from Google Apps/Suite data.
53
     */
54
    public function localSync(Request $request)
0 ignored issues
show
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
    {
56
        $this->authorize('sync-google-apps-users');
57
58
        return $this->service->localSync();
59
    }
60
61
    /**
62
     * List Google apps users.
63
     */
64
    public function all(Request $request)
65
    {
66
        $this->authorize('list-google-apps-users');
67
68
        $perPage = config('users.google_apps_users_per_page' , 15);
69
        if ($request->has('perPage')) {
70
            $perPage = $request->input('perPage');
71
        }
72
73
        $users = $this->service->getUsers($perPage);
74
75
        return $this->paginate($users, $perPage);
76
    }
77
78
    /**
79
     * Check google apps connection.
80
     *
81
     * @return array
82
     */
83
    public function check()
84
    {
85
        $this->authorize('check-google-apps-connection');
86
87
        return $this->service->getConnectionState();
88
    }
89
90
    public function google3()
91
    {
92
        $directory = Google::make('directory');
93
        dump($directory->users);
94
    }
95
96
    public function google5()
97
    {
98
        //List all users: https://developers.google.com/apps-script/advanced/admin-sdk-directory
99
100
//        page = AdminDirectory.Users.list({
101
//        domain: 'example.com',
102
//      orderBy: 'givenName',
103
//      maxResults: 100,
104
//      pageToken: pageToken
105
//    });
106
    }
107
108 View Code Duplication
    public function google4()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
109
    {
110
        //Example list 100 users
111
        $directory = Google::make('directory');
112
        dump(get_class($directory->users));
113
        dump($directory);
114
        try {
115
            $r = $directory->users->listUsers([
116
                'domain' => 'iesebre.com',
117
                'maxResults' => 500
118
            ]);
119
            dump($r);
120
        } catch (\Exception $e) {
121
            dd($e);
122
        }
123
    }
124
125 View Code Duplication
    public function google7()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
126
    {
127
        //Example list 500 users. max results maxim value is 500
128
        $directory = Google::make('directory');
129
        dump(get_class($directory->users));
130
        try {
131
            $r = $directory->users->listUsers([
132
                'domain' => 'iesebre.com',
133
                'maxResults' => 500
134
            ]);
135
            dump($r);
136
        } catch (\Exception $e) {
137
            dd($e);
138
        }
139
    }
140
141
    public function google8()
142
    {
143
        // Count total number of users
144
        $directory = Google::make('directory');
145
        $count = 0;
146
        $pageToken = null;
147 View Code Duplication
        do {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
148
            try {
149
                $r = $directory->users->listUsers([
150
                    'domain' => 'iesebre.com',
151
                    'maxResults' => 500,
152
                    'pageToken' => $pageToken
153
                ]);
154
                $pageToken = $r->nextPageToken;
155
//                dump($pageToken);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
156
//                dump($r);
157
//                dump($r->users);
158
                $count = $count + count($r->users);
159
                dump('count: ' . $count);
160
            } catch (\Exception $e) {
161
                dd($e);
162
            }
163
        } while ($pageToken);
164
165
        dd($count);
166
    }
167
168
    public function google10()
169
    {
170
        return $this->service->localSync();
171
    }
172
173
    public function esborrar()
174
    {
175
        $googleClient = Google::getClient();
0 ignored issues
show
$googleClient is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
176
//        dd($googleClient);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
177
        $directory = Google::make('directory');
178
//        dd($directory);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
179
180
        $email = "[email protected]";
181
        try {
182
            $r = $directory->users->get($email);
183
            if($r) {
184
                echo "Name: ".$r->name->fullName."<br/>";
185
                echo "Suspended?: ".(($r->suspended === true) ? 'Yes' : 'No')."<br/>";
186
                echo "Org/Unit/Path: ".$r->orgUnitPath."<br/>";
187
            } else {
188
                echo "User does not exist: $email<br/>";
189
            }
190
        } catch (\Exception $e) {
191
            dd('exception!!!');
192
        }
193
194
        // if the user doesn't exist, it's safe to create the new user
195
196
//        $user_to_impersonate = '[email protected]';
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
197
//        $scopes = array('https://www.googleapis.com/auth/admin.directory.user');
198
//        $cred = new Google_Auth_AssertionCredentials(
199
//            $service_account_name,
200
//            $scopes,
201
//            $key,
202
//            'notasecret', // Default P12 password
203
//            'http://oauth.net/grant_type/jwt/1.0/bearer', // Default grant type
204
//            $user_to_impersonate
205
//        );
206
207
//$dir = new Google_Service_Directory($client);
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
208
//$email = "[email protected]";
209
//$r = $dir->users->get($email);
210
//if($r) {
211
//    echo "Name: ".$r->name->fullName."<br/>";
212
//    echo "Suspended?: ".(($r->suspended === true) ? 'Yes' : 'No')."<br/>";
213
//    echo "Org/Unit/Path: ".$r->orgUnitPath."<br/>";
214
//} else {
215
//    echo "User does not exist: $email<br/>";
216
//    // if the user doesn't exist, it's safe to create the new user
217
//}
218
    }
219
220
}