Skip to content

Conversation

jjanuszkiewicz
Copy link
Contributor

Hash comparison should ignore end-of-line variations, but it fails in one scenario:

  • when the original hash was calculated by an older RH version, which didn't normalize the script to LF line endings before hashing
  • and the original script had CRLF line endings
  • and the same file, but with LF line endings, is executed by the migrator.

This PR refactors hash generation and comparison into a separate class, adds unit tests that demonstrate the bug and fixes it.

This is a preparation for adding unit tests for hash comparison logic.
Use just one copy of line ending variations list for all hash comparisons.
Hash comparison should ignore end-of-line variations, but it fails in one scenario:
 - when the original hash was calculated by an older RH version, which didn't normalize the script to LF line endings before hashing
 - and the original script had CRLF line endings
 - and the same file, but with LF line endings, is executed by the migrator.

This commit adds unit tests which excercise all possible EOL combinations to demonstrate the bug.
Fix incorrectly detected script changes in one scenario.
@erikbra
Copy link
Member

erikbra commented Oct 13, 2019

@jjanuszkiewicz Nice separation of the hash algorithm into a separate class and interface. And good catch. Thank you very much for your contribution! :)

@erikbra erikbra merged commit 3835cdb into chucknorris:master Oct 13, 2019
@erikbra erikbra added this to the 1.2.0 milestone Oct 13, 2019
@jjanuszkiewicz jjanuszkiewicz deleted the hash_eol_variations_bug branch October 14, 2019 07:14
@jjanuszkiewicz
Copy link
Contributor Author

@erikbra Thanks for merging this :-) Any idea when 1.2.0 will be released? My team is waiting for this fix, as we've actually been hit by this problem in practice. I'd rather not build our own temporary clone of RH if I can avoid it.

@erikbra
Copy link
Member

erikbra commented Oct 14, 2019

The plan is to get it out by the end of the month. I have two more features I would like to include (open PRs), if possible. https://github.com/chucknorris/roundhouse/milestone/10

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

Successfully merging this pull request may close these issues.

2 participants