Skip to content

Commit 86849e0

Browse files
Merge pull request #907 from Muuhh-CTJ/jp-translation-sql-injection
Japanese translation of sql-injection
2 parents 25b9f44 + 38590c7 commit 86849e0

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

docs/labs/ja_sql-injection.html

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html lang="ja">
3+
<head>
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
8+
<link rel="stylesheet" href="checker.css">
9+
<script src="checker.js"></script>
10+
<script src="sql-injection.js"></script>
11+
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
12+
13+
<!-- See create_labs.md for how to create your own lab! -->
14+
15+
</head>
16+
<body>
17+
<!-- For GitHub Pages formatting: -->
18+
<div class="container-lg px-3 my-5 markdown-body">
19+
<h1>ラボ演習 sql-injection</h1>
20+
<p>
21+
これはセキュアなソフトウェア開発に関するラボ演習です。
22+
ラボの詳細については、<a href="ja_introduction.html" target="_blank">概要</a>をご覧ください。
23+
24+
<p>
25+
<h2>ゴール</h2>
26+
<p>
27+
<b>SQL インジェクション攻撃を防ぐために、パラメータ化されたステートメントの構築方法を学びます
28+
</b>
29+
30+
<p>
31+
<h2>背景</h2>
32+
<p>
33+
パラメータ化されたステートメントは、SQLコードとデータ入力を分離することで SQL インジェクション攻撃を防ぐために使用されます。パラメータ化されたステートメントとは、ユーザー入力をクエリに直接埋め込むのではなく、プレースホルダを利用する SQL クエリです。これにより、クエリに悪意のあるコードが挿入されるのを防ぎます。
34+
<p>
35+
<h2>タスクの詳細</h2>
36+
<p>
37+
38+
<p>
39+
このラボでは、SQL インジェクション攻撃に関連するコードを学び、それを修正します。プリペアドステートメント / パラメータ化されたステートメントについて、いくつかの問いに答えてください。
40+
41+
<p>
42+
必要に応じて、「ヒント」ボタンと「諦める」ボタンを使用してください。
43+
44+
<p>
45+
<h2>演習 (<span id="grade"></span>)</h2>
46+
<p>
47+
Java で書かれた以下のサンプルコードを見ると、脆弱性を含むコードの一例であることが分かります。
48+
(この例は
49+
<a href="https://github.com/ossf/secure-sw-dev-fundamentals/blob/main/secure_software_development_fundamentals.md">Secure
50+
Software Development Fundamentals</a> コースの内容を直接引用しました)
51+
(訳注:リンクはコースの GitHub レポジトリを指しているため英語です)
52+
これをプリペアドステートメント(パラメータ化されたステートメントの一種)を使用するシーケンスとなるように書き換えます。
53+
最初の部分では、<tt>pstmt</tt> という名前で <tt>PreparedStatement</tt> 型の変数を作ります。
54+
二つ目の部分では、<tt>setString</tt> を使って検索対象を設定し、<tt>ResultSet</tt> 型の <tt>results</tt> 変数に結果を格納します。
55+
ここでは結果のコレクションを得たいので、クエリの実行には <tt>executeQuery</tt> を使用してください。
56+
57+
<form id="lab">
58+
<pre><code
59+
> // クエリの準備
60+
<textarea id="attempt0" rows="4" cols="60" spellcheck="false"
61+
> String QueryString =
62+
"select * from authors where lastname = ' " +
63+
search_lastname + " '; ";
64+
</textarea>
65+
// クエリの実行
66+
<textarea id="attempt1" rows="3" cols="60" spellcheck="false"
67+
> rs = statement.executeQuery(QueryString);
68+
</textarea>
69+
</code></pre>
70+
<button type="button" class="hintButton">ヒント</button>
71+
<button type="button" class="resetButton">リセット</button>
72+
<button type="button" class="giveUpButton">諦める</button>
73+
</form>
74+
<br><br>
75+
<p>
76+
<i>このラボは Elijah Everett, Jeremiah Howard, および Emily Lovell により
77+
<a href="https://github.com/emmet0r/contributor-catalyst"
78+
>Contributor Catalyst Program</a> の一部として、また David A. Wheeler により開発されました。</i>
79+
<br><br>
80+
<p id="correctStamp" class="small">
81+
<textarea id="debugData" class="displayNone" rows="20" cols="65" readonly>
82+
</textarea>
83+
</div>
84+
</body>
85+
</html>

docs/labs/sql-injection.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ info =
77
{
88
present: "search_lastname",
99
text: "You should replace \"search_lastname\" with a placeholder (?).",
10+
text_ja: "\"search_lastname\" をプレースホルダの (?) に置き換える必要があります。",
1011
index: 0,
1112
examples: [
1213
[
@@ -17,12 +18,14 @@ info =
1718
{
1819
absent: String.raw`\?`,
1920
text: "Write an parameterized statement with the Special character \"?\" added.",
21+
text_ja: "特殊文字である \"?\" を使ってパラメータ化されたステートメントを書いてください。",
2022
index: 0
2123
},
2224
{
2325
present: String.raw`\+`,
2426
index: 0,
2527
text: "There is no need for string concatenation. Use a simple constant string using the form \"...\".",
28+
text_ja: "文字列連結は必要ありません。\"...\" の形で定数文字列を使ってください。",
2629
examples: [
2730
[
2831
"String QueryString =\n \"select * from authors where lastname = \" + \"?\" + \" ; \";\n",
@@ -34,28 +37,33 @@ info =
3437
absent: String.raw`\s* PreparedStatement\s+pstmt = connection \.
3538
prepareStatement \( QueryString \) \; \s*`,
3639
text: "After defining the query string you should create a prepared statement, using the form `PreparedStatement pstmt = connection.prepareStatement(QueryString);`",
40+
text_ja: "クエリ文字列を定義したあとに、`PreparedStatement pstmt = connection.prepareStatement(QueryString);` の形でプリペアドステートメントを作成する必要があります。",
3741
},
3842
{
3943
absent: "search_lastname",
4044
present: "lastname",
4145
index: 1,
4246
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`.",
47+
text_ja: "`lastname` は検索するデータベースのフィールド名です。このフィールドからある特定の値を検索したいはずです。その値は `lastname` ではなく `search_lastname` に格納されています。",
4348
},
4449
{
4550
absent: String.raw`pstmt \. setString \( 1 , search_lastname \) \;`,
4651
index: 1,
4752
text: "Start the second section with a statement like `pstmt.setString(1, search_lastname);`",
53+
text_ja: "2つ目のセクションは `pstmt.setString(1, search_lastname);` で始めてください。",
4854
},
4955
{
5056
absent: "executeQuery",
5157
present: "execute",
5258
index: 1,
5359
text: "Use `executeQuery` not `execute` so we can receive and use a potential series of results (a `ResultSet`).",
60+
text_ja: "`execute` ではなく `executeQuery` を使用してください。これで一連の結果(ResultSet)を得ることができます。",
5461
},
5562
{
5663
absent: String.raw`\s* ResultSet\s+results = pstmt \. executeQuery \( \) \; \s*`,
5764
index: 1,
5865
text: "After using `setString` execute the query and place the results in `results`, something like `ResultSet results = pstmt.executeQuery();`",
66+
text_ja: "`setString` のあとでクエリを実行し、結果を `result` に格納してください。`ResultSet results = pstmt.executeQuery();` のような形になるはずです。",
5967
},
6068
],
6169
expected: [

0 commit comments

Comments
 (0)