-
Notifications
You must be signed in to change notification settings - Fork 213
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
Custom JavaScript validation for HTTP(s) JSON responses #1573
Comments
Hey @gorkem-bwl I would love to take up this issue |
Sure. Could you please arrange a time with me here to discuss on the details of this issue? It's a big one so I wanted to make sure we're on the same page. https://tidycal.com/bluewavelabs/general You can have some sort of research (eg what to code/how to design the UI), so we can deep dive about talking about the implementation. Feel free to check other similar products. |
Wanted to check back here @jasneetsingh6114 |
May I take up this if it's still open? About the main challenges: Ensuring the security of executing user-provided JavaScript code. I think maybe we can use isolated-vm? |
@YinDongFang sure, go ahead! Can you please write a list of todos on the frontend and backend? Don't think about the frontend for now - when you are done with your analysis, I'll prepare a design for you so you can use it. |
DB schema
Server side
Client side
This is my basic idea. Please let me know if I missed anything. |
Looks good so far. 3 questions that popped up on my mind:
For 2 I think we can always do that after we are done with the basics, but just wanted to write here to discuss. |
|
|
Hey @gorkem-bwl, I apologize for the delay in getting back to you—I've been caught up with some college commitments. Regarding our previous discussion, I scheduled a meeting for tomorrow, January 24th, 2025, on the very same day you mentioned that we should arrange one. However, since the issue has already been assigned to someone else, please let me know if I should cancel tomorrow’s meeting. Thanks for your understanding! |
@jasneetsingh6114 yes, let's cancel for now. You may want to check around for more issues - I'm pretty sure you can grab one. Please be on the lookout, join our Discord channel (link is in the readme.md file of the project) and do not hesitate to DM me and say hi :) It was my bad that I didn't realize it was you. There are several meetings on and off. Sorry that I didn't catch it earlier. It's me, not you. |
@gorkem-bwl @ajhollid Because of security problem of executing user code, I adopted an alternative approach to implement JSON validation. I referenced Uptime Kuma and Uptime, import About jmespath: https://jmespath.org/tutorial.html |
Some services require more complex checks of the response than a simple KEYWORD or REGEX to perform the validation "Status UP" or "Status DOWN". To accommodate this, it would be highly beneficial to allow custom JavaScript code to be executed against a parsed JSON object from an HTTP(s) response.
The parsed JSON object could be accessible from the custom JavaScript code as a variable named
msg
.The custom JavaScript code would be required to return:
true
orfalse
for binary validation results.Solution
Create a new monitor type: "HTTP(s) JSON Custom Function", derived from the existing "HTTP(s) - Keyword" monitor type.
In the UI:
Example usage
The HTTP(s) response body is parsed into a JSON object.
The JSON object is passed to the custom JavaScript function, accessible as
msg
.Example:
The result (
true
,false
, or an array) determines the status of the monitor.This allows users to implement advanced validation logic that cannot be expressed using simple keywords or regular expressions, and increases flexibility and use cases for the monitoring tool.
Potential Challenges
Additional Notes
The text was updated successfully, but these errors were encountered: