d0c-s4vage/gramfuzz

Error with `Int` field: doesn't respect min/max

mgree opened this issue · 3 comments

mgree commented

Checklist

  • I have included the [relevant portions of the] grammar used that caused the bug
  • I have filled out the environment section

Environment

Platform

  • Windows
  • Mac
  • Linux
  • Other (please specify)

Python Version

  • Python 2.7
  • Python 3.4
  • Python 3.5
  • Python 3.6
  • Python 3.7
  • Python 3.8
  • Other (please specify)

Describe the bug

Setting min and max doesn't seem to affect the Int field's behavior. The Int.build() method only checks to see whether min/max constrain a single value rather than using it has a general set of constraints.

To Reproduce

>>> from gramfuzz.fields import Int
>>> g = Int(min = 0, max=65535)
>>> g.build()
4038
>>> g.build()
-2592

Expected Behavior

I expect no values below min or above max to be generated.

Current Workaround

I use UInt with an explicit odds setting.

Thanks for reporting this! This should be an easy one :^)

Confirmed the issue, fixing...

This was fixed in gramfuzz==1.3.2 pip install --upgrade gramfuzz (or pip3 install --upgrade gramfuzz) to get the fixes.

(venv)> pip install gramfuzz==1.3.2
...
(venv)> python
Python 3.6.8 (default, Apr  9 2019, 04:59:38) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gramfuzz.fields import Int
>>> min = 0
>>> max = 65535
>>> g = Int(min=min, max=max)
>>> list(filter(lambda x: x < min and x > max, [g.build() for x in range(100000)]))
[]