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
d05a373b
Commit
d05a373b
authored
Dec 14, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6519 from pana1990/patch-1
fix mistake small [skip ci]
parents
996856c0
0f0d9020
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
security-best-practices.md
docs/guide/security-best-practices.md
+4
-4
No files found.
docs/guide/security-best-practices.md
View file @
d05a373b
Security best practices
Security best practices
=======================
=======================
Below we'll review common security principles and describe how to avoid threats when developing applications using Yii.
Below we'll review common security principles and describe how to avoid threats when developing applications using Yii.
Basic principles
Basic principles
----------------
----------------
...
@@ -56,7 +56,7 @@ SELECT * FROM user WHERE username = ''; DROP TABLE user; --'
...
@@ -56,7 +56,7 @@ SELECT * FROM user WHERE username = ''; DROP TABLE user; --'
This is valid query that will search for users with empty username and then will drop
`user`
table most probably
This is valid query that will search for users with empty username and then will drop
`user`
table most probably
resulting in broken website and data loss (you've set up regular backups, right?).
resulting in broken website and data loss (you've set up regular backups, right?).
In Yii most of database querying happens via
[
Active Record
](
db-active-record.md
)
which properly uses PDO p
er
pared
In Yii most of database querying happens via
[
Active Record
](
db-active-record.md
)
which properly uses PDO p
re
pared
statements internally. In case of prepared statements it's not possible to manipulate query as was demonstrated above.
statements internally. In case of prepared statements it's not possible to manipulate query as was demonstrated above.
Still, sometimes you need
[
raw queries
](
db-dao.md
)
or
[
query builder
](
db-query-builder.md
)
. In this case you should use
Still, sometimes you need
[
raw queries
](
db-dao.md
)
or
[
query builder
](
db-query-builder.md
)
. In this case you should use
...
@@ -69,7 +69,7 @@ $userIDs = (new Query())
...
@@ -69,7 +69,7 @@ $userIDs = (new Query())
->
from
(
'user'
)
->
from
(
'user'
)
->
where
(
'status=:status'
,
[
':status'
=>
$status
])
->
where
(
'status=:status'
,
[
':status'
=>
$status
])
->
all
();
->
all
();
// DAO
// DAO
$userIDs
=
$connection
$userIDs
=
$connection
->
createCommand
(
'SELECT id FROM user where status=:status'
)
->
createCommand
(
'SELECT id FROM user where status=:status'
)
...
@@ -138,7 +138,7 @@ Avoiding debug info and tools at production
...
@@ -138,7 +138,7 @@ Avoiding debug info and tools at production
In debug mode Yii shows quite verbose errors which are certainly helpful for development. The thing is that these
In debug mode Yii shows quite verbose errors which are certainly helpful for development. The thing is that these
verbose errors are handy for attacker as well since these could reveal database structure, configuration values and
verbose errors are handy for attacker as well since these could reveal database structure, configuration values and
parts of your code. Never run production applications with
`YII_DEBUG`
set to
`true`
in your
`index.php`
.
parts of your code. Never run production applications with
`YII_DEBUG`
set to
`true`
in your
`index.php`
.
You should never enalble Gii at production. It could be used to get information about database structure, code and to
You should never enalble Gii at production. It could be used to get information about database structure, code and to
simply rewrite code with what's generated by Gii.
simply rewrite code with what's generated by Gii.
...
...
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