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

Format all files on BE with perttier config #978

Merged
merged 4 commits into from
Oct 18, 2024

Conversation

ajhollid
Copy link
Collaborator

This PR formats all fiels on the with the new prettier configuration to give us a common baseline

verifyOwnership(Monitor, "monitorId"),
deleteChecks
);
router.delete("/:monitorId", verifyOwnership(Monitor, "monitorId"), deleteChecks);

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a database access
, but is not rate-limited.

Copilot Autofix AI 3 months ago

To fix the problem, we will add rate limiting to the Express router using the express-rate-limit package. This will ensure that the number of requests to the route is controlled, preventing potential abuse. We will set up a rate limiter with a reasonable limit, such as 100 requests per 15 minutes, and apply it to the routes that perform database access.

  1. Install the express-rate-limit package.
  2. Import the express-rate-limit package in the Server/routes/checkRoute.js file.
  3. Set up a rate limiter with a configuration that limits the number of requests.
  4. Apply the rate limiter to the routes that perform database access.
Suggested changeset 2
Server/routes/checkRoute.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Server/routes/checkRoute.js b/Server/routes/checkRoute.js
--- a/Server/routes/checkRoute.js
+++ b/Server/routes/checkRoute.js
@@ -1,2 +1,3 @@
 import { Router } from "express";
+import rateLimit from "express-rate-limit";
 import {
@@ -15,11 +16,17 @@
 
-router.get("/:monitorId", getChecks);
-router.post("/:monitorId", verifyOwnership(Monitor, "monitorId"), createCheck);
-router.delete("/:monitorId", verifyOwnership(Monitor, "monitorId"), deleteChecks);
+// Set up rate limiter: maximum of 100 requests per 15 minutes
+const limiter = rateLimit({
+    windowMs: 15 * 60 * 1000, // 15 minutes
+    max: 100, // max 100 requests per windowMs
+});
 
-router.get("/team/:teamId", getTeamChecks);
+router.get("/:monitorId", limiter, getChecks);
+router.post("/:monitorId", limiter, verifyOwnership(Monitor, "monitorId"), createCheck);
+router.delete("/:monitorId", limiter, verifyOwnership(Monitor, "monitorId"), deleteChecks);
 
-router.delete("/team/:teamId", isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);
+router.get("/team/:teamId", limiter, getTeamChecks);
 
-router.put("/team/ttl", isAllowed(["admin", "superadmin"]), updateChecksTTL);
+router.delete("/team/:teamId", limiter, isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);
+
+router.put("/team/ttl", limiter, isAllowed(["admin", "superadmin"]), updateChecksTTL);
 
EOF
@@ -1,2 +1,3 @@
import { Router } from "express";
import rateLimit from "express-rate-limit";
import {
@@ -15,11 +16,17 @@

router.get("/:monitorId", getChecks);
router.post("/:monitorId", verifyOwnership(Monitor, "monitorId"), createCheck);
router.delete("/:monitorId", verifyOwnership(Monitor, "monitorId"), deleteChecks);
// Set up rate limiter: maximum of 100 requests per 15 minutes
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // max 100 requests per windowMs
});

router.get("/team/:teamId", getTeamChecks);
router.get("/:monitorId", limiter, getChecks);
router.post("/:monitorId", limiter, verifyOwnership(Monitor, "monitorId"), createCheck);
router.delete("/:monitorId", limiter, verifyOwnership(Monitor, "monitorId"), deleteChecks);

router.delete("/team/:teamId", isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);
router.get("/team/:teamId", limiter, getTeamChecks);

router.put("/team/ttl", isAllowed(["admin", "superadmin"]), updateChecksTTL);
router.delete("/team/:teamId", limiter, isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);

router.put("/team/ttl", limiter, isAllowed(["admin", "superadmin"]), updateChecksTTL);

Server/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Server/package.json b/Server/package.json
--- a/Server/package.json
+++ b/Server/package.json
@@ -33,3 +33,4 @@
 		"swagger-ui-express": "5.0.1",
-		"winston": "^3.13.0"
+		"winston": "^3.13.0",
+		"express-rate-limit": "^7.4.1"
 	},
EOF
@@ -33,3 +33,4 @@
"swagger-ui-express": "5.0.1",
"winston": "^3.13.0"
"winston": "^3.13.0",
"express-rate-limit": "^7.4.1"
},
This fix introduces these dependencies
Package Version Security advisories
express-rate-limit (npm) 7.4.1 None
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
isAllowed(["admin", "superadmin"]),
deleteChecksByTeamId
);
router.delete("/team/:teamId", isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix AI 3 months ago

To fix the problem, we will introduce rate limiting to the route handler that performs authorization. We will use the express-rate-limit package to set up a rate limiter and apply it to the specific route. This will ensure that the route is protected against excessive requests, mitigating the risk of DoS attacks.

  1. Install the express-rate-limit package if it is not already installed.
  2. Import the express-rate-limit package in the Server/routes/checkRoute.js file.
  3. Set up a rate limiter with appropriate configuration (e.g., a maximum of 100 requests per 15 minutes).
  4. Apply the rate limiter to the route handler on line 22.
Suggested changeset 2
Server/routes/checkRoute.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Server/routes/checkRoute.js b/Server/routes/checkRoute.js
--- a/Server/routes/checkRoute.js
+++ b/Server/routes/checkRoute.js
@@ -1,2 +1,3 @@
 import { Router } from "express";
+import rateLimit from "express-rate-limit";
 import {
@@ -15,2 +16,8 @@
 
+// Set up rate limiter: maximum of 100 requests per 15 minutes
+const limiter = rateLimit({
+    windowMs: 15 * 60 * 1000, // 15 minutes
+    max: 100, // max 100 requests per windowMs
+});
+
 router.get("/:monitorId", getChecks);
@@ -21,3 +28,3 @@
 
-router.delete("/team/:teamId", isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);
+router.delete("/team/:teamId", limiter, isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);
 
EOF
@@ -1,2 +1,3 @@
import { Router } from "express";
import rateLimit from "express-rate-limit";
import {
@@ -15,2 +16,8 @@

// Set up rate limiter: maximum of 100 requests per 15 minutes
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // max 100 requests per windowMs
});

router.get("/:monitorId", getChecks);
@@ -21,3 +28,3 @@

router.delete("/team/:teamId", isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);
router.delete("/team/:teamId", limiter, isAllowed(["admin", "superadmin"]), deleteChecksByTeamId);

Server/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Server/package.json b/Server/package.json
--- a/Server/package.json
+++ b/Server/package.json
@@ -33,3 +33,4 @@
 		"swagger-ui-express": "5.0.1",
-		"winston": "^3.13.0"
+		"winston": "^3.13.0",
+		"express-rate-limit": "^7.4.1"
 	},
EOF
@@ -33,3 +33,4 @@
"swagger-ui-express": "5.0.1",
"winston": "^3.13.0"
"winston": "^3.13.0",
"express-rate-limit": "^7.4.1"
},
This fix introduces these dependencies
Package Version Security advisories
express-rate-limit (npm) 7.4.1 None
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Server/routes/inviteRoute.js Dismissed Show dismissed Hide dismissed
verifyJWT,
issueInvitation
);
router.post("/", isAllowed(["admin", "superadmin"]), verifyJWT, issueInvitation);

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.

Copilot Autofix AI 3 months ago

To fix the problem, we will introduce rate limiting to the routes in Server/routes/inviteRoute.js. We will use the express-rate-limit package to limit the number of requests that can be made to the endpoints within a specified time window. This will help mitigate the risk of denial-of-service attacks.

  1. Install the express-rate-limit package if it is not already installed.
  2. Import the express-rate-limit package in the Server/routes/inviteRoute.js file.
  3. Set up a rate limiter with appropriate configuration (e.g., maximum of 100 requests per 15 minutes).
  4. Apply the rate limiter to the routes that require protection.
Suggested changeset 2
Server/routes/inviteRoute.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Server/routes/inviteRoute.js b/Server/routes/inviteRoute.js
--- a/Server/routes/inviteRoute.js
+++ b/Server/routes/inviteRoute.js
@@ -3,2 +3,3 @@
 import { isAllowed } from "../middleware/isAllowed.js";
+import RateLimit from "express-rate-limit";
 import {
@@ -10,4 +11,10 @@
 
-router.post("/", isAllowed(["admin", "superadmin"]), verifyJWT, issueInvitation);
-router.post("/verify", issueInvitation);
+// set up rate limiter: maximum of 100 requests per 15 minutes
+const limiter = RateLimit({
+	windowMs: 15 * 60 * 1000, // 15 minutes
+	max: 100, // max 100 requests per windowMs
+});
+
+router.post("/", limiter, isAllowed(["admin", "superadmin"]), verifyJWT, issueInvitation);
+router.post("/verify", limiter, issueInvitation);
 
EOF
@@ -3,2 +3,3 @@
import { isAllowed } from "../middleware/isAllowed.js";
import RateLimit from "express-rate-limit";
import {
@@ -10,4 +11,10 @@

router.post("/", isAllowed(["admin", "superadmin"]), verifyJWT, issueInvitation);
router.post("/verify", issueInvitation);
// set up rate limiter: maximum of 100 requests per 15 minutes
const limiter = RateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // max 100 requests per windowMs
});

router.post("/", limiter, isAllowed(["admin", "superadmin"]), verifyJWT, issueInvitation);
router.post("/verify", limiter, issueInvitation);

Server/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Server/package.json b/Server/package.json
--- a/Server/package.json
+++ b/Server/package.json
@@ -33,3 +33,4 @@
 		"swagger-ui-express": "5.0.1",
-		"winston": "^3.13.0"
+		"winston": "^3.13.0",
+		"express-rate-limit": "^7.4.1"
 	},
EOF
@@ -33,3 +33,4 @@
"swagger-ui-express": "5.0.1",
"winston": "^3.13.0"
"winston": "^3.13.0",
"express-rate-limit": "^7.4.1"
},
This fix introduces these dependencies
Package Version Security advisories
express-rate-limit (npm) 7.4.1 None
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
verifyOwnership(Monitor, "monitorId"),
getMaintenanceWindowsByMonitorId
"/monitor/:monitorId",
verifyOwnership(Monitor, "monitorId"),

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a database access
, but is not rate-limited.

Copilot Autofix AI 3 months ago

To fix the problem, we will use the express-rate-limit package to add rate limiting to the routes in Server/routes/maintenanceWindowRoute.js. This will ensure that the number of requests to these routes is limited, thereby reducing the risk of a DoS attack.

  1. Install the express-rate-limit package if it is not already installed.
  2. Import the express-rate-limit package in the Server/routes/maintenanceWindowRoute.js file.
  3. Set up a rate limiter with appropriate configuration (e.g., maximum of 100 requests per 15 minutes).
  4. Apply the rate limiter to the routes that perform database operations.
Suggested changeset 2
Server/routes/maintenanceWindowRoute.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Server/routes/maintenanceWindowRoute.js b/Server/routes/maintenanceWindowRoute.js
--- a/Server/routes/maintenanceWindowRoute.js
+++ b/Server/routes/maintenanceWindowRoute.js
@@ -1,2 +1,3 @@
 import { Router } from "express";
+import RateLimit from "express-rate-limit";
 import {
@@ -14,2 +15,7 @@
 
+const limiter = RateLimit({
+    windowMs: 15 * 60 * 1000, // 15 minutes
+    max: 100, // max 100 requests per windowMs
+});
+
 router.post("/", createMaintenanceWindows);
@@ -18,2 +24,3 @@
 	"/monitor/:monitorId",
+	limiter,
 	verifyOwnership(Monitor, "monitorId"),
@@ -22,9 +29,9 @@
 
-router.get("/team/", getMaintenanceWindowsByTeamId);
+router.get("/team/", limiter, getMaintenanceWindowsByTeamId);
 
-router.get("/:id", getMaintenanceWindowById);
+router.get("/:id", limiter, getMaintenanceWindowById);
 
-router.put("/:id", editMaintenanceWindow);
+router.put("/:id", limiter, editMaintenanceWindow);
 
-router.delete("/:id", deleteMaintenanceWindow);
+router.delete("/:id", limiter, deleteMaintenanceWindow);
 
EOF
@@ -1,2 +1,3 @@
import { Router } from "express";
import RateLimit from "express-rate-limit";
import {
@@ -14,2 +15,7 @@

const limiter = RateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // max 100 requests per windowMs
});

router.post("/", createMaintenanceWindows);
@@ -18,2 +24,3 @@
"/monitor/:monitorId",
limiter,
verifyOwnership(Monitor, "monitorId"),
@@ -22,9 +29,9 @@

router.get("/team/", getMaintenanceWindowsByTeamId);
router.get("/team/", limiter, getMaintenanceWindowsByTeamId);

router.get("/:id", getMaintenanceWindowById);
router.get("/:id", limiter, getMaintenanceWindowById);

router.put("/:id", editMaintenanceWindow);
router.put("/:id", limiter, editMaintenanceWindow);

router.delete("/:id", deleteMaintenanceWindow);
router.delete("/:id", limiter, deleteMaintenanceWindow);

Server/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Server/package.json b/Server/package.json
--- a/Server/package.json
+++ b/Server/package.json
@@ -33,3 +33,4 @@
 		"swagger-ui-express": "5.0.1",
-		"winston": "^3.13.0"
+		"winston": "^3.13.0",
+		"express-rate-limit": "^7.4.1"
 	},
EOF
@@ -33,3 +33,4 @@
"swagger-ui-express": "5.0.1",
"winston": "^3.13.0"
"winston": "^3.13.0",
"express-rate-limit": "^7.4.1"
},
This fix introduces these dependencies
Package Version Security advisories
express-rate-limit (npm) 7.4.1 None
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
id: "123",
},
headers: {
authorization: "Bearer token",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Bearer token" is used as
authorization header
.
params: {},
query: {},
headers: {
authorization: "Bearer token",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Bearer token" is used as
authorization header
.
},
query: {},
headers: {
authorization: "Bearer token",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Bearer token" is used as
authorization header
.
},
query: {},
headers: {
authorization: "Bearer token",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Bearer token" is used as
authorization header
.
},
query: {},
headers: {
authorization: "Bearer token",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Bearer token" is used as
authorization header
.
Copy link

coderabbitai bot commented Oct 17, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request involve formatting adjustments across numerous files, primarily transitioning from spaces to tabs for indentation. This effort aims to enhance code readability and maintain consistency without altering the logical structure or functionality of the code. Noteworthy updates include a property name change in .prettierrc and various controllers, models, middleware, and route files being reformatted for improved organization and clarity.

Changes

Files Change Summary
.prettierrc Updated property name from jsx-single-quote to jsxSingleQuote.
Server/configs/db.js Adjusted indentation in connectDbAndRunServer function.
Server/controllers/*.js Reformatted for consistent indentation and organization.
Server/db/models/*.js Reformatted for consistent indentation while preserving structure.
Server/db/mongo/modules/*.js Adjusted indentation for consistent formatting.
Server/middleware/*.js Reformatted for consistent indentation without logic changes.
Server/routes/*.js Modified for improved readability and organization.
Server/tests/controllers/*.test.js Reformatted for consistent indentation, maintaining original logic.
Server/utils/*.json, Server/templates/*.mjml Restructured for improved readability without content changes.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • marcelluscaio
  • jennifer-gan

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ab0f4e4 and 8bdade2.

📒 Files selected for processing (57)
  • .prettierrc (1 hunks)
  • Server/configs/db.js (1 hunks)
  • Server/controllers/checkController.js (2 hunks)
  • Server/controllers/inviteController.js (2 hunks)
  • Server/controllers/maintenanceWindowController.js (2 hunks)
  • Server/controllers/queueController.js (1 hunks)
  • Server/controllers/settingsController.js (1 hunks)
  • Server/db/FakeDb.js (1 hunks)
  • Server/db/models/AppSettings.js (1 hunks)
  • Server/db/models/Check.js (1 hunks)
  • Server/db/models/InviteToken.js (1 hunks)
  • Server/db/models/MaintenanceWindow.js (1 hunks)
  • Server/db/models/Monitor.js (1 hunks)
  • Server/db/models/Notification.js (1 hunks)
  • Server/db/models/PageSpeedCheck.js (3 hunks)
  • Server/db/models/RecoveryToken.js (1 hunks)
  • Server/db/models/Team.js (1 hunks)
  • Server/db/mongo/MongoDB.js (2 hunks)
  • Server/db/mongo/modules/checkModule.js (5 hunks)
  • Server/db/mongo/modules/inviteModule.js (3 hunks)
  • Server/db/mongo/modules/maintenanceWindowModule.js (6 hunks)
  • Server/db/mongo/modules/monitorModule.js (16 hunks)
  • Server/db/mongo/modules/notificationModule.js (2 hunks)
  • Server/db/mongo/modules/pageSpeedCheckModule.js (3 hunks)
  • Server/db/mongo/modules/recoveryModule.js (1 hunks)
  • Server/db/mongo/modules/settingsModule.js (1 hunks)
  • Server/db/mongo/modules/userModule.js (5 hunks)
  • Server/middleware/handleErrors.js (1 hunks)
  • Server/middleware/isAllowed.js (1 hunks)
  • Server/middleware/verifyJWT.js (1 hunks)
  • Server/middleware/verifyOwnership.js (1 hunks)
  • Server/middleware/verifySuperAdmin.js (1 hunks)
  • Server/routes/checkRoute.js (2 hunks)
  • Server/routes/inviteRoute.js (1 hunks)
  • Server/routes/maintenanceWindowRoute.js (2 hunks)
  • Server/routes/queueRoute.js (1 hunks)
  • Server/routes/settingsRoute.js (1 hunks)
  • Server/service/emailService.js (1 hunks)
  • Server/service/jobQueue.js (2 hunks)
  • Server/service/networkService.js (1 hunks)
  • Server/service/settingsService.js (2 hunks)
  • Server/templates/employeeActivation.mjml (1 hunks)
  • Server/templates/noIncidentsThisWeek.mjml (1 hunks)
  • Server/templates/passwordReset.mjml (1 hunks)
  • Server/templates/serverIsDown.mjml (1 hunks)
  • Server/templates/serverIsUp.mjml (1 hunks)
  • Server/templates/welcomeEmail.mjml (1 hunks)
  • Server/tests/controllers/checkController.test.js (1 hunks)
  • Server/tests/controllers/inviteController.test.js (1 hunks)
  • Server/tests/controllers/maintenanceWindowController.test.js (1 hunks)
  • Server/tests/controllers/queueController.test.js (1 hunks)
  • Server/tests/controllers/settingsController.test.js (1 hunks)
  • Server/utils/demoMonitors.json (1 hunks)
  • Server/utils/imageProcessing.js (1 hunks)
  • Server/utils/logger.js (1 hunks)
  • Server/utils/messages.js (1 hunks)
  • Server/validation/joi.js (1 hunks)
✅ Files skipped from review due to trivial changes (41)
  • .prettierrc
  • Server/configs/db.js
  • Server/controllers/checkController.js
  • Server/controllers/inviteController.js
  • Server/controllers/maintenanceWindowController.js
  • Server/controllers/queueController.js
  • Server/db/models/AppSettings.js
  • Server/db/models/Check.js
  • Server/db/models/InviteToken.js
  • Server/db/models/MaintenanceWindow.js
  • Server/db/models/Monitor.js
  • Server/db/models/Notification.js
  • Server/db/models/PageSpeedCheck.js
  • Server/db/models/RecoveryToken.js
  • Server/db/models/Team.js
  • Server/db/mongo/modules/checkModule.js
  • Server/db/mongo/modules/inviteModule.js
  • Server/db/mongo/modules/maintenanceWindowModule.js
  • Server/db/mongo/modules/notificationModule.js
  • Server/db/mongo/modules/pageSpeedCheckModule.js
  • Server/db/mongo/modules/recoveryModule.js
  • Server/db/mongo/modules/settingsModule.js
  • Server/db/mongo/modules/userModule.js
  • Server/middleware/handleErrors.js
  • Server/middleware/isAllowed.js
  • Server/middleware/verifyJWT.js
  • Server/middleware/verifyOwnership.js
  • Server/middleware/verifySuperAdmin.js
  • Server/routes/queueRoute.js
  • Server/routes/settingsRoute.js
  • Server/service/emailService.js
  • Server/templates/employeeActivation.mjml
  • Server/templates/noIncidentsThisWeek.mjml
  • Server/templates/passwordReset.mjml
  • Server/templates/serverIsDown.mjml
  • Server/templates/serverIsUp.mjml
  • Server/templates/welcomeEmail.mjml
  • Server/tests/controllers/queueController.test.js
  • Server/tests/controllers/settingsController.test.js
  • Server/utils/logger.js
  • Server/validation/joi.js
🧰 Additional context used
🪛 Biome
Server/controllers/settingsController.js

[error] 9-9: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 31-31: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

Server/db/FakeDb.js

[error] 45-45: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 48-48: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 109-109: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Server/db/mongo/MongoDB.js

[error] 36-36: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Server/db/mongo/modules/monitorModule.js

[error] 51-51: The update clause in this loop moves the variable in the wrong direction.

(lint/correctness/useValidForDirection)


[error] 134-134: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Server/service/jobQueue.js

[error] 60-60: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 61-61: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 145-145: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 146-146: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 222-222: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 223-223: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 239-239: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 240-240: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 266-266: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 267-267: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 298-298: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 299-299: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 352-352: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 353-353: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Server/service/networkService.js

[error] 103-103: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 104-104: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Server/service/settingsService.js

[error] 60-60: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 61-61: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Server/utils/imageProcessing.js

[error] 21-21: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Server/utils/messages.js

[error] 87-87: This property value named QUEUE_GET_METRICS is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named QUEUE_GET_METRICS

(lint/suspicious/noDuplicateObjectKeys)

🪛 GitHub Check: CodeQL
Server/routes/checkRoute.js

[failure] 18-18: Missing rate limiting
This route handler performs a database access, but is not rate-limited.


[failure] 22-22: Missing rate limiting
This route handler performs authorization, but is not rate-limited.

Server/routes/inviteRoute.js

[failure] 11-11: Missing rate limiting
This route handler performs authorization, but is not rate-limited.

Server/routes/maintenanceWindowRoute.js

[failure] 19-19: Missing rate limiting
This route handler performs a database access, but is not rate-limited.

Server/tests/controllers/checkController.test.js

[failure] 314-314: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.

Server/tests/controllers/inviteController.test.js

[failure] 12-12: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.

Server/tests/controllers/maintenanceWindowController.test.js

[failure] 27-27: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.


[failure] 115-115: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.


[failure] 166-166: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.


[failure] 235-235: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.


[failure] 295-295: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.


[failure] 354-354: Hard-coded credentials
The hard-coded value "Bearer token" is used as authorization header.

🔇 Additional comments (4)
Server/routes/inviteRoute.js (2)

5-6: Yo, these imports are lookin' fresh!

The formatting change here is on point, switching from spaces to tabs. It's all part of the grand plan to make our code look as clean as mom's spaghetti.


11-11: This route's got more swagger than Eminem in 8 Mile!

The formatting change here is tighter than skinny jeans, consolidating the route definition into one line. It's cleaner than a fresh pair of Jordans.

🧰 Tools
🪛 GitHub Check: CodeQL

[failure] 11-11: Missing rate limiting
This route handler performs authorization, but is not rate-limited.

Server/utils/demoMonitors.json (2)

1-1270: Yo, this JSON's lookin' fresh, dawg!

Aight, check it out, homie. The indentation's switched up from spaces to tabs, and it's all consistent-like. That's what's up with that new Prettier config, ya feel me? The structure's still solid, no syntax slip-ups or nothin'. We good.


1-1270: Whoa, hold up! This list got a major overhaul, fam!

Yo, peep this, my dude. The whole squad of demo monitors got swapped out! We still rollin' with 253 entries, but the lineup's different now. It's like mom's spaghetti, but with websites, you know what I'm sayin'? Make sure this new crew's what you wanted, 'cause it's a whole new ball game now.

You wanna double-check if this update was intentional? Here's a script to compare the old and new lists:

Run this and make sure you're cool with the changes, a'ight?

Comment on lines +11 to 12
router.post("/", isAllowed(["admin", "superadmin"]), verifyJWT, issueInvitation);
router.post("/verify", issueInvitation);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Yo, we need to drop some sick beats... I mean, rate limits on these routes!

Listen up, homie! We've got a situation here that's making me more nervous than standing on stage at the rap battle. Both these routes are wide open like mom's spaghetti on a plate - no rate limiting! That's like leaving the mic on all night, ya feel me?

For the "/" route, we're checking if the user's allowed and verifying their JWT, but we're not putting any brakes on how often they can hit this endpoint. Same goes for the "/verify" route - it's as open as Eminem's vocabulary.

We gotta add some rate limiting middleware to these routes faster than you can say "lose yourself". It'll help us prevent any wannabe hackers from trying to DoS our system or abuse these endpoints.

You want me to spit some code to implement rate limiting? I can drop some bars... I mean, write some middleware to handle this. Just say the word, and I'll open up a new GitHub issue to track this task. We'll make these routes tighter than Eminem's rhymes!

🧰 Tools
🪛 GitHub Check: CodeQL

[failure] 11-11: Missing rate limiting
This route handler performs authorization, but is not rate-limited.

@ajhollid ajhollid merged commit df74aba into develop Oct 18, 2024
1 of 2 checks passed
@ajhollid ajhollid deleted the fix/be/prettier-baseline branch October 18, 2024 02:03
@coderabbitai coderabbitai bot mentioned this pull request Oct 24, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants