Issues (7)

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.

Classes/Service/AccessService.php (2 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
 * Handling the detail page access
4
 *
5
 * @package    Html5videoplayerPowermail\Service
6
 * @author     Tim Lochmüller
7
 */
8
9
namespace HVP\Html5videoplayerPowermail\Service;
10
11
use HVP\Html5videoplayerPowermail\Utility\GlobalUtility;
12
use HVP\Html5videoplayer\Domain\Model\Video;
13
use In2code\Powermail\Domain\Model\Form;
14
use TYPO3\CMS\Backend\Utility\BackendUtility;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3\CMS\Core\Utility\HttpUtility;
17
use TYPO3\CMS\Core\Utility\MathUtility;
18
use TYPO3\CMS\Frontend\Page\PageRepository;
19
20
/**
21
 * Handling the detail page access
22
 *
23
 * @author     Tim Lochmüller
24
 */
25
class AccessService extends AbstractService
26
{
27
28
    /**
29
     * Session service
30
     *
31
     * @var \HVP\Html5videoplayerPowermail\Service\SessionService
32
     * @inject
33
     */
34
    protected $sessionService;
35
36
    /**
37
     * Uri Builder
38
     *
39
     * @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
40
     * @inject
41
     */
42
    protected $uriBuilder;
43
44
    /**
45
     * Flexform service
46
     *
47
     * @var \TYPO3\CMS\Extbase\Service\FlexFormService
48
     * @inject
49
     */
50
    protected $flexFormService;
51
52
    /**
53
     * The session name
54
     *
55
     * @var string
56
     */
57
    protected $sessionName = 'submittedForms';
58
59
    /**
60
     * @param Video $video
61
     */
62
    public function checkVideoAccess(Video $video = null)
63
    {
64
        if ($video === null) {
65
            return;
66
        }
67
68
        $formProtection = $this->getFormProtection($video);
69
        if ($formProtection <= 0) {
70
            return;
71
        }
72
73
        // disable the cache
74
        $message = 'Do not cache video detail page, because every request is check via html5videoplayer_powermail';
75
        GlobalUtility::getTypoScriptFrontendController($message)
0 ignored issues
show
The call to GlobalUtility::getTypoScriptFrontendController() has too many arguments starting with $message.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
76
            ->set_no_cache();
77
78
        if ($this->isAccessableByCurrentUser($formProtection)) {
79
            return;
80
        }
81
82
        $formPage = $this->findFormPage($formProtection);
83
        if ($formPage) {
84
            $this->sessionService->set('videoReturnUrl', GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
85
86
            $uri = $this->uriBuilder->setTargetPageUid($formPage)
87
                ->build();
88
            HttpUtility::redirect($uri, HttpUtility::HTTP_STATUS_403);
89
        }
90
    }
91
92
    /**
93
     * @param Form $form
94
     */
95
    public function triggerFormSubmit(Form $form)
96
    {
97
        if ($this->sessionService->has('videoReturnUrl') && $this->isProtectionForm($form)) {
98
            $forms = $this->sessionService->has($this->sessionName) ? $this->sessionService->get($this->sessionName) : [];
99
            $forms[] = $form->getUid();
100
            $this->sessionService->set($this->sessionName, $forms);
101
            HttpUtility::redirect($this->sessionService->get('videoReturnUrl'));
102
        }
103
    }
104
105
    /**
106
     * Find the given page UID of the form Protection ID
107
     *
108
     * @param int $formProtectionId
109
     *
110
     * @return int
111
     */
112
    protected function findFormPage($formProtectionId)
113
    {
114
        $pluings = $this->findPowermailPlugins();
115
        foreach ($pluings as $plugin) {
0 ignored issues
show
The expression $pluings of type null|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
116
            $configuration = $this->flexFormService->convertFlexFormContentToArray($plugin['pi_flexform']);
117
            if (isset($configuration['settings']['flexform']['main']['form'])) {
118
                $formId = $configuration['settings']['flexform']['main']['form'];
119
                if (MathUtility::canBeInterpretedAsInteger($formId) && (int)$formId == $formProtectionId) {
120
                    return $plugin['pid'];
121
                }
122
            }
123
        }
124
        return 0;
125
    }
126
127
    /**
128
     * Find all includes Powermail plugins
129
     *
130
     * @return array
131
     */
132
    protected function findPowermailPlugins()
133
    {
134
        $database = GlobalUtility::getDatabaseConnection();
135
        $pageRepository = new PageRepository();
136
        $where = 'CType="list" AND list_type="powermail_pi1"' . $pageRepository->enableFields('tt_content');
137
        return $database->exec_SELECTgetRows('uid,pid,pi_flexform', 'tt_content', $where);
138
    }
139
140
    /**
141
     * @param $formProtectionId
142
     *
143
     * @return bool
144
     */
145
    protected function isAccessableByCurrentUser($formProtectionId)
146
    {
147
        $forms = $this->sessionService->has($this->sessionName) ? $this->sessionService->get($this->sessionName) : [];
148
        return in_array((int)$formProtectionId, $forms);
149
    }
150
151
    /**
152
     * @param Form $form
153
     *
154
     * @return bool
155
     */
156
    protected function isProtectionForm(Form $form)
157
    {
158
        return (bool)GlobalUtility::getDatabaseConnection()
159
            ->exec_SELECTcountRows('*', 'tx_html5videoplayer_domain_model_video', 'powermail_protection=' . $form->getUid());
160
    }
161
162
    /**
163
     * Get the Form protection value
164
     *
165
     * @param Video $video
166
     *
167
     * @return int
168
     */
169
    protected function getFormProtection(Video $video)
170
    {
171
        $record = BackendUtility::getRecord('tx_html5videoplayer_domain_model_video', $video->getUid());
172
        return (int)$record['powermail_protection'];
173
    }
174
}
175