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

Template: Enumerator::ArithmeticSequence support for length #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

noraj
Copy link
Contributor

@noraj noraj commented Sep 11, 2023

This example is on the documentation but currently doesn't work

https://github.com/noraj/ronin-fuzzer/blob/e398afb5020eb37c6b94db1b1e1b5ff2a8921a07/lib/ronin/fuzzing/core_ext/string.rb#L81-L84

irb(main):067:1* String.generate(['/AA', (1..100).step(5)]) do |path|
irb(main):068:1*   puts path
irb(main):069:0> end
/home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/ronin-fuzzer-0.1.0/lib/ronin/fuzzing/template.rb:86:in `block in initialize': length must be an Integer, Range or Array (TypeError)

            raise(TypeError,"length must be an Integer, Range or Array")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/ronin-fuzzer-0.1.0/lib/ronin/fuzzing/template.rb:54:in `each'
        from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/ronin-fuzzer-0.1.0/lib/ronin/fuzzing/template.rb:54:in `initialize'
        from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/ronin-fuzzer-0.1.0/lib/ronin/fuzzing/core_ext/string.rb:89:in `new'
        from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/ronin-fuzzer-0.1.0/lib/ronin/fuzzing/core_ext/string.rb:89:in `generate'
        from (irb):67:in `<main>'
        from /home/noraj/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
        from /home/noraj/.asdf/installs/ruby/3.2.2/bin/irb:25:in `load'
        from /home/noraj/.asdf/installs/ruby/3.2.2/bin/irb:25:in `<main>'
irb(main):070:0> (1..100).step(5).class
=> Enumerator::ArithmeticSequence
irb(main):071:0> (1..100).class
=> Range

@noraj
Copy link
Contributor Author

noraj commented Sep 11, 2023

Maybe this fix should not be only for Enumerator::ArithmeticSequence but to more generic enumerators. However, I'm not sure of the consequences of a broader change.

@postmodern
Copy link
Member

We could also support Enumerable. It appears that Ronin::Fuzzing::Repeater#initialize accepts an Enumerable lengths value.

Also, this definitely needs a test.

@postmodern postmodern added bug Something isn't working documentation Improvements or additions to documentation labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants