Skip to content

Commit 05561ad

Browse files
committed
Japanese translation of redos
Japanese translaton for docs/labs/redos.html and redos.js Signed-off-by: Muuhh IKEDA <[email protected]>
1 parent 1888053 commit 05561ad

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

docs/labs/ja_redos.html

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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="redos.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>ラボ演習 ReDoS</h1>
20+
<p>
21+
これはセキュアなソフトウェア開発に関するラボ演習です。
22+
ラボの詳細については、<a href="ja_introduction.html" target="_blank">概要</a>をご覧ください。
23+
24+
<p>
25+
<h2>タスク</h2>
26+
<p>
27+
ReDoS 攻撃の影響を受けるコードを特定し、修正する方法を学びます。
28+
29+
<p>
30+
<h2>背景</h2>
31+
<p>
32+
正規表現は、データが特定のパターンにマッチするかどうか確認する入力検証の一手段として使用されます。貧弱な設計の正規表現は、正規表現サービス拒否(regular expression denial-of-service : ReDoS)攻撃に対する脆弱性をもたらします。この攻撃は多くの正規表現実装が極端な状態に陥ることがあることを悪用するもので、攻撃者は正規表現実装が非常に長い間実行される状況を引き起こすことができます。しばしばその実行時間は入力の長さに対して指数関数的に増加します。
33+
34+
<p>
35+
この演習では ReDoS 攻撃に影響を受けやすい正規表現を用いた入力検証を修正します。
36+
37+
<p>
38+
<h2>タスクの詳細</h2>
39+
<p>
40+
41+
<p>
42+
以下のコードはパス <tt>/parts</tt> に対する get リクエストのハンドラを設定しています。このコードでは、例えば <tt>http://localhost:3000/parts?id=AB123</tt>(localhost のポート 3000 で待ち受けていることを想定)へのリクエストによって起動します。もし入力検証にエラーがなければ、このコードはパーツの ID を表示します。入力検証にエラーがある場合は、リクエストが何らかの理由で無効であることを示す HTTP エラーコード 422("Unprocessable Content")をエラーメッセージと共に返します。
43+
44+
<p>
45+
この演習では、ReDoS 攻撃に影響を受けやすい正規表現に対策を盛り込みます。
46+
<ol>
47+
<li>入力文字列の長さ上限を設け、最初に長さをチェックする。
48+
<ol>
49+
<li>ID パラメータ((<tt>query('id')</tt>)を選択したのち、文字列の長さを制限するために検証条件 <tt>isLength()</tt> を設ける。サイズの上限を設定するためのオプションパラメータを使用する必要があります : <tt>isLength({max: YOUR_MAXIMUM})</tt></li>
50+
</ol>
51+
</li>
52+
<li>最悪の事態を避けるために正規表現を修正する。特に、グループ "(...)" が分岐を含んでいたり、繰り返しで終わっていたり、それ自身が繰り返されていることがないように注意する必要があります。</li>
53+
</ol>
54+
55+
<p>
56+
必要に応じて、「ヒント」ボタンと「諦める」ボタンを使用してください。
57+
58+
<p>
59+
<h2>演習 (<span id="grade"></span>)</h2>
60+
<p>
61+
ReDoS 攻撃を回避するための変更を以下のコードへ加えてください。
62+
<ol>
63+
<li>クエリーパラメータ id が <b>50文字</b> を超えないように、入力文字列の長さに上限を設けてください。 </li>
64+
<li>最悪の事態に陥らないように正規表現を修正してください。正規表現はこの場合のパーツ ID フォーマットにマッチするよう設定します。すなわち 1文字以上の大文字アルファベットおよび数字 です。</li>
65+
</ol>
66+
67+
<form id="lab">
68+
<pre><code
69+
>// Express フレームワークと express-validator ライブラリのセットアップ
70+
const express = require("express");
71+
const app = express();
72+
const { query, matchedData, validationResult } =
73+
require('express-validator');
74+
75+
// リクエストに対する実装 例: http://localhost:3000/parts?id=1
76+
app.get('/parts',
77+
<input id="attempt0" type="text" size="65" spellcheck="false"
78+
value=" query('id').matches( /^([A-Z0-9]+)+$/ ) ,">
79+
(req, res) =&gt; { // もし /parts があればここが実行される
80+
const result = validationResult(req); // エラーを取得
81+
if (result.isEmpty()) { // エラーがない場合
82+
const data = matchedData(req); // マッチしたデータを取得
83+
return res.send(`You requested part id ${data.id}!`);
84+
}
85+
res.status(422).send(`Invalid input`);
86+
})
87+
</code></pre>
88+
<button type="button" class="hintButton">ヒント</button>
89+
<button type="button" class="resetButton">リセット</button>
90+
<button type="button" class="giveUpButton">諦める</button>
91+
<br><br>
92+
<p>
93+
<i>このラボは Camila Vilarinho によって開発されました。</i>
94+
<br><br><!-- These go in the last form if there's more than one: -->
95+
<p id="correctStamp" class="small">
96+
<textarea id="debugData" class="displayNone" rows="20" cols="65" readonly>
97+
</textarea>
98+
</form>
99+
</div><!-- End GitHub pages formatting -->
100+
</body>
101+
</html>

docs/labs/redos.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,72 +7,87 @@ info =
77
{
88
absent: ", $",
99
text: "This is a parameter, it must end with a comma.",
10+
text_ja: "これはパラメータです。カンマで終わる必要があります。",
1011
},
1112
{
1213
absent: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \)
1314
`,
1415
text: "Use query() with an 'id' parameter.",
16+
text_ja: "`id` をパラメータとして query() を使用してください。",
1517
},
1618
{
1719
present: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \) [^. ]
1820
`,
1921
text: "After query(\"id\") use a period to invoke a verification method.",
22+
text_ja: "検証メソッドを起動するため、query(\"id\") のあとにピリオドが必要です。",
2023
},
2124
{
2225
present: "(islength|Islength|IsLength|ISLENGTH)\n",
2326
text: "JavaScript is case-sensitive. Use isLength instead of the case you have.\n",
27+
text_ja: "JavaScript は大文字と小文字を区別します。isLength としてください。\n",
2428
},
2529
{
2630
absent: "isLength",
2731
text: "Limit the maximum length of input strings using isLength().",
32+
text_ja: "isLength() を使って入力文字列の長さを制限してください。",
2833
},
2934
{
3035
present: String.raw`isLength \( m
3136
`,
3237
text: "You need to pass isLength() an object with the max parameter, e.g., isLength({max: VALUE}).\n",
38+
text_ja: "isLength() には最大値とともにオブジェクトを渡します。例:isLength({max: VALUE}).\n",
3339
},
3440
{
3541
absent: "matches",
3642
text: "Use matches().",
43+
text_ja: "matches() を使ってください。",
3744
},
3845
{
3946
present: String.raw`matches \( /[^^]
4047
`,
4148
text: "Match the whole string - begin the regular expression with ^",
49+
text_ja: "文字列全体にマッチするよう、正規表現は ^ で始めてください。",
4250
},
4351
{
4452
present: String.raw`matches \( /.*[^$]/
4553
`,
4654
text: "Match the whole string - end the regular expression with $",
55+
text_ja: "文字列全体にマッチするよう、正規表現の最後は $ としてください。",
4756
},
4857
{
4958
present: String.raw`matches \( /.*[^$]/
5059
`,
5160
text: "Match the whole string - end the regular expression with $",
61+
text_ja: "文字列全体にマッチするよう、正規表現の最後は $ としてください。",
5262
},
5363
{
5464
present: String.raw`matches \( /\^\[A-Z\]
5565
`,
5666
text: "That would match only letters, you need digits as well.",
67+
text_ja: "文字にしかマッチしません。数字にもマッチさせる必要があります。",
5768
},
5869
{
5970
present: String.raw`matches \( /\^\[a-z\]
6071
`,
6172
text: "That would match only lower case letters, the format requirement is uppercase letters.",
73+
text_ja: "小文字にしかマッチしません。フォーマットへの要求は大文字です。",
6274
},
6375
{
6476
present: String.raw`matches \( /\^\(\[A-Z0-9\]\+\)\+\$
6577
`,
6678
text: "Remember to fix the regex, the outer + quantifier causes backtracking by trying to match one or more sequences of one or more uppercase alphanumeric characters.",
79+
text_ja: "正規表現の修正を忘れないでください。外側の + は一つ以上の大文字アルファベットおよび数字にマッチしようとして処理をさかのぼって繰り返す必要があります。",
6780
},
6881
{
6982
present: String.raw`matches \( /\^\(\[A-Z0-9\]\+\)\$
7083
`,
7184
text: "Remove the grouping, you don’t need the parentheses.",
85+
text_ja: "グルーピングを削除してください。カッコは必要ありません。",
7286
},
7387
{
7488
present: String.raw`\[0-9[Aa]-[Zz]\]`,
7589
text: "It's conventional to list letters first, so use [A-Z0-9] not [0-9A-Z]",
90+
text_ja: "文字を最初に並べるのが通例です。[0-9A-Z] ではなく、[A-Z0-9] とします。",
7691
},
7792
],
7893
expected: [

0 commit comments

Comments
 (0)