diff --git a/docs/labs/ja_sql-injection.html b/docs/labs/ja_sql-injection.html new file mode 100644 index 00000000..a5a7c8cc --- /dev/null +++ b/docs/labs/ja_sql-injection.html @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + +
+

ラボ演習 sql-injection

+

+これはセキュアなソフトウェア開発に関するラボ演習です。 +ラボの詳細については、概要をご覧ください。 + +

+

ゴール

+

+SQL インジェクション攻撃を防ぐために、パラメータ化されたステートメントの構築方法を学びます + + +

+

背景

+

+パラメータ化されたステートメントは、SQLコードとデータ入力を分離することで SQL インジェクション攻撃を防ぐために使用されます。パラメータ化されたステートメントとは、ユーザー入力をクエリに直接埋め込むのではなく、プレースホルダを利用する SQL クエリです。これにより、クエリに悪意のあるコードが挿入されるのを防ぎます。 +

+

タスクの詳細

+

+ +

+このラボでは、SQL インジェクション攻撃に関連するコードを学び、それを修正します。プリペアドステートメント / パラメータ化されたステートメントについて、いくつかの問いに答えてください。 + +

+必要に応じて、「ヒント」ボタンと「諦める」ボタンを使用してください。 + +

+

演習 ()

+

+Java で書かれた以下のサンプルコードを見ると、脆弱性を含むコードの一例であることが分かります。 +(この例は +Secure +Software Development Fundamentals コースの内容を直接引用しました) +(訳注:リンクはコースの GitHub レポジトリを指しているため英語です) +これをプリペアドステートメント(パラメータ化されたステートメントの一種)を使用するシーケンスとなるように書き換えます。 +最初の部分では、pstmt という名前で PreparedStatement 型の変数を作ります。 +二つ目の部分では、setString を使って検索対象を設定し、ResultSet 型の results 変数に結果を格納します。 +ここでは結果のコレクションを得たいので、クエリの実行には executeQuery を使用してください。 + +

+
 // クエリの準備
+
+  // クエリの実行
+
+
+ + + +
+

+

+このラボは Elijah Everett, Jeremiah Howard, および Emily Lovell により +Contributor Catalyst Program の一部として、また David A. Wheeler により開発されました。 +

+

+ +

+ + diff --git a/docs/labs/sql-injection.js b/docs/labs/sql-injection.js index 65e1dda8..1249b773 100644 --- a/docs/labs/sql-injection.js +++ b/docs/labs/sql-injection.js @@ -7,6 +7,7 @@ info = { present: "search_lastname", text: "You should replace \"search_lastname\" with a placeholder (?).", + text_ja: "\"search_lastname\" をプレースホルダの (?) に置き換える必要があります。", index: 0, examples: [ [ @@ -17,12 +18,14 @@ info = { absent: String.raw`\?`, text: "Write an parameterized statement with the Special character \"?\" added.", + text_ja: "特殊文字である \"?\" を使ってパラメータ化されたステートメントを書いてください。", index: 0 }, { present: String.raw`\+`, index: 0, text: "There is no need for string concatenation. Use a simple constant string using the form \"...\".", + text_ja: "文字列連結は必要ありません。\"...\" の形で定数文字列を使ってください。", examples: [ [ "String QueryString =\n \"select * from authors where lastname = \" + \"?\" + \" ; \";\n", @@ -34,28 +37,33 @@ info = absent: String.raw`\s* PreparedStatement\s+pstmt = connection \. prepareStatement \( QueryString \) \; \s*`, text: "After defining the query string you should create a prepared statement, using the form `PreparedStatement pstmt = connection.prepareStatement(QueryString);`", + text_ja: "クエリ文字列を定義したあとに、`PreparedStatement pstmt = connection.prepareStatement(QueryString);` の形でプリペアドステートメントを作成する必要があります。", }, { absent: "search_lastname", present: "lastname", index: 1, text: "The term `lastname` is the name of the database field to be searched, However, you want to search for a specific value in that field. That value is held in the variable `search_lastname`, not in `lastname`.", + text_ja: "`lastname` は検索するデータベースのフィールド名です。このフィールドからある特定の値を検索したいはずです。その値は `lastname` ではなく `search_lastname` に格納されています。", }, { absent: String.raw`pstmt \. setString \( 1 , search_lastname \) \;`, index: 1, text: "Start the second section with a statement like `pstmt.setString(1, search_lastname);`", + text_ja: "2つ目のセクションは `pstmt.setString(1, search_lastname);` で始めてください。", }, { absent: "executeQuery", present: "execute", index: 1, text: "Use `executeQuery` not `execute` so we can receive and use a potential series of results (a `ResultSet`).", + text_ja: "`execute` ではなく `executeQuery` を使用してください。これで一連の結果(ResultSet)を得ることができます。", }, { absent: String.raw`\s* ResultSet\s+results = pstmt \. executeQuery \( \) \; \s*`, index: 1, text: "After using `setString` execute the query and place the results in `results`, something like `ResultSet results = pstmt.executeQuery();`", + text_ja: "`setString` のあとでクエリを実行し、結果を `result` に格納してください。`ResultSet results = pstmt.executeQuery();` のような形になるはずです。", }, ], expected: [