Issues (13)

Security Analysis    not enabled

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

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/DashboardController.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace agoalofalife\postman\Http\Controllers;
4
5
use agoalofalife\postman\Http\Requests\TaskRequest;
6
use agoalofalife\postman\Models\Email;
7
use agoalofalife\postman\Models\EmailUser;
8
use agoalofalife\postman\Models\ModePostEmail;
9
use agoalofalife\postman\Models\SheduleEmail;
10
use agoalofalife\postman\Models\Status;
11
use agoalofalife\postman\Models\User;
12
use Illuminate\Http\JsonResponse;
13
use Illuminate\Http\Request;
14
use Illuminate\Support\Collection;
15
16
class DashboardController
17
{
18
    /**
19
     * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|static[] | void
20
     */
21 1
    public function index() : Collection
22
    {
23 1
        return SheduleEmail::with(['email.users', 'mode', 'status'])->get();
24
    }
25
26
    /**
27
     * Get list modes
28
     * @return JsonResponse
29
     */
30 1
    public function listMode() : JsonResponse
31
    {
32 1
        return response()->json(ModePostEmail::all());
0 ignored issues
show
The method json() does not exist on Symfony\Component\HttpFoundation\Response. It seems like you code against a sub-type of Symfony\Component\HttpFoundation\Response such as Illuminate\Http\Response or Illuminate\Http\JsonResponse or Illuminate\Http\RedirectResponse. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        return response()->/** @scrutinizer ignore-call */ json(ModePostEmail::all());
Loading history...
33
    }
34
35
    /**
36
     * @return JsonResponse
37
     */
38 1
    public function users() : JsonResponse
39
    {
40 1
        return response()->json(User::all());
41
    }
42
43
    /**
44
     * @return JsonResponse
45
     */
46 1
    public function statuses() : JsonResponse
47
    {
48 1
        return response()->json(Status::all());
49
    }
50
51
    /**
52
     * Get table column
53
     * @return \Illuminate\Http\JsonResponse
54
     */
55 1
    public function tableColumn() : JsonResponse
56
    {
57 1
        $response = [];
58
59 1
        foreach (config('postman.ui.table') as $column => $size) {
60 1
            $response['columns'][] = [
61 1
                'prop' => $column,
62 1
                'size' => $size,
63 1
                'label' => trans("postman::dashboard.{$column}")
64
            ];
65
        }
66
        
67 1
        $response['button'] = [
68 1
            'edit' => trans('postman::dashboard.button.edit'),
69 1
            'remove' => trans('postman::dashboard.button.remove'),
70
        ];
71
72 1
        return response()->json($response);
73
    }
74
75
    /**
76
     * Base this is text for form
77
     * @return \Illuminate\Http\JsonResponse
78
     */
79 1
    public function formColumn()
80
    {
81
        $forms = [
82 1
           'date' =>  [
83 1
                'label' => trans('postman::dashboard.date'),
84
                'rule' => [
85
                    'required'=> true, 'message'=> 'Please input Activity name', 'trigger'=> 'blur',
86
                ]
87
            ],
88
            'theme' => [
89 1
                'label' => trans('postman::dashboard.email.theme'),
90
            ],
91
            'text' => [
92 1
                'label' => trans('postman::dashboard.email.text'),
93
            ],
94
            'type' => [
95 1
                'label' => trans('postman::dashboard.mode.name'),
96 1
                'placeholder' => trans('postman::dashboard.mode.placeholder'),
97
            ],
98
            'users' => [
99 1
                'label' => trans('postman::dashboard.users.name'),
100 1
                'placeholder' => trans('postman::dashboard.users.placeholder'),
101
            ],
102
           'statuses' => [
103 1
               'label' => trans('postman::dashboard.statuses.name'),
104 1
               'placeholder' => trans('postman::dashboard.statuses.placeholder'),
105
           ],
106
            'button' => [
107 1
                'success' => trans('postman::dashboard.form.button.success'),
108 1
                'cancel' => trans('postman::dashboard.form.button.cancel'),
109
            ],
110
            'popup' => [
111 1
              'question' => trans('postman::dashboard.popup.question'),
112 1
              'title' => trans('postman::dashboard.popup.title'),
113 1
              'confirmButtonText' => trans('postman::dashboard.popup.confirmButtonText'),
114 1
              'cancelButtonText' => trans('postman::dashboard.popup.cancelButtonText'),
115 1
              'success.message' => trans('postman::dashboard.popup.success.message'),
116 1
              'info.message' => trans('postman::dashboard.popup.info.message'),
117
            ],
118
        ];
119
120 1
        return response()->json($forms);
121
    }
122
123
    /**
124
     * @param TaskRequest $request
125
     * @return \Illuminate\Http\JsonResponse
126
     */
127 1
    public function createTask(TaskRequest $request)
128
    {
129 1
        $request->datePostman($request);
0 ignored issues
show
The method datePostman() does not exist on agoalofalife\postman\Http\Requests\TaskRequest. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

129
        $request->/** @scrutinizer ignore-call */ 
130
                  datePostman($request);
Loading history...
130
131 1
        $email = Email::create([
132 1
            'theme' => $request->theme,
133 1
            'text' => $request->text,
134
        ]);
135
136 1
        array_map(function($user_id) use($email) {
137 1
            EmailUser::create([
138 1
                'user_id' => $user_id,
139 1
                'email_id' => $email->id,
140
            ]);
141 1
        }, $request->users);
142
143 1
        $email->tasks()->create([
144 1
            'date' => $request->date,
145 1
            'mode_id' => $request->mode,
146 1
            'status_id' => $request->statuses
147
        ]);
148
149 1
        return response()->json(['status' => true]);
150
    }
151
152
    /**
153
     * Update task
154
     * @param TaskRequest $request
155
     * @return \Illuminate\Http\JsonResponse
156
     */
157 1
    public function updateTask(TaskRequest $request)
158
    {
159 1
        $request->datePostman($request);
160 1
        $task = SheduleEmail::find($request->id);
161
162 1
        $task->update([
163 1
            'mode_id' => $request->mode,
164 1
            'date' => $request->date,
165 1
            'status_id' => $request->statuses,
166
        ]);
167
168 1
        $task->email->update([
169 1
            'theme' => $request->theme,
170 1
            'text' => $request->text,
171
        ]);
172
173 1
        $goalList = EmailUser::where('email_id', $task->email->id);
174 1
        $removal  = $goalList->get()->pluck('user_id')->diff($request->users)->values();
175 1
        $goalList->whereIn('user_id', $removal)->delete();
176
177 1
        collect($request->users)->each(function($user_id) use($task, &$usersToEmail) {
178 1
            EmailUser::firstOrCreate(['email_id' => $task->email->id, 'user_id' => $user_id]);
179 1
        });
180 1
        return response()->json(['status' => true]);
181
    }
182
    /**
183
     * @param $id
184
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
185
     */
186 1
    public function remove($id)
187
    {
188 1
        SheduleEmail::destroy($id);
189 1
        return response()->json(true);
190
    }
191
}