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

234 - Set default values on Server Settings if color is not set #235

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
3 changes: 2 additions & 1 deletion rair-front/src/components/ServerSettings/colorSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ const ColorSettings = () => {
darkModeText: '#FFF',
buttonPrimaryColor: royalPurple,
buttonFadeColor: bubblegum,
buttonSecondaryColor: arcticBlue
buttonSecondaryColor: arcticBlue,
iconColor: bubblegum
});
}}>
Reset colors
Expand Down
2 changes: 1 addition & 1 deletion rair-front/src/redux/colorSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import { ServerSettings } from '../types/databaseTypes';

const buttons: ButtonInfo = {
primaryButtonColor: `linear-gradient(to right, ${royalPurple}, ${bubblegum})`,
secondaryButtonColor: `linear-gradient(to right, ${arcticBlue}, ${royalPurple})`
secondaryButtonColor: `linear-gradient(to right, ${bubblegum}, ${royalPurple})`
};

const colorThemes: ColorLibrary = {
Expand Down
3 changes: 2 additions & 1 deletion rair-node/bin/api/transactions/transactions.Controller.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const { Router } = require('express');
const { requireUserSession } = require('../../middleware');
const { processUserTransaction } = require('./transactions.Service');

const router = Router();

router.post(
'/:network/:hash',
requireUserSession,
processUserTransaction
processUserTransaction,

Check failure

Code scanning / CodeQL

Missing rate limiting High

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

Copilot Autofix AI 2 months ago

To fix the problem, we need to introduce rate limiting to the route handler to prevent abuse. The express-rate-limit package is a well-known library for this purpose. We will:

  1. Install the express-rate-limit package.
  2. Set up a rate limiter with appropriate configuration.
  3. Apply the rate limiter to the specific route that handles user transactions.
Suggested changeset 2
rair-node/bin/api/transactions/transactions.Controller.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/rair-node/bin/api/transactions/transactions.Controller.js b/rair-node/bin/api/transactions/transactions.Controller.js
--- a/rair-node/bin/api/transactions/transactions.Controller.js
+++ b/rair-node/bin/api/transactions/transactions.Controller.js
@@ -3,2 +3,3 @@
 const { processUserTransaction } = require('./transactions.Service');
+const RateLimit = require('express-rate-limit');
 
@@ -6,4 +7,11 @@
 
+// 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(
     '/:network/:hash',
+    limiter,
     requireUserSession,
EOF
@@ -3,2 +3,3 @@
const { processUserTransaction } = require('./transactions.Service');
const RateLimit = require('express-rate-limit');

@@ -6,4 +7,11 @@

// 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(
'/:network/:hash',
limiter,
requireUserSession,
rair-node/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/rair-node/package.json b/rair-node/package.json
--- a/rair-node/package.json
+++ b/rair-node/package.json
@@ -74,3 +74,4 @@
     "winston-transport": "^4.6.0",
-    "yoti": "^4.6.0"
+    "yoti": "^4.6.0",
+    "express-rate-limit": "^7.4.0"
   },
EOF
@@ -74,3 +74,4 @@
"winston-transport": "^4.6.0",
"yoti": "^4.6.0"
"yoti": "^4.6.0",
"express-rate-limit": "^7.4.0"
},
This fix introduces these dependencies
Package Version Security advisories
express-rate-limit (npm) 7.4.0 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
);

module.exports = router;
14 changes: 7 additions & 7 deletions rair-node/bin/models/serverSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ const ServerSetting = new Schema({
superAdminsOnVault: { type: Boolean, default: false },
databaseResales: { type: Boolean, default: false },
// Dark mode colors
darkModePrimary: { type: String, required: false },
darkModeSecondary: { type: String, required: false },
darkModeText: { type: String, required: false },
darkModePrimary: { type: String, required: true, default: '#222021' },
darkModeSecondary: { type: String, required: true, default: '#dedede' },
darkModeText: { type: String, required: true, default: 'white' },
// Logo images
darkModeBannerLogo: { type: String, required: false },
darkModeMobileLogo: { type: String, required: false },
// Mobile logo images
lightModeBannerLogo: { type: String, required: false },
lightModeMobileLogo: { type: String, required: false },
// Button
buttonPrimaryColor: { type: String, required: false },
buttonFadeColor: { type: String, required: false },
buttonSecondaryColor: { type: String, required: false },
buttonPrimaryColor: { type: String, required: true, default: '#725bdb' },
buttonFadeColor: { type: String, required: true, default: '#e882d5' },
buttonSecondaryColor: { type: String, required: true, default: '#19a7f6' },
// Icon color
iconColor: { type: String, required: false },
iconColor: { type: String, required: true, default: '#e882d5' },
// Custom footer
footerLinks: {
type: [{
Expand Down
Loading