-
Notifications
You must be signed in to change notification settings - Fork 18
Harden module loading #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/usr/bin/perl | ||
|
|
||
| use strict; | ||
| use warnings; | ||
|
|
||
| use Test::More tests => 6; | ||
|
|
||
| use Net::OpenSSH::ModuleLoader; | ||
|
|
||
| ok(_load_module('strict'), 'loads a valid module name'); | ||
|
|
||
| eval { _load_module('strict; die "boom"') }; | ||
| like($@, qr/bad Perl module name/, 'rejects unsafe module names'); | ||
|
|
||
| eval { _load_module(undef) }; | ||
| like($@, qr/bad Perl module name/, 'rejects undefined module names without warnings'); | ||
|
|
||
| eval { _load_module('strict', 999_999) }; | ||
| like($@, qr/strict version 999999 required|strict version 999999 required--this is only version/, | ||
| 'uses standard VERSION checks for too-new requirements'); | ||
|
|
||
| { | ||
| package Test::Net::OpenSSH::ModuleLoader::Versioned; | ||
| our $VERSION = '1.02'; | ||
| } | ||
|
Comment on lines
+22
to
+25
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This concern does not hold for the test as written. The |
||
|
|
||
| $INC{'Test/Net/OpenSSH/ModuleLoader/Versioned.pm'} = __FILE__; | ||
|
|
||
| ok(_load_module('Test::Net::OpenSSH::ModuleLoader::Versioned', '1.01'), | ||
| 'accepts a sufficient version'); | ||
|
|
||
| eval { _load_module('Test::Net::OpenSSH::ModuleLoader::Versioned', '1.03') }; | ||
| like($@, qr/Test::Net::OpenSSH::ModuleLoader::Versioned version 1.03 required/, | ||
| 'rejects an insufficient version'); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 4e504a6 by handling undefined module names before applying the regex, with a regression assertion in
t/module-loader.t.