From 9767169c451e6dd503c87f126562ff289f2ebdfe Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Fri, 30 Aug 2024 16:10:44 +0000 Subject: [PATCH 01/12] fix: Dockerfile to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-ALPINE317-BUSYBOX-6913412 - https://snyk.io/vuln/SNYK-ALPINE317-BUSYBOX-7254940 - https://snyk.io/vuln/SNYK-ALPINE317-BUSYBOX-7254941 - https://snyk.io/vuln/SNYK-ALPINE317-BUSYBOX-7254942 - https://snyk.io/vuln/SNYK-ALPINE317-OPENSSL-6148880 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3822f2e..06ae981 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18.18-alpine3.17 as builder +FROM node:20.8.0-alpine3.17 as builder RUN apk --update add git build-base @@ -16,7 +16,7 @@ COPY /src ./src/ RUN npm run build -FROM node:18.18-alpine3.17 +FROM node:20.8.0-alpine3.17 ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.2/wait /wait RUN chmod +x /wait From bd02aadb62549fac24dcf55399cf592315d24171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:27:25 +0200 Subject: [PATCH 02/12] Update Node.js to v20 in GitHub Actions workflow --- .github/workflows/tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 020fb6e..b5ee13a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,17 +10,11 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: '18' + node-version: '20' - name: Install modules run: npm install - name: Build the docker-compose stack run: docker-compose -f docker-compose.testing.yaml up -d - # - name: Run contract tests - # run: npm run test:contract - # env: - # ENVIRONMENT: CI - # JWT_TOKEN: 123 - # JWT_TOKEN_LOGIN: 456 - name: Run integration tests run: npm run test:integration env: From 387411a67cf018c8925420232c977eef79caa80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:28:46 +0200 Subject: [PATCH 03/12] Update Node.js to v20 in GitHub Actions workflow --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4d4205..9d53cfe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: '18' + node-version: '20' - name: Install modules run: npm install - name: Build the docker-compose stack From 25804e57797290a2a0ec4ba92d5cc12501ab32b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:46:43 +0200 Subject: [PATCH 04/12] Update axios dependency to version 1.7.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6cb9a34..77bcd21 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "ISC", "dependencies": { "@breejs/ts-worker": "^2.0.0", - "axios": "^1.6.8", + "axios": "^1.7.5", "bcrypt": "^5.1.1", "body-parser": "^1.20.1", "boom": "^7.2.0", From 926add21625c9ec5d5d6cdcd6c728d1713abbd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:49:53 +0200 Subject: [PATCH 05/12] Revert "Update axios dependency to version 1.7.5" This reverts commit 25804e57797290a2a0ec4ba92d5cc12501ab32b7. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77bcd21..6cb9a34 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "ISC", "dependencies": { "@breejs/ts-worker": "^2.0.0", - "axios": "^1.7.5", + "axios": "^1.6.8", "bcrypt": "^5.1.1", "body-parser": "^1.20.1", "boom": "^7.2.0", From f5fc3d0e58904eb85611779a5c7084961250e48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:53:13 +0200 Subject: [PATCH 06/12] Add Keep-Alive header to integration test requests --- src/tests/integration/helper/state.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/integration/helper/state.ts b/src/tests/integration/helper/state.ts index 29fcf47..846dad5 100644 --- a/src/tests/integration/helper/state.ts +++ b/src/tests/integration/helper/state.ts @@ -13,6 +13,7 @@ const options = (state, consumer): AxiosRequestConfig => { }, headers: { "Content-Type": "application/json", + "Keep-Alive": false, }, } } From 9c9373fe426167af7c581fe0b43a2c265ce6b5f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:03:58 +0200 Subject: [PATCH 07/12] Update state.ts to set up HTTP Agent with keepAlive false --- src/tests/integration/helper/state.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/integration/helper/state.ts b/src/tests/integration/helper/state.ts index 846dad5..5bee9f9 100644 --- a/src/tests/integration/helper/state.ts +++ b/src/tests/integration/helper/state.ts @@ -1,4 +1,5 @@ import axios, { AxiosRequestConfig, AxiosResponse } from "axios" +import { Agent } from "http" const PROVIDER_URL = "http://localhost:5000" @@ -13,8 +14,8 @@ const options = (state, consumer): AxiosRequestConfig => { }, headers: { "Content-Type": "application/json", - "Keep-Alive": false, }, + httpAgent: new Agent({ keepAlive: false }), } } From 044db0b99d5dbe627b56b623cf4d261a07f098fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:11:37 +0200 Subject: [PATCH 08/12] Refactor Axios client initialization and request logic --- src/tests/integration/helper/state.ts | 63 ++++++++++++++------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/src/tests/integration/helper/state.ts b/src/tests/integration/helper/state.ts index 5bee9f9..cbe9da6 100644 --- a/src/tests/integration/helper/state.ts +++ b/src/tests/integration/helper/state.ts @@ -4,44 +4,47 @@ import { Agent } from "http" const PROVIDER_URL = "http://localhost:5000" const options = (state, consumer): AxiosRequestConfig => { - return { - url: "/api/contract/states", - baseURL: PROVIDER_URL, - method: "POST", - data: { - consumer, - state, - }, - headers: { - "Content-Type": "application/json", - }, - httpAgent: new Agent({ keepAlive: false }), - } + return { + url: "/api/contract/states", + baseURL: PROVIDER_URL, + method: "POST", + data: { + consumer, + state, + }, + headers: { + "Content-Type": "application/json", + }, + } } +const client = axios.create({ + httpAgent: new Agent({ keepAlive: false }), +}) + export const stateSetup = (state, consumer = "integration-tests") => { - return axios(options(state, consumer)) + return client.request(options(state, consumer)) } export const userSetup = (): Promise => { - return axios({ - url: "/api/contract/test-user", - baseURL: PROVIDER_URL, - method: "POST", - headers: { - "Content-Type": "application/json", - }, - }) + return axios({ + url: "/api/contract/test-user", + baseURL: PROVIDER_URL, + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }) } export const apiTokenSetup = (): Promise => { - return axios({ - url: "/api/contract/api-token", - baseURL: PROVIDER_URL, - method: "POST", - headers: { - "Content-Type": "application/json", - }, - }) + return axios({ + url: "/api/contract/api-token", + baseURL: PROVIDER_URL, + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }) } From ddc0bd5e551b53d91beb02cf9b002e901e4d719b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:14:01 +0200 Subject: [PATCH 09/12] Revert "Refactor Axios client initialization and request logic" This reverts commit 044db0b99d5dbe627b56b623cf4d261a07f098fb. --- src/tests/integration/helper/state.ts | 63 +++++++++++++-------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/src/tests/integration/helper/state.ts b/src/tests/integration/helper/state.ts index cbe9da6..5bee9f9 100644 --- a/src/tests/integration/helper/state.ts +++ b/src/tests/integration/helper/state.ts @@ -4,47 +4,44 @@ import { Agent } from "http" const PROVIDER_URL = "http://localhost:5000" const options = (state, consumer): AxiosRequestConfig => { - return { - url: "/api/contract/states", - baseURL: PROVIDER_URL, - method: "POST", - data: { - consumer, - state, - }, - headers: { - "Content-Type": "application/json", - }, - } -} - -const client = axios.create({ + return { + url: "/api/contract/states", + baseURL: PROVIDER_URL, + method: "POST", + data: { + consumer, + state, + }, + headers: { + "Content-Type": "application/json", + }, httpAgent: new Agent({ keepAlive: false }), -}) + } +} export const stateSetup = (state, consumer = "integration-tests") => { - return client.request(options(state, consumer)) + return axios(options(state, consumer)) } export const userSetup = (): Promise => { - return axios({ - url: "/api/contract/test-user", - baseURL: PROVIDER_URL, - method: "POST", - headers: { - "Content-Type": "application/json", - }, - }) + return axios({ + url: "/api/contract/test-user", + baseURL: PROVIDER_URL, + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }) } export const apiTokenSetup = (): Promise => { - return axios({ - url: "/api/contract/api-token", - baseURL: PROVIDER_URL, - method: "POST", - headers: { - "Content-Type": "application/json", - }, - }) + return axios({ + url: "/api/contract/api-token", + baseURL: PROVIDER_URL, + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }) } From 8f6622c175f2e0b2470c00668fc330b22b5fb83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:14:07 +0200 Subject: [PATCH 10/12] Revert "Update state.ts to set up HTTP Agent with keepAlive false" This reverts commit 9c9373fe426167af7c581fe0b43a2c265ce6b5f1. --- src/tests/integration/helper/state.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tests/integration/helper/state.ts b/src/tests/integration/helper/state.ts index 5bee9f9..846dad5 100644 --- a/src/tests/integration/helper/state.ts +++ b/src/tests/integration/helper/state.ts @@ -1,5 +1,4 @@ import axios, { AxiosRequestConfig, AxiosResponse } from "axios" -import { Agent } from "http" const PROVIDER_URL = "http://localhost:5000" @@ -14,8 +13,8 @@ const options = (state, consumer): AxiosRequestConfig => { }, headers: { "Content-Type": "application/json", + "Keep-Alive": false, }, - httpAgent: new Agent({ keepAlive: false }), } } From 53b25eac51d73dbb1d304c727eeb6acd6d22b586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:14:11 +0200 Subject: [PATCH 11/12] Revert "Add Keep-Alive header to integration test requests" This reverts commit f5fc3d0e58904eb85611779a5c7084961250e48f. --- src/tests/integration/helper/state.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tests/integration/helper/state.ts b/src/tests/integration/helper/state.ts index 846dad5..29fcf47 100644 --- a/src/tests/integration/helper/state.ts +++ b/src/tests/integration/helper/state.ts @@ -13,7 +13,6 @@ const options = (state, consumer): AxiosRequestConfig => { }, headers: { "Content-Type": "application/json", - "Keep-Alive": false, }, } } From 03153c75023395cd2ae26e357aaa57b5e8a7194f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lud=C4=9Bk=20Nov=C3=BD?= <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:14:24 +0200 Subject: [PATCH 12/12] Revert "Update Node.js to v20 in GitHub Actions workflow" This reverts commit 387411a67cf018c8925420232c977eef79caa80a. --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9d53cfe..d4d4205 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: '20' + node-version: '18' - name: Install modules run: npm install - name: Build the docker-compose stack