-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Original fields are making search noise #5466
Comments
@Ionys320, Sorry, I missed that you had created a new issue for this. Let's keep the conversation here regarding this bug. Can you show it in a screencast what you mean? Because what you're saying, I can't recreate. |
Okay, this is strange. When I manually add the code and use Uptime-Kuma in Dev mode, this bug doesn't occur. However, when I run the following command:
I encounter this bug. Is this the same for you, @Ionys320? |
@homelab-alpha, yes indeed, I changed my issue on purpose. This issue is related to the PR because the PR extends the used fields. There is two possibilities to fix this:
|
@Ionys320, I can now also reproduce the bug in Uptime Kuma's Dev mode. If you delete the As for the option 'Set to NULL/empty strings unused fields for a monitor at the save time (my favorite option)', I think this is a good fix. |
@Ionys320, here is a revision of the code with a regular expression that escapes special characters. I have also updated the comments. However, the bug still exists in this revision unless you remove Could you verify this for me. // Filter monitors based on the search text
// Matches monitor name, URL, hostname, DNS resolve server, or tag names and values
let searchTextMatch = true;
if (this.searchText !== "") {
try {
// Escape special characters for use in the regular expression
const escapeRegExp = (string) => {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
};
// Create a case-insensitive regex for the search text
const escapedSearchText = escapeRegExp(this.searchText);
const regex = new RegExp(escapedSearchText, "i");
// Test the regex against strings safely
const safeRegexTest = (str) => str && regex.test(str);
// Check if any relevant fields match the search text
searchTextMatch =
regex.test(monitor.name) ||
safeRegexTest(monitor.url) ||
safeRegexTest(monitor.hostname) ||
safeRegexTest(monitor.dns_resolve_server) ||
monitor.tags.some(tag => regex.test(tag.name) || safeRegexTest(tag.value));
} catch (e) {
// Log error if the regex pattern is invalid
console.error("Invalid regex pattern:", e);
searchTextMatch = false;
}
} |
Hi @homelab-alpha! Regarding ignoring Therefore, I keep my issue opened to maybe approve the clean of unused fields before saving. |
@Ionys320, It doesn't seem like a big problem to wait 0.1 seconds longer for escaping the regex expression, as this will cause fewer issues in the long run. As for ignoring |
@Ionys320, my mistake. I misread and misunderstood your message. You can apply the suggestion you made earlier to fix the bug:
|
@Ionys320, update: okay, our issue is not a real bug, but rather a misconfiguration in Uptime Kuma itself. When you add a new monitor, for example:
And then change the monitor type to:
And you save the configuration, two different URLs are stored in the database:
Now, if we search for Conclusion: It doesn't matter which monitor type you switch to, the fields you have modified are not removed. In this case, the I will be offline for the next few days due to the holidays. I wishing you and your loved ones a Merry Christmas 🎄✨🎁 |
- Added optional chaining to safely access `this.monitor.hostname`. - Introduced default URL (`https://`) assignment to `this.monitor.url`. - Ensured `hostname` is trimmed after the URL is set. Fixes [louislam#5466](louislam#5466) modified: src/pages/EditMonitor.vue
@Ionys320, if we make the following change in NOTE: I concluded that I need to do additional testing for the rest that rely on this.monitor.hostname. Fromif (this.monitor.url) {
this.monitor.url = this.monitor.url.trim();
} Toif (this.monitor?.hostname) {
this.monitor.url = "https://";
this.monitor.hostname = this.monitor.hostname.trim();
} This will resolve the issue, as shown in the video.
|
@Ionys320, I have completed my tests, and this is the correct solution in my opinion. I have checked all monitor types. And it possible to provide a default value for for My question to you now is whether you agree with this solution, and if you would be willing to test it to verify the solution? The list of v-models is incomplete, but to check which monitor types use
|
Hi @homelab-alpha, hope you have a nice Christmas! Regarding your work, would you mind doing a PR to simplify the tests? I'm not the one that will approve it anyway, but I can still test it. |
@Ionys320, Thanks for asking, I had a great Christmas. I hope it was the same for you. To be honest, I have never done a PR before, only for myself for testing, and I make enough mistakes with that already. So, if you don't mind, you can make the change yourself in From: if (this.monitor.url) {
this.monitor.url = this.monitor.url.trim();
} To: if (this.monitor?.hostname) {
this.monitor.url = "https://";
this.monitor.hostname = this.monitor.hostname.trim();
} And your PR is still in draft, so you can make the change directly in your PR. I'm sorry, I'm still learning |
@Ionys320, I created a PR with the change of docker run --rm -it -p 3000:3000 -p 3001:3001 --pull always -e 'UPTIME_KUMA_GH_REPO=homelab-alpha:feat-searchText-from-stringbase-to-regexbase' louislam/uptime-kuma:pr-test2 |
@Ionys320, it's not cool to give a thumbs down. You yourself said, I quote: "Would you mind doing a PR to simplify the tests?" As I mentioned before, I had never created a PR. I figured out how to create a proper PR, and now this isn't the intention?! What's the problem? If you wanted something different, you should have put more effort into clarifying your intentions. |
Hi @homelab-alpha! I think I'll do another issue instead of keeping this one, the problem is larger than just having noise, it's also about removing irrelevant data from the DB. |
@Ionys320, The problem lies in the "Add New Monitor" menu, as the URL is processed in various ways (such as monitor.url, monitor.hostname, monitor.grpcUrl, etc.). The solution is that the "Add New Monitor" menu needs to be completely rewritten for better compatibility. |
📑 I have found these related issues/pull requests
Not found any related issue.
🛡️ Security Policy
Description
When switching from a monitor type to another, the fields are not cleaned, meaning irrelevant fields may be used during the search process.
For example, in PR #5438, because every monitor as
1.1.1.1
as default DNS resolve server, searching for 1.1.1.1 will find all the monitors (or almost).👟 Reproduction steps
google.fr
as the URL (no need to save) ;cloudflare.com
and save it ;google.fr
in the searchbar of the monitors list.👀 Expected behavior
No monitor should be displayed.
😓 Actual Behavior
The ping monitor is displayed, because the URL still contains
google.fr
.🐻 Uptime-Kuma Version
2.0.0-beta.1 with changes of #5438 (note: this issue is only since this PR, because it extends the fields used for the search. That's why the last beta doesn't have it).
💻 Operating System and Arch
Windows 11 x64
🌐 Browser
Vivaldi 7.0.3495.27 (Stable channel) (64 bits)
🖥️ Deployment Environment
📝 Relevant log output
No response
The text was updated successfully, but these errors were encountered: