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

FACT-2116 CVEs for December #65

Merged
merged 9 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@
"cichecks": "yarn && yarn build && yarn lint && yarn test && yarn test:routes && yarn test:a11y"
},
"dependencies": {
"@hmcts/info-provider": "^1.2.1",
"@hmcts/nodejs-healthcheck": "^1.7.3",
"@hmcts/info-provider": "^1.2.2",
"@hmcts/nodejs-healthcheck": "^1.8.5",
"@hmcts/nodejs-logging": "^4.0.4",
"@hmcts/properties-volume": "^1.1.0",
"@types/config": "^3.0.0",
"@types/cookie-parser": "^1.4.2",
"@types/csurf": "^1.9.36",
"@types/es6-promisify": "^6.0.1",
"@hmcts/properties-volume": "^1.2.0",
"@types/config": "^3.3.5",
"@types/cookie-parser": "^1.4.8",
"@types/csurf": "^1.11.5",
"@types/es6-promisify": "^6.0.4",
"@types/express": "^4.17.21",
"@types/glob": "^8.1.0",
"@types/helmet": "^4.0.0",
"@types/jquery": "^3.5.32",
"@types/lodash": "^4.17.12",
"@types/node": "^20.0.0",
"@types/lodash": "^4.17.13",
"@types/node": "^20.17.10",
"@types/nunjucks": "^3.2.6",
"@types/require-directory": "^2.1.6",
"@types/serve-favicon": "^2.5.7",
"applicationinsights": "^2.9.6",
"axios": "^1.7.7",
"axios": "^1.7.9",
"config": "^3.3.12",
"cookie-parser": "^1.4.7",
"csurf": "^1.11.0",
"express": "^4.21.1",
"express": "^5.0.1",
"express-nunjucks": "^3.1.2",
"glob": "^11.0.0",
"govuk-frontend": "^5.0.0",
"govuk-frontend": "5.0.0",
"helmet": "^5.1.1",
"jquery": "^3.7.1",
"lodash": "^4.17.21",
Expand All @@ -58,9 +58,9 @@
"typescript": "^5.6.3"
},
"devDependencies": {
"@babel/core": "^7.25.9",
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/preset-env": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@types/chai-as-promised": "^8.0.1",
"@types/jest": "^29.5.14",
"@types/jest-when": "^3.5.5",
Expand All @@ -74,35 +74,35 @@
"codeceptjs": "^3.6.7",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"debug": "^4.3.7",
"eslint": "^8.57.0",
"debug": "^4.4.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-prettier": "^5.2.1",
"html-webpack-plugin": "^5.6.3",
"husky": "^9.1.6",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-html-reporter": "^3.10.2",
"lint-staged": "^15.2.10",
"mini-css-extract-plugin": "^2.9.1",
"nock": "^13.5.5",
"lint-staged": "^15.2.11",
"mini-css-extract-plugin": "^2.9.2",
"nock": "^13.5.6",
"node-sass": "^9.0.0",
"nodemon": "^3.1.7",
"pa11y": "^6.1.1",
"playwright": "^1.48.1",
"prettier": "^3.3.3",
"playwright": "^1.49.1",
"prettier": "^3.4.2",
"request": "^2.88.2",
"sass-lint": "^1.13.1",
"sass-loader": "^16.0.2",
"sass-loader": "^16.0.4",
"sinon": "^19.0.2",
"sinon-chai": "^4.0.0",
"sonar-scanner": "^3.1.0",
"style-loader": "^4.0.0",
"supertest": "^7.0.0",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"webpack": "^5.66.0",
"webpack": "^5.97.1",
"webpack-cli": "^5.1.4",
"webpack-dev-middleware": "^7.4.2",
"webpack-node-externals": "^3.0.0"
Expand Down
60 changes: 46 additions & 14 deletions src/test/a11y/a11y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,45 +36,77 @@ class PallyIssue {
}
}

function ensurePageCallWillSucceed(url: string): Promise<void> {
return agent.get(url).then((res: supertest.Response) => {
async function ensurePageCallWillSucceed(url: string): Promise<void> {
try {
console.log(`Ensuring page call for URL: ${url}`);
const res = await agent.get(url);
console.log(`Response for URL: ${url} - Status: ${res.status} - Text: ${res.text}`);

if (res.redirect) {
throw new Error(`Call to ${url} resulted in a redirect to ${res.get('Location')}`);
}
if (res.serverError) {
throw new Error(`Call to ${url} resulted in internal server error`);
throw new Error(`Call to ${url} resulted in internal server error: ${res.text}`);
}
});
} catch (err) {
console.error(`Error ensuring page call for URL ${url}:`, err);
throw err;
}
}

function runPally(url: string): Promise<Pa11yResult> {
return pa11y(url, {
hideElements: '.govuk-footer__licence-logo, .govuk-header__logotype-crown',
});
async function runPally(url: string): Promise<Pa11yResult> {
try {
console.log(`Running Pa11y on URL: ${url}`);
const result = await pa11y(url, {
hideElements: '.govuk-footer__licence-logo, .govuk-header__logotype-crown',
});
console.log(`Pa11y result for URL: ${url} - Result:`, result);
return result;
} catch (err) {
console.error(`Pa11y error on URL ${url}:`, err);
throw err;
}
}

function expectNoErrors(messages: PallyIssue[]): void {
const errors = messages.filter(m => m.type === 'error');

if (errors.length > 0) {
const errorsAsJson = `${JSON.stringify(errors, null, 2)}`;
throw new Error(`There are accessibility issues: \n${errorsAsJson}\n`);
console.error('Accessibility issues found:', errorsAsJson);
throw new Error(`There are accessibility issues:
${errorsAsJson}
`);
}
}

function testAccessibility(url: string): void {
describe(`Page ${url}`, () => {
test('should have no accessibility errors', async () => {
await ensurePageCallWillSucceed(url);
const result = await runPally(agent.get(url).url);
expect(result.issues).toEqual(expect.any(Array));
expectNoErrors(result.issues);
try {
console.log(`Starting accessibility test for URL: ${url}`);
await ensurePageCallWillSucceed(url);
const result = await runPally(agent.get(url).url);
expect(result.issues).toEqual(expect.any(Array));
expectNoErrors(result.issues);
} catch (err) {
console.error(`Accessibility test failed for URL ${url} with error:`, err);
throw err;
}
});
});
}

describe('Accessibility', () => {
// testing accessibility of the home page
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
});

process.on('uncaughtException', err => {
console.error('Uncaught Exception thrown', err);
process.exit(1);
});

testAccessibility('/');

// TODO: include each path of your application in accessibility checks
Expand Down
Loading
Loading