Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: merge Release 4.51.0 into master #976

Merged
merged 40 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d3ad016
chore(deps-dev): bump @babel/core from 7.12.3 to 7.12.10 (#878)
dependabot[bot] Dec 14, 2020
d9ae40f
chore(deps-dev): bump husky from 4.3.5 to 4.3.6 (#877)
dependabot[bot] Dec 14, 2020
55ab297
fix: upgrade twilio from 3.51.0 to 3.52.0 (#869)
snyk-bot Dec 14, 2020
f482399
Merge pull request #884 from opengovsg/release-v4.50.1
tshuli Dec 15, 2020
6f2ee65
chore(deps-dev): bump jest from 26.6.2 to 26.6.3 (#890)
dependabot[bot] Dec 15, 2020
ef5d6c6
fix(deps): bump @sentry/integrations from 5.27.4 to 5.29.0 (#888)
dependabot[bot] Dec 15, 2020
afc73ab
refactor: validateAndProcessEncryptSubmission to typescript (#887)
tshuli Dec 15, 2020
d265c66
fix: upgrade angular-ui-router from 1.0.26 to 1.0.28 (#868)
snyk-bot Dec 16, 2020
811ab92
feat: add FIXED_LINE_OR_MOBILE numbers to pass homeno validation (#886)
karrui Dec 16, 2020
acc349f
fix(deps): bump uuid from 8.3.1 to 8.3.2 (#892)
dependabot[bot] Dec 16, 2020
b0e009d
chore(deps-dev): bump lint-staged from 10.5.2 to 10.5.3 (#893)
dependabot[bot] Dec 16, 2020
12ff86c
refactor: inline form permissions check for presigned POST URL endpoi…
karrui Dec 17, 2020
bea640c
fix: upgrade fp-ts from 2.8.6 to 2.9.0 (#896)
snyk-bot Dec 17, 2020
ed7adc5
fix(deps): bump @sentry/browser from 5.29.0 to 5.29.1 (#899)
dependabot[bot] Dec 17, 2020
daae34a
fix(deps): bump opossum from 5.0.2 to 5.1.1 (#898)
dependabot[bot] Dec 17, 2020
18d0cdf
Merge pull request #895 from opengovsg/release-v4.50.2
liangyuanruo Dec 17, 2020
df0449c
fix(deps): bump web-streams-polyfill from 2.1.1 to 3.0.1 (#838)
dependabot[bot] Dec 17, 2020
acc1707
fix(deps): bump mongoose from 5.10.18 to 5.11.8 (#889)
dependabot[bot] Dec 21, 2020
195b0be
fix: upgrade sortablejs from 1.10.2 to 1.12.0 (#865)
snyk-bot Dec 21, 2020
53248f4
fix: upgrade intl-tel-input from 12.1.16 to 12.4.0 (#866)
snyk-bot Dec 21, 2020
ce90ab3
chore(deps-dev): bump core-js from 3.6.5 to 3.8.1 (#907)
dependabot[bot] Dec 21, 2020
e22448e
chore(deps-dev): bump @types/jest from 26.0.16 to 26.0.19 (#906)
dependabot[bot] Dec 21, 2020
1b2cf19
chore(deps-dev): bump @types/express-serve-static-core (#905)
dependabot[bot] Dec 21, 2020
d18e5ce
chore(deps-dev): bump @types/node from 14.14.11 to 14.14.14 (#900)
dependabot[bot] Dec 21, 2020
4322c1a
fix: upgrade angular-moment from 1.2.0 to 1.3.0 (#870)
snyk-bot Dec 21, 2020
06f463e
feat: harden rate limits (#909)
mantariksh Dec 21, 2020
4725ee7
chore(deps-dev): bump @typescript-eslint/parser from 4.9.0 to 4.10.0 …
dependabot[bot] Dec 21, 2020
973e573
chore(deps-dev): bump csv-parse from 4.14.1 to 4.14.2 (#911)
dependabot[bot] Dec 21, 2020
9775a29
fix(deps): bump twilio from 3.52.0 to 3.54.1 (#913)
dependabot[bot] Dec 21, 2020
48967b5
docs(public-form): add warning comment to GET endpoint in case of API…
liangyuanruo Dec 21, 2020
bee431a
fix: add request metadata to email data error log (#915)
mantariksh Dec 21, 2020
ce79eb7
fix(deps): bump fp-ts from 2.9.0 to 2.9.1 (#914)
dependabot[bot] Dec 21, 2020
859017e
fix(deps): run snyk wizard (#876)
mantariksh Dec 21, 2020
c90318a
fix: upgrade to use latest Node v12 (#879)
mantariksh Dec 21, 2020
d18d2d4
fix: include noopener, noreferrer to <a> tags that open in a new page…
liangyuanruo Dec 21, 2020
ae8f5df
fix: backend validation does not prevent responses on hidden fields (…
tshuli Dec 21, 2020
ab5369a
Merge pull request #919 from opengovsg/release-4.50.3
mantariksh Dec 22, 2020
a05ef47
refactor: prepareEncryptSubmission to typescript (#891)
tshuli Dec 22, 2020
f2facdb
chore: bump version to 4.51.0
tshuli Dec 22, 2020
37561c9
test: add SPCP authentication integration tests (#921)
mantariksh Dec 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 133 additions & 17 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Dockerfile.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12.18.4-alpine3.12
FROM node:12-alpine3.12
LABEL maintainer=FormSG<formsg@data.gov.sg>

WORKDIR /opt/formsg
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12.18.4-alpine3.12 AS node-modules-builder
FROM node:12-alpine3.12 AS node-modules-builder
# node-modules-builder stage installs/compiles the node_modules folder
# Python version must be specified starting in alpine3.12
RUN apk update && apk upgrade && \
Expand All @@ -11,7 +11,7 @@ RUN npm ci
COPY . /opt/formsg

# This stage builds the final container
FROM node:12.18.4-alpine3.12
FROM node:12-alpine3.12
LABEL maintainer=FormSG<formsg@data.gov.sg>
WORKDIR /opt/formsg

Expand Down
4 changes: 2 additions & 2 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ A list of common issues that developers face and how to resolve them.
## `Error: Module did not self-register.`

This could happen if node modules were compiled with a different version of node, or if node modules fail to compile due to other configuration errors.
Running tests locally requires `node` to specifically be of version `12.18.4`. You can use `nvm` to manually set the node version.
Running tests locally requires `node` to specifically be the latest version of NodeJS 12. You can use `nvm` to manually set the node version.

### [Node Versioning Error](https://stackoverflow.com/questions/28486891/uncaught-error-module-did-not-self-register)

Run the following commands to set the node version and then re-install the node modules:

```
nvm use 12.18.4
nvm use 12
rm -r node_modules
npm install
```
Expand Down
2,970 changes: 782 additions & 2,188 deletions package-lock.json

Large diffs are not rendered by default.

51 changes: 25 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "FormSG",
"description": "Form Manager for Government",
"version": "4.50.3",
"version": "4.51.0",
"homepage": "https://form.gov.sg",
"authors": [
"FormSG <formsg@data.gov.sg>"
Expand All @@ -12,7 +12,7 @@
"url": "https://github.com/datagovsg/formsg.git"
},
"engines": {
"node": "~12.18.4",
"node": "~12",
"npm": "~6.4.0"
},
"scripts": {
Expand Down Expand Up @@ -68,8 +68,8 @@
"@opengovsg/myinfo-gov-client": "^2.1.2",
"@opengovsg/ng-file-upload": "^12.2.14",
"@opengovsg/spcp-auth-client": "^1.4.0",
"@sentry/browser": "^5.29.0",
"@sentry/integrations": "^5.27.4",
"@sentry/browser": "^5.29.1",
"@sentry/integrations": "^5.29.0",
"@stablelib/base64": "^1.0.0",
"JSONStream": "^1.3.5",
"angular": "~1.8.2",
Expand All @@ -78,14 +78,14 @@
"angular-cookies": "~1.8.2",
"angular-drag-scroll": "^0.2.1",
"angular-messages": "^1.8.2",
"angular-moment": "~1.2.0",
"angular-moment": "~1.3.0",
"angular-permission": "~1.1.1",
"angular-resource": "^1.8.2",
"angular-sanitize": "^1.8.2",
"angular-translate": "^2.18.3",
"angular-translate-loader-partial": "^2.18.3",
"angular-ui-bootstrap": "~2.5.6",
"angular-ui-router": "~1.0.22",
"angular-ui-router": "~1.0.28",
"await-to-js": "^2.1.1",
"aws-info": "^1.1.0",
"aws-sdk": "^2.805.0",
Expand Down Expand Up @@ -115,22 +115,22 @@
"express-session": "^1.15.6",
"express-winston": "^4.0.5",
"fetch-readablestream": "^0.2.0",
"file-loader": "^4.0.0",
"file-loader": "^4.3.0",
"file-saver": "^2.0.5",
"font-awesome": "4.7.0",
"fp-ts": "^2.8.6",
"fp-ts": "^2.9.1",
"has-ansi": "^4.0.0",
"helmet": "^4.2.0",
"http-status-codes": "^2.1.4",
"intl-tel-input": "~12.1.6",
"intl-tel-input": "~12.4.0",
"json-stringify-safe": "^5.0.1",
"jszip": "^3.2.2",
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.9.6",
"lodash": "^4.17.20",
"moment-timezone": "0.5.32",
"mongodb-uri": "^0.9.7",
"mongoose": "^5.10.18",
"mongoose": "^5.11.8",
"multiparty": ">=4.2.2",
"neverthrow": "^3.0.0",
"ng-infinite-scroll": "^1.3.0",
Expand All @@ -140,28 +140,28 @@
"node-cache": "^5.1.2",
"nodemailer": "^6.4.16",
"nodemailer-direct-transport": "~3.3.2",
"opossum": "^5.0.2",
"opossum": "^5.1.1",
"promise-retry": "^2.0.1",
"puppeteer-core": "^5.3.1",
"selectize": "0.12.6",
"slick-carousel": "1.8.1",
"sortablejs": "~1.10.2",
"sortablejs": "~1.12.0",
"text-encoding": "^0.7.0",
"toastr": "^2.1.4",
"triple-beam": "^1.3.0",
"tweetnacl": "^1.0.1",
"twilio": "^3.51.0",
"twilio": "^3.54.1",
"ui-select": "^0.19.8",
"uid-generator": "^2.0.0",
"uuid": "^8.3.1",
"uuid": "^8.3.2",
"validator": "^13.5.2",
"web-streams-polyfill": "^2.1.1",
"web-streams-polyfill": "^3.0.1",
"whatwg-fetch": "^3.5.0",
"winston": "^3.3.3",
"winston-cloudwatch": "^2.4.0"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/core": "^7.12.10",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.7",
"@opengovsg/mockpass": "^2.6.0",
Expand All @@ -176,17 +176,16 @@
"@types/express": "^4.17.9",
"@types/express-rate-limit": "^5.1.0",
"@types/express-request-id": "^1.4.1",
"@types/express-serve-static-core": "^4.17.15",
"@types/express-serve-static-core": "^4.17.17",
"@types/express-session": "^1.17.0",
"@types/has-ansi": "^3.0.0",
"@types/helmet": "4.0.0",
"@types/ip": "^1.1.0",
"@types/jest": "^26.0.16",
"@types/jest": "^26.0.19",
"@types/json-stringify-safe": "^5.0.0",
"@types/mongodb": "^3.6.3",
"@types/mongodb-uri": "^0.9.0",
"@types/mongoose": "^5.10.1",
"@types/node": "^14.14.11",
"@types/node": "^14.14.14",
"@types/nodemailer": "^6.4.0",
"@types/nodemailer-direct-transport": "^1.0.31",
"@types/opossum": "^4.1.1",
Expand All @@ -198,16 +197,16 @@
"@types/uuid": "^8.3.0",
"@types/validator": "^13.1.0",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.9.0",
"@typescript-eslint/parser": "^4.10.0",
"auto-changelog": "^2.2.1",
"axios-mock-adapter": "^1.19.0",
"babel-loader": "^8.2.2",
"concurrently": "^5.3.0",
"copy-webpack-plugin": "^6.0.2",
"core-js": "^3.6.4",
"core-js": "^3.8.1",
"coveralls": "^3.1.0",
"css-loader": "^2.1.1",
"csv-parse": "^4.14.1",
"csv-parse": "^4.14.2",
"env-cmd": "^10.1.0",
"eslint": "^7.14.0",
"eslint-config-prettier": "^7.0.0",
Expand All @@ -220,13 +219,13 @@
"google-fonts-plugin": "4.1.0",
"html-loader": "~0.5.5",
"htmlhint": "^0.14.2",
"husky": "^4.3.5",
"husky": "^4.3.6",
"jasmine": "^3.6.3",
"jasmine-core": "^3.6.0",
"jasmine-sinon": "^0.4.0",
"jasmine-spec-reporter": "^6.0.0",
"jest": "^26.6.2",
"lint-staged": "^10.5.2",
"jest": "^26.6.3",
"lint-staged": "^10.5.3",
"maildev": "^1.1.0",
"mini-css-extract-plugin": "^0.5.0",
"mockdate": "^3.0.2",
Expand Down
79 changes: 0 additions & 79 deletions src/app/controllers/encrypt-submissions.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,90 +8,11 @@ const {
} = require('../models/submission.server.model')
const EncryptSubmission = getEncryptSubmissionModel(mongoose)

const { checkIsEncryptedEncoding } = require('../utils/encryption')
const { ConflictError } = require('../modules/submission/submission.errors')
const { createReqMeta } = require('../utils/request')
const logger = require('../../config/logger').createLoggerWithLabel(module)
const {
aws: { attachmentS3Bucket, s3 },
} = require('../../config/config')
const {
getProcessedResponses,
} = require('../modules/submission/submission.service')

/**
* Extracts relevant fields, injects questions, verifies visibility of field and validates answers
* to produce req.body.parsedResponses
*
* @param {Express.Request} req - Express request object
* @param {Express.Response} res - Express response object
* @param {Function} next - Express next middleware function
*/
exports.validateEncryptSubmission = function (req, res, next) {
const { form } = req

const isEncryptedResult = checkIsEncryptedEncoding(req.body.encryptedContent)
if (isEncryptedResult.isErr()) {
logger.error({
message: 'Invalid encryption',
meta: {
action: 'validateEncryptSubmission',
...createReqMeta(req),
formId: form._id,
},
error: isEncryptedResult.error,
})
return res
.status(StatusCodes.BAD_REQUEST)
.json({ message: 'Invalid data was found. Please submit again.' })
}

if (!req.body.responses) {
return res.sendStatus(StatusCodes.BAD_REQUEST)
}

const getProcessedResponsesResult = getProcessedResponses(
form,
req.body.responses,
)
if (getProcessedResponsesResult.isErr()) {
const err = getProcessedResponsesResult.error
logger.error({
message: 'Error processing responses',
meta: {
action: 'validateEncryptSubmission',
...createReqMeta(req),
formId: form._id,
},
error: err,
})
if (err instanceof ConflictError) {
return res.status(err.status).json({
message: 'The form has been updated. Please refresh and submit again.',
})
}
return res.status(StatusCodes.BAD_REQUEST).json({
message:
'There is something wrong with your form submission. Please check your responses and try again. If the problem persists, please refresh the page.',
})
}
req.body.parsedResponses = getProcessedResponsesResult.value
delete req.body.responses // Prevent downstream functions from using responses by deleting it
return next()
}

/**
* Verify structure of encrypted response
*
* @param {Express.Request} req - Express request object
* @param {Express.Response} res - Express response object
* @param {Function} next - Express next middleware function
*/
exports.prepareEncryptSubmission = (req, res, next) => {
req.formData = req.body.encryptedContent
req.attachmentData = req.body.attachments || {}
return next()
}

/**
* @param {Error} err - the Error to report
Expand Down
1 change: 1 addition & 0 deletions src/app/controllers/forms.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const formPublicFields = [
*/
exports.read = (requestType) =>
/**
* ! Note that this function should not call any mongoose functions on req.form as it is possibly already a plain JSON object.
* Takes the form and replaces admin details with agency details, as well as scrubbing the form if the
* request is not for admin purposes.
* @param {Object} req - Express request object
Expand Down
3 changes: 2 additions & 1 deletion src/app/controllers/myinfo.server.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ResWithSpcpSession,
ResWithUinFin,
WithForm,
WithJsonForm,
} from '../../types'
import { MyInfoFactory } from '../services/myinfo/myinfo.factory'
import { mapVerifyMyInfoError } from '../services/myinfo/myinfo.util'
Expand Down Expand Up @@ -58,7 +59,7 @@ export const addMyInfo: RequestHandler<ParamsDictionary> = async (
// Step 3: Hash the values and save them
.andThen((prefilledFields) => {
form.form_fields = prefilledFields
;(req as WithForm<typeof req>).form = form
;(req as WithJsonForm<typeof req>).form = form
return MyInfoFactory.saveMyInfoHashes(uinFin, formId, prefilledFields)
})
.map(() => next())
Expand Down
Loading