Issues (524)

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.

code/model/jobs/DNGitFetch.php (6 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
/**
4
 * Class DNGitFetch
5
 *
6
 * @property string $ResqueToken
7
 *
8
 * @method DNProject Project()
9
 * @property int $ProjectID
10
 * @method Member Deployer()
11
 * @property int $DeployerID
12
 *
13
 */
14
class DNGitFetch extends DataObject {
0 ignored issues
show
The property $has_one is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
15
16
	/**
17
	 * @var array
18
	 */
19
	private static $db = array(
20
		"ResqueToken" => "Varchar(255)",
21
		// Observe that this is not the same as Resque status, since ResqueStatus is not persistent
22
		// It's used for finding successful deployments and displaying that in history views in the frontend
23
		"Status" => "Enum('Queued, Started, Finished, Failed, n/a', 'n/a')",
24
	);
25
26
	/**
27
	 * @var array
28
	 */
29
	private static $has_one = array(
30
		"Project" => "DNProject",
31
		"Deployer" => "Member"
32
	);
33
34
	/**
35
	 * @param int $int
36
	 * @return string
37
	 */
38 View Code Duplication
	public static function map_resque_status($int) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
		$remap = array(
40
			Resque_Job_Status::STATUS_WAITING => "Queued",
41
			Resque_Job_Status::STATUS_RUNNING => "Running",
42
			Resque_Job_Status::STATUS_FAILED => "Failed",
43
			Resque_Job_Status::STATUS_COMPLETE => "Complete",
44
			false => "Invalid",
45
		);
46
		return $remap[$int];
47
	}
48
49
	/**
50
	 * Queue a fetch job
51
	 * @param bool $forceClone Force repository to be re-cloned
52
	 */
53
	public function start($forceClone = false) {
54
		$project = $this->Project();
55
		$log = $this->log();
56
57
		if(!$this->DeployerID) {
58
			$this->DeployerID = Member::currentUserID();
59
		}
60
61 View Code Duplication
		if($this->DeployerID) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
			$deployer = $this->Deployer();
63
			$message = sprintf(
64
				'Update repository job for %s initiated by %s (%s)',
65
				$project->Name,
66
				$deployer->getName(),
67
				$deployer->Email
68
			);
69
			$log->write($message);
70
		}
71
72
		// write first, so we have the ID. We have to write again
73
		// later once we have the resque token.
74
		$this->write();
75
76
		$args = array(
77
			'projectID' => $project->ID,
78
			'logfile' => $this->logfile(),
79
			'fetchID' => $this->ID,
80
			'forceClone' => $forceClone
81
		);
82
83
		$token = Resque::enqueue('git', 'FetchJob', $args, true);
84
		$this->ResqueToken = $token;
85
		$this->write();
86
87
		$message = sprintf('Fetch queued as job %s', $token);
88
		$log->write($message);
89
	}
90
91
	/**
92
	 * @param Member|null $member
93
	 * @return bool
94
	 */
95
	public function canView($member = null) {
96
		return $this->Project()->canView($member);
97
	}
98
99
	/**
100
	 * Return a path to the log file.
101
	 * @return string
102
	 */
103
	protected function logfile() {
104
		return sprintf(
105
			'%s.fetch.%s.log',
106
			$this->Project()->Name,
107
			$this->ID
108
		);
109
	}
110
111
	/**
112
	 * @return \DeploynautLogFile
113
	 */
114
	public function log() {
115
		return new DeploynautLogFile($this->logfile());
116
	}
117
118
	/**
119
	 * @return string
120
	 */
121
	public function LogContent() {
122
		return $this->log()->content();
123
	}
124
125
	/**
126
	 * Returns the status of the resque job
127
	 *
128
	 * @return string
129
	 */
130
	public function ResqueStatus() {
131
		$status = new Resque_Job_Status($this->ResqueToken);
0 ignored issues
show
It seems like $this->ResqueToken can also be of type false; however, Resque_Job_Status::__construct() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
132
		$statusCode = $status->get();
133
		// The Resque job can no longer be found, fallback to the DNDeployment.Status
134
		if($statusCode === false) {
135
			// Translate from the DNDeployment.Status to the Resque job status for UI purposes
136
			switch($this->Status) {
0 ignored issues
show
The property Status does not exist on object<DNGitFetch>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
137
				case 'Finished':
138
					return 'Complete';
139
				case 'Started':
140
					return 'Running';
141
				default:
142
					return $this->Status;
0 ignored issues
show
The property Status does not exist on object<DNGitFetch>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
143
			}
144
		}
145
		return self::map_resque_status($statusCode);
146
	}
147
148
}
149