-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: ignore secure config #34
Conversation
4a8e85c
to
960646d
Compare
lib/error_view.js
Outdated
@@ -294,7 +294,7 @@ class ErrorView { | |||
serializeAppInfo() { | |||
return { | |||
baseDir: this.app.config.baseDir, | |||
config: util.inspect(this.app.config), | |||
config: util.inspect(this.app.dumpConfigToObject().config.config), |
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.
这里生成的结构�所有版本都支持吗
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.
什么版本?
ci 挂了 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #34 +/- ##
==========================================
- Coverage 98.12% 98.08% -0.04%
==========================================
Files 5 5
Lines 480 470 -10
Branches 88 86 -2
==========================================
- Hits 471 461 -10
Misses 9 9 ☔ View full report in Codecov by Sentry. |
WalkthroughThe changes involve modifications to the Changes
Possibly related PRs
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
[skip ci] ## [2.4.0](v2.3.1...v2.4.0) (2024-10-13) ### Features * ignore secure config ([#34](#34)) ([bf61d5e](bf61d5e))
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: 1
🧹 Outside diff range and nitpick comments (1)
test/onerror.test.js (1)
197-205
: Improve test description for clarityThe new test case is a good addition and aligns with the PR objective of ignoring secure config. However, the test description could be more specific about what it's actually testing.
Consider updating the test description to be more explicit about what's being tested. For example:
- it('should ignore secure config on html response', () => { + it('should mask secure config keys in HTML response for 400 status', () => {This change would make it clearer that the test is specifically checking for the masking of secure configuration keys in the HTML response when a 400 status is returned.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- lib/error_view.js (1 hunks)
- test/onerror.test.js (2 hunks)
🧰 Additional context used
🔇 Additional comments (4)
lib/error_view.js (2)
Line range hint
1-274
: Summary of changes and recommendationsThe changes to the
serializeAppInfo
method in theErrorView
class introduce more flexibility in retrieving the app configuration. While this is a positive improvement, there are a few points to consider:
- Verify the nested
config.config
access and adjust if necessary.- Implement error handling in the configuration retrieval process.
- Assess the impact of these changes on the generated error page content.
- Add or update test cases to cover the new configuration retrieval logic.
Overall, the changes appear to be beneficial, but careful testing and verification are recommended to ensure they don't introduce any unintended side effects.
265-271
: Consider the impact on error page content and add a test case.The changes in the
serializeAppInfo
method may affect the content of the generated error page. To ensure that the new configuration retrieval logic doesn't introduce any unexpected behavior:
- Verify that the error page still displays all necessary configuration information correctly.
- Add a test case that covers both scenarios: when
dumpConfigToObject
is available and when it's not.To assist in verifying the impact, you can run the following script:
This script will help identify existing test cases and areas where new tests might be needed to cover the recent changes.
test/onerror.test.js (2)
300-301
: Improved test assertion for better specificityThe modification to the existing test case enhances its reliability and clarity. By replacing the regex test with a more specific match assertion, the test now provides a more precise check for the expected log content.
This change aligns with best practices for writing robust and maintainable tests. It improves the test's ability to catch potential issues without altering its core functionality.
Line range hint
197-301
: Summary of changesThe modifications in this file enhance the test suite by:
- Adding a new test case to verify the handling of secure configuration in error responses.
- Improving an existing test case with a more specific assertion.
These changes align well with the PR objectives and contribute to a more robust error handling test suite.
let config = this.app.config; | ||
if (typeof this.app.dumpConfigToObject === 'function') { | ||
config = this.app.dumpConfigToObject().config.config; | ||
} | ||
return { | ||
baseDir: this.app.config.baseDir, | ||
config: util.inspect(this.app.config), | ||
config: util.inspect(config), |
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.
🛠️ Refactor suggestion
Verify the configuration retrieval logic and consider error handling.
The changes to the serializeAppInfo
method introduce a new way of retrieving the app configuration, which is good for flexibility. However, there are a couple of points to consider:
-
The nested
config.config
access inconfig = this.app.dumpConfigToObject().config.config;
seems unusual. Is this intentional, or should it be justconfig = this.app.dumpConfigToObject().config;
? -
There's no error handling if
this.app.dumpConfigToObject()
throws an error. Consider adding a try-catch block to handle potential errors gracefully.
Here's a suggested improvement:
serializeAppInfo() {
let config;
try {
if (typeof this.app.dumpConfigToObject === 'function') {
const dumpedConfig = this.app.dumpConfigToObject();
config = dumpedConfig.config || dumpedConfig;
} else {
config = this.app.config;
}
} catch (error) {
console.error('Error retrieving app configuration:', error);
config = this.app.config;
}
return {
baseDir: this.app.config.baseDir,
config: util.inspect(config),
};
}
This suggestion adds error handling and provides a fallback in case of errors. It also allows for flexibility in the structure of the dumped config object.
Checklist
npm test
passesAffected core subsystem(s)
Description of change
Summary by CodeRabbit
New Features
Bug Fixes
Tests