tobyink / p5-type-tiny

Perl 5 distribution Type-Tiny; see homepage for downloads and documentation.
https://typetiny.toby.ink/
54 stars 48 forks source link

Possible regression caused in Crypt::HSXKPasswd by Type::Tiny 2.000001 #127

Closed perlpunk closed 1 year ago

perlpunk commented 1 year ago

I'm not sure if this is a regression in Type::Tiny or a mistake in Crypt::HSXKPasswd

https://rt.cpan.org/Public/Bug/Display.html?id=144672

There are currently two reproducers for two similar, probably related bugs:

perl -T -I/tmp/p5-type-tiny/lib -Ilib -e 'use Crypt::HSXKPasswd; Crypt::HSXKPasswd->new(dictionary_list => [qw(seme tes words)])'
Alternative signatures must be CODE, HASH, or ARRAY refs at /tmp/p5-type-tiny/lib/Type/Params/Signature.pm line 26.
[   30s] 
[   30s] #   Failed test 'password generation with named argument 'dictionary_list''
[   30s] #   at t/02-generate-passwords.t line 28.
[   30s] 
[   30s] #   Failed test 'password generation with named argument 'dictionary_file''
[   30s] #   at t/02-generate-passwords.t line 35.
[   30s] 
[   30s] #   Failed test 'password generation with named arguments 'dictionary_file' & 'dictionary_file_encoding''
[   30s] #   at t/02-generate-passwords.t line 41.
[   30s] # Looks like you failed 3 tests of 10.
[   30s] t/02-generate-passwords.t .. 
[   30s] Dubious, test returned 3 (wstat 768, 0x300)
[   30s] Failed 3/10 subtests 

If I output $@ I get:

    ERROR - Crypt::HSXKPasswd::hsxkpasswd(): Failed to generate password with the following error: Can't use an undefined value as a subroutine reference at /tmp/Crypt-HSXKPasswd-v3.6/blib/lib/Crypt/HSXKPasswd/Dictionary/Basic.pm line 221

Maybe the code in Crypt::HSXKPasswd is using it in the wrong way, but it would be nice if you could have a quick look.

I can also reproduce it with the latest developer version.

edit: fix code markers

tobyink commented 1 year ago

Interesting. A quick look seems to suggest the module is calling multisig correctly, so the bug is probably in Type::Tiny (or more specifically, in Type::Params::Alternatives).

tobyink commented 1 year ago

It's calling multisig incorrectly. I'll add details to the Crypt::HSXKPasswd ticket.

perlpunk commented 1 year ago

Thanks!