Issues (15)

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/Command/DiffCommand.php (2 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
/**
4
 * Copyright (c) Andreas Heigl<[email protected]>
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
 * THE SOFTWARE.
23
 *
24
 * @author    Andreas Heigl<[email protected]>
25
 * @copyright Andreas Heigl
26
 * @license   http://www.opensource.org/licenses/mit-license.php MIT-License
27
 * @since     14.06.2016
28
 * @link      http://github.com/heiglandreas/org.heigl.junitdiff
29
 */
30
31
namespace Org_Heigl\JUnitDiff\Command;
32
33
use Org_Heigl\JUnitDiff\JUnitParser;
34
use Symfony\Component\Console\Command\Command;
35
use Symfony\Component\Console\Input\InputInterface;
36
use Symfony\Component\Console\Input\InputOption;
37
use Symfony\Component\Console\Output\OutputInterface;
38
39
class DiffCommand extends Command
40
{
41
    protected function configure()
42
    {
43
        $this->setName('diff')
44
             ->setDescription('Shows a diff between two JUnit log files')
45
             ->setDefinition([
46
                 new InputOption('input1', '1', InputOption::VALUE_REQUIRED, 'First input file'),
47
                 new InputOption('input2', '2', InputOption::VALUE_REQUIRED, 'Second input file')
48
             ])
49
             ->setHelp('');
50
    }
51
52
53
    protected function execute(InputInterface $input, OutputInterface $output)
54
    {
55
        $output->writeln([
0 ignored issues
show
array($this->getApplicat...->getLongVersion(), '') is of type array<integer,?,{"0":"?","1":"string"}>, but the function expects a string|object<Symfony\Co...onsole\Output\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
56
            $this->getApplication()->getLongVersion(),
57
            '',
58
        ]);
59
60
        $parser = new JUnitParser();
61
62
        try {
63
            $file1  = $input->getOption('input1');
64
            $array1 = $parser->parseFile($file1);
65
        } catch (\Exception $e) {
66
            $output->writeln('<bg=red;fg=white>  ' . $e->getMessage() . '  </>');
67
            return;
68
        }
69
70
        try {
71
            $file2  = $input->getOption('input2');
72
            $array2 = $parser->parseFile($file2);
73
        } catch (\Exception $e) {
74
            $output->writeln('<bg=red;fg=white> ' . $e->getMessage() . '  </>');
75
            return;
76
        }
77
78
        $array = $this->merge($array1, $array2);
79
80
        foreach ($array as $key => $value) {
81
            if (! isset($value['base'])) {
82
                $output->writeln('<bg=green;fg=black>+</> ' . $key);
83
                continue;
84
            }
85
            if (! isset($value['current'])) {
86
                $output->writeln('<bg=red;fg=yellow>-</> ' . $key);
87
                continue;
88
            }
89
90
            if ($value['base']['result'] != $value['current']['result']) {
91
                $output->writeln(sprintf(
92
                    '<bg=blue;fg=yellow>o</> %s changed from <fg=cyan>%s</> to <fg=magenta>%s</>',
93
                    $key,
94
                    $array1[$key]['result'],
95
                    $array2[$key]['result']
96
                ));
97
                continue;
98
            }
99
        }
100
101
        $output->writeln('');
102
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
103
            $output->writeln([
0 ignored issues
show
array(sprintf('<bg=green...', $file1, $file2), '') is of type array<integer,string,{"0..."string","3":"string"}>, but the function expects a string|object<Symfony\Co...onsole\Output\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
104
                sprintf(
105
                    '<bg=green;fg=black>+</>: This test was added in file %s',
106
                    $file2
107
                ),
108
                sprintf(
109
                    '<bg=red;fg=yellow>-</>: This test was removed in file %s',
110
                    $file2
111
                ),
112
                sprintf(
113
                    '<bg=blue;fg=yellow>o</>: The test-result changed between file %s and %s',
114
                    $file1,
115
                    $file2
116
                ),
117
                ''
118
            ]);
119
        }
120
        $output->writeln(sprintf(
121
            '<fg=yellow>Analyzed %s tests in total, %s tests in file %s and %s tests in file %s',
122
            count($array),
123
            count($array1),
124
            basename($file1),
125
            count($array2),
126
            basename($file2)
127
        ));
128
    }
129
130
    protected function merge(array $array1, array $array2)
131
    {
132
        $merged = [];
133
        foreach ($array1 as $key => $value) {
134
            $merged[$key]['base'] = $value;
135
        }
136
137
        foreach ($array2 as $key => $value) {
138
            $merged[$key]['current'] = $value;
139
        }
140
141
        ksort($merged);
142
143
        return $merged;
144
    }
145
}
146