質問編集履歴
2
引用の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -44,20 +44,22 @@
|
|
44
44
|
よく理解できずじまいの状態です。
|
45
45
|
|
46
46
|
原文は以下です。
|
47
|
-
## Unsafe SQL calls
|
48
47
|
|
48
|
+
> 引用テキスト
|
49
|
-
|
49
|
+
> ## Unsafe SQL calls
|
50
50
|
|
51
|
+
> When making database calls, it's highly important to protect > your code from SQL injection vulnerabilities. You need to > > update your code to use prepare() with your queries to protect > them.
|
52
|
+
>
|
51
|
-
Please review the following:
|
53
|
+
> Please review the following:
|
54
|
+
>
|
55
|
+
> * http://codex.wordpress.org/Class_Reference/wpdb#Protect_Queries> _Against_SQL_Injection_Attacks
|
56
|
+
> * http://codex.wordpress.org/Data_Validation#Database
|
57
|
+
> * http://make.wordpress.org/core/2012/12/12/php-warning-> missing-argument-2-for-wpdb-prepare/
|
58
|
+
> * http://ottopress.com/2013/better-know-a-vulnerability-sql-> injection/
|
59
|
+
>
|
52
60
|
|
53
|
-
* http://codex.wordpress.org/Class_Reference/wpdb#Protect_Queries_Against_SQL_Injection_Attacks
|
54
|
-
* http://codex.wordpress.org/Data_Validation#Database
|
55
|
-
* http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/
|
56
|
-
* http://ottopress.com/2013/better-know-a-vulnerability-sql-injection/
|
57
61
|
|
58
62
|
|
59
|
-
|
60
|
-
|
61
63
|
セキュリティ的な問題があるということはなんとなくわかったのですが、
|
62
64
|
結果的にどのような形にしたら良いのかアドバイス、ヒント等ご教授いただければ幸いです。
|
63
65
|
|
1
コードブロックで囲いました。編集・追記依頼似合わせて編集しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,12 +2,34 @@
|
|
2
2
|
データベースの内容を読み込んで利用するときに
|
3
3
|
例として以下のようにしています。
|
4
4
|
|
5
|
+
データベースにアクセスしてるのは複数ありますが、
|
6
|
+
主にはselectとupdateで以下の2つような形を使いまわしております。
|
7
|
+
|
8
|
+
```
|
5
9
|
global $wpdb;
|
6
10
|
$result = $wpdb->get_results( "SELECT * FROM wp_posts ORDER BY post_date ASC" );
|
7
11
|
foreach ($result as $value){
|
8
|
-
|
12
|
+
//もろもろ処理が入ってます。
|
9
13
|
}
|
10
14
|
|
15
|
+
|
16
|
+
|
17
|
+
//特定のidの記事のデータ一部を更新してます。
|
18
|
+
$post_id = $value->ID;
|
19
|
+
$wpdb->update($wpdb->posts,
|
20
|
+
array(
|
21
|
+
'カラム名1' => 値1,
|
22
|
+
'カラム名2' => 値2
|
23
|
+
),
|
24
|
+
array(
|
25
|
+
'ID' => $post_id
|
26
|
+
)
|
27
|
+
);
|
28
|
+
|
29
|
+
|
30
|
+
```
|
31
|
+
|
32
|
+
|
11
33
|
特にエラーなどもなく、作成したプラグイン自体は正常に動作はしているのですが、
|
12
34
|
wordpress.orgの公式にプラグインをアップの申請をした際に、
|
13
35
|
|
@@ -21,7 +43,23 @@
|
|
21
43
|
いっしょに、参考のURLも記載されていたのですが、リンク先がいずれも英語のため、
|
22
44
|
よく理解できずじまいの状態です。
|
23
45
|
|
46
|
+
原文は以下です。
|
47
|
+
## Unsafe SQL calls
|
48
|
+
|
49
|
+
When making database calls, it's highly important to protect your code from SQL injection vulnerabilities. You need to update your code to use prepare() with your queries to protect them.
|
50
|
+
|
51
|
+
Please review the following:
|
52
|
+
|
53
|
+
* http://codex.wordpress.org/Class_Reference/wpdb#Protect_Queries_Against_SQL_Injection_Attacks
|
54
|
+
* http://codex.wordpress.org/Data_Validation#Database
|
55
|
+
* http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/
|
56
|
+
* http://ottopress.com/2013/better-know-a-vulnerability-sql-injection/
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
24
61
|
セキュリティ的な問題があるということはなんとなくわかったのですが、
|
25
62
|
結果的にどのような形にしたら良いのかアドバイス、ヒント等ご教授いただければ幸いです。
|
26
63
|
|
27
|
-
よろしくお願いいたします。
|
64
|
+
よろしくお願いいたします。
|
65
|
+
追記:情報が不足していてすみませんでした。
|