Issues (36)

Security Analysis    no request data  

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/NewsController.php (1 issue)

Labels
Severity

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 FaithGen\News\Http\Controllers;
4
5
use FaithGen\News\Http\Requests\CommentRequest;
6
use FaithGen\News\Http\Requests\CreateRequest;
7
use FaithGen\News\Http\Requests\GetRequest;
8
use FaithGen\News\Http\Requests\UpdateImageRequest;
9
use FaithGen\News\Http\Requests\UpdateRequest;
10
use FaithGen\News\Http\Resources\Lists\News as ListResource;
11
use FaithGen\News\Http\Resources\News as NewsResource;
12
use FaithGen\News\Jobs\MessageFollowers;
13
use FaithGen\News\Jobs\ProcessImage;
14
use FaithGen\News\Jobs\S3Upload;
15
use FaithGen\News\Jobs\UploadImage;
16
use FaithGen\News\Models\News;
17
use FaithGen\News\Services\NewsService;
18
use FaithGen\SDK\Helpers\CommentHelper;
19
use FaithGen\SDK\Http\Requests\IndexRequest;
20
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
21
use Illuminate\Foundation\Bus\DispatchesJobs;
22
use Illuminate\Foundation\Validation\ValidatesRequests;
23
use Illuminate\Http\Request;
24
use Illuminate\Routing\Controller;
25
use InnoFlash\LaraStart\Helper;
26
use InnoFlash\LaraStart\Traits\APIResponses;
27
28
class NewsController extends Controller
29
{
30
    use AuthorizesRequests, ValidatesRequests, APIResponses, DispatchesJobs;
31
    /**
32
     * @var NewsService
33
     */
34
    private $newsService;
35
36
    public function __construct(NewsService $newsService)
37
    {
38
        $this->newsService = $newsService;
39
    }
40
41
    /**
42
     * Lists news items.
43
     *
44
     * @param IndexRequest $request
45
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
46
     */
47
    public function index(IndexRequest $request)
48
    {
49
        $news = auth()->user()->news()
50
            ->latest()
51
            ->where(fn ($news) => $news->search(['title', 'created_at'], $request->filter_text))
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_DOUBLE_ARROW, expecting ',' or ')'
Loading history...
52
            ->with(['image'])
53
            ->exclude(['news'])
54
            ->paginate(Helper::getLimit($request));
55
56
        ListResource::wrap('news');
57
58
        return ListResource::collection($news);
59
    }
60
61
    /**
62
     * Creates news article.
63
     *
64
     * @param CreateRequest $request
65
     * @return \Illuminate\Http\JsonResponse
66
     */
67
    public function create(CreateRequest $request)
68
    {
69
        return $this->newsService->createFromParent($request->validated(), 'Article created successfully!');
70
    }
71
72
    /**
73
     * Fetches an article.
74
     *
75
     * @param News $news
76
     * @return NewsResource
77
     * @throws \Illuminate\Auth\Access\AuthorizationException
78
     */
79
    public function view(News $news)
80
    {
81
        $this->authorize('view', $news);
82
83
        NewsResource::withoutWrapping();
84
85
        return new NewsResource($news);
86
    }
87
88
    /**
89
     * Delete a news article.
90
     *
91
     * @param GetRequest $request
92
     * @return mixed
93
     */
94
    public function delete(GetRequest $request)
95
    {
96
        return $this->newsService->destroy('News article deleted');
97
    }
98
99
    /**
100
     * Update an article.
101
     *
102
     * @param UpdateRequest $request
103
     * @return \Illuminate\Http\JsonResponse|mixed
104
     */
105
    public function update(UpdateRequest $request)
106
    {
107
        return $this->newsService->update($request->validated(), 'News updated successfully');
108
    }
109
110
    /**
111
     * Update news picture.
112
     *
113
     * @param UpdateImageRequest $request
114
     * @return mixed
115
     */
116
    public function updatePicture(UpdateImageRequest $request)
117
    {
118
        $this->newsService->deleteFiles($this->newsService->getNews());
119
        try {
120
            MessageFollowers::withChain([
121
                new UploadImage($this->newsService->getNews(), $request->image),
122
                new ProcessImage($this->newsService->getNews()),
123
                new S3Upload($this->newsService->getNews()),
124
            ])->dispatch($this->newsService->getNews());
125
126
            return $this->successResponse('News banner updated successfully!');
127
        } catch (\Exception $e) {
128
            abort(500, $e->getMessage());
129
        }
130
    }
131
132
    /**
133
     * Comments an article.
134
     *
135
     * @param CommentRequest $request
136
     * @return \Illuminate\Http\JsonResponse
137
     */
138
    public function comment(CommentRequest $request)
139
    {
140
        return CommentHelper::createComment($this->newsService->getNews(), $request);
141
    }
142
143
    /**
144
     * Gets article comments.
145
     *
146
     * @param Request $request
147
     * @param News $news
148
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
149
     * @throws \Illuminate\Auth\Access\AuthorizationException
150
     */
151
    public function comments(Request $request, News $news)
152
    {
153
        $this->authorize('view', $news);
154
155
        return CommentHelper::getComments($news, $request);
156
    }
157
}
158