Skip to content

Commit 5459af3

Browse files
author
vrana
committed
Fix dynamic string usage as safe input
Test Plan: $ arc lint Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4796
1 parent a808133 commit 5459af3

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

src/applications/auth/view/PhabricatorOAuthFailureView.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ public function render() {
7070

7171
$provider_key = $provider->getProviderKey();
7272
$diagnose = hsprintf(
73-
'<a href="/oauth/'.$provider_key.'/diagnose/" class="button green">'.
73+
'<a href="/oauth/%s/diagnose/" class="button green">'.
7474
'Diagnose %s OAuth Problems'.
7575
'</a>',
76+
$provider_key,
7677
$provider_name);
7778
}
7879

src/applications/diffusion/view/DiffusionBrowseTableView.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,21 @@ private static function loadLintMessagesCount(DiffusionRequest $drequest) {
9696

9797
$conn = $drequest->getRepository()->establishConnection('r');
9898

99-
$where = '';
99+
$path = '/'.$drequest->getPath();
100+
$where = (substr($path, -1) == '/'
101+
? qsprintf($conn, 'AND path LIKE %>', $path)
102+
: qsprintf($conn, 'AND path = %s', $path));
103+
100104
if ($drequest->getLint()) {
101-
$where = qsprintf(
102-
$conn,
103-
'AND code = %s',
104-
$drequest->getLint());
105+
$where .= qsprintf($conn, ' AND code = %s', $drequest->getLint());
105106
}
106107

107-
$like = (substr($drequest->getPath(), -1) == '/' ? 'LIKE %>' : '= %s');
108108
return head(queryfx_one(
109109
$conn,
110-
'SELECT COUNT(*) FROM %T WHERE branchID = %d %Q AND path '.$like,
110+
'SELECT COUNT(*) FROM %T WHERE branchID = %d %Q',
111111
PhabricatorRepository::TABLE_LINTMESSAGE,
112112
$branch->getID(),
113-
$where,
114-
'/'.$drequest->getPath()));
113+
$where));
115114
}
116115

117116
public function render() {

src/applications/search/engine/PhabricatorSearchEngineMySQL.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ public function executeSearch(PhabricatorSearchQuery $query) {
161161
if (strlen($q)) {
162162
$join[] = qsprintf(
163163
$conn_r,
164-
"{$t_field} field ON field.phid = document.phid");
164+
'%T field ON field.phid = document.phid',
165+
$t_field);
165166
$where[] = qsprintf(
166167
$conn_r,
167168
'MATCH(corpus) AGAINST (%s IN BOOLEAN MODE)',

src/infrastructure/celerity/CelerityResourceTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function transformResource($path, $data) {
7474
$bin = $root.'/externals/javelin/support/jsxmin/jsxmin';
7575

7676
if (@file_exists($bin)) {
77-
$future = new ExecFuture("{$bin} __DEV__:0");
77+
$future = new ExecFuture('%s __DEV__:0', $bin);
7878
$future->write($data);
7979
list($err, $result) = $future->resolve();
8080
if (!$err) {

src/infrastructure/lint/linter/PhabricatorJavelinLinter.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ private function loadSymbols($path) {
187187
}
188188

189189
private function newSymbolsFuture($path) {
190-
$javelinsymbols = 'javelinsymbols';
191-
192-
$future = new ExecFuture($javelinsymbols.' # '.escapeshellarg($path));
190+
$future = new ExecFuture('javelinsymbols # %s', $path);
193191
$future->write($this->getData($path));
194192
return $future;
195193
}

0 commit comments

Comments
 (0)