Issues (10)

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/Sunlight.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
 * Sunlight-php
4
 *
5
 * PHP Version 7.0.1
6
 *
7
 * @category Sunlight_Foundation_API
8
 * @package  ContactMyReps
9
 * @author   edfialk <[email protected]>
10
 * @license  http://opensource.org/licenses/MIT MIT License
11
 * @link     https://github.com/contactmyreps/sunlight-php
12
 */
13
14
namespace ContactMyReps\Sunlight;
15
16
use ContactMyReps\Sunlight\API\OpenStates;
17
18
/**
19
* Sunlight Foundation API wrapper
20
* For more information see http://sunlightfoundation.com/api
21
*
22
* @category Sunlight_Foundation_API
23
* @package  ContactMyReps
24
* @author   edfialk <[email protected]>
25
* @license  http://opensource.org/licenses/MIT MIT License
26
* @link     https://github.com/contactmyreps/sunlight-php
27
*/
28
class Sunlight
29
{
30
31
    private static $key = null;
32
33
    public $options = [
34
    'asnyc' => false,
35
    'format' => 'json'
36
    ];
37
38
    /**
39
     * Create the Sunlight object
40
     *
41
     * @param string $key     Sunlight Foundation API Key
42
     * @param array  $options global config options
43
     */
44
    public function __construct($key = null, $options = [])
45
    {
46
        if ($key === null) {
47
            if (self::$key === null) {
48
                $msg = 'No key provided, and none is globally set. ';
49
                $msg .= 'Use Sunlight::setKey, or instantiate the Sunlight class with a $key parameter.';
50
                throw new APIException($msg);
51
            }
52
        } else {
53
            self::$key = $key;
54
        }
55
56
        $this->options = array_merge($this->options, $options);
57
    }
58
59
    /**
60
     * Set or retrieve option value
61
     *
62
     * @param string or array $key   the option key to set/retrieve, or an array of options to set
63
     * @param object          $value value to store
64
     *
65
     * @return object          if key is string and value is null, return options[key] value
66
     */
67 View Code Duplication
    public function option($key, $value = null)
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...
68
    {
69
        if (is_array($key)) {
70
            $this->options = array_merge($this->options, $key);
71
            return;
72
        }
73
74
        if (null === $value) {
75
            return $this->options[$key] ? $this->options[$key] : null;
76
        }
77
78
        $this->options[$key] = $value;
79
    }
80
81
    /**
82
     * Get an API instance
83
     *
84
     * @param string $api     api class path
85
     * @param array  $options local options for api
86
     *
87
     * @return object          api instance
88
     */
89
    public function get($api, $options)
90
    {
91
        return $api::getInstance(self::$key, $options);
92
    }
93
94
    /**
95
     * Get OpenStates API instance
96
     *
97
     * @param array $options OpenStates api options
98
     *
99
     * @return object          OpenStates api
100
     */
101
    public function openStates($options = [])
102
    {
103
        $options = array_merge($this->options, $options);
104
105
        return $this->get('\\ContactMyReps\\Sunlight\\api\\OpenStates', $options);
106
    }
107
108
    /**
109
     * Get Congress API instance
110
     *
111
     * @param array $options Congress api options
112
     *
113
     * @return object          Congress api
114
     */
115
    public function congress($options = [])
116
    {
117
        $options = array_merge($this->options, $options);
118
119
        return $this->get('\\ContactMyReps\\Sunlight\\api\\Congress', $options);
120
    }
121
}
122