-
Notifications
You must be signed in to change notification settings - Fork 2
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
Pull from main to Move-InsightsAndSettingsLogic-to-component #377
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] <[email protected]>
…/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] <[email protected]>
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] <[email protected]>
…/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] <[email protected]>
…/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/[email protected]...@slack/[email protected]) --- updated-dependencies: - dependency-name: "@slack/web-api" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
…/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] <[email protected]>
…/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
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months 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.
-
Copy modified line R118 -
Copy modified lines R120-R132
@@ -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
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months 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
path
module. - 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.
-
Copy modified line R3 -
Copy modified lines R19-R25 -
Copy modified line R27
@@ -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
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months 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.
-
Copy modified line R4 -
Copy modified line R27 -
Copy modified lines R30-R37 -
Copy modified line R40
@@ -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
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months 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
path
module. - 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.
-
Copy modified line R4 -
Copy modified lines R29-R35 -
Copy modified lines R38-R41
@@ -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.