Skip to content

Commit 5931ca0

Browse files
committed
Translate input1 to JA
Translate input1.html, input1.js, checker.js to JA Signed-off-by: Non Kawana <[email protected]>
1 parent bb0cf24 commit 5931ca0

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
@@ -47,16 +47,16 @@ const resources = {
4747
already_correct: '答えはすでに正しいです!',
4848
complete: '完了',
4949
completed: '完了しました',
50-
congrats: 'おめでとうございます!」あなたの答えは正解です!',
51-
congrats_all: '素晴らしい仕事でした!あなたの答えはすべて正解です!',
50+
congrats: 'おめでとうございます!正解です!',
51+
congrats_all: '素晴らしい!すべて正解です!',
5252
expecting: "次のような答えを期待していました:\n{0}",
5353
give_up_title: '諦めて答えを示してください。',
5454
hint_title: '現在の試行に関するヒントを提供します。',
5555
no_hints: '申し訳ありませんが、このラボにはヒントがありません。',
5656
no_matching_hint: '申し訳ありませんが、あなたの試みに一致するヒントが見つかりません。',
57-
reset_title: '初期状態をリセットします (現在の試行を破棄します)。',
58-
to_be_completed: '完成する',
59-
try_harder: 'もっと頑張ってください! すぐに諦めないでください。現在の所要時間 (秒): {0}',
57+
reset_title: '初期状態にリセットします (現在の試行を破棄します)。',
58+
to_be_completed: '完了する',
59+
try_harder: 'もっと頑張ってください! すぐに諦めないでください。現在の所要時間 (秒): {0}',
6060
},
6161
},
6262
fr: {

docs/labs/input1.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ info =
44
{
55
absent: ", $",
66
text: "This is a parameter, it must end with a comma.",
7+
text_ja: "パラメータはカンマで終わる必要があります。",
78
examples: [
89
[ " " ]
910
],
1011
},
1112
{
1213
absent: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \)`,
1314
text: "Add query(\"id\") to verify its value.",
15+
text_ja: "query(\"id\")を追加して、値を検証してください。",
1416
examples: [
1517
[ "," ],
1618
[ " query()," ]
@@ -19,13 +21,15 @@ info =
1921
{
2022
present: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \) [^. ]`,
2123
text: "After query(\"id\") use a period to invoke a verification method.",
24+
text_ja: "query(\"id\")の後にピリオドを追加して、バリデーションメソッドを呼び出してください。",
2225
examples: [
2326
[ " query('id')," ]
2427
],
2528
},
2629
{
2730
present: "(isint|Isint|IsInt|ISINT)",
2831
text: "JavaScript is case-sensitive. Use isInt instead of the case you have.",
32+
text_ja: "JavaScriptは大文字と小文字を区別します。使用している文字の代わりにisIntを使用してください。",
2933
examples: [
3034
[ " query('id').isint()," ],
3135
[ " query('id').IsInt()," ]
@@ -34,55 +38,63 @@ info =
3438
{
3539
absent: "isInt",
3640
text: "Use isInt to determine if the parameter is an integer.",
41+
text_ja: "パラメータが整数かどうかを判断するためにisIntを使用してください。",
3742
examples: [
3843
[ " query('id').," ]
3944
],
4045
},
4146
{
4247
present: String.raw` query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \).*\([^)]*$`,
4348
text: "After query(\"id\") you have an ( but there's no matching ).",
49+
text_ja: "query(\"id\") の後に必要なものがありません。",
4450
examples: [
4551
[ " query('id').isInt(," ]
4652
],
4753
},
4854
{
4955
absent: String.raw`isInt \(.*\)`,
5056
text: "isInt should be followed by (...).",
57+
text_ja: "isIntの後に書くべきものがあります。",
5158
examples: [
5259
[ " query('id').isInt," ]
5360
],
5461
},
5562
{
5663
present: String.raw`\{[^}]*$`,
5764
text: "You have started an object using { but there's no matching }.",
65+
text_ja: "{を使用してオブジェクトを開始していますが、対応する}がありません。",
5866
examples: [
5967
[ " query('id').isInt({)," ]
6068
],
6169
},
6270
{
6371
absent: String.raw`isInt \( \{.*\} \)`,
6472
text: "Inside the parenthesis of isInt() you should have an object like {...}.",
73+
text_ja: "isInt()の括弧内には、{...}のようなオブジェクトを記述する必要があります。",
6574
examples: [
6675
[ " query('id').isInt()," ]
6776
],
6877
},
6978
{
7079
absent: "min",
7180
text: "Use min: to specify a minimum value.",
81+
text_ja: "最小値を指定するには min: を使用してください。",
7282
examples: [
7383
[ " query('id').isInt({})," ]
7484
],
7585
},
7686
{
7787
absent: "max",
7888
text: "Use max: to specify a minimum value.",
89+
text_ja: "最大値を指定するには max: を使用してください。",
7990
examples: [
8091
[ " query('id').isInt({min: 1})," ]
8192
],
8293
},
8394
{
8495
present: "max.*min",
8596
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.",
97+
text_ja: "JavaScriptではハッシュエントリの順序は任意ですが、人間にとっては混乱する可能性があります。慣例的に最小値は最大値の前に記述されますので、この慣例に従ってください。",
8698
examples: [
8799
[ " query('id').isInt({max: 9999, min: 1})," ]
88100
],

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)