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/Command/SyncKitsuWithMal.php (10 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\Command;
18
19
use Amp\Artax;
20
use Aviat\AnimeClient\API\Kitsu;
21
22
/**
23
 * Clears the API Cache
24
 */
25
class SyncKitsuWithMal extends BaseCommand {
26
27
	protected $kitsuModel;
28
	protected $malModel;
29
30
	/**
31
	 * Run the image conversion script
32
	 *
33
	 * @param array $args
34
	 * @param array $options
35
	 * @return void
36
	 * @throws \ConsoleKit\ConsoleException
37
	 */
38
	public function execute(array $args, array $options = [])
39
	{
40
		$this->setContainer($this->setupContainer());
41
		$this->setCache($this->container->get('cache'));
42
		$this->kitsuModel = $this->container->get('kitsu-model');
43
		$this->malModel = $this->container->get('mal-model');
44
45
		//$kitsuCount = $this->getKitsuAnimeListPageCount();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
46
		//$this->echoBox("List item count: {$kitsuCount}");
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% 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...
47
		$this->MALItemCreate();
48
49
		//echo json_encode($this->getMALList(), \JSON_PRETTY_PRINT);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
50
	}
51
52
53
	public function getMALList()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
54
	{
55
		return $this->malModel->getFullList();
56
	}
57
58
	public function getKitsuAnimeListPageCount()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
59
	{
60
		$cacheItem = $this->cache->getItem(Kitsu::AUTH_TOKEN_CACHE_KEY);
61
62
		$query = http_build_query([
63
			'filter' => [
64
				'user_id' => $this->kitsuModel->getUserIdByUsername(),
65
				'media_type' => 'Anime'
66
			],
67
			// 'include' => 'anime,anime.genres,anime.mappings,anime.streamingLinks',
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
68
			'page' => [
69
				'limit' => 1
70
			],
71
			'sort' => '-updated_at'
72
		]);
73
		$request = (new Artax\Request)
74
			->setUri("https://kitsu.io/api/edge/library-entries?{$query}")
75
			->setProtocol('1.1')
76
			->setAllHeaders([
77
				'Accept' => 'application/vnd.api+json',
78
				'Content-Type' => 'application/vnd.api+json',
79
				'User-Agent' => "Tim's Anime Client/4.0"
80
			]);
81
82
		if ($cacheItem->isHit())
83
		{
84
			$token = $cacheItem->get();
85
			$request->setHeader('Authorization', "bearer {$token}");
86
		}
87
		else
88
		{
89
			$this->echoBox("WARNING: NOT LOGGED IN\nSome data might be missing");
90
		}
91
92
		$response = \Amp\wait((new Artax\Client)->request($request));
93
94
		$body = json_decode($response->getBody(), TRUE);
95
		return $body['meta']['count'];
96
	}
97
98
	public function MALItemCreate()
99
	{
100
		$input = json_decode('{
0 ignored issues
show
$input is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
101
			"watching_status": "current",
102
			"user_rating": "",
103
			"episodes_watched": "4",
104
			"rewatched": "0",
105
			"notes": "",
106
			"id": "15794526",
107
			"mal_id": "33731",
108
			"edit": "true"
109
		}', TRUE);
110
111
		$response = $this->malModel->createListItem([
0 ignored issues
show
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
112
			'id' => 12255,
113
			'status' => 'planned',
114
			'type' => 'anime'
115
		]);
116
117
		//$response = $this->malModel->updateListItem($input);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
118
		//print_r($response);
119
		//echo $response->getBody();
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% 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...
120
121
	}
122
123
	public function diffLists()
124
	{
125
		// Get libraryEntries with media.mappings from Kitsu
126
		// Organize mappings, and ignore entries without mappings
127
128
		// Get MAL list data
129
130
		// Compare each list entry
131
			// If a list item exists only on MAL, create it on Kitsu with the existing data from MAL
132
			// If a list item exists only on Kitsu, create it on MAL with the existing data from Kitsu
133
			// If an item already exists on both APIS:
134
				// Compare last updated dates, and use the later one
135
				// Otherwise, use rewatch count, then episode progress as critera for selecting the more up
136
				// to date entry
137
				// Based on the 'newer' entry, update the other api list item
138
	}
139
140
141
}