Issues (2)

Security Analysis    no request data  

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/Response/ConduitResponse.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 namespace Phabricator\Response;
2
3
use BuildR\Foundation\Exception\RuntimeException;
4
5
/**
6
 * Object representation of a conduit API response
7
 *
8
 * Phabricator PHP API
9
 *
10
 * @author Zoltán Borsos <[email protected]>
11
 * @package Phabricator
12
 * @subpackage Response
13
 *
14
 * @copyright    Copyright 2016, Zoltán Borsos.
15
 * @license      https://github.com/Zolli/Phabricator-PHP-API/blob/master/LICENSE.md
16
 * @link         https://github.com/Zolli/Phabricator-PHP-API
17
 */
18
class ConduitResponse {
19
20
    /**
21
     * The raw result data
22
     *
23
     * @type array
24
     */
25
    protected $result;
26
27
    /**
28
     * ConduitResponse constructor.
29
     *
30
     * @param string $result Raw JSON response
31
     */
32 2
    public function __construct($result) {
33 2
        $this->result = $this->processRawResponse($result);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->processRawResponse($result) of type * is incompatible with the declared type array of property $result.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34 2
    }
35
36
    /**
37
     * Process the raw JSON response, given from conduit.
38
     * Throw an exception when given JSON is malformed
39
     *
40
     * @param $rawResult
41
     *
42
     * @throws \BuildR\Foundation\Exception\RuntimeException
43
     *
44
     * @return mixed
45
     */
46 4
    protected function processRawResponse($rawResult) {
47 4
        $result = json_decode($rawResult, TRUE);
48
49 4
        if(json_last_error() !== JSON_ERROR_NONE) {
50 1
            throw new RuntimeException('Malformed JSON response! Message: ' . json_last_error_msg());
51
        }
52
53 3
        return $result;
54
    }
55
56
    /**
57
     * Determines that the current response is successful or not
58
     *
59
     * @return bool
60
     */
61 2
    public function isSuccessful() {
62 2
        return ($this->result['error_code'] === NULL && $this->result['error_info'] === NULL) ? TRUE : FALSE;
63
    }
64
65
    /**
66
     * Determines that the current response is failed or not
67
     *
68
     * @return bool
69
     */
70 2
    public function isFailed() {
71 2
        return !$this->isSuccessful();
72
    }
73
74
    /**
75
     * Returns the error information from the response. Returns an empty string when
76
     * the API is not provide textual information
77
     *
78
     * @return string
79
     */
80 2
    public function getErrorInfo() {
81 2
        return (!empty($this->result['error_info'])) ? $this->result['error_info'] : '';
82
    }
83
84
    /**
85
     * Returns the error code from the API response, if tha request is not successes
86
     * This is not valid "error code". The conduit API returns short (constant like)
87
     * text, that represents the error, like: ERR_CERT_INVALID
88
     *
89
     * @return string
90
     */
91 2
    public function getErrorCode() {
92 2
        return (!empty($this->result['error_code'])) ? $this->result['error_code'] : '';
93
    }
94
95
    /**
96
     * Returns the API response
97
     *
98
     * @return array
99
     */
100 2
    public function getResult() {
101 2
        return $this->result['result'];
102
    }
103
104
}