|
13 | 13 | - [Postgres with Docker](#postgres-with-docker)
|
14 | 14 | - [Feature Considerations](#feature-considerations)
|
15 | 15 | - [Security Checks](#security-checks)
|
| 16 | + - [Add Security Check](#add-security-check) |
| 17 | + - [Wording Guideline](#wording-guideline) |
16 | 18 | - [Parse Error](#parse-error)
|
17 | 19 | - [Parse Server Configuration](#parse-server-configuration)
|
18 | 20 | - [Code of Conduct](#code-of-conduct)
|
@@ -162,7 +164,55 @@ A security check needs to be added for every new feature or enhancement that all
|
162 | 164 |
|
163 | 165 | For example, allowing public read and write to a class may be useful to simplify development but should be disallowed in a production environment.
|
164 | 166 |
|
165 |
| -Security checks are added in [SecurityChecks.js](https://github.com/parse-community/parse-server/blob/master/src/SecurityChecks.js). |
| 167 | +Security checks are added in [CheckGroups](https://github.com/parse-community/parse-server/tree/master/src/Security/CheckGroups). |
| 168 | + |
| 169 | +#### Add Security Check |
| 170 | +Adding a new security check for your feature is easy and fast: |
| 171 | +1. Look into [CheckGroups](https://github.com/parse-community/parse-server/tree/master/src/Security/CheckGroups) whether there is an existing `CheckGroup[Category].js` file for the category of check to add. For example, a check regarding the database connection is added to `CheckGroupDatabase.js`. |
| 172 | +2. If you did not find a file, duplicate an existing file and replace the category name in `setName()` and the checks in `setChecks()`: |
| 173 | + ```js |
| 174 | + class CheckGroupNewCategory extends CheckGroup { |
| 175 | + setName() { |
| 176 | + return 'House'; |
| 177 | + } |
| 178 | + setChecks() { |
| 179 | + return [ |
| 180 | + new Check({ |
| 181 | + title: 'Door locked', |
| 182 | + warning: 'Anyone can enter your house.', |
| 183 | + solution: 'Lock the door.', |
| 184 | + check: () => { |
| 185 | + return; // Example of a passing check |
| 186 | + } |
| 187 | + }), |
| 188 | + new Check({ |
| 189 | + title: 'Camera online', |
| 190 | + warning: 'Security camera is offline.', |
| 191 | + solution: 'Check the camera.', |
| 192 | + check: async () => { |
| 193 | + throw 1; // Example of a failing check |
| 194 | + } |
| 195 | + }), |
| 196 | + ]; |
| 197 | + } |
| 198 | + } |
| 199 | + ``` |
| 200 | + |
| 201 | +3. If you added a new file in the previous step, reference the file in [CheckGroups.js](https://github.com/parse-community/parse-server/blob/master/src/Security/CheckGroups/CheckGroups.js), which is the collector of all security checks: |
| 202 | + ``` |
| 203 | + export { default as CheckGroupNewCategory } from './CheckGroupNewCategory'; |
| 204 | + ``` |
| 205 | +4. Add a test that covers the new check to [SecurityCheckGroups.js](https://github.com/parse-community/parse-server/blob/master/spec/SecurityCheckGroups.js) for the cases of success and failure. |
| 206 | + |
| 207 | +#### Wording Guideline |
| 208 | +Consider the following when adding a new security check: |
| 209 | +- *Group.name*: The category name; ends without period as this is a headline. |
| 210 | +- *Check.title*: Is the positive hypothesis that should be checked, for example "Door locked" instead of "Door unlocked"; ends without period as this is a title. |
| 211 | +- *Check.warning*: The warning if the test fails; ends with period as this is a description. |
| 212 | +- *Check.solution*: The recommended solution if the test fails; ends with period as this is an instruction. |
| 213 | +- The wordings must not contain any sensitive information such as keys, as the security report may be exposed in logs. |
| 214 | +- The wordings should be concise and not contain verbose explanations, for example "Door locked" instead of "Door has been locked securely". |
| 215 | +- Do not use pronouns such as "you" or "your" because log files can have various readers with different roles. Do not use pronouns such as "I" or "me" because although we love it dearly, Parse Server is not a human. |
166 | 216 |
|
167 | 217 | ### Parse Error
|
168 | 218 |
|
|
0 commit comments