From b1de0ccabbf403d4ebb09cc0bb627930bb367c19 Mon Sep 17 00:00:00 2001 From: Felix Hoops <9974641+jfelixh@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:41:07 +0200 Subject: [PATCH] Log redaction Signed-off-by: Felix Hoops <9974641+jfelixh@users.noreply.github.com> --- .github/workflows/playwright.yml | 10 ++-------- compose.yaml | 2 -- vclogin/__tests__/e2e/e2e.spec.ts | 8 +++++--- vclogin/config/logger.ts | 1 + vclogin/middleware/logging.ts | 20 +++++++++++++++++++- vclogin/package.json | 2 +- vclogin/playwright.config.ts | 16 ++++++++-------- 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 03fa55b..05e41ca 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,9 +1,9 @@ name: Playwright Tests on: push: - branches: [main, master] + branches: ["main"] pull_request: - branches: [main, master] + branches: ["main"] jobs: test: timeout-minutes: 60 @@ -22,9 +22,3 @@ jobs: run: npx playwright install --with-deps - name: Run Playwright tests run: npm run test:e2e - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 diff --git a/compose.yaml b/compose.yaml index 25ea305..625a3a4 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,5 +1,3 @@ -version: "3" - services: hydra-migrate: image: oryd/hydra:v2.2.0 diff --git a/vclogin/__tests__/e2e/e2e.spec.ts b/vclogin/__tests__/e2e/e2e.spec.ts index a2f3cde..a18820c 100644 --- a/vclogin/__tests__/e2e/e2e.spec.ts +++ b/vclogin/__tests__/e2e/e2e.spec.ts @@ -51,18 +51,20 @@ test.describe("Login Page", () => { await expect( page.getByRole("heading", { name: "SSI-to-OIDC Bridge" }), - ).toBeVisible(); + ).toBeVisible({ timeout: 15000 }); }); test("has CTA", async ({ page }) => { await page.goto(url + "/login?login_challenge=challenge123"); - await expect(page.getByRole("heading", { name: /Scan/i })).toBeVisible(); + await expect(page.getByRole("heading", { name: /Scan/i })).toBeVisible({ + timeout: 15000, + }); }); test("has QR Code", async ({ page }) => { await page.goto(url + "/login?login_challenge=challenge123"); - await expect(page.locator("canvas")).toBeVisible(); + await expect(page.locator("canvas")).toBeVisible({ timeout: 15000 }); }); }); diff --git a/vclogin/config/logger.ts b/vclogin/config/logger.ts index 3ac2b8a..84cd05c 100644 --- a/vclogin/config/logger.ts +++ b/vclogin/config/logger.ts @@ -7,4 +7,5 @@ import pino from "pino"; export const logger = pino({ level: process.env.NODE_ENV === "production" ? "info" : "debug", + redact: ["req.query.*", "res.headers.*"], }); diff --git a/vclogin/middleware/logging.ts b/vclogin/middleware/logging.ts index 81162e5..8333cfd 100644 --- a/vclogin/middleware/logging.ts +++ b/vclogin/middleware/logging.ts @@ -5,9 +5,27 @@ import { logger } from "@/config/logger"; import { NextApiRequest, NextApiResponse } from "next"; +import pino from "pino"; import { pinoHttp } from "pino-http"; -const loggerHttp = pinoHttp({ logger: logger }); +const loggerHttp = pinoHttp({ + logger: logger, + serializers: { + req: pino.stdSerializers.wrapRequestSerializer((r) => { + return { + id: r.id, + method: r.method, + url: r.url.split("?")[0], + query: r.query, + headers: { + host: r.raw.headers.host, + "user-agent": r.raw.headers["user-agent"], + referer: r.raw.headers.referer, + }, + }; + }), + }, +}); export const withLogging = ( handler: (a: NextApiRequest, b: NextApiResponse) => Promise, diff --git a/vclogin/package.json b/vclogin/package.json index d4cff55..ee8a314 100644 --- a/vclogin/package.json +++ b/vclogin/package.json @@ -8,7 +8,7 @@ "start": "NODE_OPTIONS='-r next-logger' next start", "lint": "next lint", "test": "jest --coverage", - "test:e2e": "npx playwright test --project='chromium'" + "test:e2e": "npx playwright test" }, "dependencies": { "@material-tailwind/react": "^2.0.3", diff --git a/vclogin/playwright.config.ts b/vclogin/playwright.config.ts index 9f9b12a..d18a643 100644 --- a/vclogin/playwright.config.ts +++ b/vclogin/playwright.config.ts @@ -37,15 +37,15 @@ export default defineConfig({ use: { ...devices["Desktop Chrome"] }, }, - { - name: "firefox", - use: { ...devices["Desktop Firefox"] }, - }, + //{ + // name: "firefox", + // use: { ...devices["Desktop Firefox"] }, + //}, - { - name: "webkit", - use: { ...devices["Desktop Safari"] }, - }, + //{ + // name: "webkit", + // use: { ...devices["Desktop Safari"] }, + //}, /* Test against mobile viewports. */ // {