Skip to content

Commit 3ed85ab

Browse files
committed
docs: translate the first half of the security guide
1 parent ee5dc3f commit 3ed85ab

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

Diff for: src/guide/security.md

+37-37
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,122 @@
1-
# Security
1+
# セキュリティ
22

3-
## Reporting Vulnerabilities
3+
## 脆弱性の報告
44

5-
When a vulnerability is reported, it immediately becomes our top concern, with a full-time contributor dropping everything to work on it. To report a vulnerability, please email [[email protected]](mailto:[email protected]).
5+
脆弱性が報告されると、それは直ちに私たちの最重要課題となり、フルタイムコミットのコントリビュータがすべてを投げ出して取り組みます。脆弱性の報告は、[[email protected]](mailto:[email protected]) までメールしてください。
66

7-
While the discovery of new vulnerabilities is rare, we also recommend always using the latest versions of Vue and its official companion libraries to ensure your application remains as secure as possible.
7+
新しい脆弱性が発見されることはめったにありませんが、あなたのアプリケーションを可能な限り安全に保つために、Vue とその公式ライブラリの最新バージョンを常に利用することをおすすめします。
88

9-
## Rule No.1: Never Use Non-trusted Templates
9+
## 一番のルール: 信頼できないテンプレートを使わない
1010

11-
The most fundamental security rule when using Vue is **never use non-trusted content as your component template**. Doing so is equivalent to allowing arbitrary JavaScript execution in your application - and worse, could lead to server breaches if the code is executed during server-side rendering. An example of such usage:
11+
Vue を使うときの最も基本的なセキュリティルールは、 **信頼されていないコンテンツをコンポーネントのテンプレートに使わないこと** です。これはあなたのアプリケーションで任意の JavaScript の実行を許可することと同じで、さらに悪いことに、そのコードがサーバサイドレンダリング中に実行されると、サーバの侵害につながる可能性があります。そのような使い方の例です:
1212

1313
```js
1414
Vue.createApp({
15-
template: `<div>` + userProvidedString + `</div>` // NEVER DO THIS
15+
template: `<div>` + userProvidedString + `</div>` // 絶対にやってはいけないこと
1616
}).mount('#app')
1717
```
1818

19-
Vue templates are compiled into JavaScript, and expressions inside templates will be executed as part of the rendering process. Although the expressions are evaluated against a specific rendering context, due to the complexity of potential global execution environments, it is impractical for a framework like Vue to completely shield you from potential malicious code execution without incurring unrealistic performance overhead. The most straightforward way to avoid this category of problems altogether is to make sure the contents of your Vue templates are always trusted and entirely controlled by you.
19+
Vue のテンプレートは JavaScript にコンパイルされていて、テンプレート内の式はレンダリング処理の一部として実行されます。それらの式は特定のレンダリング・コンテキストに対して評価されますが、潜在的にグローバル実行環境が複雑なため、Vue のようなフレームワークが非現実的なパフォーマンスのオーバーヘッドを発生させることなく、潜在的な悪意のあるコードの実行から完全に保護することは現実的ではありません。このカテゴリの問題を完全に回避する最も簡単な方法は、あなたの Vue テンプレートのコンテンツが常に信頼され、完全に制御されるようにすることです。
2020

21-
## What Vue Does to Protect You
21+
## Vue があなたを守るために行っていること
2222

23-
### HTML content
23+
### HTML コンテンツ
2424

25-
Whether using templates or render functions, content is automatically escaped. That means in this template:
25+
テンプレートでも Render 関数でも、コンテンツは自動的にエスケープされます。つまり、このテンプレートでは:
2626

2727
```html
2828
<h1>{{ userProvidedString }}</h1>
2929
```
3030

31-
if `userProvidedString` contained:
31+
`userProvidedString` が含まれている場合:
3232

3333
```js
3434
'<script>alert("hi")</script>'
3535
```
3636

37-
then it would be escaped to the following HTML:
37+
これは次のような HTML にエスケープされます:
3838

3939
```html
4040
&lt;script&gt;alert(&quot;hi&quot;)&lt;/script&gt;
4141
```
4242

43-
thus preventing the script injection. This escaping is done using native browser APIs, like `textContent`, so a vulnerability can only exist if the browser itself is vulnerable.
43+
これにより、スクリプトの注入を防ぐことができます。このエスケープは、`textContent` のようなブラウザのネイティブ API を使って行われるため、ブラウザ自体に脆弱性がある場合にのみ脆弱性が存在します。
4444

45-
### Attribute bindings
45+
### 属性の束縛
4646

47-
Similarly, dynamic attribute bindings are also automatically escaped. That means in this template:
47+
同じように、動的な属性の束縛も自動的にエスケープされます。つまり、このテンプレートでは:
4848

4949
```html
5050
<h1 :title="userProvidedString">
5151
hello
5252
</h1>
5353
```
5454

55-
if `userProvidedString` contained:
55+
`userProvidedString` が含まれている場合:
5656

5757
```js
5858
'" onclick="alert(\'hi\')'
5959
```
6060

61-
then it would be escaped to the following HTML:
61+
これは次のような HTML にエスケープされます:
6262

6363
```html
6464
&quot; onclick=&quot;alert('hi')
6565
```
6666

67-
thus preventing the close of the `title` attribute to inject new, arbitrary HTML. This escaping is done using native browser APIs, like `setAttribute`, so a vulnerability can only exist if the browser itself is vulnerable.
67+
これにより、新しい任意の HTML を注入するために `title` 属性を閉じることができなくなります。このエスケープは、`setAttribute` のようなブラウザのネイティブ API を使って行われるため、ブラウザ自体に脆弱性がある場合にのみ脆弱性が存在します。
6868

69-
## Potential Dangers
69+
## 潜在的な危険性
7070

71-
In any web application, allowing unsanitized, user-provided content to be executed as HTML, CSS, or JavaScript is potentially dangerous, so should be avoided wherever possible. There are times when some risk may be acceptable though.
71+
ウェブアプリケーションにおいてはどれも、ユーザが提供したサニタイズしていないコンテンツを HTMLCSSJavaScript として実行させることは、潜在的に危険なため、可能な限り避けるべきです。しかし、いくつかのリスクを許容できる場合もあるでしょう。
7272

73-
For example, services like CodePen and JSFiddle allow user-provided content to be executed, but it's in a context where this is expected and sandboxed to some extent inside iframes. In the cases when an important feature inherently requires some level of vulnerability, it's up to your team to weigh the importance of the feature against the worst-case scenarios the vulnerability enables.
73+
例えば、CodePen JSFiddle といったサービスでは、ユーザが提供したコンテンツを実行することができますが、それは iframe の中である程度サンドボックス化されていて、想定されたコンテキストの中でのことです。もし重要な機能が本質的にいくらかの脆弱性を必要とする場合、その機能の重要性とその脆弱性が起こす可能性のある最悪のシナリオを比較検討するのは、あなたのチームの責任です。
7474

75-
### Injecting HTML
75+
### HTML の注入
7676

77-
As you learned earlier, Vue automatically escapes HTML content, preventing you from accidentally injecting executable HTML into your application. However, in cases where you know the HTML is safe, you can explicitly render HTML content:
77+
以前学んだように、Vue は自動的に HTML コンテンツをエスケープして、あなたのアプリケーション内で実行可能な HTML を誤って注入してしまうことを防ぎます。しかし、HTML が安全だとわかっている場合には、HTML コンテンツを明示的にレンダリングすることができます:
7878

79-
- Using a template:
79+
- テンプレートを利用:
8080

8181
```html
8282
<div v-html="userProvidedHtml"></div>
8383
```
8484

85-
- Using a render function:
85+
- Render 関数を利用:
8686

8787
```js
8888
h('div', {
8989
innerHTML: this.userProvidedHtml
9090
})
9191
```
9292

93-
- Using a render function with JSX:
93+
- JSX と Render 関数を利用:
9494

9595
```jsx
9696
<div innerHTML={this.userProvidedHtml}></div>
9797
```
9898

9999
:::tip
100-
Note that user-provided HTML can never be considered 100% safe unless it's in a sandboxed iframe or in a part of the app where only the user who wrote that HTML can ever be exposed to it. Additionally, allowing users to write their own Vue templates brings similar dangers.
100+
ユーザが提供した HTML は、サンドボックス化された iframe や、その HTML を書いたユーザだけがアクセスできるアプリケーションの一部に置かない限り、100% 安全とは言えないことにちゅうしてください。加えて、ユーザが独自の Vue テンプレートを書けるようにしても同様の危険があります。
101101
:::
102102

103-
### Injecting URLs
103+
### URL の注入
104104

105-
In a URL like this:
105+
このような URL :
106106

107107
```html
108108
<a :href="userProvidedUrl">
109109
click me
110110
</a>
111111
```
112112

113-
There's a potential security issue if the URL has not been "sanitized" to prevent JavaScript execution using `javascript:`. There are libraries such as [sanitize-url](https://www.npmjs.com/package/@braintree/sanitize-url) to help with this, but note:
113+
`javascript:` を使った JavaScript の実行を防ぐ URL の「サニタイズ」がされていないと、これにはセキュリティの問題を抱える可能性があります。[sanitize-url](https://www.npmjs.com/package/@braintree/sanitize-url) のようなライブラリがこのような問題の助けになりますが、注意が必要です:
114114

115115
:::tip
116-
If you're ever doing URL sanitization on the frontend, you already have a security issue. User-provided URLs should always be sanitized by your backend before even being saved to a database. Then the problem is avoided for _every_ client connecting to your API, including native mobile apps. Also note that even with sanitized URLs, Vue cannot help you guarantee that they lead to safe destinations.
116+
あなたがフロントエンドで URL のサニタイズをしているのであれば、すでにセキュリティの問題があります。ユーザが提供した URL は、データベースに保存する前に、常にバックエンドでサニタイズされるべきです。そうすれば、ネイティブ・モバイルアプリケーションを含む API に接続する _すべての_ クライアントに対して、この問題を回避することができます。またサニタイズされた URL でも、Vue はそれが安全なリンク先につながることを保証できないことに注意してください。
117117
:::
118118

119-
### Injecting Styles
119+
### スタイルの注入
120120

121121
Looking at this example:
122122

@@ -151,7 +151,7 @@ To keep your users fully safe from click jacking, we recommend only allowing ful
151151
</a>
152152
```
153153

154-
### Injecting JavaScript
154+
### JavaScript の注入
155155

156156
We strongly discourage ever rendering a `<script>` element with Vue, since templates and render functions should never have side effects. However, this isn't the only way to include strings that would be evaluated as JavaScript at runtime.
157157

@@ -167,7 +167,7 @@ Sometimes we receive vulnerability reports on how it's possible to do cross-site
167167

168168
2. The developer is mounting Vue to an entire HTML page which happens to contain server-rendered and user-provided content. This is fundamentally the same problem as \#1, but sometimes devs may do it without realizing. This can lead to possible vulnerabilities where the attacker provides HTML which is safe as plain HTML but unsafe as a Vue template. The best practice is to never mount Vue on nodes that may contain server-rendered and user-provided content.
169169

170-
## Best Practices
170+
## ベストプラクティス
171171

172172
The general rule is that if you allow unsanitized, user-provided content to be executed (as either HTML, JavaScript, or even CSS), you might be opening yourself up to attacks. This advice actually holds true whether using Vue, another framework, or even no framework.
173173

@@ -178,10 +178,10 @@ Beyond the recommendations made above for [Potential Dangers](#potential-dangers
178178

179179
Then use what you learn to also review the source code of your dependencies for potentially dangerous patterns, if any of them include 3rd-party components or otherwise influence what's rendered to the DOM.
180180

181-
## Backend Coordination
181+
## バックエンドの調整
182182

183183
HTTP security vulnerabilities, such as cross-site request forgery (CSRF/XSRF) and cross-site script inclusion (XSSI), are primarily addressed on the backend, so aren't a concern of Vue's. However, it's still a good idea to communicate with your backend team to learn how to best interact with their API, e.g. by submitting CSRF tokens with form submissions.
184184

185-
## Server-Side Rendering (SSR)
185+
## サーバサイドレンダリング(SSR
186186

187187
There are some additional security concerns when using SSR, so make sure to follow the best practices outlined throughout [our SSR documentation](ssr/introduction.html) to avoid vulnerabilities.

0 commit comments

Comments
 (0)