Skip to content

Commit 4c56f71

Browse files
Merge pull request #788 from ninan27/translate-input1
Translate "Lab Exercise input1" into Japanese
2 parents 3c2baf3 + 63cdbbd commit 4c56f71

File tree

3 files changed

+138
-5
lines changed

3 files changed

+138
-5
lines changed

docs/labs/checker.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ const resources = {
6161
already_correct: '答えはすでに正しいです!',
6262
complete: '完了',
6363
completed: '完了しました',
64-
congrats: 'おめでとうございます!」あなたの答えは正解です!',
65-
congrats_all: '素晴らしい仕事でした!あなたの答えはすべて正解です!',
64+
congrats: 'おめでとうございます!正解です!',
65+
congrats_all: '素晴らしい!すべて正解です!',
6666
expecting: "次のような答えを期待していました:\n{0}",
6767
give_up_title: '諦めて答えを示してください。',
6868
hint_title: '現在の試行に関するヒントを提供します。',
6969
no_hints: '申し訳ありませんが、このラボにはヒントがありません。',
7070
no_matching_hint: '申し訳ありませんが、あなたの試みに一致するヒントが見つかりません。',
71-
reset_title: '初期状態をリセットします (現在の試行を破棄します)。',
72-
to_be_completed: '完成する',
71+
reset_title: '初期状態にリセットします (現在の試行を破棄します)。',
72+
to_be_completed: '完了する',
7373
try_harder_give_up: 'もっと頑張れ!そんなにすぐに諦めないでください。開始または最後のヒントから経過した現在の時間 (秒単位): {0}',
74-
try_harder_hint: "もっと頑張れ!すぐにヒントを求めず、少なくとも {0} 秒待ちます。",
74+
try_harder: 'もっと頑張ってください! すぐに諦めないでください。現在の所要時間 (秒): {0}',
7575
},
7676
},
7777
fr: {

docs/labs/input1.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ info =
77
{
88
absent: ", $",
99
text: "This is a parameter, it must end with a comma.",
10+
text_ja: "パラメータはカンマで終わる必要があります。",
1011
examples: [
1112
[ " " ]
1213
],
1314
},
1415
{
1516
absent: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \)`,
1617
text: "Add query(\"id\") to verify its value.",
18+
text_ja: "query(\"id\")を追加して、値を検証してください。",
1719
examples: [
1820
[ "," ],
1921
[ " query()," ]
@@ -22,13 +24,15 @@ info =
2224
{
2325
present: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \) [^. ]`,
2426
text: "After query(\"id\") use a period to invoke a verification method.",
27+
text_ja: "query(\"id\")の後にピリオドを追加して、バリデーションメソッドを呼び出してください。",
2528
examples: [
2629
[ " query('id')," ]
2730
],
2831
},
2932
{
3033
present: "(isint|Isint|IsInt|ISINT)",
3134
text: "JavaScript is case-sensitive. Use isInt instead of the case you have.",
35+
text_ja: "JavaScriptは大文字と小文字を区別します。使用している文字の代わりにisIntを使用してください。",
3236
examples: [
3337
[ " query('id').isint()," ],
3438
[ " query('id').IsInt()," ]
@@ -37,55 +41,63 @@ info =
3741
{
3842
absent: "isInt",
3943
text: "Use isInt to determine if the parameter is an integer.",
44+
text_ja: "パラメータが整数かどうかを判断するためにisIntを使用してください。",
4045
examples: [
4146
[ " query('id').," ]
4247
],
4348
},
4449
{
4550
present: String.raw` query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \).*\([^)]*$`,
4651
text: "After query(\"id\") you have an ( but there's no matching ).",
52+
text_ja: "query(\"id\") の後に必要なものがありません。",
4753
examples: [
4854
[ " query('id').isInt(," ]
4955
],
5056
},
5157
{
5258
absent: String.raw`isInt \(.*\)`,
5359
text: "isInt should be followed by (...).",
60+
text_ja: "isIntの後に書くべきものがあります。",
5461
examples: [
5562
[ " query('id').isInt," ]
5663
],
5764
},
5865
{
5966
present: String.raw`\{[^}]*$`,
6067
text: "You have started an object using { but there's no matching }.",
68+
text_ja: "{を使用してオブジェクトを開始していますが、対応する}がありません。",
6169
examples: [
6270
[ " query('id').isInt({)," ]
6371
],
6472
},
6573
{
6674
absent: String.raw`isInt \( \{.*\} \)`,
6775
text: "Inside the parenthesis of isInt() you should have an object like {...}.",
76+
text_ja: "isInt()の括弧内には、{...}のようなオブジェクトを記述する必要があります。",
6877
examples: [
6978
[ " query('id').isInt()," ]
7079
],
7180
},
7281
{
7382
absent: "min",
7483
text: "Use min: to specify a minimum value.",
84+
text_ja: "最小値を指定するには min: を使用してください。",
7585
examples: [
7686
[ " query('id').isInt({})," ]
7787
],
7888
},
7989
{
8090
absent: "max",
8191
text: "Use max: to specify a minimum value.",
92+
text_ja: "最大値を指定するには max: を使用してください。",
8293
examples: [
8394
[ " query('id').isInt({min: 1})," ]
8495
],
8596
},
8697
{
8798
present: "max.*min",
8899
text: "JavaScript allows hash entries to be in any order, but this can be confusing to humans. Conventionally minimum values are given before maximum values; please follow that convention.",
100+
text_ja: "JavaScriptではハッシュエントリの順序は任意ですが、人間にとっては混乱する可能性があります。慣例的に最小値は最大値の前に記述されますので、この慣例に従ってください。",
89101
examples: [
90102
[ " query('id').isInt({max: 9999, min: 1})," ]
91103
],

docs/labs/ja_input1.html

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<!DOCTYPE html>
2+
<html lang="ja">
3+
<head>
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
7+
<link rel="stylesheet" href="checker.css">
8+
<script src="checker.js"></script>
9+
<script src="input1.js"></script>
10+
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
11+
12+
<!-- See create_labs.md for how to create your own lab! -->
13+
14+
</head>
15+
<body>
16+
<!-- For GitHub Pages formatting: -->
17+
<div class="container-lg px-3 my-5 markdown-body">
18+
<h1>ラボ演習 input1</h1>
19+
<p>
20+
これはセキュアなソフトウェア開発に関するラボ演習です。
21+
ラボの詳細については、<a href="introduction.html" target="_blank">概要</a>をご覧ください。
22+
23+
<p>
24+
<h2>ゴール</h2>
25+
<p>
26+
単純なデータ型の入力の検証を練習します。
27+
28+
<p>
29+
<h2>背景</h2>
30+
<p>
31+
この演習では、Expressフレームワーク(バージョン4)とexpress-validatorライブラリを使用して、JavaScriptで書かれたサーバー側のプログラムに簡単な入力検証を追加します。
32+
ポイントは、これらの特定の技術について学ぶことではなく、一般的に安全なソフトウェアを書く方法を学ぶことです。
33+
34+
<p>
35+
<!-- https://expressjs.com/en/guide/routing.html -->
36+
Expressでは、システムが特定のリクエストを受け取ったときに、関数のリスト"handlers(ハンドラ)"を実行するように指定できます。
37+
<tt>express-validator</tt>ライブラリは、バリデーションチェックを簡単に追加できるようにするための関数のセットを提供しています。
38+
39+
<p>
40+
以下のコードでは、<tt>/invoices</tt> パスの <tt>get</tt> リクエストに対してハンドラを設定しています。バリデーションエラーがない場合は、コードは請求書IDを表示します。
41+
バリデーションエラーがある場合は、HTTPエラーコード422"Unprocessable Content(処理できないコンテンツ)"で応答します。
42+
これは、何らかの理由でリクエストが無効であったことを示すステータスコードであり、エラーメッセージも表示されます。
43+
44+
45+
<p>
46+
残念ながら、このプログラムは適切な入力検証を行っていません。
47+
このアプリケーションでは、<tt>id</tt>は1から9999までの整数でなければなりませんが、そのチェックを実行していません。
48+
そのため、このプログラムにはクロスサイト スクリプティング(XSS)と呼ばれる、まだ説明していない脆弱性があります。
49+
このXSS脆弱性により、攻撃者は<tt>id</tt>の中に悪意のあるスクリプトを挿入することができてしまうので、ビューアーがそれを自動的に実行する可能性があります!
50+
この脆弱性は、入力検証をすることで完全に防ぐことができます。
51+
52+
<p>
53+
<h2>タスク</h2>
54+
<p>
55+
タスクを完了するには、以下を実行します。
56+
<ol>
57+
<li><tt>app.get</tt>の最初のパラメータ<tt>'/invoices'</tt>の後に、コンマで区切られた新しいパラメータを追加します。
58+
<li>この新しいパラメータを<tt>query('id')</tt>で開始して、検証用の<tt>id</tt>パラメータを選択します (開始しやすいようにこの部分は入力してあります)。
59+
<li><tt>query('id')</tt>の後(終了のカンマの前) に、ピリオド(<tt>.</tt>)と検証要件 <tt>isInt()</tt>を追加します
60+
(<tt>isInt()</tt>は、名前付きパラメータが整数であることを検証します)。
61+
<li><tt>isInt</tt>メソッドは、括弧内のオプションパラメーターとして、最小値と最大値を提供するオブジェクトを受け取ります
62+
(例: <tt>isInt({min: YOUR_MINIMUM, max: YOUR_MAXIMUM})</tt>) 。許容範囲を指定するには、minとmaxを設定します。
63+
</ol>
64+
65+
<p>
66+
注意: JavaScript の名前は大文字と小文字が区別されるため、<tt>isint</tt>では機能しません。
67+
このパラメータの末尾をコンマで示すことを忘れないでください (開始時に入力されているテキストではこれを行っています)。
68+
69+
<p>
70+
必要に応じてヒントボタンを使用してください。
71+
72+
<p>
73+
<h2>Interactive Lab (<span id="grade"></span>)</h2>
74+
<p>
75+
<b>
76+
以下のコードは、クエリパラメータ<tt>id</tt>を入力として受け入れます。<tt>id</tt>が1から9999までの整数 (1と9999も含む) である場合にのみ、受け入れられるように変更してください。
77+
</b>
78+
<p>
79+
<!--
80+
You can use this an example for new labs.
81+
For multi-line inputs, instead of <input id="attempt0" type="text" ...>, use
82+
<textarea id="attempt" rows="2" cols="65">...</textarea>
83+
-->
84+
<form id="lab">
85+
<pre><code
86+
>// Set up Express framework and express-validator library
87+
const express = require("express");
88+
const app = express();
89+
const { query, matchedData, validationResult } =
90+
require('express-validator');
91+
92+
// Implement requests, e.g., http://localhost:3000/invoices?id=1
93+
app.get('/invoices',
94+
<input id="attempt0" type="text" size="65" spellcheck="false"
95+
value=" query('id'),">
96+
(req, res) =&gt; { // Execute this code if /invoices seen
97+
const result = validationResult(req); // Retrieve errors
98+
if (result.isEmpty()) { // No errors
99+
const data = matchedData(req); // Retrieve matching data
100+
return res.send(`You requested invoice id ${data.id}!`);
101+
}
102+
res.status(422).send(`Invalid input`);
103+
})
104+
</code></pre>
105+
<button type="button" class="hintButton">Hint</button>
106+
<button type="button" class="resetButton">Reset</button>
107+
<button type="button" class="giveUpButton">Give up</button>
108+
<br><br>
109+
<p>
110+
<i>This lab was developed by David A. Wheeler at
111+
<a href="https://www.linuxfoundation.org/"
112+
>The Linux Foundation</a>.</i>
113+
<br><br><!-- These go in the last form if there's more than one: -->
114+
<p id="correctStamp" class="small">
115+
<textarea id="debugData" class="displayNone" rows="20" cols="65" readonly>
116+
</textarea>
117+
</form>
118+
119+
</div><!-- End GitHub pages formatting -->
120+
</body>
121+
</html>

0 commit comments

Comments
 (0)