Issues (1)

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/Prompt/CopyrightPrompt.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 CL\ComposerInit\Prompt;
4
5
use GuzzleHttp\Client;
6
use CL\ComposerInit\GitConfig;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Helper\DialogHelper;
9
10
/**
11
 * @author    Ivan Kerin <[email protected]>
12
 * @copyright (c) 2014 Clippings Ltd.
13
 * @license   http://spdx.org/licenses/BSD-3-Clause
14
 */
15
class CopyrightPrompt implements PromptInterface
16
{
17
    /**
18
     * Github Client
19
     * @var Client
20
     */
21
    private $github;
22
23
    /**
24
     * @var GitConfig
25
     */
26
    private $gitConfig;
27
28
    /**
29
     * @param GitConfig $gitConfig
30
     * @param Client    $github
31
     */
32 1
    public function __construct(GitConfig $gitConfig, Client $github)
33
    {
34 1
        $this->github = $github;
35 1
        $this->gitConfig = $gitConfig;
36 1
    }
37
38
    /**
39
     * @return GitConfig
40
     */
41 1
    public function getGitConfig()
42
    {
43 1
        return $this->gitConfig;
44
    }
45
46
    /**
47
     * @return Client
48
     */
49 1
    public function getGithub()
50
    {
51 1
        return $this->github;
52
    }
53
54
    /**
55
     * Get default values from different sources
56
     *
57
     *  - github organization
58
     *  - github user
59
     *  - git user
60
     *  - file owner
61
     *
62
     * @return array
63
     */
64 3
    public function getDefaults()
65
    {
66 3
        $defaults = [];
67 3
        $origin = $this->gitConfig->getOrigin();
68
69 3
        if (null !== $origin) {
70 1
            $response = $this->github->get("/repos/{$origin}");
71 1
            $repo = json_decode($response->getBody(), true);
72
73 1
            if (isset($repo['organization'])) {
74 1
                $response = $this->github->get("/orgs/{$repo['organization']['login']}");
75 1
                $organizaion = json_decode($response->getBody(), true);
76 1
                $defaults []= $organizaion['name'];
77 1
            }
78
79 1
            $response = $this->github->get("/users/{$repo['owner']['login']}");
80
81 1
            $owner = json_decode($response->getBody(), true);
82 1
            $defaults []= $owner['name'];
83 1
        }
84
85 3
        $defaults []= $this->gitConfig->get('user.name');
86 3
        $defaults []= get_current_user();
87
88 3
        return array_values(
89 3
            array_unique(
90 3
                array_filter(
91
                    $defaults
92 3
                )
93 3
            )
94 3
        );
95
    }
96
97
    /**
98
     * Prepend a string to all items in array
99
     *
100
     * @param  string $prepend
101
     * @param  array  $array
102
     * @return array
103
     */
104
    public function prependToArray($prepend, array $array)
105
    {
106 1
        return array_map(function($item) use ($prepend) {
0 ignored issues
show
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
107 1
            return $prepend.$item;
108 1
        }, $array);
109
    }
110
111
    /**
112
     * @param  OutputInterface $output
113
     * @param  DialogHelper    $dialog
114
     * @return array
115
     */
116 1
    public function getValues(OutputInterface $output, DialogHelper $dialog)
117
    {
118 1
        $defaults = $this->prependToArray(
119 1
            date('Y').', ',
120 1
            $this->getDefaults()
121 1
        );
122
123 1
        $value = $dialog->ask(
124 1
            $output,
125 1
            "<info>Copyright</info> ({$defaults[0]}): ",
126 1
            $defaults[0],
127
            $defaults
128 1
        );
129
130
        return [
131 1
            'copyright' => $value,
132 1
            'copyright_entity' => preg_replace('/^\d{4}, +/', '', $value),
133 1
        ];
134
    }
135
}
136
137