Issues (287)

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.

src/Model/Collection.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 declare(strict_types=1);
2
/**
3
 * Anime List Client
4
 *
5
 * An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
6
 *
7
 * PHP version 7
8
 *
9
 * @package     AnimeListClient
10
 * @author      Timothy J. Warren <[email protected]>
11
 * @copyright   2015 - 2017  Timothy J. Warren
12
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @version     4.0
14
 * @link        https://github.com/timw4mail/HummingBirdAnimeClient
15
 */
16
17
namespace Aviat\AnimeClient\Model;
18
19
20
use Aviat\Ion\Di\ContainerAware;
21
use Aviat\Ion\Di\ContainerInterface;
22
use Aviat\Ion\Model\DB;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Aviat\AnimeClient\Model\DB.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
23
use PDO;
24
use PDOException;
25
26
/**
27
 * Base model for anime and manga collections
28
 */
29
class Collection extends DB {
30
	
31
	use ContainerAware;
32
33
	/**
34
	 * Anime API Model
35
	 * @var object $anime_model
36
	 */
37
	protected $anime_model;
38
39
	/**
40
	 * Whether the database is valid for querying
41
	 * @var boolean
42
	 */
43
	protected $valid_database = FALSE;
44
45
	/**
46
	 * Create a new collection object
47
	 *
48
	 * @param ContainerInterface $container
49
	 */
50
	public function __construct(ContainerInterface $container)
51
	{
52
		$this->container = $container;
53
		
54
		parent::__construct($container->get('config'));
55
56
		try
57
		{
58
			$this->db = \Query($this->db_config['collection']);
59
		}
60
		catch (PDOException $e)
61
		{
62
			//$this->valid_database = FALSE;
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
63
			//return FALSE;
64
		}
65
		$this->anime_model = $container->get('anime-model');
66
67
		// Is database valid? If not, set a flag so the
68
		// app can be run without a valid database
69
		if ($this->db_config['collection']['type'] === 'sqlite')
70
		{
71
			$db_file_name = $this->db_config['collection']['file'];
72
73
			if ($db_file_name !== ':memory:' && file_exists($db_file_name))
74
			{
75
				$db_file = file_get_contents($db_file_name);
76
				$this->valid_database = (strpos($db_file, 'SQLite format 3') === 0);
77
			}
78
			else
79
			{
80
				$this->valid_database = FALSE;
81
			}
82
		}
83
		else
84
		{
85
			$this->valid_database = TRUE;
86
		}
87
	}
88
89
	/**
90
	 * Get genres for anime collection items
91
	 *
92
	 * @param array $filter
93
	 * @return array
94
	 */
95
	public function get_genre_list($filter = [])
96
	{
97
		$this->db->select('hummingbird_id, genre')
98
			->from('genre_anime_set_link gl')
99
			->join('genres g', 'g.id=gl.genre_id', 'left');
100
101
102
		if ( ! empty($filter))
103
		{
104
			$this->db->where_in('hummingbird_id', $filter);
105
		}
106
107
		$query = $this->db->order_by('hummingbird_id')
108
			->order_by('genre')
109
			->get();
110
111
		$output = [];
112
113
		foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row)
114
		{
115
			$id = $row['hummingbird_id'];
116
			$genre = $row['genre'];
117
118
			// Empty genre names aren't useful
119
			if (empty($genre))
120
			{
121
				continue;
122
			}
123
124
			if (array_key_exists($id, $output))
125
			{
126
				array_push($output[$id], $genre);
127
			}
128
			else
129
			{
130
				$output[$id] = [$genre];
131
			}
132
		}
133
134
		return $output;
135
	}
136
137
}
138
// End of Collection.php