Issues (37)

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\LoaderError
41
     * @throws \Twig\Error\RuntimeError
42
     * @throws \Twig\Error\SyntaxError
43
     * @throws \craft\errors\SiteNotFoundException
44
     * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException
45
     * @throws \yii\web\UnauthorizedHttpException
46
     */
47
    public function run($organization = null)
48
    {
49
        $organization = (null !== $organization) ? $this->find($organization) : $this->create();
50
        return $this->runInternal($organization);
51
    }
52
53
    /**
54
     * @inheritdoc
55
     * @return OrganizationElement
56
     */
57
    protected function find($identifier)
58
    {
59
        $site = $this->resolveSiteFromRequest();
60
        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 60 which is incompatible with the return type documented by flipbox\organizations\cp...zation\SwitchType::find of type flipbox\organizations\elements\Organization|null.
Loading history...
61
            is_numeric($identifier) ? 'id' : 'slug' => $identifier,
62
            $site ? $site->id : null
63
        ]);
64
    }
65
66
    /**
67
     * @inheritdoc
68
     * @return OrganizationElement
69
     */
70
    protected function create()
71
    {
72
        $site = $this->resolveSiteFromRequest();
73
        return new Organization([
74
            'siteId' => $site ? $site->id : null
75
        ]);
76
    }
77
78
    /**
79
     * @param OrganizationElement $element
80
     * @return array|mixed
81
     * @throws \Twig\Error\LoaderError
82
     * @throws \Twig\Error\RuntimeError
83
     * @throws \Twig\Error\SyntaxError
84
     * @throws \craft\errors\SiteNotFoundException
85
     * @throws \yii\web\UnauthorizedHttpException
86
     */
87
    protected function runInternal(OrganizationElement $element)
88
    {
89
        // Check access
90
        if (($access = $this->checkAccess($element)) !== true) {
91
            return $access;
92
        }
93
94
        return $this->data(
95
            $this->populate($element)
96
        );
97
    }
98
99
    /**
100
     * @param OrganizationElement $element
101
     * @return array
102
     * @throws \Twig\Error\LoaderError
103
     * @throws \Twig\Error\RuntimeError
104
     * @throws \Twig\Error\SyntaxError
105
     * @throws \craft\errors\SiteNotFoundException
106
     */
107
    protected function data(OrganizationElement $element): array
108
    {
109
        $view = Craft::$app->getView();
110
111
        return [
112
            'tabsHtml' => $view->renderTemplate(
113
                '_includes/tabs',
114
                [
115
                    'tabs' => $this->getTabs($element, true)
116
                ]
117
            ),
118
            'fieldsHtml' => $view->renderTemplate(
119
                'organizations/_cp/organization/__fields',
120
                [
121
                    'element' => $element,
122
                    'fieldLayout' => $element->getFieldLayout()
123
                ]
124
            ),
125
            'sitesHtml' => $view->renderTemplate(
126
                'organizations/_cp/organization/__sites',
127
                [
128
                    'element' => $element,
129
                    'enabledSiteIds' => $this->getEnabledSiteIds($element),
130
                    'siteIds' => $this->getSiteIds(),
131
                    'url' => $this->getSiteUrl($element)
132
                ]
133
            ),
134
            'sidebarHtml' => $view->renderTemplate(
135
                'organizations/_cp/organization/__enabled',
136
                [
137
                    'element' => $element,
138
                    'showSites' => $this->showSites()
139
                ]
140
            ),
141
            'headHtml' => $view->getHeadHtml(),
142
            'footHtml' => $view->getBodyHtml(),
143
        ];
144
    }
145
146
    /**
147
     * @param OrganizationElement $element
148
     * @return OrganizationElement
149
     * @throws \Exception
150
     */
151
    public function populate(OrganizationElement $element): OrganizationElement
152
    {
153
        $this->parentPopulate($element);
154
        $this->populateFromRequest($element);
155
156
        return $element;
157
    }
158
}
159