Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
37ec930f
Commit
37ec930f
authored
Dec 17, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added note on how to deal with filtering column names
parent
57bca30e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
security-best-practices.md
docs/guide/security-best-practices.md
+14
-1
No files found.
docs/guide/security-best-practices.md
View file @
37ec930f
...
@@ -77,7 +77,20 @@ $userIDs = $connection
...
@@ -77,7 +77,20 @@ $userIDs = $connection
->
queryColumn
();
->
queryColumn
();
```
```
If data is used to specify column names or table names it should be escaped. Yii has special syntax for such escaping
If data is used to specify column names or table names the best thing to do is to allow only predefined set of values:
```
php
function
actionList
(
$orderBy
=
null
)
{
if
(
!
in_array
(
$orderBy
,
[
'name'
,
'status'
]))
{
throw
new
BadRequestHttpException
(
'Only name and status are allowed to order by.'
)
}
// ...
}
```
In case it's not possible, table and column names should be escaped. Yii has special syntax for such escaping
which allows doing it the same way for all databases it supports:
which allows doing it the same way for all databases it supports:
```
php
```
php
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment