Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kentnl/test-withtaint

Ensure a Test is run reliably with taint
https://github.com/kentnl/test-withtaint

Last synced: 4 days ago
JSON representation

Ensure a Test is run reliably with taint

Awesome Lists containing this project

README

        

=begin Pod::Coverage

taint_supported taint_enabled

=end Pod::Coverage

=cut

=head1 NAME

Test::WithTaint - Ensure a Test is run reliably with taint

=head1 SYNOPSIS

# re-execute self with tainting t/foo-tainting.t
use Test::WithTaint;

# execute a different script with tainting
use Test::WithTaint -exec => 't/foo.t'

=head1 DESCRIPTION

This module aims to facilitate taint testing in several ways.

=over 4

=item * Permit skipping taint-dependent tests in the event a future Perl release lacks taint support

=item * Permit forcing taint mode on a test that is not already running in taint mode

=item * Simplify running the an existing test both in and out of taint mode

=item * Clean up environment when invoking taint-dependent tests to avoid common traps in taint + %ENV

=back

=head1 USAGE

=head2 Simple Mode

This mode is the most recommended usage, and it adds a layer of safety
that is too hard to achieve with a hash-bang trick.

# inside foo.t
use Test::WithTaint;

Here, the default behavior is to:

=over 4

=item * Check your Perl supports tainting, and skip the test if it does not.

=item * Check your Perl is running in taint mode, and continue execution if it is.

=item * In the event Perl is B running in taint mode, clean up the environment slightly
and re-execute the test under taint mode.

=back

=head2 Indirect Mode

This mode is a variation on C designed to reduce code duplication.

# inside foo-tainted.t
use Test::WithTaint -exec => 't/foo.t';

This:

=over 4

=item * Checks Perl supports tainting, and skips the test if it does not.

=item * Cleans up the environment, and Forcefully invokes the test passed to C<-exec> with C;

=back

=head1 AUTHOR

Kent Fredric

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Kent Fredric .

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut