Issues (114)

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.

protected/controllers/ProfileController.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
class ProfileController extends CiiController
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
	/**
7
	 * The layout to use for this controller
8
	 * @var string
9
	 */
10
	public $layout = '//layouts/main';
11
12
	/**
13
	 * @return array action filters
14
	 */
15
	public function filters()
16
	{
17
		return CMap::mergeArray(parent::filters(), array('accessControl'));
18
	}
19
20
	/**
21
	 * Specifies the access control rules.
22
	 * This method is used by the 'accessControl' filter.
23
	 * @return array access control rules
24
	 */
25
	public function accessRules()
26
	{
27
		return array(
28
			array('allow',  // Allow all users to any section
29
				'actions' => array('index'),
30
				'users'=>array('*'),
31
			),
32
			array('allow',  // deny all users
33
				'actions' => array('edit', 'resend'),
34
				'users'=>array('@'),
35
			),
36
			array('deny',  // deny all users
37
				'users'=>array('*'),
38
			),
39
		);
40
	}
41
42
	/**
43
	 * Provides functionality to view a given profile
44
	 * @param  int 	  $id          The ID belonging to the user
45
	 * @param  string $username    The user's display name. This isn't super necessary, it just is better for SEO
46
	 */
47
	public function actionIndex($id=NULL, $username=NULL)
48
	{
49
		// If an ID isn't provided, throw an error
50
		if ($id === NULL)
51
			throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
52
53
		// For SEO, if the display name isn't in the url, reroute it
54
		if ($id !== NULL && $username === NULL)
55
		{
56
			$model = Users::model()->findByPk($id);
57
			if ($model === NULL || $model->status == 0)
58
				throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
59
			else
60
				$this->redirect('/profile/' . $model->id . '/' . preg_replace('/[^\da-z]/i', '', $model->username));
61
		}
62
63
		$model = Users::model()->findByPk($id);
64
65
		// Don't allow null signings or invalidated users to pollute our site
66
		if($model->status == 0)
67
			throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!"));
68
69
		$this->pageTitle = Yii::t('ciims.controllers.Profile', 'User {{user}} - CiiMS | {{sitename}}', array('{{user}}' => $model->name, '{{sitename}}' => Cii::getConfig('name', Yii::app()->name)));
70
		$this->render('index', array(
71
			'model' => $model,
72
			'md' => new CMarkdownParser
73
		));
74
	}
75
76
	/**
77
	 * Provides functionality for a user to edit their profile
78
	 */
79
	public function actionEdit()
0 ignored issues
show
actionEdit uses the super-global variable $_POST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
80
	{
81
		$model = new ProfileForm;
82
		$model->load(Yii::app()->user->id);
83
84
		if (Cii::get($_POST, 'ProfileForm', NULL) !== NULL)
85
		{
86
			$model->attributes = $_POST['ProfileForm'];
87
			$model->password_repeat = $_POST['ProfileForm']['password_repeat'];
88
89
			if ($model->save())
90
			{
91
				Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'Your profile has been updated!'));
92
				$this->redirect($this->createUrl('profile/index', array(
93
					'id' => $model->id,
94
					'username' => $model->username
95
				)));
96
			}
97
			else
98
				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Profile', 'There were errors saving your profile. Please correct them before trying to save again.'));
99
		}
100
101
		$this->render('edit', array(
102
			'model' => $model
103
		));
104
	}
105
106
	/**
107
	 * Send a new verification email to the user
108
	 */
109
	public function actionResend()
110
	{
111
		$model = new ProfileForm;
112
		$model->load(Yii::app()->user->id);
113
114
		// If we don't have one on file, then someone the user got to a page they shouldn't have gotten to
115
		// Seamlessly redirect them back
116
		if ($model->getNewEmail() == NULL)
117
			$this->redirect(Yii::app()->user->returnUrl);
118
119
		if ($model->sendVerificationEmail())
120
			Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'A new verification email has been resent to {{user}}. Please check your email address.', array(
121
				'{{user}}' => $model->getNewEmail()
122
			)));
123
		else
124
			Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Profile', 'There was an error resending the verification email. Please try again later.'));
125
126
		$this->redirect($this->createUrl('profile/edit'));
127
	}
128
}
129