core.job.id: improve create_unique_job_id()
The previous implementation was mixing non-random information with
random data before applying a hash on top of everything. Given that,
we couldn't use the hash later to validate the information and the
entropy was limited to 64 bits, which was the random part.
So I've got rid of the sha1 code and just used a 160 random number.
A future improvement would be the use a random number in the first
part of the ID (a salt) and a hash of relevant information in the
second part. In pseudo-code:
info = hostname, date, list of tests, etc
salt = str(hex(getrandbits(120)))[[2:-1]
hash = sha1(info).hexdigest()[:10]
return salt+hash
Includes a functional test to check the ID is indeed a 40 digit hex
number.
Signed-off-by: NAdemar de Souza Reis Jr <areis@redhat.com>
Showing
想要评论请 注册 或 登录