Issues (128)

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.

application/controllers/AdminPanel.php (5 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); defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class AdminPanel extends Admin_Controller {
4
	public function __construct() {
5
		parent::__construct();
6
7
		$this->load->library('table');
8
9
		$this->load->helper('form');
10
		$this->load->library('form_validation');
11
	}
12
13
	public function index() : void {
14
		$this->header_data['title'] = 'Admin Panel';
15
		$this->header_data['page']  = 'admin-panel';
16
17
		$this->body_data['complete_list'] = array_merge([['id', 'site_class', 'url']], $this->_list_complete_titles());
18
		$this->body_data['id_sql']        = 'SELECT * FROM `tracker_titles` WHERE id IN('.implode(',', array_column($this->body_data['complete_list'], 'id')).')';
19
20
		$template = array(
21
			'table_open' => '<table class="table table-striped">'
22
		);
23
24
		$this->table->set_template($template);
25
		$this->_render_page('AdminPanel');
26
	}
27
28
	public function update_normal() {
29
		set_time_limit(0);
30
31
		ob_start();
32
		$this->Tracker->admin->updateLatestChapters();
33
		ob_end_clean();
34
35
		$this->_redirect('Normal Update complete.');
36
	}
37
	public function update_custom() {
38
		set_time_limit(0);
39
		ob_start();
40
		$this->Tracker->admin->updateCustom();
41
		ob_end_clean();
42
43
		$this->_redirect('Custom Update complete.');
44
	}
45
	public function update_titles() {
46
		set_time_limit(0);
47
		$this->Tracker->admin->updateTitles();
0 ignored issues
show
The method updateTitles() does not seem to exist on object<Tracker_Admin_Model>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
49
		$this->_redirect('(Actual) Titles updated.');
50
	}
51
	public function update_mal_id() {
52
		set_time_limit(0);
53
		$this->_update_mal_backend();
54
55
		$this->_redirect('MAL Backend IDs updated.');
56
	}
57
	public function populate_db() {
58
		if(ENVIRONMENT === 'development') {
59
			//Populate list
60
			$randomUpdateData = [
61
				['mangadex.org', '18806:--:English', '12612:--:v1/c1'],
62
				['helveticascans.com', 'mousou-telepathy', 'en/0/1'],
63
				['elpsycongroo.tk', 'otomedanshi', 'en/1/1']
64
			];
65
			foreach($randomUpdateData as $updateData) {
66
				$updateData[] = TRUE; //Active marker
67
				$this->Tracker->list->update($this->User->id, ...$updateData);
0 ignored issues
show
The call to update() misses some required arguments starting with $title.
Loading history...
$updateData is of type array<integer,string|boolean>, but the function expects a string.

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...
68
69
			}
70
71
			//Populate favorites
72
			$randomFavouriteData = [
73
				['mangadex.org', '18806:--:English', '306123:--:c19', 10],
74
				['helveticascans.com', 'mousou-telepathy', 'en/0/564', NULL],
75
				['elpsycongroo.tk', 'otomedanshi', 'en/2/239', NULL]
76
			];
77
			foreach($randomFavouriteData as $favouriteData) {
78
				$favouriteData[] = FALSE;
79
				$this->Tracker->favourites->set($this->User->id, ...$favouriteData);
0 ignored issues
show
The call to set() misses some required arguments starting with $title.
Loading history...
$favouriteData is of type array<integer,?>, but the function expects a string.

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...
80
			}
81
82
			$this->_redirect('Populated Dev DB with data.');
83
		} else {
84
			$this->_redirect('Populate Dev DB failed as ENVIRONMENT is not development.');
85
		}
86
	}
87
88
	private function _redirect(string $message) : void {
89
		$this->session->set_flashdata('notices', $message);
90
		redirect(site_url('admin_panel'));
91
	}
92
93
	private function _list_complete_titles() {
94
		$query = $this->db->select('tracker_titles.id, tracker_sites.site_class, tracker_titles.title, tracker_titles.title_url')
95
		                  ->from('tracker_chapters')
96
		                  ->join('tracker_titles', 'tracker_chapters.title_id = tracker_titles.id', 'left')
97
		                  ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left')
98
		                  ->like('tracker_chapters.tags', 'complete')
99
		                  ->where('tracker_titles.status', 0)
100
		                  ->get();
101
102
		$completeList = [];
103
		if($query->num_rows() > 0) {
104
			foreach($query->result() as $row) {
105
				$data = [
106
					'id'         => $row->id,
107
					'site_class' => $row->site_class,
108
					'url'        => "<a href='".$this->Tracker->sites->{$row->site_class}->getFullTitleURL($row->title_url)."'>{$row->title}</a>"
109
				];
110
				$completeList[] = $data;
111
			}
112
		}
113
114
		return $completeList;
115
	}
116
117
	private function _update_mal_backend() : void {
118
		//Would prefer to use the query generator here, but don't think it's possible with what I'd like to do here.
119
120
		//Set backend MAL id if more than one person has it set as the same ID.
121
		//- This should be bumped up as we get more users to avoid abuse.
122
		$this->db->query('
123
			UPDATE
124
				tracker_titles dest,
125
				(
126
					SELECT tt.id, tc.mal_id
127
					FROM `tracker_chapters` tc
128
					LEFT JOIN `tracker_titles` tt ON tt.`id` = tc.`title_id`
129
					WHERE tt.mal_id IS NULL AND tc.mal_id IS NOT NULL
130
					GROUP BY tt.id, tc.mal_id
131
					HAVING COUNT(tc.mal_id) > 1
132
				) src
133
			SET dest.mal_id = src.mal_id
134
			WHERE dest.id = src.id
135
		');
136
137
		//Set backend MAL id if an admin has it set.
138
		//TODO: Preferably we'd have a trusted users group, but that is for later down the line...
139
		$this->db->query('
140
			UPDATE
141
				tracker_titles dest,
142
				(
143
					SELECT tt.id, tc.mal_id
144
					FROM `tracker_chapters` tc
145
					LEFT JOIN `tracker_titles` tt ON tt.`id` = tc.`title_id`
146
					LEFT JOIN `auth_users_groups` aug ON tc.`user_id` = aug.`user_id`
147
					WHERE tc.mal_id IS NOT NULL
148
					AND aug.`group_id` = 1
149
				) src
150
			SET dest.mal_id = src.mal_id
151
			WHERE dest.id = src.id
152
		');
153
	}
154
}
155