-
Notifications
You must be signed in to change notification settings - Fork 158
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
Check for authentication obj before delete operation #1415 (#1416) #1417
Conversation
WalkthroughThe recent updates involve enhancing the Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range and nitpick comments (6)
server/utils/common.ts (3)
Line range hint
82-82
: Consider using optional chaining to safely access nested properties and avoid runtime errors.- config.nodes?.map((node) => this.removeAuthSecureData(node)); + config.nodes?.forEach((node) => this.removeAuthSecureData(node)); - if (req.session.selectedNode && req.session.selectedNode.authentication.options) { - req.session.selectedNode.authentication.options.method = ... - } + req.session.selectedNode?.authentication?.options?.method = ...Also applies to: 136-136, 157-157, 207-207
Tools
Biome
[error] 51-51: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 52-52: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 53-53: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 54-54: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 55-55: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
Line range hint
201-203
: Consider removing unnecessaryelse
clauses to simplify the code and improve readability.- if (condition) { - // code - } else { - // code - } + if (condition) { - // code - } + // codeAlso applies to: 318-324, 321-323
Tools
Biome
[error] 51-51: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 52-52: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 53-53: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 54-54: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 55-55: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
Line range hint
27-27
: Remove the unnecessary constructor to clean up the code.- constructor() {}
Tools
Biome
[error] 51-51: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 52-52: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 53-53: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 54-54: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 55-55: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
backend/utils/common.js (3)
Line range hint
53-57
: Consider setting properties toundefined
instead of usingdelete
for better performance.- delete config.rtlConfFilePath; - delete config.rtlPass; - delete config.multiPass; - delete config.multiPassHashed; - delete config.secret2FA; + config.rtlConfFilePath = undefined; + config.rtlPass = undefined; + config.multiPass = undefined; + config.multiPassHashed = undefined; + config.secret2FA = undefined;Tools
Biome
[error] 44-44: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 45-45: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 46-46: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 47-47: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 48-48: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
Line range hint
73-73
: Use optional chaining to safely access deeply nested properties.- config.nodes?.map((node) => this.removeAuthSecureData(node)); + config.nodes?.forEach((node) => this.removeAuthSecureData(node)); - if (req.session.selectedNode.authentication.swapMacaroonPath) { + if (req.session.selectedNode?.authentication?.swapMacaroonPath) { - if (req.session.selectedNode.authentication.boltzMacaroonPath) { + if (req.session.selectedNode?.authentication?.boltzMacaroonPath) { - if (req.session.selectedNode && req.session.selectedNode.lnImplementation) { + if (req.session.selectedNode?.lnImplementation) { - if (this.nodes[0].authentication.options && this.nodes[0].authentication.options.headers) { + if (this.nodes[0]?.authentication?.options?.headers) {Also applies to: 126-126, 146-146, 195-195, 314-314
Tools
Biome
[error] 44-44: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 45-45: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 46-46: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 47-47: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 48-48: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
Line range hint
190-192
: Remove unnecessaryelse
clauses to simplify control flow and enhance readability.- else { - throw new Error(err); - } + throw new Error(err); - else { - this.logger.log({ selectedNode: this.selectedNode, level: 'ERROR', fileName: 'Common', msg: 'Common Set Options Error', error: err }); - node.authentication.options = { - url: '', - rejectUnauthorized: false, - json: true, - form: '' - }; - } + this.logger.log({ selectedNode: this.selectedNode, level: 'ERROR', fileName: 'Common', msg: 'Common Set Options Error', error: err }); + node.authentication.options = { + url: '', + rejectUnauthorized: false, + json: true, + form: '' + };Also applies to: 298-305, 302-304
Tools
Biome
[error] 44-44: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 45-45: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 46-46: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 47-47: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 48-48: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- backend/utils/common.js (1 hunks)
- server/utils/common.ts (1 hunks)
Additional context used
Biome
server/utils/common.ts
[error] 27-27: This constructor is unnecessary. (lint/complexity/noUselessConstructor)
Unsafe fix: Remove the unnecessary constructor.
[error] 51-51: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 52-52: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 53-53: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 54-54: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 55-55: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 61-61: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 62-62: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 63-63: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 64-64: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 65-65: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 82-82: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 136-136: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 138-138: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 139-139: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 157-157: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 201-203: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 207-207: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 318-324: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 321-323: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
backend/utils/common.js
[error] 44-44: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 45-45: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 46-46: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 47-47: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 48-48: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 53-53: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 54-54: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 55-55: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 56-56: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 57-57: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 73-73: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 126-126: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 128-128: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 129-129: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 146-146: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 190-192: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 195-195: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
[error] 298-305: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 302-304: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)
Unsafe fix: Omit the else clause.
[error] 314-314: Change to an optional chain. (lint/complexity/useOptionalChain)
Unsafe fix: Change to an optional chain.
Additional comments not posted (1)
server/utils/common.ts (1)
50-56
: Ensure the conditional check is robust and handles potential null values effectively.Tools
Biome
[error] 51-51: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 52-52: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 53-53: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 54-54: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 55-55: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
delete node.authentication.macaroonPath; | ||
delete node.authentication.runePath; | ||
delete node.authentication.runeValue; | ||
delete node.authentication.lnApiPassword; | ||
delete node.authentication.options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replacing the delete
operator with setting properties to undefined
to enhance performance.
- delete node.authentication.macaroonPath;
- delete node.authentication.runePath;
- delete node.authentication.runeValue;
- delete node.authentication.lnApiPassword;
- delete node.authentication.options;
+ node.authentication.macaroonPath = undefined;
+ node.authentication.runePath = undefined;
+ node.authentication.runeValue = undefined;
+ node.authentication.lnApiPassword = undefined;
+ node.authentication.options = undefined;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
delete node.authentication.macaroonPath; | |
delete node.authentication.runePath; | |
delete node.authentication.runeValue; | |
delete node.authentication.lnApiPassword; | |
delete node.authentication.options; | |
node.authentication.macaroonPath = undefined; | |
node.authentication.runePath = undefined; | |
node.authentication.runeValue = undefined; | |
node.authentication.lnApiPassword = undefined; | |
node.authentication.options = undefined; |
Tools
Biome
[error] 51-51: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 52-52: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 53-53: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 54-54: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 55-55: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
if (node.authentication) { | ||
delete node.authentication.macaroonPath; | ||
delete node.authentication.runePath; | ||
delete node.authentication.runeValue; | ||
delete node.authentication.lnApiPassword; | ||
delete node.authentication.options; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the existence of node.authentication
before deleting properties to prevent runtime errors.
While the logic is correct, consider replacing delete
with setting properties to undefined
for performance improvements, as suggested by static analysis.
- delete node.authentication.macaroonPath;
- delete node.authentication.runePath;
- delete node.authentication.runeValue;
- delete node.authentication.lnApiPassword;
- delete node.authentication.options;
+ node.authentication.macaroonPath = undefined;
+ node.authentication.runePath = undefined;
+ node.authentication.runeValue = undefined;
+ node.authentication.lnApiPassword = undefined;
+ node.authentication.options = undefined;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (node.authentication) { | |
delete node.authentication.macaroonPath; | |
delete node.authentication.runePath; | |
delete node.authentication.runeValue; | |
delete node.authentication.lnApiPassword; | |
delete node.authentication.options; | |
} | |
if (node.authentication) { | |
node.authentication.macaroonPath = undefined; | |
node.authentication.runePath = undefined; | |
node.authentication.runeValue = undefined; | |
node.authentication.lnApiPassword = undefined; | |
node.authentication.options = undefined; | |
} |
Tools
Biome
[error] 44-44: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 45-45: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 46-46: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 47-47: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 48-48: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
Summary by CodeRabbit
removeAuthSecureData
method to ensure properties are only deleted ifnode.authentication
exists.