This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved |
||
4 | * Copyright (c) Enalean, 2015. All Rights Reserved. |
||
5 | * |
||
6 | * This file is a part of Tuleap. |
||
7 | * |
||
8 | * Tuleap is free software; you can redistribute it and/or modify |
||
9 | * it under the terms of the GNU General Public License as published by |
||
10 | * the Free Software Foundation; either version 2 of the License, or |
||
11 | * (at your option) any later version. |
||
12 | * |
||
13 | * Tuleap is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | * GNU General Public License for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU General Public License |
||
19 | * along with Tuleap. If not, see <http://www.gnu.org/licenses/>. |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * Data Access Object for PluginHudsonJob |
||
24 | */ |
||
25 | class PluginHudsonJobDao extends DataAccessObject { |
||
26 | |||
27 | /** |
||
28 | * Gets all jobs in the db |
||
29 | * @return DataAccessResult |
||
30 | */ |
||
31 | function searchAll() { |
||
32 | $sql = "SELECT * FROM plugin_hudson_job"; |
||
33 | return $this->retrieve($sql); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Searches PluginHudsonJob by Codendi group ID |
||
38 | * @return DataAccessResult |
||
39 | */ |
||
40 | function searchByGroupID($group_id) { |
||
41 | $sql = sprintf("SELECT * |
||
42 | FROM plugin_hudson_job |
||
43 | WHERE group_id = %s", |
||
44 | $this->da->quoteSmart($group_id)); |
||
45 | return $this->retrieve($sql); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Searches PluginHudsonJob by job ID |
||
50 | * @return DataAccessResult |
||
51 | */ |
||
52 | function searchByJobID($job_id) { |
||
53 | $sql = sprintf("SELECT * |
||
54 | FROM plugin_hudson_job |
||
55 | WHERE job_id = %s", |
||
56 | $this->da->quoteSmart($job_id)); |
||
57 | return $this->retrieve($sql); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Searches PluginHudsonJob by job name |
||
62 | * @return DataAccessResult |
||
63 | */ |
||
64 | function searchByJobName($job_name) { |
||
65 | $sql = sprintf("SELECT * |
||
66 | FROM plugin_hudson_job |
||
67 | WHERE name = %s", |
||
68 | $this->da->quoteSmart($job_name)); |
||
69 | return $this->retrieve($sql); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Searches PluginHudsonJob by user ID |
||
74 | * means "all the jobs of all projects the user is member of" |
||
75 | * @return DataAccessResult |
||
76 | */ |
||
77 | function searchByUserID($user_id) { |
||
78 | $sql = sprintf("SELECT j.* |
||
79 | FROM plugin_hudson_job j, user u, user_group ug |
||
80 | WHERE ug.group_id = j.group_id AND |
||
81 | u.user_id = ug.user_id AND |
||
82 | u.user_id = %s", |
||
83 | $this->da->quoteSmart($user_id)); |
||
84 | return $this->retrieve($sql); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * create a row in the table plugin_hudson_job |
||
89 | * @return inserted job id if there is no error |
||
90 | */ |
||
91 | public function createHudsonJob( |
||
92 | $project_id, |
||
93 | $hudson_job_url, |
||
94 | $job_name, |
||
95 | $use_svn_trigger = false, |
||
96 | $use_cvs_trigger = false, |
||
97 | $token = null, |
||
98 | $svn_paths |
||
99 | ) { |
||
100 | $project_id = $this->da->quoteSmart($project_id); |
||
101 | $hudson_job_url = $this->da->quoteSmart($hudson_job_url); |
||
102 | $job_name = $this->da->quoteSmart($job_name); |
||
103 | $use_svn_trigger = $this->da->escapeInt($use_svn_trigger); |
||
104 | $use_cvs_trigger = $this->da->escapeInt($use_cvs_trigger); |
||
105 | $token = ($token !== null)? $this->da->quoteSmart($token) : $this->da->quoteSmart(''); |
||
106 | $svn_paths = $this->da->quoteSmart($svn_paths); |
||
107 | |||
108 | $sql = "INSERT INTO plugin_hudson_job (group_id, job_url, name, use_svn_trigger, use_cvs_trigger, token, svn_paths) |
||
109 | VALUES ($project_id, $hudson_job_url, $job_name, $use_svn_trigger, $use_cvs_trigger, $token, $svn_paths)"; |
||
110 | |||
111 | return $this->updateAndGetLastId($sql); |
||
112 | } |
||
113 | |||
114 | public function updateHudsonJob( |
||
115 | $job_id, |
||
116 | $hudson_job_url, |
||
117 | $job_name, |
||
118 | $use_svn_trigger = false, |
||
119 | $use_cvs_trigger = false, |
||
120 | $token = null, |
||
121 | $svn_paths |
||
122 | ) { |
||
123 | $job_id = $this->da->quoteSmart($job_id); |
||
124 | $hudson_job_url = $this->da->quoteSmart($hudson_job_url); |
||
125 | $job_name = $this->da->quoteSmart($job_name); |
||
126 | $use_svn_trigger = $this->da->escapeInt($use_svn_trigger); |
||
127 | $use_cvs_trigger = $this->da->escapeInt($use_cvs_trigger); |
||
128 | $token = ($token !== null)? $this->da->quoteSmart($token) : $this->da->quoteSmart(''); |
||
129 | $svn_paths = $this->da->quoteSmart($svn_paths); |
||
130 | |||
131 | $sql = "UPDATE plugin_hudson_job |
||
132 | SET job_url = $hudson_job_url, |
||
133 | name = $job_name, |
||
134 | use_svn_trigger = $use_svn_trigger, |
||
135 | use_cvs_trigger = $use_cvs_trigger, |
||
136 | token = $token, |
||
137 | svn_paths = $svn_paths |
||
138 | WHERE job_id = $job_id"; |
||
139 | |||
140 | return $this->update($sql); |
||
141 | } |
||
142 | |||
143 | function deleteHudsonJob($job_id) { |
||
144 | $sql = sprintf("DELETE FROM plugin_hudson_job WHERE job_id = %s", |
||
145 | $this->da->quoteSmart($job_id)); |
||
146 | $updated = $this->update($sql); |
||
147 | return $updated; |
||
148 | } |
||
149 | |||
150 | function deleteHudsonJobsByGroupID($group_id) { |
||
151 | $sql = sprintf("DELETE FROM plugin_hudson_job WHERE group_id = %s", |
||
152 | $this->da->quoteSmart($group_id)); |
||
153 | $updated = $this->update($sql); |
||
154 | return $updated; |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * Get jobs number |
||
159 | * |
||
160 | * @param Integer $groupId Id of the project |
||
161 | * |
||
162 | * @return DataAccessResult |
||
163 | */ |
||
164 | function countJobs($groupId = null) { |
||
165 | $condition = ''; |
||
166 | if ($groupId) { |
||
0 ignored issues
–
show
|
|||
167 | $condition = "AND group_id = ".$this->da->escapeInt($groupId); |
||
168 | } |
||
169 | $sql = "SELECT COUNT(*) AS count |
||
170 | FROM plugin_hudson_job |
||
171 | JOIN groups USING (group_id) |
||
172 | WHERE status = 'A' |
||
173 | ".$condition; |
||
174 | return $this->retrieve($sql); |
||
175 | } |
||
176 | } |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: