Pull from main to Move-InsightsAndSettingsLogic-to-component#377
Pull from main to Move-InsightsAndSettingsLogic-to-component#377Tr01ler merged 45 commits intoMove-InsightsAndSettings-Logic-to-componentfrom
Conversation
Autoformat the entire codebase
Bumps [next](https://github.com/vercel/next.js) from 15.0.3 to 15.1.0. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](vercel/next.js@v15.0.3...v15.1.0) --- updated-dependencies: - dependency-name: next dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…/next-15.1.0 [npm]: Bump next from 15.0.3 to 15.1.0
Fix ESLint warnings
…implement bulk user and pit report retrieval in ClientApi
…seRouter for routing
…ation and remove useRouter
Bumps [react-icons](https://github.com/react-icons/react-icons) from 5.3.0 to 5.4.0. - [Release notes](https://github.com/react-icons/react-icons/releases) - [Commits](react-icons/react-icons@v5.3.0...v5.4.0) --- updated-dependencies: - dependency-name: react-icons dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [daisyui](https://github.com/saadeghi/daisyui) from 4.12.14 to 4.12.22. - [Release notes](https://github.com/saadeghi/daisyui/releases) - [Changelog](https://github.com/saadeghi/daisyui/blob/master/CHANGELOG.md) - [Commits](saadeghi/daisyui@v4.12.14...v4.12.22) --- updated-dependencies: - dependency-name: daisyui dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
…/daisyui-4.12.22 [npm]: Bump daisyui from 4.12.14 to 4.12.22
Bumps [@eslint/js](https://github.com/eslint/eslint/tree/HEAD/packages/js) from 9.16.0 to 9.17.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/commits/v9.17.0/packages/js) --- updated-dependencies: - dependency-name: "@eslint/js" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…/react-icons-5.4.0 [npm]: Bump react-icons from 5.3.0 to 5.4.0
Bumps [@slack/web-api](https://github.com/slackapi/node-slack-sdk) from 7.7.0 to 7.8.0. - [Release notes](https://github.com/slackapi/node-slack-sdk/releases) - [Commits](https://github.com/slackapi/node-slack-sdk/compare/@slack/web-api@7.7.0...@slack/web-api@7.8.0) --- updated-dependencies: - dependency-name: "@slack/web-api" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…/eslint/js-9.17.0 [npm]: Bump @eslint/js from 9.16.0 to 9.17.0
Bumps [@yudiel/react-qr-scanner](https://github.com/yudielcurbelo/react-qr-scanner) from 2.0.8 to 2.1.0. - [Release notes](https://github.com/yudielcurbelo/react-qr-scanner/releases) - [Commits](yudielcurbelo/react-qr-scanner@v2.0.8...v2.1.0) --- updated-dependencies: - dependency-name: "@yudiel/react-qr-scanner" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…/slack/web-api-7.8.0 [npm]: Bump @slack/web-api from 7.7.0 to 7.8.0
…/yudiel/react-qr-scanner-2.1.0 [npm]: Bump @yudiel/react-qr-scanner from 2.0.8 to 2.1.0
| .finally(() => { | ||
| if (location.href.includes("offline")) | ||
| location.href = `/offline/${props.compId}`; | ||
| else location.href = `/${teamSlug}/${seasonSlug}/${competitonSlug}`; |
Check warning
Code scanning / CodeQL
Client-side URL redirect Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that the URL redirection only uses trusted and validated values. One way to achieve this is by maintaining a list of authorized redirects and choosing from that list based on the user input provided. This approach ensures that only predefined and safe URLs are used for redirection.
We will create a list of authorized redirects and use a function to validate the teamSlug, seasonSlug, and competitonSlug values against this list before performing the redirection. If the values are not valid, we can redirect to a default safe URL or show an error message.
| @@ -117,5 +117,17 @@ | ||
| .finally(() => { | ||
| if (location.href.includes("offline")) | ||
| if (location.href.includes("offline")) { | ||
| location.href = `/offline/${props.compId}`; | ||
| else location.href = `/${teamSlug}/${seasonSlug}/${competitonSlug}`; | ||
| } else { | ||
| const authorizedRedirects = [ | ||
| `/${teamSlug}/${seasonSlug}/${competitonSlug}`, | ||
| // Add other authorized redirects here | ||
| ]; | ||
| const redirectUrl = `/${teamSlug}/${seasonSlug}/${competitonSlug}`; | ||
| if (authorizedRedirects.includes(redirectUrl)) { | ||
| location.href = redirectUrl; | ||
| } else { | ||
| // Redirect to a default safe URL or show an error message | ||
| location.href = '/default-safe-url'; | ||
| } | ||
| } | ||
| }); |
| highWaterMark: 256 * 1024, | ||
| }); | ||
| res.writeHead(200, { "content-type": "image/*" }); | ||
| var s = fs.createReadStream(process.env.IMAGE_UPLOAD_DIR + `/${filename}`, { |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that the constructed file path is contained within a safe root directory. This can be achieved by normalizing the path using path.resolve and then checking that the normalized path starts with the root directory. If the path is not within the root directory, we should return an error response.
- Import the
pathmodule. - Normalize the constructed file path using
path.resolve. - Check if the normalized path starts with the root directory (
process.env.IMAGE_UPLOAD_DIR). - If the path is valid, proceed with reading the file. Otherwise, return a 403 error response.
| @@ -2,2 +2,3 @@ | ||
| import * as fs from "fs"; | ||
| import * as path from "path"; | ||
|
|
||
| @@ -17,4 +18,11 @@ | ||
|
|
||
| const rootDir = process.env.IMAGE_UPLOAD_DIR; | ||
| const filePath = path.resolve(rootDir, filename); | ||
|
|
||
| if (!filePath.startsWith(rootDir)) { | ||
| return res.status(403).send({ status: 403, message: "Forbidden" }); | ||
| } | ||
|
|
||
| res.writeHead(200, { "content-type": "image/*" }); | ||
| var s = fs.createReadStream(process.env.IMAGE_UPLOAD_DIR + `/${filename}`, { | ||
| var s = fs.createReadStream(filePath, { | ||
| highWaterMark: 256 * 1024, |
| } else { | ||
| return res.send({ status: 400, message: "Invalid Request" }); | ||
| } | ||
| var tempFile = fs.readFileSync(file.filepath, { encoding: "base64" }); |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that the file path derived from user input is validated and sanitized before being used. We can achieve this by normalizing the path and ensuring it is contained within a designated safe directory. This involves using path.resolve to normalize the path and then checking that the resulting path starts with the intended root directory.
| @@ -3,3 +3,3 @@ | ||
| import * as fs from "fs"; | ||
|
|
||
| import * as path from "path"; | ||
| export const config = { | ||
| @@ -26,9 +26,16 @@ | ||
|
|
||
| const ROOT = process.env.IMAGE_UPLOAD_DIR; | ||
| var filetype = file.mimetype.split("image/")[1]; | ||
| var filename = `/${file.newFilename}.${filetype}`; | ||
| console.log(process.env.IMAGE_UPLOAD_DIR + filename); | ||
| console.log(process.env.IMAGE_UPLOAD_DIR); | ||
| var filePath = path.resolve(ROOT, filename); | ||
|
|
||
| if (!filePath.startsWith(ROOT)) { | ||
| throw new Error("Invalid file path"); | ||
| } | ||
|
|
||
| console.log(filePath); | ||
| console.log(ROOT); | ||
|
|
||
| var tempFile = fs.readFileSync(file.filepath, { encoding: "base64" }); | ||
| fs.writeFile(process.env.IMAGE_UPLOAD_DIR + filename, tempFile, (err) => { | ||
| fs.writeFile(filePath, tempFile, (err) => { | ||
| res.send({ status: 200, filename: filename }); |
| return res.send({ status: 400, message: "Invalid Request" }); | ||
| } | ||
| var tempFile = fs.readFileSync(file.filepath, { encoding: "base64" }); | ||
| fs.writeFile(process.env.IMAGE_UPLOAD_DIR + filename, tempFile, (err) => { |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that the constructed file path is contained within a safe root folder. We can achieve this by normalizing the path using path.resolve and then checking that the normalized path starts with the root folder. This will prevent directory traversal attacks by ensuring that the file path does not escape the intended directory.
- Import the
pathmodule. - Normalize the constructed file path using
path.resolve. - Check that the normalized path starts with the root folder (
process.env.IMAGE_UPLOAD_DIR). - If the check fails, return an error response.
- If the check passes, proceed with the file system operation.
| @@ -3,2 +3,3 @@ | ||
| import * as fs from "fs"; | ||
| import * as path from "path"; | ||
|
|
||
| @@ -27,8 +28,15 @@ | ||
| var filetype = file.mimetype.split("image/")[1]; | ||
| var filename = `/${file.newFilename}.${filetype}`; | ||
| console.log(process.env.IMAGE_UPLOAD_DIR + filename); | ||
| console.log(process.env.IMAGE_UPLOAD_DIR); | ||
| var filename = `${file.newFilename}.${filetype}`; | ||
| var uploadDir = process.env.IMAGE_UPLOAD_DIR; | ||
| var filePath = path.resolve(uploadDir, filename); | ||
|
|
||
| if (!filePath.startsWith(uploadDir)) { | ||
| return res.send({ status: 403, message: "Forbidden" }); | ||
| } | ||
|
|
||
| var tempFile = fs.readFileSync(file.filepath, { encoding: "base64" }); | ||
| fs.writeFile(process.env.IMAGE_UPLOAD_DIR + filename, tempFile, (err) => { | ||
| fs.writeFile(filePath, tempFile, (err) => { | ||
| if (err) { | ||
| return res.send({ status: 500, message: err.message }); | ||
| } | ||
| res.send({ status: 200, filename: filename }); |
570523b
into
Move-InsightsAndSettings-Logic-to-component
No description provided.