Skip to content

Commit

Permalink
Feature/57884 update pupil api deps (#2452)
Browse files Browse the repository at this point in the history
* Bump bl in /design/spikes/function-fs-access/functions

Bumps [bl](https://github.com/rvagg/bl) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/rvagg/bl/releases)
- [Changelog](https://github.com/rvagg/bl/blob/master/CHANGELOG.md)
- [Commits](rvagg/bl@v1.2.2...v1.2.3)

---
updated-dependencies:
- dependency-name: bl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* Upgrade minor and patch versions

* [pupil-api] upgrade major versions uuid, dotenv

* [pupil-api] upgrade @azure/service-bus major version

* Upgrade redis major version

* Upgrade major versions of: jest, ts-jest

* major upgrade eslint*
Lint fixes for new rules

* Major upgrade jest

* Upgrade helmet to to v6

Remove deprecated directive block-all-mixed-content from Content-Security-Policy

Remove deprecated header Expect-CT

Add headers:--

Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Origin-Agent-Cluster: ?1

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy
https://whatpr.org/html/6214/origin.html#origin-keyed-agent-clusters

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mohsen Qureshi <[email protected]>
  • Loading branch information
3 people authored Feb 23, 2023
1 parent d746b87 commit 33c7072
Show file tree
Hide file tree
Showing 20 changed files with 1,520 additions and 1,616 deletions.
42 changes: 26 additions & 16 deletions design/spikes/function-fs-access/functions/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ base64-js@^1.0.2:
integrity sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==

bl@^1.0.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c"
integrity sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==
version "1.2.3"
resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.3.tgz#1e8dd80142eac80d7158c9dccc047fb620e035e7"
integrity sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==
dependencies:
readable-stream "^2.3.5"
safe-buffer "^5.1.1"
Expand Down Expand Up @@ -148,9 +148,9 @@ [email protected]:
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==

core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
version "1.0.3"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85"
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==

crc32-stream@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -231,15 +231,20 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"

inherits@2, inherits@~2.0.3:
inherits@2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=

inherits@~2.0.3:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==

isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==

jsonfile@^4.0.0:
version "4.0.0"
Expand Down Expand Up @@ -367,14 +372,14 @@ path-is-absolute@^1.0.0:
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=

process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"
integrity sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==

readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.3.0, readable-stream@^2.3.5:
version "2.3.6"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==
version "2.3.7"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57"
integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
Expand All @@ -389,7 +394,12 @@ remove-trailing-separator@^1.0.1:
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8=

safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
safe-buffer@^5.1.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==

safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
Expand Down Expand Up @@ -427,7 +437,7 @@ universalify@^0.1.0:
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==

wrappy@1:
version "1.0.2"
Expand Down
39 changes: 20 additions & 19 deletions pupil-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,51 @@
"**/**/lodash": "^4.17.21"
},
"dependencies": {
"@azure/service-bus": "^1.1.1",
"applicationinsights": "^2.3.1",
"@azure/service-bus": "^7.8.0",
"applicationinsights": "^2.4.1",
"body-parser": "^1.20.1",
"cors": "^2.8.4",
"dotenv": "^10.0.0",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express-winston": "^4.0.2",
"feature-toggles": "^1.4.0",
"helmet": "^4.3.1",
"ioredis": "^4.28.5",
"helmet": "^6.0.1",
"ioredis": "^5.3.1",
"moment": "^2.29.4",
"morgan": "^1.9.0",
"ramda": "^0.28.0",
"swagger-ui-express": "^4.6.0",
"to-bool": "0.0.1",
"uuid": "^8.3.2",
"uuid": "^9.0.0",
"winston": "^3.8.1",
"winston-azure-application-insights": "^3.0.0"
"winston-azure-application-insights": "^4.0.0"
},
"devDependencies": {
"@types/body-parser": "^1.17.0",
"@types/cors": "^2.8.12",
"@types/debug": "4.1.7",
"@types/express": "^4.11.1",
"@types/ioredis": "^4.28.10",
"@types/jest": "^27.4.1",
"@types/ioredis": "^5.0.0",
"@types/jest": "^29.4.0",
"@types/morgan": "^1.7.35",
"@types/node": "14",
"@types/ramda": "^0.27.46",
"@types/ramda": "^0.28.23",
"@types/string": "0.0.31",
"@types/swagger-ui-express": "^4.1.3",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "4.31",
"@typescript-eslint/parser": "4.31",
"eslint": "7.32",
"eslint-config-standard-with-typescript": "^21.0.1",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "5.52.0",
"@typescript-eslint/parser": "5.52.0",
"eslint": "8.34.0",
"eslint-config-standard-with-typescript": "^34.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "24.4",
"eslint-plugin-jest": "27.2.1",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-node": "11",
"eslint-plugin-promise": "5.1",
"eslint-plugin-promise": "6.1.1",
"gulp": "^4.0.2",
"jest": "^27.2.0",
"jest": "^29.4.3",
"node-mocks-http": "^1.7.0",
"ts-jest": "^27.1.4",
"ts-jest": "^29.0.5",
"typescript": "4.3.5"
}
}
6 changes: 3 additions & 3 deletions pupil-api/src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as dotenv from 'dotenv'
import * as express from 'express'
import * as bodyParser from 'body-parser'
import * as cors from 'cors'
import * as helmet from 'helmet'
import helmet from 'helmet'
import { v4 as uuidv4 } from 'uuid'
import * as appInsights from './helpers/app-insights'
import logger from './services/log.service'
Expand Down Expand Up @@ -39,7 +39,7 @@ class App {
this.express = express()
this.middleware()
this.routes()
appInsights.startInsightsIfConfigured().catch(e => logger.error(e))
appInsights.startInsightsIfConfigured().catch(e => { logger.error(e) })
}

// Configure Express middleware.
Expand Down Expand Up @@ -105,7 +105,7 @@ class App {
err.errorId = errorId
err.status = err.status ?? 500
if (req.app.get('env') === 'development') {
res.status(err.status).json({ error: err.message, errorId: errorId })
res.status(err.status).json({ error: err.message, errorId })
} else {
res.status(err.status).json({ error: 'An error occurred' })
}
Expand Down
2 changes: 1 addition & 1 deletion pupil-api/src/controllers/api-response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Response } from 'express'
import type { Response } from 'express'
import { DefaultSecurityHeaders } from '../routes/default-security-headers'

const apiResponse = {
Expand Down
2 changes: 1 addition & 1 deletion pupil-api/src/controllers/ping.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Request, Response } from 'express'
import type { Request, Response } from 'express'
import * as moment from 'moment'
import { DefaultSecurityHeaders } from '../routes/default-security-headers'
import { PingService } from '../services/ping.service'
Expand Down
6 changes: 3 additions & 3 deletions pupil-api/src/controllers/redis.auth.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RedisAuthController } from './redis.auth.controller'
import * as httpMocks from 'node-mocks-http'
import logger from '../services/log.service'
import { IPupilAuthenticationService } from '../services/redis-pupil-auth.service'
import { Request } from 'express'
import type { IPupilAuthenticationService } from '../services/redis-pupil-auth.service'
import type { Request } from 'express'

const RedisPupilAuthServiceMock = jest.fn<IPupilAuthenticationService, any>(() => ({
authenticate: jest.fn()
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('redis auth controller', () => {
})
})

function createMockRequest (contentType: String): any {
function createMockRequest (contentType: string): any {
return httpMocks.createRequest({
method: 'POST',
url: '/auth',
Expand Down
7 changes: 4 additions & 3 deletions pupil-api/src/controllers/redis.auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Request, Response } from 'express'
import type { Request, Response } from 'express'
import logger from '../services/log.service'
import * as apiResponse from './api-response'
import { RedisPupilAuthenticationService, IPupilAuthenticationService } from '../services/redis-pupil-auth.service'
import { IAuthController } from '../routes/auth'
import { RedisPupilAuthenticationService } from '../services/redis-pupil-auth.service'
import type { IPupilAuthenticationService } from '../services/redis-pupil-auth.service'
import type { IAuthController } from '../routes/auth'

export class RedisAuthController implements IAuthController {
private readonly redisAuthService: IPupilAuthenticationService
Expand Down
4 changes: 2 additions & 2 deletions pupil-api/src/helpers/cors-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const whitelist = config.Cors.Whitelist.split(',')
const options = {
origin: function (origin: string, callback: (error?: Error | null, flag?: boolean) => void) {
if (whitelist.includes(origin) || origin === undefined) {
return callback(null, true)
callback(null, true)
} else {
return callback(new Error(`CORS policy does not allow ${origin}`))
callback(new Error(`CORS policy does not allow ${origin}`))
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions pupil-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function normalizePort (val: number | string): number | string | boolean {
function onError (error: NodeJS.ErrnoException): void {
if (error.syscall !== 'listen') throw error
const bind = (typeof port === 'string') ? `Pipe ${port}` : `Port ${port}`
/* eslint-disable no-fallthrough */
switch (error.code) {
case 'EACCES':
console.error(`${bind} requires elevated privileges`)
Expand All @@ -37,6 +38,7 @@ function onError (error: NodeJS.ErrnoException): void {
default:
throw error
}
/* eslint-enable no-fallthrough */
}

function onListening (): void {
Expand Down
5 changes: 3 additions & 2 deletions pupil-api/src/routes/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Router, Request, Response } from 'express'
import { Router } from 'express'
import type { Request, Response } from 'express'
import { RedisAuthController } from '../controllers/redis.auth.controller'

export interface IAuthController {
Expand All @@ -16,7 +17,7 @@ export class AuthRouter {
}

public init (): any {
this.router.route('/').all((req: Request, res: Response) => {
this.router.route('/').all((req: Request, res: Response) => { // eslint-disable-line @typescript-eslint/no-misused-promises
if (req.method !== 'POST') return res.sendStatus(405)
return this.authController.postAuth(req, res)
})
Expand Down
2 changes: 1 addition & 1 deletion pupil-api/src/routes/default-security-headers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Response } from 'express'
import type { Response } from 'express'

export class DefaultSecurityHeaders {
static setResponseHeaders (res: Response): void {
Expand Down
3 changes: 2 additions & 1 deletion pupil-api/src/routes/head.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Router, Request, Response } from 'express'
import { Router } from 'express'
import type { Request, Response } from 'express'

export class HeadRouter {
router: Router
Expand Down
3 changes: 2 additions & 1 deletion pupil-api/src/routes/ping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Router, Request, Response } from 'express'
import { Router } from 'express'
import type { Request, Response } from 'express'
import { PingController } from '../controllers/ping.controller'

export class PingRouter {
Expand Down
2 changes: 1 addition & 1 deletion pupil-api/src/services/log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class Logger {
const baseLogOptions = {
levels: winston.config.syslog.levels,
level: this.level,
format: format,
format,
transports: [
new winston.transports.Console({ level: this.level, silent: false, consoleWarnLevels: ['warn', 'error'] })
],
Expand Down
4 changes: 2 additions & 2 deletions pupil-api/src/services/ping.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ describe('ping.service', () => {

test('getCommitId - returns error message when cannot be obtained', async () => {
const actual = await sut.getCommitId()
expect(actual).toStrictEqual('NOT FOUND')
expect(actual).toBe('NOT FOUND')
})

test('getBuildNumber - returns error message when cannot be obtained', async () => {
const actual = await sut.getBuildNumber()
expect(actual).toStrictEqual('NOT FOUND')
expect(actual).toBe('NOT FOUND')
})
})
14 changes: 7 additions & 7 deletions pupil-api/src/services/queue-message.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import * as sb from '@azure/service-bus'
import { ServiceBusClient } from '@azure/service-bus'
import type { ServiceBusSender } from '@azure/service-bus'
import config from '../config'

export interface IQueueMessageService {
Expand All @@ -11,18 +11,18 @@ export interface IServiceBusQueueMessage {
}

export class SbQueueMessageService implements IQueueMessageService {
private readonly sender: sb.Sender
private readonly sender: ServiceBusSender
private readonly queueName = 'pupil-login'

constructor () {
if (config.ServiceBus.connectionString === undefined) {
throw new Error('Azure Service Bus Connection String missing')
}
const sbClient = sb.ServiceBusClient.createFromConnectionString(config.ServiceBus.connectionString)
const sbQueueClient = sbClient.createQueueClient('pupil-login')
this.sender = sbQueueClient.createSender()
const serviceBusClient = new ServiceBusClient(config.ServiceBus.connectionString)
this.sender = serviceBusClient.createSender(this.queueName)
}

async dispatch (message: IServiceBusQueueMessage): Promise<void> {
return this.sender.send(message)
return this.sender.sendMessages(message)
}
}
Loading

0 comments on commit 33c7072

Please sign in to comment.