Skip to content

Commit a049d3d

Browse files
committed
Fix bcrypt salt regex checks
The two-digit header of a bcrypt salt is a strength parameter. Valid values for the strength parameter range from 4 to 31 inclusive. Update the regex used to check the salt to only match against values from 04 to 31.
1 parent 7280c6c commit a049d3d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/puppet/parser/functions/pw_hash.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
'md5' => { prefix: '1' },
4949
'sha-256' => { prefix: '5' },
5050
'sha-512' => { prefix: '6' },
51-
'bcrypt' => { prefix: '2b', salt: %r{^[0-9]{2}\$[./A-Za-z0-9]{22}} },
52-
'bcrypt-a' => { prefix: '2a', salt: %r{^[0-9]{2}\$[./A-Za-z0-9]{22}} },
53-
'bcrypt-x' => { prefix: '2x', salt: %r{^[0-9]{2}\$[./A-Za-z0-9]{22}} },
54-
'bcrypt-y' => { prefix: '2y', salt: %r{^[0-9]{2}\$[./A-Za-z0-9]{22}} },
51+
'bcrypt' => { prefix: '2b', salt: %r{^(0[4-9]|[12][0-9]|3[01])\$[./A-Za-z0-9]{22}} },
52+
'bcrypt-a' => { prefix: '2a', salt: %r{^(0[4-9]|[12][0-9]|3[01])\$[./A-Za-z0-9]{22}} },
53+
'bcrypt-x' => { prefix: '2x', salt: %r{^(0[4-9]|[12][0-9]|3[01])\$[./A-Za-z0-9]{22}} },
54+
'bcrypt-y' => { prefix: '2y', salt: %r{^(0[4-9]|[12][0-9]|3[01])\$[./A-Za-z0-9]{22}} },
5555
}
5656

5757
raise ArgumentError, 'pw_hash(): first argument must be a string' unless args[0].is_a?(String) || args[0].nil?

0 commit comments

Comments
 (0)