From 7c724645a73f51cf022b1ebecd09ba64e8febb05 Mon Sep 17 00:00:00 2001 From: fukachan Date: Sun, 25 Nov 2001 12:03:23 +0000 Subject: how to restrict and check input data --- fml/doc/ja/tutorial/book.sgml | 5 +- fml/doc/ja/tutorial/include/chapters.ent | 3 +- fml/doc/ja/tutorial/internals/restriction.sgml | 92 ++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 fml/doc/ja/tutorial/internals/restriction.sgml diff --git a/fml/doc/ja/tutorial/book.sgml b/fml/doc/ja/tutorial/book.sgml index 3579d99b..f2004f2c 100644 --- a/fml/doc/ja/tutorial/book.sgml +++ b/fml/doc/ja/tutorial/book.sgml @@ -2,7 +2,7 @@ This is an sgml using DocBook dtd. Use sgmltools version 2.0.x or above to generate various output formats. -$FML: book.sgml,v 1.25 2001/11/25 03:52:12 fukachan Exp $ +$FML: book.sgml,v 1.26 2001/11/25 06:06:56 fukachan Exp $ --> + &chapter.restriction; + &chapter.db; &chapter.dbms; diff --git a/fml/doc/ja/tutorial/include/chapters.ent b/fml/doc/ja/tutorial/include/chapters.ent index 9b0388d2..d0521c9b 100644 --- a/fml/doc/ja/tutorial/include/chapters.ent +++ b/fml/doc/ja/tutorial/include/chapters.ent @@ -1,5 +1,5 @@ @@ -60,6 +60,7 @@ + diff --git a/fml/doc/ja/tutorial/internals/restriction.sgml b/fml/doc/ja/tutorial/internals/restriction.sgml new file mode 100644 index 00000000..3deb431c --- /dev/null +++ b/fml/doc/ja/tutorial/internals/restriction.sgml @@ -0,0 +1,92 @@ + + + + + 制限 + + + + + + FML::Restriction クラス + + + +入力データや、 +コマンドの ACL は +FML::Restriction クラス以下にモジュールを配置することにしています。 + + + +例えば、CGI では +FML::Restriction::CGI クラスのモジュールを用いて +入力データがある正規表現の中に収まるかどうか?の検査をしています。 + + + +FML::Restriction 以下では +Base を継承したりしますが、 +他のモジュールでは、FML::Restriction クラスを object composition +として使って下さい。 +例えば、 + +use FML::Restriction::CGI; +$safe = new FML::Restriction::CGI; +my $allowed_regexp = $safe->param_regexp(); + +if ($value =~ /^$allowed_regexp{$key}$) { ... ok, do something ... ;} + +のように使います。 + + + + + + + + CGI における入力データの制限 + + + +CGI では +FML::Restriction::CGI クラスのモジュールを用いて +入力データがある正規表現の中に収まるかどうか?の検査をします。 + + + +入力値は、前述のクラスの入力制限をうけるべきです。 +そのため、直接 param() を使ってはいけません。 +必ず safe_param_xxx() メソッドを通じてのみ、 +param() ( CGI モジュール )からのデータ入力をして下さい。 + + + +なお、入力されたキーワード一覧を調べるために、 + +for my $dirty_buf (param()) { + ... check ... +} + +のような構文は許す必要はあるでしょうが、 + +param($dirtty_buf) + +などとはしてはいけません。必ず + +for my $key (param()) { + ... check ... + + if (key eq $key) { + value = safe_param_key() + } +} + +のように書いて下さい。 + + + + + + -- cgit v1.2.1