Issues (5)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/StatFetcher.php (4 issues)

1
<?php
2
3
namespace Vanbrabantf\NpmStatFetcher;
4
5
use Cake\Chronos\Chronos;
6
use DateTimeInterface;
7
use Vanbrabantf\NpmStatFetcher\Dates\DateChecker;
0 ignored issues
show
The type Vanbrabantf\NpmStatFetcher\Dates\DateChecker was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Vanbrabantf\NpmStatFetcher\Dates\DateRange;
9
use Vanbrabantf\NpmStatFetcher\Package\Package;
10
use Vanbrabantf\NpmStatFetcher\Statistics\DownloadStatistics;
11
12
class StatFetcher
13
{
14
    /**
15
     * @var NpmRegistryRepository
16
     */
17
    private $repository;
18
19
    /**
20
     * @param NpmRegistryRepository $repository
21
     */
22
    public function __construct(NpmRegistryRepository $repository = null)
23
    {
24
        $this->repository = $repository ?: new NpmRegistryRepository(ClientFactory::Build());
25
    }
26
27
28
    /**
29
     * @param string $packageName
30
     *
31
     * @return DownloadStatistics
32
     */
33
    public function getDownloadsLastDay(string $packageName): DownloadStatistics
34
    {
35
        $package = new Package($packageName);
36
37
        $resource = $this->repository->getResourceByPath(
38
            '/downloads/point/last-day/' . $package
39
        );
40
41
        return DownloadStatistics::fromJson($package, $resource);
42
    }
43
44
    /**
45
     * @param string $packageName
46
     *
47
     * @return DownloadStatistics
48
     */
49 View Code Duplication
    public function getDownloadsLastWeek(string $packageName): DownloadStatistics
0 ignored issues
show
This method 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...
50
    {
51
        $package = new Package($packageName);
52
53
        $resource = $this->repository->getResourceByPath(
54
            '/downloads/point/last-week/' . $package
55
        );
56
57
        return DownloadStatistics::fromJson($package, $resource);
58
    }
59
60
    /**
61
     * @param string $packageName
62
     *
63
     * @return DownloadStatistics
64
     */
65 View Code Duplication
    public function getDownloadsLastMonth(string $packageName): DownloadStatistics
0 ignored issues
show
This method 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...
66
    {
67
        $package = new Package($packageName);
68
69
        $resource = $this->repository->getResourceByPath(
70
            '/downloads/point/last-month/' . $package
71
        );
72
73
        return DownloadStatistics::fromJson($package, $resource);
74
    }
75
76
    /**
77
     * @param string $packageName
78
     *
79
     * @return DownloadStatistics
80
     */
81 View Code Duplication
    public function getDownloadsLastYear(string $packageName): DownloadStatistics
0 ignored issues
show
This method 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...
82
    {
83
        $package = new Package($packageName);
84
85
        $resource = $this->repository->getResourceByPath(
86
            '/downloads/point/last-year/' . $package
87
        );
88
89
        return DownloadStatistics::fromJson($package, $resource);
90
    }
91
92
    /**
93
     * @param string $packageName
94
     *
95
     * @return DownloadStatistics
96
     */
97
    public function getDownloads(string $packageName): DownloadStatistics
98
    {
99
        $package = new Package($packageName);
100
        $dateRange = new DateRange(new Chronos('1999-01-01'), new Chronos());
101
102
        $resource = $this->repository->getResourceByPath(
103
            '/downloads/point/' . $dateRange->getStartDate()->format('Y-m-d') .
104
            ':' . $dateRange->getEndDate()->format('Y-m-d') . '/' . $package
105
        );
106
107
        return DownloadStatistics::fromJson($package, $resource);
108
    }
109
110
    /**
111
     * @param string $packageName
112
     * @param DateTimeInterface $start
113
     * @param DateTimeInterface $end
114
     *
115
     * @return DownloadStatistics
116
     */
117
    public function getDownloadsBetweenDates(
118
        string $packageName,
119
        DateTimeInterface $start,
120
        DateTimeInterface $end
121
    ): DownloadStatistics {
122
        return $this->getDownloadsInDateRange(
123
            $packageName,
124
            new DateRange($start, $end)
125
        );
126
    }
127
128
    /**
129
     * @param string $packageName
130
     * @param DateRange $dateRange
131
     *
132
     * @return DownloadStatistics
133
     */
134
    public function getDownloadsInDateRange(
135
        string $packageName,
136
        DateRange $dateRange
137
    ): DownloadStatistics {
138
        $package = new Package($packageName);
139
140
        $resource = $this->repository->getResourceByPath(
141
            '/downloads/point/' . $dateRange->getStartDate()->format('Y-m-d') .
142
            ':' . $dateRange->getEndDate()->format('Y-m-d') . '/' . $package
143
        );
144
145
        return DownloadStatistics::fromJson($package, $resource);
146
    }
147
}
148