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/api/Congress.php (3 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
 * 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\API;
15
16
use ContactMyReps\Sunlight\api\BaseAPI;
17
use GuzzleHttp\Client;
18
19
/**
20
* Sunlight Foundation Congress API wrapper
21
* For more information see https://sunlightlabs.github.io/congress/
22
*
23
* @category Sunlight_Foundation_API
24
* @package  ContactMyReps
25
* @author   edfialk <[email protected]>
26
* @license  http://opensource.org/licenses/MIT MIT License
27
* @link     https://github.com/contactmyreps/sunlight-php
28
*/
29
class Congress extends BaseAPI
30
{
31
32
    const BASE_URI = 'https://congress.api.sunlightfoundation.com/';
33
34
    /**
35
     * Create Congress API instance
36
     *
37
     * @param array $options api options
38
     */
39
    public function __construct($options = [])
40
    {
41
        parent::__construct($options);
42
    }
43
44
    /**
45
     * Create Guzzle Client
46
     *
47
     * @param string $key Sunlight Foundation api key
48
     *
49
     * @return null
50
     */
51 View Code Duplication
    public function setClient($key)
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...
52
    {
53
        $this->client = new Client(
0 ignored issues
show
The property client does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
54
            [
55
            'base_uri' => self::BASE_URI,
56
            'headers' => [
57
            'X-APIKEY' => $key
58
            ]
59
            ]
60
        );
61
    }
62
63
    /**
64
     * Return Congress API Guzzle Client
65
     *
66
     * @return GuzzleHTTP\Client Guzzle Client
67
     */
68
    public function getClient()
69
    {
70
        return $this->client;
71
    }
72
73
    /**
74
     * Search Congress API legislators
75
     *
76
     * @param array $search search fields
77
     * @param array $fields display fields
78
     *
79
     * @return Response         API Response
80
     */
81 View Code Duplication
    public function legislators($search = [], $fields = [])
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...
82
    {
83
        $url = 'legislators?';
84
        if (count($search) > 0) {
85
            $p = [];
86
            foreach ($search as $k => $v) {
87
                $p[] = "$k=$v";
88
            }
89
            $url .= implode("&", $p);
90
        }
91
92
        return $this->get($url, $fields);
93
    }
94
95
    /**
96
     * Find reps for a given zip
97
     *
98
     * @param int   $zip    zip code
99
     * @param array $fields display fields
100
     *
101
     * @return Response         API Response
102
     */
103
    public function locateByZip($zip, $fields = [])
104
    {
105
        $url = 'legislators/locate?zip='.$zip;
106
        return $this->get($url, $fields);
107
    }
108
109
    /**
110
     * Find reps for a given lat/lng
111
     *
112
     * @param float $lat    latitude
113
     * @param float $lng    longitude
114
     * @param array $fields display fields
115
     *
116
     * @return Response         API Response
117
     */
118
    public function locateByGeo($lat, $lng, $fields = [])
119
    {
120
        $url = 'legislators/locate?latitude='.$lat.'&longitude='.$lng;
121
        return $this->get($url, $fields);
122
    }
123
}
124