You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'Do not pass ALL environment variables to the client.',
49
+
'Не передавайте ВСЕ переменные окружения клиенту.',
50
50
process.env
51
51
);
52
52
```
53
53
54
-
[See more examples below.](#usage)
54
+
[См. больше примеров ниже.](#usage)
55
55
56
-
#### Parameters {/*parameters*/}
56
+
#### Параметры {/*parameters*/}
57
57
58
-
*`message`: The message you want to display if the object gets passed to a Client Component. This message will be displayed as a part of the Error that will be thrown if the object gets passed to a Client Component.
58
+
*`message`: Сообщение, которое вы хотите отобразить, если объект будет передан в Client Component. Это сообщение будет отображаться как часть ошибки, которая будет выброшена, если объект будет передан в Client Component.
59
59
60
-
*`object`: The object to be tainted. Functions and class instances can be passed to`taintObjectReference`as`object`. Functions and classes are already blocked from being passed to Client Components but the React's default error message will be replaced by what you defined in `message`. When a specific instance of a Typed Array is passed to `taintObjectReference`as`object`, any other copies of the Typed Array will not be tainted.
60
+
*`object`: Объект, который нужно пометить. Функции и экземпляры классов могут быть переданы в`taintObjectReference`как`object`. Функции и классы уже заблокированы для передачи в Client Components, но стандартное сообщение об ошибке React будет заменено тем, что вы определили в `message`. Когда конкретный экземпляр Typed Array передается в `taintObjectReference`как`object`, любые другие копии этого Typed Array не будут помечены.
-Recreating or cloning a tainted object creates a new untainted object which may contain sensitive data. For example, if you have a tainted `user` object, `const userInfo = {name: user.name, ssn: user.ssn}`or`{...user}`will create new objects which are not tainted. `taintObjectReference`only protects against simple mistakes when the object is passed through to a Client Component unchanged.
68
+
-Воссоздание или клонирование помеченного объекта создает новый непомеченный объект, который может содержать конфиденциальные данные. Например, если у вас есть помеченный объект `user`, `const userInfo = {name: user.name, ssn: user.ssn}`или`{...user}`создадут новые объекты, которые не помечены. `taintObjectReference`защищает только от простых ошибок, когда объект передается в Client Component без изменений.
69
69
70
70
<Pitfall>
71
71
72
-
**Do not rely on just tainting for security.**Tainting an object doesn't prevent leaking of every possible derived value. For example, the clone of a tainted object will create a new untainted object. Using data from a tainted object (e.g.`{secret: taintedObj.secret}`) will create a new value or object that is not tainted. Tainting is a layer of protection; a secure app will have multiple layers of protection, well designed APIs, and isolation patterns.
72
+
**Не полагайтесь только на пометку для обеспечения безопасности.**Пометка объекта не предотвращает утечку всех возможных производных значений. Например, клон помеченного объекта создаст новый непомеченный объект. Использование данных из помеченного объекта (например,`{secret: taintedObj.secret}`) создаст новое значение или объект, который не помечен. Пометка — это уровень защиты; безопасное приложение будет иметь несколько уровней защиты, хорошо спроектированные API и паттерны изоляции.
73
73
74
74
</Pitfall>
75
75
76
76
---
77
77
78
-
## Usage {/*usage*/}
78
+
## Использование {/*usage*/}
79
79
80
-
### Prevent user data from unintentionally reaching the client {/*prevent-user-data-from-unintentionally-reaching-the-client*/}
80
+
### Предотвращение непреднамеренной передачи пользовательских данных клиенту {/*prevent-user-data-from-unintentionally-reaching-the-client*/}
81
81
82
-
A Client Component should never accept objects that carry sensitive data. Ideally, the data fetching functions should not expose data that the current user should not have access to. Sometimes mistakes happen during refactoring. To protect against these mistakes happening down the line we can "taint" the user object in our data API.
82
+
Client Component никогда не должен принимать объекты, содержащие конфиденциальные данные. В идеале, функции получения данных не должны раскрывать данные, к которым текущий пользователь не должен иметь доступа. Иногда ошибки случаются во время рефакторинга. Чтобы защититься от таких ошибок в будущем, мы можем "пометить" объект пользователя в нашем API данных.
constuser=await db`SELECT * FROM users WHERE id = ${id}`;
89
89
experimental_taintObjectReference(
90
-
'Do not pass the entire user object to the client. '+
91
-
'Instead, pick off the specific properties you need for this use case.',
90
+
'Не передавайте весь объект пользователя клиенту. '+
91
+
'Вместо этого выбирайте конкретные свойства, которые вам нужны для данного случая использования.',
92
92
user,
93
93
);
94
94
return user;
95
95
}
96
96
```
97
97
98
-
Now whenever anyone tries to pass this object to a Client Component, an error will be thrown with the passed in error message instead.
98
+
Теперь, когда кто-либо попытается передать этот объект в Client Component, будет выброшена ошибка с переданным сообщением об ошибке.
99
99
100
100
<DeepDive>
101
101
102
-
#### Protecting against leaks in data fetching {/*protecting-against-leaks-in-data-fetching*/}
102
+
#### Защита от утечек при получении данных {/*protecting-against-leaks-in-data-fetching*/}
103
103
104
-
If you're running a Server Components environment that has access to sensitive data, you have to be careful not to pass objects straight through:
104
+
Если вы работаете в среде Server Components, имеющей доступ к конфиденциальным данным, вы должны быть осторожны, чтобы не передавать объекты напрямую:
105
105
106
106
```js
107
107
// api.js
@@ -117,7 +117,7 @@ import { InfoCard } from 'components.js';
117
117
118
118
exportasyncfunctionProfile(props) {
119
119
constuser=awaitgetUser(props.userId);
120
-
//DO NOT DO THIS
120
+
//НЕ ДЕЛАЙТЕ ЭТОГО
121
121
return<InfoCard user={user} />;
122
122
}
123
123
```
@@ -131,8 +131,7 @@ export async function InfoCard({ user }) {
131
131
}
132
132
```
133
133
134
-
Ideally, the `getUser` should not expose data that the current user should not have access to. To prevent passing the `user` object to a Client Component down the line we can "taint" the user object:
135
-
134
+
В идеале, `getUser` не должен раскрывать данные, к которым текущий пользователь не должен иметь доступа. Чтобы предотвратить передачу объекта `user` в Client Component в дальнейшем, мы можем "пометить" объект пользователя:
136
135
137
136
```js
138
137
// api.js
@@ -141,14 +140,15 @@ import {experimental_taintObjectReference} from 'react';
141
140
exportasyncfunctiongetUser(id) {
142
141
constuser=await db`SELECT * FROM users WHERE id = ${id}`;
143
142
experimental_taintObjectReference(
144
-
'Do not pass the entire user object to the client. '+
145
-
'Instead, pick off the specific properties you need for this use case.',
143
+
'Не передавайте весь объект пользователя клиенту. '+
144
+
'Вместо этого выбирайте конкретные свойства, которые вам нужны для данного случая использования.',
146
145
user,
147
146
);
148
147
return user;
149
148
}
150
149
```
151
150
152
-
Now if anyone tries to pass the `user`object to a Client Component, an error will be thrown with the passed in error message.
151
+
Теперь, если кто-либо попытается передать объект `user`в Client Component, будет выброшена ошибка с переданным сообщением.
0 commit comments