Patch for an Issue #703

This commit is contained in:
Miroslav Stampar 2014-05-27 21:41:07 +02:00
parent 8b341e86fa
commit 680ab10ca6
2 changed files with 15 additions and 9 deletions

View File

@ -917,7 +917,7 @@ def readInput(message, default=None, checkBatch=True):
return retVal return retVal
def randomRange(start=0, stop=1000): def randomRange(start=0, stop=1000, seed=None):
""" """
Returns random integer value in given range Returns random integer value in given range
@ -926,9 +926,11 @@ def randomRange(start=0, stop=1000):
423 423
""" """
return int(random.randint(start, stop)) randint = random.WichmannHill(seed).randint if seed is not None else random.randint
def randomInt(length=4): return int(randint(start, stop))
def randomInt(length=4, seed=None):
""" """
Returns random integer value with provided number of digits Returns random integer value with provided number of digits
@ -937,9 +939,11 @@ def randomInt(length=4):
874254 874254
""" """
return int("".join(random.choice(string.digits if _ != 0 else string.digits.replace('0', '')) for _ in xrange(0, length))) choice = random.WichmannHill(seed).choice if seed is not None else random.choice
def randomStr(length=4, lowercase=False, alphabet=None): return int("".join(choice(string.digits if _ != 0 else string.digits.replace('0', '')) for _ in xrange(0, length)))
def randomStr(length=4, lowercase=False, alphabet=None, seed=None):
""" """
Returns random string value with provided number of characters Returns random string value with provided number of characters
@ -948,12 +952,14 @@ def randomStr(length=4, lowercase=False, alphabet=None):
'RNvnAv' 'RNvnAv'
""" """
choice = random.WichmannHill(seed).choice if seed is not None else random.choice
if alphabet: if alphabet:
retVal = "".join(random.choice(alphabet) for _ in xrange(0, length)) retVal = "".join(choice(alphabet) for _ in xrange(0, length))
elif lowercase: elif lowercase:
retVal = "".join(random.choice(string.ascii_lowercase) for _ in xrange(0, length)) retVal = "".join(choice(string.ascii_lowercase) for _ in xrange(0, length))
else: else:
retVal = "".join(random.choice(string.ascii_letters) for _ in xrange(0, length)) retVal = "".join(choice(string.ascii_letters) for _ in xrange(0, length))
return retVal return retVal

View File

@ -83,7 +83,7 @@ def _goInference(payload, expression, charsetType=None, firstChar=None, lastChar
expression = "SELECT %s FROM (%s)" % (field, expression) expression = "SELECT %s FROM (%s)" % (field, expression)
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL): if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
expression += " AS %s" % randomStr(lowercase=True) expression += " AS %s" % randomStr(lowercase=True, seed=hash(expression))
if field and conf.hexConvert or conf.binaryFields and field in conf.binaryFields.split(','): if field and conf.hexConvert or conf.binaryFields and field in conf.binaryFields.split(','):
nulledCastedField = agent.nullAndCastField(field) nulledCastedField = agent.nullAndCastField(field)