Skip to content

Commit 39a9421

Browse files
committed
Merge branch 'master' into add-deprecation-policy
2 parents 9f0d213 + a080e4c commit 39a9421

File tree

114 files changed

+5569
-3755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+5569
-3755
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
jobs:
1414
check-ci:
1515
name: CI Self-Check
16-
timeout-minutes: 30
16+
timeout-minutes: 15
1717
runs-on: ubuntu-18.04
1818
steps:
1919
- uses: actions/checkout@v2
@@ -32,6 +32,26 @@ jobs:
3232
run: npm ci
3333
- name: CI Self-Check
3434
run: npm run ci:check
35+
check-lint:
36+
name: Lint
37+
timeout-minutes: 15
38+
runs-on: ubuntu-18.04
39+
steps:
40+
- uses: actions/checkout@v2
41+
- name: Use Node.js ${{ matrix.NODE_VERSION }}
42+
uses: actions/setup-node@v1
43+
with:
44+
node-version: ${{ matrix.node-version }}
45+
- name: Cache Node.js modules
46+
uses: actions/cache@v2
47+
with:
48+
path: ~/.npm
49+
key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
50+
restore-keys: |
51+
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-
52+
- name: Install dependencies
53+
run: npm ci
54+
- run: npm run lint
3555
check-mongo:
3656
strategy:
3757
matrix:
@@ -40,45 +60,46 @@ jobs:
4060
MONGODB_VERSION: 4.4.4
4161
MONGODB_TOPOLOGY: replicaset
4262
MONGODB_STORAGE_ENGINE: wiredTiger
43-
NODE_VERSION: 14.15.5
63+
NODE_VERSION: 14.16.0
4464
- name: Mongo 4.2, ReplicaSet, WiredTiger
45-
MONGODB_VERSION: 4.2.12
65+
MONGODB_VERSION: 4.2.13
4666
MONGODB_TOPOLOGY: replicaset
4767
MONGODB_STORAGE_ENGINE: wiredTiger
48-
NODE_VERSION: 14.15.5
68+
NODE_VERSION: 14.16.0
4969
- name: Mongo 4.0, ReplicaSet, WiredTiger
5070
MONGODB_VERSION: 4.0.23
5171
MONGODB_TOPOLOGY: replicaset
5272
MONGODB_STORAGE_ENGINE: wiredTiger
53-
NODE_VERSION: 14.15.5
73+
NODE_VERSION: 14.16.0
5474
- name: Mongo 3.6, Standalone, MMAPv1
55-
MONGODB_VERSION: 3.6.22
75+
MONGODB_VERSION: 3.6.23
5676
MONGODB_TOPOLOGY: standalone
5777
MONGODB_STORAGE_ENGINE: mmapv1
58-
NODE_VERSION: 14.15.5
78+
NODE_VERSION: 14.16.0
5979
- name: Redis Cache
6080
PARSE_SERVER_TEST_CACHE: redis
6181
MONGODB_VERSION: 4.4.4
6282
MONGODB_TOPOLOGY: standalone
6383
MONGODB_STORAGE_ENGINE: wiredTiger
64-
NODE_VERSION: 14.15.5
84+
NODE_VERSION: 14.16.0
6585
- name: Node 10
6686
MONGODB_VERSION: 4.4.4
6787
MONGODB_TOPOLOGY: standalone
6888
MONGODB_STORAGE_ENGINE: wiredTiger
69-
NODE_VERSION: 10.23.3
89+
NODE_VERSION: 10.24.0
7090
- name: Node 12
7191
MONGODB_VERSION: 4.4.4
7292
MONGODB_TOPOLOGY: standalone
7393
MONGODB_STORAGE_ENGINE: wiredTiger
74-
NODE_VERSION: 12.20.2
94+
NODE_VERSION: 12.21.0
7595
- name: Node 15
7696
MONGODB_VERSION: 4.4.4
7797
MONGODB_TOPOLOGY: standalone
7898
MONGODB_STORAGE_ENGINE: wiredTiger
79-
NODE_VERSION: 15.9.0
99+
NODE_VERSION: 15.12.0
100+
fail-fast: false
80101
name: ${{ matrix.name }}
81-
timeout-minutes: 30
102+
timeout-minutes: 15
82103
runs-on: ubuntu-18.04
83104
services:
84105
redis:
@@ -106,8 +127,6 @@ jobs:
106127
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-
107128
- name: Install dependencies
108129
run: npm ci
109-
- if: ${{ matrix.name == 'Mongo 3.6.21' }}
110-
run: npm run lint
111130
- run: npm run pretest
112131
- run: npm run coverage
113132
env:
@@ -127,8 +146,9 @@ jobs:
127146
POSTGRES_IMAGE: postgis/postgis:12-3.0
128147
- name: Postgres 13, Postgis 3.1
129148
POSTGRES_IMAGE: postgis/postgis:13-3.1
149+
fail-fast: false
130150
name: ${{ matrix.name }}
131-
timeout-minutes: 30
151+
timeout-minutes: 15
132152
runs-on: ubuntu-18.04
133153
services:
134154
redis:

CHANGELOG.md

Lines changed: 206 additions & 117 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
- [Deprecation Policy](#deprecation-policy)
1616
- [Feature Considerations](#feature-considerations)
1717
- [Security Checks](#security-checks)
18+
- [Add Security Check](#add-security-check)
19+
- [Wording Guideline](#wording-guideline)
1820
- [Parse Error](#parse-error)
1921
- [Parse Server Configuration](#parse-server-configuration)
2022
- [Code of Conduct](#code-of-conduct)
@@ -84,6 +86,14 @@ Once you have babel running in watch mode, you can start making changes to parse
8486
* All the tests should point to sources in the `lib/` folder.
8587
* The `lib/` folder is produced by `babel` using either the `npm run build`, `npm run watch`, or the `npm run prepare` step.
8688
* The `npm run prepare` step is automatically invoked when your package depends on forked parse-server installed via git for example using `npm install --save git+https://github.com/[username]/parse-server#[branch/commit]`.
89+
* The tests are run against a single server instance. You can change the server configurations using `await reconfigureServer({ ... some configuration })` found in `spec/helper.js`.
90+
* The tests are ran at random.
91+
* Caches and Configurations are reset after every test.
92+
* Users are logged out after every test.
93+
* Cloud Code hooks are removed after every test.
94+
* Database is deleted after every test (indexes are not removed for speed)
95+
* Tests are located in the `spec` folder
96+
* For better test reporting enable `PARSE_SERVER_LOG_LEVEL=debug`
8797

8898
### Troubleshooting
8999

@@ -108,13 +118,14 @@ Once you have babel running in watch mode, you can start making changes to parse
108118
* Run the tests for the whole project to make sure the code passes all tests. This can be done by running the test command for a single file but removing the test file argument. The results can be seen at *<PROJECT_ROOT>/coverage/lcov-report/index.html*.
109119
* Lint your code by running `npm run lint` to make sure the code is not going to be rejected by the CI.
110120
* **Do not** publish the *lib* folder.
121+
* Mocks belong in the `spec/support` folder.
111122
* Please consider if any changes to the [docs](http://docs.parseplatform.org) are needed or add additional sections in the case of an enhancement or feature.
112123

113124
### Test against Postgres
114125

115126
If your pull request introduces a change that may affect the storage or retrieval of objects, you may want to make sure it plays nice with Postgres.
116127

117-
* Run the tests against the postgres database with `PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_TEST_DATABASE_URI=postgres://postgres:password@localhost:5432/parse_server_postgres_adapter_test_database npm run testonly`. You'll need to have postgres running on your machine and setup [appropriately](https://github.com/parse-community/parse-server/blob/master/.travis.yml#L43) or use [`Docker`](#run-a-parse-postgres-with-docker).
128+
* Run the tests against the postgres database with `PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_TEST_DATABASE_URI=postgres://postgres:password@localhost:5432/parse_server_postgres_adapter_test_database npm run testonly`. You'll need to have postgres running on your machine and setup [appropriately](https://github.com/parse-community/parse-server/blob/master/scripts/before_script_postgres.sh) or use [`Docker`](#run-a-parse-postgres-with-docker).
118129
* The Postgres adapter has a special debugger that traces all the sql commands. You can enable it with setting the environment variable `PARSE_SERVER_LOG_LEVEL=debug`
119130
* If your feature is intended to only work with MongoDB, you should disable PostgreSQL-specific tests with:
120131

@@ -137,7 +148,7 @@ If your pull request introduces a change that may affect the storage or retrieva
137148
[PostGIS images (select one with v2.2 or higher) on docker dashboard](https://hub.docker.com/r/postgis/postgis) is based off of the official [postgres](https://registry.hub.docker.com/_/postgres/) image and will work out-of-the-box (as long as you create a user with the necessary extensions for each of your Parse databases; see below). To launch the compatible Postgres instance, copy and paste the following line into your shell:
138149

139150
```
140-
docker run -d --name parse-postgres -p 5432:5432 -e POSTGRES_PASSWORD=password --rm postgis/postgis:11-3.0-alpine && sleep 20 && docker exec -it parse-postgres psql -U postgres -c 'CREATE DATABASE parse_server_postgres_adapter_test_database;' && docker exec -it parse-postgres psql -U postgres -c 'CREATE EXTENSION postgis;' -d parse_server_postgres_adapter_test_database && docker exec -it parse-postgres psql -U postgres -c 'CREATE EXTENSION postgis_topology;' -d parse_server_postgres_adapter_test_database
151+
docker run -d --name parse-postgres -p 5432:5432 -e POSTGRES_PASSWORD=password --rm postgis/postgis:11-3.0-alpine && sleep 20 && docker exec -it parse-postgres psql -U postgres -c 'CREATE DATABASE parse_server_postgres_adapter_test_database;' && docker exec -it parse-postgres psql -U postgres -c 'CREATE EXTENSION pgcrypto; CREATE EXTENSION postgis;' -d parse_server_postgres_adapter_test_database && docker exec -it parse-postgres psql -U postgres -c 'CREATE EXTENSION postgis_topology;' -d parse_server_postgres_adapter_test_database
141152
```
142153
To stop the Postgres instance:
143154

@@ -189,13 +200,61 @@ A security check needs to be added for every new feature or enhancement that all
189200

190201
For example, allowing public read and write to a class may be useful to simplify development but should be disallowed in a production environment.
191202

192-
Security checks are added in [SecurityChecks.js](https://github.com/parse-community/parse-server/blob/master/src/SecurityChecks.js).
203+
Security checks are added in [CheckGroups](https://github.com/parse-community/parse-server/tree/master/src/Security/CheckGroups).
204+
205+
#### Add Security Check
206+
Adding a new security check for your feature is easy and fast:
207+
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`.
208+
2. If you did not find a file, duplicate an existing file and replace the category name in `setName()` and the checks in `setChecks()`:
209+
```js
210+
class CheckGroupNewCategory extends CheckGroup {
211+
setName() {
212+
return 'House';
213+
}
214+
setChecks() {
215+
return [
216+
new Check({
217+
title: 'Door locked',
218+
warning: 'Anyone can enter your house.',
219+
solution: 'Lock the door.',
220+
check: () => {
221+
return; // Example of a passing check
222+
}
223+
}),
224+
new Check({
225+
title: 'Camera online',
226+
warning: 'Security camera is offline.',
227+
solution: 'Check the camera.',
228+
check: async () => {
229+
throw 1; // Example of a failing check
230+
}
231+
}),
232+
];
233+
}
234+
}
235+
```
236+
237+
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:
238+
```
239+
export { default as CheckGroupNewCategory } from './CheckGroupNewCategory';
240+
```
241+
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.
242+
243+
#### Wording Guideline
244+
Consider the following when adding a new security check:
245+
- *Group.name*: The category name; ends without period as this is a headline.
246+
- *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.
247+
- *Check.warning*: The warning if the test fails; ends with period as this is a description.
248+
- *Check.solution*: The recommended solution if the test fails; ends with period as this is an instruction.
249+
- The wordings must not contain any sensitive information such as keys, as the security report may be exposed in logs.
250+
- The wordings should be concise and not contain verbose explanations, for example "Door locked" instead of "Door has been locked securely".
251+
- 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.
193252

194253
### Parse Error
195254

196255
Introducing new Parse Errors requires the following steps:
197256

198-
1. Research whether an existing Parse Error already covers the error scenario. Keep in mind that reusing an already existing Parse Error does not allow to distinguish between scenarios in which the same error is thrown, so it may be necessary to add a new and more specific Parse Error, eventhough an more general Parse Error already exists.
257+
1. Research whether an existing Parse Error already covers the error scenario. Keep in mind that reusing an already existing Parse Error does not allow to distinguish between scenarios in which the same error is thrown, so it may be necessary to add a new and more specific Parse Error, even though a more general Parse Error already exists.
199258
⚠️ Currently (as of Dec. 2020), there are inconsistencies between the Parse Errors documented in the Parse Guides, coded in the Parse JS SDK and coded in Parse Server, therefore research regarding the availability of error codes has to be conducted in all of these sources.
200259
1. Add the new Parse Error to [/src/ParseError.js](https://github.com/parse-community/Parse-SDK-JS/blob/master/src/ParseError.js) in the Parse JavaScript SDK. This is the primary reference for Parse Errors for the Parse JavaScript SDK and Parse Server.
201260
1. Create a pull request for the Parse JavaScript SDK including the new Parse Errors. The PR needs to be merged and a new Parse JS SDK version needs to be released.

0 commit comments

Comments
 (0)