Issues (38)

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/ErrorPage/ErrorPageViewModel.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 Facade\Ignition\ErrorPage;
4
5
use Closure;
6
use Exception;
7
use Facade\FlareClient\Report;
8
use Facade\Ignition\Ignition;
9
use Facade\Ignition\IgnitionConfig;
10
use Facade\Ignition\Solutions\SolutionTransformer;
11
use Illuminate\Contracts\Support\Arrayable;
12
use Laravel\Telescope\Http\Controllers\HomeController;
13
use Laravel\Telescope\IncomingExceptionEntry;
14
use Laravel\Telescope\Telescope;
15
use Throwable;
16
17
class ErrorPageViewModel implements Arrayable
18
{
19
    /** @var \Throwable|null */
20
    protected $throwable;
21
22
    /** @var array */
23
    protected $solutions;
24
25
    /** @var \Facade\Ignition\IgnitionConfig */
26
    protected $ignitionConfig;
27
28
    /** @var \Facade\FlareClient\Report */
29
    protected $report;
30
31
    /** @var string */
32
    protected $defaultTab;
33
34
    /** @var array */
35
    protected $defaultTabProps = [];
36
37
    public function __construct(?Throwable $throwable, IgnitionConfig $ignitionConfig, Report $report, array $solutions)
38
    {
39
        $this->throwable = $throwable;
40
41
        $this->ignitionConfig = $ignitionConfig;
42
43
        $this->report = $report;
44
45
        $this->solutions = $solutions;
46
    }
47
48
    public function throwableString(): string
49
    {
50
        if (! $this->throwable) {
51
            return '';
52
        }
53
54
        return sprintf(
55
            "%s: %s in file %s on line %d\n\n%s\n",
56
            get_class($this->throwable),
57
            $this->throwable->getMessage(),
58
            $this->throwable->getFile(),
59
            $this->throwable->getLine(),
60
            $this->report->getThrowable()->getTraceAsString()
61
        );
62
    }
63
64
    public function telescopeUrl(): ?string
65
    {
66
        try {
67
            if (! class_exists(Telescope::class)) {
68
                return null;
69
            }
70
71
            if (! count(Telescope::$entriesQueue)) {
72
                return null;
73
            }
74
75
            $telescopeEntry = collect(Telescope::$entriesQueue)->first(function ($entry) {
76
                return $entry instanceof IncomingExceptionEntry;
0 ignored issues
show
The class Laravel\Telescope\IncomingExceptionEntry does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
77
            });
78
79
            if (is_null($telescopeEntry)) {
80
                return null;
81
            }
82
83
            $telescopeEntryId = (string) $telescopeEntry->uuid;
84
85
            return url(action([HomeController::class, 'index'])."/exceptions/{$telescopeEntryId}");
86
        } catch (Exception $exception) {
87
            return null;
88
        }
89
    }
90
91
    public function title(): string
92
    {
93
        return "🧨 {$this->report->getMessage()}";
94
    }
95
96
    public function config(): array
97
    {
98
        return $this->ignitionConfig->toArray();
99
    }
100
101
    public function solutions(): array
102
    {
103
        $solutions = [];
104
105
        foreach ($this->solutions as $solution) {
106
            $solutions[] = (new SolutionTransformer($solution))->toArray();
107
        }
108
109
        return $solutions;
110
    }
111
112
    protected function shareEndpoint(): string
113
    {
114
        try {
115
            // use string notation as L5.5 and L5.6 don't support array notation yet
116
            return action('\Facade\Ignition\Http\Controllers\ShareReportController');
117
        } catch (Exception $exception) {
118
            return '';
119
        }
120
    }
121
122
    public function report(): array
123
    {
124
        return $this->report->toArray();
125
    }
126
127
    public function jsonEncode($data): string
128
    {
129
        $jsonOptions = JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
130
131
        return json_encode($data, $jsonOptions);
132
    }
133
134
    public function getAssetContents(string $asset): string
135
    {
136
        $assetPath = __DIR__."/../../resources/compiled/{$asset}";
137
138
        return file_get_contents($assetPath);
139
    }
140
141
    public function styles(): array
142
    {
143
        return array_keys(Ignition::styles());
144
    }
145
146
    public function scripts(): array
147
    {
148
        return array_keys(Ignition::scripts());
149
    }
150
151
    public function tabs(): string
152
    {
153
        return json_encode(Ignition::$tabs);
154
    }
155
156
    public function defaultTab(?string $defaultTab, ?array $defaultTabProps)
157
    {
158
        $this->defaultTab = $defaultTab ?? 'StackTab';
159
160
        if ($defaultTabProps) {
161
            $this->defaultTabProps = $defaultTabProps;
162
        }
163
    }
164
165
    public function toArray(): array
166
    {
167
        return [
168
            'throwableString' => $this->throwableString(),
169
            'telescopeUrl' => $this->telescopeUrl(),
170
            'shareEndpoint' => $this->shareEndpoint(),
171
            'title' => $this->title(),
172
            'config' => $this->config(),
173
            'solutions' => $this->solutions(),
174
            'report' => $this->report(),
175
            'housekeepingEndpoint' => url(config('ignition.housekeeping_endpoint_prefix', '_ignition')),
176
            'styles' => $this->styles(),
177
            'scripts' => $this->scripts(),
178
            'tabs' => $this->tabs(),
179
            'jsonEncode' => Closure::fromCallable([$this, 'jsonEncode']),
180
            'getAssetContents' => Closure::fromCallable([$this, 'getAssetContents']),
181
            'defaultTab' => $this->defaultTab,
182
            'defaultTabProps' => $this->defaultTabProps,
183
        ];
184
    }
185
}
186