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

A bunch of questions and feature suggestions :-) #143

Open
yonjah opened this issue Sep 3, 2018 · 3 comments
Open

A bunch of questions and feature suggestions :-) #143

yonjah opened this issue Sep 3, 2018 · 3 comments
Assignees
Labels

Comments

@yonjah
Copy link

yonjah commented Sep 3, 2018

Hi I just started using Felicity for automatically Fuzz test my hapi routes and overall It's working great.
Initially I couldn't get it to work as is and I had to add some minor hacks to get it to work ( I think mostly because I use Joi 13.x and felicity is using Joi 11.x).

So I have a few suggestions / questions trying to figure out if I'm using it wrong or can implementation improve.

  1. When generating an example, I noticed the description that is derived from the schema is later used to recreate parts of the schema. I wonder why is it needed and if it's not possible to use the original schema.
  2. Is it possible to have an option to include a custom Joi instance with extension ?
    I saw a feature request regarding extensions and in my own trials I replaced Joi with a custom instance and it worked well (but it had very simple extensions)
  3. It would be great if there was an option to override the actual example generation for some specific types like all plain strings, or emails etc. like passing a function that gets a description and returns the value to be used in the example.
@WesTyler
Copy link
Member

WesTyler commented Sep 4, 2018

Hey there! So glad you've got it working, and thanks for checking it out and giving feedback! All feedback is greatly appreciated.

Regarding your startup woes, yeah I need to bump my dependency versions. In the next couple of days I will publish a v3 major update to bring everything current. Going to do it as a major so that I can bring in significant breaking changes in Joi and also drop support for Node 4 since it is well outside of maintenance.

For your specific questions:

  1. Yeah, I don't love it either. However, the output of schema.describe() is stable and safe to rely on, while internals are not. So unfortunately it is ultimately safer for me to continue to use the describe output for flags and options since those should only break in major version of Joi, while Joi _internals can break at any time in a patch.
  2. Hopefully! Felicity absolutely works with extended Joi, but handling how to generate examples with extension methods is super hairy. The next question actually drives this one as well.
  3. I agree wholeheartedly! Since the vast majority of the functionality of Felicity is flowing through Joi code, it has been difficult for me to find a clean way to pass functions like this from the schema, through Joi, and into Felicity. That's why I'm still stuck on the subject of extensions. If you have an idea and want to try it out, I am absolutely open to suggestions!

Thanks again for taking the time to open this up! Conversations like this are the best way for the usability and power of Felicity to improve! Let me know if you have any followup questions, or if I didn't address something sufficiently :D

@WesTyler WesTyler self-assigned this Sep 4, 2018
@yonjah
Copy link
Author

yonjah commented Sep 5, 2018

HI @WesTyler Thank you for your answers.

With the fist point I was actually meaning the opposite. Using schema.describe() seems like the right way to go, But after getting the description the schema is regenerated again from the description (using helpers.descriptionCompiler ) It seem like most issues I was having were since the recompilation steps failed so I was wondering why it is necessary at all.

I see you just published v3 to npm I'll check it out. Thanks!

@yonjah
Copy link
Author

yonjah commented Oct 8, 2018

@WesTyler I tried to have a go at implementing my own generator just following the description provided from Joi it seem like most of it is working OK but there are a few edge cases where the description is just not good enough to deduce a valid example.

With regards to overriding generated values I allow passing a method that will replace the generated values depending on the value that the library generated and the actual description.

This is not only useful for the override but also for custom Joi versions. the replace function can inspect the description and if it's of a custom property replace it with a valid one.

It is still a major WIP and I was kinda hacking Joi tests to get it to work so the design is not that great.
But if you think any of this makes sense to be added into felicity context feel free to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants