Issues (8)

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/Output/BaseOutput.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
namespace Rs\VersionEye\Output;
4
5
use Rs\VersionEye\Http\Pager;
6
use Symfony\Component\Console\Helper\Table;
7
use Symfony\Component\Console\Helper\TableHelper;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * BaseOutput.
12
 *
13
 * @author Robert Schönthal <[email protected]>
14
 */
15
abstract class BaseOutput
16
{
17
    /**
18
     * prints a table, values can be modified via $callback.
19
     *
20
     * @param OutputInterface $output
21
     * @param string[]        $headings
22
     * @param string[]        $keys
23
     * @param array|Pager     $data
24
     * @param \Closure        $callback
25
     */
26 13
    protected function printTable(OutputInterface $output, array $headings, array $keys, $data, \Closure $callback = null)
27
    {
28 13
        $table = $this->createTable($output);
29
30 13
        $table->setHeaders(array_map('trim', $headings));
31
32 13
        foreach ($data as $row) {
33 13
            $rowData = array_merge(array_flip($keys), array_intersect_key($row, array_flip($keys)));
34 13
            if ($callback) {
35 5
                $rowData = array_map($callback, array_keys($rowData), $rowData);
36
            }
37 13
            $table->addRow(array_map('trim', $rowData));
38
        }
39
40 13
        $table->render($output);
0 ignored issues
show
The call to Table::render() has too many arguments starting with $output.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
41 13
    }
42
43
    /**
44
     * prints a simple boolean.
45
     *
46
     * @param OutputInterface $output
47
     * @param string          $success
48
     * @param string          $fail
49
     * @param bool            $value
50
     * @param bool            $line
51
     *
52
     * @return string
53
     */
54 18
    protected function printBoolean(OutputInterface $output, $success, $fail, $value, $line = true)
55
    {
56 18
        if ($value) {
57 14
            $message = '<info>' . $success . '</info>';
58
        } else {
59 8
            $message = '<error>' . $fail . '</error>';
60
        }
61
62 18
        if (false === $line) {
63 4
            return $message;
64
        }
65
66 14
        $output->writeln($message);
67 14
    }
68
69
    /**
70
     * prints a list combined as <comment>Heading</comment> : <info>Value</info>, values can be modified via $callback.
71
     *
72
     * @param OutputInterface $output
73
     * @param string[]        $headings
74
     * @param string[]        $keys
75
     * @param array           $data
76
     * @param \Closure        $callback
77
     */
78 10
    protected function printList(OutputInterface $output, array $headings, array $keys, array $data, \Closure $callback = null)
79
    {
80 10
        $width = $this->getColumnWidth($headings);
81 10
        $data  = array_merge(array_flip($keys), array_intersect_key($data, array_flip($keys)));
82
83 10
        foreach ($headings as $key => $heading) {
84 10
            $value = array_values($data)[$key];
85 10
            if ($callback) {
86 5
                $value = $callback($heading, $value);
87
            }
88 10
            $value = is_bool($value) ? (true === $value ? 'Yes' : 'No') : $value;
89
90 10
            $output->writeln(sprintf('<comment>%s%s</comment> : <info>%s</info>', $heading, str_repeat(' ', $width - strlen($heading)), $value));
91
        }
92 10
    }
93
94
    /**
95
     * output for references/search api.
96
     *
97
     * @param OutputInterface $output
98
     * @param array|Pager     $products
99
     */
100 6
    protected function printProducts(OutputInterface $output, $products)
101
    {
102 6
        $this->printTable($output,
103 6
            ['Name', 'Language', 'Version', 'Type'],
104 6
            ['name', 'language', 'version', 'prod_type'],
105 6
            $products
106
        );
107 6
    }
108
109
    /**
110
     * prints a simple message.
111
     *
112
     * @param OutputInterface $output
113
     * @param array           $response
114
     */
115 3
    protected function printMessage(OutputInterface $output, array $response)
116
    {
117 3
        $this->printBoolean($output, $response['message'], $response['message'], true === $response['success']);
118 3
    }
119
120
    /**
121
     * calculates the max width of a given set of string.
122
     *
123
     * @param string[] $headings
124
     *
125
     * @return int
126
     */
127 10
    private function getColumnWidth(array $headings)
128
    {
129 10
        $width = 0;
130 10
        foreach ($headings as $heading) {
131 10
            $width = strlen($heading) > $width ? strlen($heading) : $width;
132
        }
133
134 10
        return $width + 5;
135
    }
136
137
    /**
138
     * @param OutputInterface $output
139
     *
140
     * @return Table|TableHelper
141
     */
142 16
    protected function createTable(OutputInterface $output)
143
    {
144 16
        if (!class_exists('Symfony\Component\Console\Helper\Table')) {
145
            $table = new TableHelper(false);
146
        } else {
147 16
            $table = new Table($output);
148
        }
149
150 16
        return $table;
151
    }
152
}
153