Issues (55)

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/cp/actions/organization/SwitchType.php (1 issue)

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
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-ember/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-ember
7
 */
8
9
namespace flipbox\organizations\cp\actions\organization;
10
11
use Craft;
12
use flipbox\craft\ember\actions\CheckAccessTrait;
13
use flipbox\craft\ember\actions\LookupTrait;
14
use flipbox\craft\ember\actions\PopulateTrait;
15
use flipbox\organizations\actions\organizations\PopulateOrganizationTrait;
16
use flipbox\organizations\cp\controllers\OrganizationTabsTrait;
17
use flipbox\organizations\cp\controllers\OrganizationSitesTrait;
18
use flipbox\organizations\elements\Organization;
19
use flipbox\organizations\elements\Organization as OrganizationElement;
20
use yii\base\Action;
21
22
/**
23
 * @author Flipbox Factory <[email protected]>
24
 * @since 1.0.0
25
 */
26
class SwitchType extends Action
27
{
28
    use OrganizationSitesTrait,
29
        OrganizationTabsTrait,
30
        PopulateOrganizationTrait,
31
        PopulateTrait,
32
        LookupTrait,
33
        CheckAccessTrait {
34
        populate as parentPopulate;
35
    }
36
37
    /**
38
     * @param null $organization
39
     * @return array|mixed
40
     * @throws \Twig_Error_Loader
41
     * @throws \yii\base\Exception
42
     * @throws \yii\web\UnauthorizedHttpException
43
     */
44
    public function run($organization = null)
45
    {
46
        $organization = (null !== $organization) ? $this->find($organization) : $this->create();
47
        return $this->runInternal($organization);
48
    }
49
50
    /**
51
     * @inheritdoc
52
     * @return OrganizationElement
53
     */
54
    protected function find($identifier)
55
    {
56
        $site = $this->resolveSiteFromRequest();
57
        return Organization::findOne([
0 ignored issues
show
Bug Compatibility introduced by Nate Iler
The expression \flipbox\organizations\e...e ? $site->id : null)); of type craft\base\Element|null|craft\base\Element[] adds the type craft\base\Element[] to the return on line 57 which is incompatible with the return type documented by flipbox\organizations\cp...zation\SwitchType::find of type flipbox\organizations\elements\Organization|null.
Loading history...
58
            is_numeric($identifier) ? 'id' : 'slug' => $identifier,
59
            $site ? $site->id : null
60
        ]);
61
    }
62
63
    /**
64
     * @inheritdoc
65
     * @return OrganizationElement
66
     */
67
    protected function create()
68
    {
69
        $site = $this->resolveSiteFromRequest();
70
        return new Organization([
71
            'siteId' => $site ? $site->id : null
72
        ]);
73
    }
74
75
    /**
76
     * @inheritdoc
77
     * @throws \Twig_Error_Loader
78
     * @throws \yii\base\Exception
79
     * @throws \yii\web\UnauthorizedHttpException
80
     */
81
    protected function runInternal(OrganizationElement $element)
82
    {
83
        // Check access
84
        if (($access = $this->checkAccess($element)) !== true) {
85
            return $access;
86
        }
87
88
        return $this->data(
89
            $this->populate($element)
90
        );
91
    }
92
93
    /**
94
     * @param OrganizationElement $element
95
     * @return array
96
     * @throws \Twig_Error_Loader
97
     * @throws \yii\base\Exception
98
     */
99
    protected function data(OrganizationElement $element): array
100
    {
101
        $view = Craft::$app->getView();
102
103
        return [
104
            'tabsHtml' => $view->renderTemplate(
105
                '_includes/tabs',
106
                [
107
                    'tabs' => $this->getTabs($element, false)
108
                ]
109
            ),
110
            'fieldsHtml' => $view->renderTemplate(
111
                'organizations/_cp/organization/__fields',
112
                [
113
                    'element' => $element,
114
                    'fieldLayout' => $element->getFieldLayout()
115
                ]
116
            ),
117
            'sitesHtml' => $view->renderTemplate(
118
                'organizations/_cp/organization/__sites',
119
                [
120
                    'element' => $element,
121
                    'enabledSiteIds' => $this->getEnabledSiteIds($element),
122
                    'siteIds' => $this->getSiteIds(),
123
                    'url' => $this->getSiteUrl($element)
124
                ]
125
            ),
126
            'sidebarHtml' => $view->renderTemplate(
127
                'organizations/_cp/organization/__enabled',
128
                [
129
                    'element' => $element,
130
                    'showSites' => $this->showSites()
131
                ]
132
            ),
133
            'headHtml' => $view->getHeadHtml(),
134
            'footHtml' => $view->getBodyHtml(),
135
        ];
136
    }
137
138
    /**
139
     * @inheritdoc
140
     * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException
141
     */
142
    public function populate(OrganizationElement $element): OrganizationElement
143
    {
144
        $this->parentPopulate($element);
145
        $this->populateFromRequest($element);
146
147
        return $element;
148
    }
149
}
150