Issues (34)

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.

client_example/ClientPoller.php (4 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
#!/usr/bin/php
2
3
<?php
4
5
/**
6
 * This is an example of a client application listening for SQS messages
7
 * The CPE stack sends output message back to the client using the "output" SQS queue
8
 * The application needs to listen to this output queue to get updates 
9
 * Using the CpeClientSdk you can easily listen to the SQS
10
 */
11
12
require __DIR__ . "/vendor/autoload.php";
13
14
function poll_SQS_queues($CpeClientSdk, $decodedClient)
15
{
16
    try {
17
        // Will poll for 2 seconds
18
        if ($msg = $CpeClientSdk->receive_message($decodedClient, 10))
19
        {
20
            if (!($decoded = json_decode($msg['Body']))) {
21
                throw new Exception("JSON output data is invalid!");
22
            } else {
23
                handle_output($decoded);
24
            }
25
        }
26
    } catch (Exception $e) {
27
        print("[ERROR] " . $e->getMessage() . "\n");
28
    }
29
                    
30
    // Message polled. We delete it from SQS
31
    if (isset($msg) && $msg != "") {
32
        $CpeClientSdk->delete_message($decodedClient, $msg);
33
    }
34
}
35
36
function handle_output($output)
37
{
38
    global $debug;
39
    
40
    if ($debug) {
41
        print_r($output);
42
    }
43
}
44
45
/**
46
 * CLIENT POLLER START
47
 */
48
49
$debug  = false;
50
$region = getenv("AWS_DEFAULT_REGION");
51
$key    = getenv("AWS_ACCESS_KEY_ID");
52
$secret = getenv("AWS_SECRET_KEY");
53
54 View Code Duplication
function usage()
0 ignored issues
show
This function 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...
The function usage() has been defined more than once; this definition is ignored, only the first definition in client_example/ClientCommander.php (L110-123) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
55
{
56
    echo("Usage: php " . basename(__FILE__) . " -c configFile [-h] [-k <key>] [-s <secret>] [-r <region>]\n");
57
    echo("-h: Print this help\n");
58
    echo("-d: Debug mode\n");
59
    echo("-c: configFile\n");
60
    echo("-k <AWS key>: Optional. Will use env variables by default\n");
61
    echo("-s <AWS secret>: Optional. Will use env variables by default\n");
62
    echo("-r <AWS region>: Optional. Will use env variables by default\n");
63
    exit(0);
64
}
65
66 View Code Duplication
function check_input_parameters()
0 ignored issues
show
This function 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...
The function check_input_parameters() has been defined more than once; this definition is ignored, only the first definition in client_example/ClientCommander.php (L63-108) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
67
{
68
    global $region;
69
    global $secret;
70
    global $key;
71
    global $debug;
72
    global $clientInfo;
73
    global $argv;
74
    
75
    // Handle input parameters
76
    if (!($options = getopt("c:k::s::r::hd"))) {
77
        usage();
78
    }
79
    if (isset($options['h'])) {
80
        usage();
81
    }
82
    
83
    if (isset($options['d'])) {
84
        $debug = true;
85
    }
86
87
    if (isset($options['c']))
88
    {
89
        $clientConfFile = $options['c'];
90
        if (!file_exists($clientConfFile)) {
91
            throw new Exception("The client config file is not valid!");
92
        }
93
        if (!($clientInfo = file_get_contents($clientConfFile))) {
94
            throw new Exception("Unable to read the file");
95
        }
96
    } else {
97
        throw new Exception("Please provide the client config file!\n");
98
    }
99
  
100
    if (isset($options['k'])) {
101
        $key = $options['k'];
102
    } else {
103
        $key = getenv("AWS_ACCESS_KEY_ID");
104
    }
105
    
106
    if (isset($options['s'])) {
107
        $secret = $options['s'];
108
    } else {
109
        $secret = getenv("AWS_SECRET_KEY");
110
    }
111
112
    if (isset($options['r'])) {
113
        $region = $options['r'];
114
    } else {
115
        $region = getenv("AWS_DEFAULT_REGION");
116
    }
117
    if (!$region) {
118
        throw new Exception("Please provide your AWS region as parameter or using AWS_DEFAULT_REGION env var !");
119
    }
120
}
121
122
// Instanciate ComSDK to communicate with the stack
123
try {
124
    check_input_parameters();
125
    $CpeClientSdk = new SA\CpeClientSdk($key, $secret, $region, $debug);
126
} catch (Exception $e) {
127
    exit($e->getMessage());
128
  }
129
130
// You must JSON decode it
131
$decodedClient = json_decode($clientInfo);
132
133
// Keep polling for output messages!
134
while (42) {
135
    poll_SQS_queues($CpeClientSdk, $decodedClient);
136
}
137