GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (84)

Security Analysis    not enabled

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.

bundle/Command/DataAnonymizerCommand.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
namespace Netgen\Bundle\InformationCollectionBundle\Command;
4
5
use Netgen\InformationCollection\Core\Persistence\Anonymizer\AnonymizerServiceFacade;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Command\HelpCommand;
8
use Symfony\Component\Console\Input\InputDefinition;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use Symfony\Component\Console\Question\ConfirmationQuestion;
13
use DateInterval;
14
use DateTime;
15
use Exception;
16
17
class DataAnonymizerCommand extends Command
18
{
19
    protected static $defaultName = 'nginfocollector:anonymize';
20
21
    /**
22
     * @var \Netgen\InformationCollection\Core\Persistence\Anonymizer\AnonymizerServiceFacade
23
     */
24
    protected $anonymizer;
25
26
    /**
27
     * @var \DateInterval
28
     */
29
    protected $period;
30
31
    public function __construct(AnonymizerServiceFacade $anonymizerServiceFacade)
32
    {
33
        $this->anonymizer = $anonymizerServiceFacade;
34
35
        // Parent constructor call is mandatory for commands registered as services
36
        parent::__construct();
37
    }
38
39
    protected function configure()
40
    {
41
        $this->setName("nginfocollector:anonymize");
42
        $this->setDescription("Anonymizes collected data in collected info tables.");
43
        $this->setHelp("This command allows you to anonymize data collected by this library in collected info tables.");
44
45
        $this->setDefinition(
46
            new InputDefinition(
47
                [
48
                    new InputOption('content-id', 'c', InputOption::VALUE_REQUIRED, "Content id."),
49
                    new InputOption('field-identifiers', 'f', InputOption::VALUE_REQUIRED, "Field definition identifiers list."),
50
                    new InputOption('period', 'p', InputOption::VALUE_REQUIRED, "Attributes older that this period will be anonymized."),
51
                    new InputOption('all', 'a', InputOption::VALUE_NONE, "Anonymize all fields."),
52
                    new InputOption('neglect', 'nn', InputOption::VALUE_NONE, "Do not ask for confirmation."),
53
                ]
54
            )
55
        );
56
57
        $this->addUsage("--content-id=123 --field-identifiers=title,name,last_name");
58
        $this->addUsage("--info-collection-id=456 --field-identifiers=title,name,last_name");
59
    }
60
61
    protected function execute(InputInterface $input, OutputInterface $output)
62
    {
63 View Code Duplication
        if (is_null($input->getOption('content-id'))) {
0 ignored issues
show
This code seems to be duplicated across 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
            $output->writeln("<error>                                       </error>");
65
            $output->writeln("<error>     Missing content-id parameter.     </error>");
66
            $output->writeln("<error>                                       </error>");
67
68
            return $this->displayHelp($input, $output);
69
        }
70
71 View Code Duplication
        if (is_null($input->getOption('field-identifiers')) && !$input->getOption('all')) {
0 ignored issues
show
This code seems to be duplicated across 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...
72
            $output->writeln("<error>                                              </error>");
73
            $output->writeln("<error>     Missing field-identifiers parameter.     </error>");
74
            $output->writeln("<error>                                              </error>");
75
76
            return $this->displayHelp($input, $output);
77
        }
78
79
        $contentId = intval($input->getOption('content-id'));
80
        $fields = $this->getFields($input);
81
82
        $info = sprintf("Command will anonymize <info>%s</info> fields for content #%d", empty($fields) ? 'all': implode(", ", $fields), $contentId);
83
        $output->writeln($info);
84
85
        if ($this->proceedWithAction($input, $output)) {
86
            $output->write("<info>Running.... </info>");
87
            $count = $this->anonymizer->anonymize($contentId, $fields, $this->getDateFromPeriod());
0 ignored issues
show
$this->getDateFromPeriod() is of type object<DateTime>, but the function expects a object<DateTimeImmutable>|null.

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...
88
            $output->writeln("<info>Done.</info>");
89
            $output->writeln("<info>Anonymized #{$count} collections.</info>");
90
            return 0;
91
        }
92
93
        $output->writeln("<info>Canceled.</info>");
94
    }
95
96
    protected function initialize(InputInterface $input, OutputInterface $output)
97
    {
98
        if (!empty($input->getOption('period'))) {
99
100
            try {
101
                $period = $input->getOption('period');
102
                if (is_string($period)) {
103
                    $this->period = new DateInterval($period);
104
                }
105
            } catch (Exception $exception) {
106
                $output->writeln("Please enter valid DateInterval string.");
107
                exit(0);
108
            }
109
        }
110
    }
111
112
    protected function displayHelp(InputInterface $input, OutputInterface $output)
113
    {
114
        $help = new HelpCommand();
115
        $help->setCommand($this);
116
117
        return $help->run($input, $output);
118
    }
119
120
    protected function getFields(InputInterface $input)
121
    {
122
        if (!empty($input->getOption('all'))) {
123
            return [];
124
        }
125
126
        if (!is_null($input->getOption('field-identifiers'))) {
127
128
            $ids = [];
129
            $fieldIdentifiers = $input->getOption('field-identifiers');
130
131
            if (is_string($fieldIdentifiers)) {
132
                $ids = explode(",", $fieldIdentifiers);
133
            }
134
135
            if (is_array($fieldIdentifiers)) {
136
                $ids = array_filter($fieldIdentifiers);
137
            }
138
139
            return array_unique((array)$ids);
140
        }
141
142
        return [];
143
    }
144
145
    protected function proceedWithAction(InputInterface $input, OutputInterface $output)
146
    {
147
        if ($input->getOption('neglect')) {
148
            return true;
149
        }
150
        $helper = $this->getHelper('question');
151
        $question = new ConfirmationQuestion("Continue with this action? y/n ", false, '/^(y|j)/i');
152
153
        if ($helper->ask($input, $output, $question)) {
154
            return true;
155
        }
156
157
        return false;
158
    }
159
160
    protected function getDateFromPeriod()
161
    {
162
        $dt = new DateTime();
163
        $dt->sub($this->period);
164
165
        return $dt;
166
    }
167
}
168