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/ClientCommander.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
#!/usr/bin/php
2
3
<?php
4
5
/**
6
 * This is an example of client application that send commands to the CPE stack
7
 * Your application initiate new workflows
8
 * Using the CpeClientSdk it's easy to send the proper SQS message to the CPE stack
9
 * You message will be read by the CPE Stack InputPoller process
10
 * The InputPoller will read your message and initiate the proper actions
11
 * Such as: Start a new workflow
12
 **/
13
14
require __DIR__ . "/vendor/autoload.php";
15
16
function start_job($args)
17
{
18
    global $CpeClientSdk;
19
    global $clientInfo;
20
21
    if (count($args) != 2)
22
    {
23
        print("[ERROR] Invalid args! Please provide a filename after the command! (try again if you used [tab] to find your file. It fails somehow.)\n");
24
        return;
25
    }
26
    if (!file_exists($args[1]))
27
    {
28
        print("[ERROR] The file provided doesn't exists!\n");
29
        return;
30
    }
31
    if (!($content = file_get_contents($args[1])))
32
    {
33
        print("[ERROR] Unable to read file '$args[1]'!\n");
34
        return;
35
    }
36
    
37
    try {
38
        print("[INFO] Starting a new job!\n");
39
        // You must JSON decode it
40
        $decodedClient = json_decode($clientInfo);
41
        
42
        $CpeClientSdk->start_job($decodedClient, $content);
43
    }
44
    catch (Exception $e) {
45
        print("[ERROR] " . $e->getMessage() . "\n");
46
    }
47
}
48
49
50
/**
51
 * CLIENT COMMANDER
52
 */
53
54
$help = <<<EOF
55
Use the following commands to send messages to the stack.
56
57
Commands:
58
start_job <filepath>: Start a new job. Pass a JSON file containing the instruction (see: input_samples folder)
59
60
EOF;
61
62
    
63 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...
64
{
65
    global $region;
66
    global $secret;
67
    global $key;
68
    global $debug;
69
    global $clientInfo;
70
    global $argv;
71
        
72
    // Handle input parameters
73
    if (!($options = getopt("c:k::s::r::hd")))
74
        usage();
75
    if (isset($options['h']))
76
        usage();
77
    
78
    if (isset($options['d']))
79
        $debug = true;
80
  
81
    if (isset($options['c']))
82
    {
83
        $clientConfFile = $options['c'];
84
        if (!file_exists($clientConfFile))
85
            throw new Exception("The client config file is not valid!");
86
        if (!($clientInfo = file_get_contents($clientConfFile)))
87
            throw new Exception("Unable to read the file");
88
    }
89
    else
90
        throw new Exception("Please provide the client config file!");
91
92
    if (isset($options['k']))
93
        $key = $options['k'];
94
    else
95
        $key = getenv("AWS_ACCESS_KEY_ID");
96
    
97
    if (isset($options['s']))
98
        $secret = $options['s'];
99
    else
100
        $secret = getenv("AWS_SECRET_KEY");
101
102
    if (isset($options['r']))
103
        $region = $options['r'];
104
    else 
105
        $region = getenv("AWS_DEFAULT_REGION");
106
    if (!$region)
107
        throw new Exception("Please provide your AWS region as parameter or using AWS_DEFAULT_REGION env var !");
108
}
109
110
    function usage()
111
    {
112
        global $help;
113
    
114
        echo("Usage: php ". basename(__FILE__) . " -c configFile [-h] [-k <key>] [-s <secret>] [-r <region>]\n");
115
        echo("-h: Print this help\n");
116
        echo("-d: Debug mode\n");
117
        echo("-c: configFile\n");
118
        echo("-k <AWS key>: Optional. Will use env variables by default\n");
119
        echo("-s <AWS secret>: Optional. Will use env variables by default\n");
120
        echo("-r <AWS region>: Optional. Will use env variables by default\n\n");
121
        echo($help);
122
        exit(0);
123
    }
124
    
125
126
try {
127
    check_input_parameters();
128
} 
129
catch (Exception $e) {
130
    print "[ERROR] " . $e->getMessage() . "\n";
131
    exit(2);
132
}
133
134
// Instanciate ComSDK to communicate with the stack
135
try {
136
    $CpeClientSdk = new SA\CpeClientSdk($key, $secret, $region, $debug);
137
} catch (Exception $e) {
138
    exit($e->getMessage());
139
  }
140
141
// Commands mapping
142
$commandMap = [
143
    "start_job" => "start_job",
144
];
145
146
// Look for input commands
147
print($help);
148
while (42)
149
{
150
    // Prompt (<3 php)
151
    $line = readline("Command [enter]: ");
152
    if (!$line)
153
        continue;
154
    readline_add_history($line);
155
156
    // Process user input
157
    $args = explode(" ", $line);
158
    if (!isset($commandMap[$args[0]]))
159
        print "[ERROR] Command not found!\n";
160
    else 
161
        $commandMap[$args[0]]($args);
162
}