]>
iEval git - acme-evil.git/blob - lib/evil.pm
10 my $INTERMEDIATE = __PACKAGE__
.'/intermediate';
11 my $LAX = __PACKAGE__
.'/lax';
19 croak
"Cannot load evil module when \"no evil ':strict'\" is in effect" if %wants_strict;
21 my $hinthash = (caller 0)[10] || {};
22 croak
"Current module requested no evilness" if $hinthash->{$LAX};
24 $hinthash = (caller 3)[10] || {};
25 croak
"Cannot load evil module when parent requested \"no evil ':lax'\"" if $hinthash->{$LAX};
29 while (@caller = caller $level) {
30 $hinthash = $caller[10] || {};
31 croak
"Cannot load evil module when ancestor requested \"no evil ':intermediate'\""
32 if $hinthash->{$INTERMEDIATE};
36 $tainted{caller()} = 1;
40 my $strict_arg = grep /^:strict$/, @_;
41 my $intermediate_arg = grep /^:intermediate$/, @_;
42 my $lax_arg = grep /^:lax$/, @_;
43 my $disable_arg = grep /^:disable/, @_;
45 if (!$disable_arg && $tainted{caller()}) { # caller is evil
46 croak
'Current module is evil'
50 $wants_strict{caller()} = 1;
51 croak
"Evil module already loaded. Cannot enforce \"no evil ':strict'\"" if %tainted
54 } elsif ($disable_arg) {
55 delete $wants_strict{caller()};
57 delete $^H
{$INTERMEDIATE};
58 } else { # $intermediate_arg or no arg
59 $^H
{$INTERMEDIATE} = $^H
{$LAX} = 1
70 evil - RFC 3514 (evil bit) implementation for Perl modules
88 L<RFC3514|https://www.ietf.org/rfc/rfc3514.txt> introduces a new flag
89 called the "evil bit" in all IP packets. The intention is to simplify
90 the work of firewalls. Software that sends IP packets with malicious
91 intent must set the evil bit to true, and firewalls can simply drop
94 The evil pragma is a Perl implementation of the same concept. With
95 this pragma malicious modules can declare their evil intent while
96 critical modules can request that they will only use / run alongside
99 The pragma can be used in the following ways:
105 Marks the current package as evil. All malicious modules MUST use this
106 directive to ensure the full functionality of this module.
108 =item no B<evil> ':strict';
110 The calling module function properly if malignant code is loaded
111 anywhere in the program. Throws an exception if an evil module is
112 loaded, whether at the moment of calling this pragma or in the future.
114 =item no B<evil> ':disable';
116 Removes the effect of any previous C<no B<evil> ':strict'>. In other
117 words evil modules will now be allowed to be loaded.
119 =item no B<evil> ':intermediate'; (TODO)
121 Not yet implemented. The calling module cannot function properly if it
122 is using evil code, whether directly or indirectly. Throws an
123 exception if an evil module is loaded by the calling module or by one
124 of the children modules (or by one of their children modules, etc).
126 =item no B<evil> ':lax'; (TODO)
128 Not yet implemented. The calling module cannot function properly if it
129 is using evil code direcly. Throws an exception if the calling module
130 loads an evil module.
134 This would normally be equivalent to C<no evil ':intermediate';> but
135 since that mode is not yet implemented this call does the same as
136 C<no evil ':strict';> while also emitting a warning saying that this
137 behaviour will change in a future version.
143 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
145 =head1 COPYRIGHT AND LICENSE
147 Copyright (C) 2016 by Marius Gavrilescu
149 This library is free software; you can redistribute it and/or modify
150 it under the same terms as Perl itself, either Perl version 5.22.2 or,
151 at your option, any later version of Perl 5 you may have available.
This page took 0.075634 seconds and 5 git commands to generate.