Initial commit 0.001
authorMarius Gavrilescu <marius@ieval.ro>
Tue, 31 May 2016 23:33:04 +0000 (00:33 +0100)
committerMarius Gavrilescu <marius@ieval.ro>
Tue, 31 May 2016 23:33:04 +0000 (00:33 +0100)
12 files changed:
Changes [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
Makefile.PL [new file with mode: 0644]
README [new file with mode: 0644]
lib/Acme/Evil.pm [new file with mode: 0644]
lib/evil.pm [new file with mode: 0644]
t/strict-die.t [new file with mode: 0644]
t/strict-safe.t [new file with mode: 0644]
t/t1/Direct.pm [new file with mode: 0644]
t/t1/Evil.pm [new file with mode: 0644]
t/t1/Indirect.pm [new file with mode: 0644]
t/t1/Unrelated.pm [new file with mode: 0644]

diff --git a/Changes b/Changes
new file mode 100644 (file)
index 0000000..ec5e4d2
--- /dev/null
+++ b/Changes
@@ -0,0 +1,4 @@
+Revision history for Perl extension Acme::Evil.
+
+0.001 2016-06-01T00:33+01:00
+ - Initial release
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..228f413
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,12 @@
+Changes
+lib/Acme/Evil.pm
+lib/evil.pm
+Makefile.PL
+MANIFEST
+README
+t/strict-die.t
+t/strict-safe.t
+t/t1/Direct.pm
+t/t1/Evil.pm
+t/t1/Indirect.pm
+t/t1/Unrelated.pm
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644 (file)
index 0000000..de6774f
--- /dev/null
@@ -0,0 +1,20 @@
+use 5.008009;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+       NAME              => 'Acme::Evil',
+       VERSION_FROM      => 'lib/evil.pm',
+       ABSTRACT          => 'RFC 3514 (evil bit) implementation for Perl modules',
+       AUTHOR            => 'Marius Gavrilescu <marius@ieval.ro>',
+       MIN_PERL_VERSION  => '5.8.9',
+       LICENSE           => 'perl',
+       SIGN              => 1,
+       PREREQ_PM         => {},
+       META_ADD         => {
+               dynamic_config => 0,
+               resources      => {
+                       repository => 'https://git.ieval.ro/?p=acme-evil.git',
+               },
+       }
+
+);
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..7fb83db
--- /dev/null
+++ b/README
@@ -0,0 +1,35 @@
+Acme-Evil version 0.001
+=======================
+
+RFC3514 introduces a new flag called the "evil bit" in all IP packets.
+The intention is to simplify the work of firewalls. Software that
+sends IP packets with malicious intent must set the evil bit to true,
+and firewalls can simply drop such packets.
+
+The evil pragma is a Perl implementation of the same concept. With
+this pragma malicious modules can declare their evil intent while
+critical modules can request that they will only use / run alongside
+non-evil code.
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DEPENDENCIES
+
+This module requires no other modules and libraries.
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2016 by Marius Gavrilescu
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.22.2 or,
+at your option, any later version of Perl 5 you may have available.
+
+
diff --git a/lib/Acme/Evil.pm b/lib/Acme/Evil.pm
new file mode 100644 (file)
index 0000000..70b3a56
--- /dev/null
@@ -0,0 +1,47 @@
+package Acme::Evil;
+
+use 5.008009;
+use strict;
+use warnings;
+
+our $VERSION = '0.001';
+
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Acme::Evil - Empty module
+
+=head1 SYNOPSIS
+
+  use Acme::Evil; # does nothing
+
+=head1 DESCRIPTION
+
+This is an empty module needed for the dist permissions to work
+properly.
+
+See the documentation of the L<evil> pragma for useful informaton
+about this dist.
+
+=head1 SEE ALSO
+
+L<evil>
+
+=head1 AUTHOR
+
+Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2016 by Marius Gavrilescu
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.22.2 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
diff --git a/lib/evil.pm b/lib/evil.pm
new file mode 100644 (file)
index 0000000..db7968d
--- /dev/null
@@ -0,0 +1,115 @@
+#!/usr/bin/perl
+package evil;
+
+use 5.008009;
+use strict;
+use warnings;
+
+use Carp;
+
+our $VERSION = 0.001;
+
+our %tainted;
+our $strict;
+
+sub import {
+       $tainted{caller()} = 1;
+       croak "Cannot load evil module when \"no evil ':strict'\" is in effect" if $strict;
+}
+
+sub unimport {
+       my $strict_arg = grep /^:strict$/, @_;
+       carp 'no evil; interpreted as no evil ":strict". This will change in a future version of Acme::Evil' unless $strict_arg;
+       $strict = 1; # To be changed when other modes are implemented
+       if ($strict && %tainted) {
+               croak "Evil module already loaded. Cannot enforce \"no evil ':strict'\"";
+       }
+}
+
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+evil - RFC 3514 (evil bit) implementation for Perl modules
+
+=head1 SYNOPSIS
+
+  # in A.pm
+  package A;
+  use evil;
+  ...
+
+  # in B.pm
+  package B;
+  no evil ':strict';
+  use A; # <dies>
+  ...
+
+
+=head1 DESCRIPTION
+
+L<RFC3514|https://www.ietf.org/rfc/rfc3514.txt> introduces a new flag
+called the "evil bit" in all IP packets. The intention is to simplify
+the work of firewalls. Software that sends IP packets with malicious
+intent must set the evil bit to true, and firewalls can simply drop
+such packets.
+
+The evil pragma is a Perl implementation of the same concept. With
+this pragma malicious modules can declare their evil intent while
+critical modules can request that they will only use / run alongside
+non-evil code.
+
+The pragma can be used in the following ways:
+
+=over
+
+=item use B<evil>;
+
+Marks the current package as evil. All malicious modules MUST use this
+directive to ensure the full functionality of this module.
+
+=item no B<evil> ':strict';
+
+The calling module function properly if malignant code is loaded
+anywhere in the program. Throws an exception if an evil module is
+loaded, whether at the moment of calling this pragma or in the future.
+
+=item no B<evil> ':intermediate'; (TODO)
+
+Not yet implemented. The calling module cannot function properly if it
+is using evil code, whether directly or indirectly. Throws an
+exception if an evil module is loaded by the calling module or by one
+of the children modules (or by one of their children modules, etc).
+
+=item no B<evil> ':lax'; (TODO)
+
+Not yet implemented. The calling module cannot function properly if it
+is using evil code direcly. Throws an exception if the calling module
+loads an evil module.
+
+=item no B<evil>;
+
+This would normally be equivalent to C<no evil ':intermediate';> but
+since that mode is not yet implemented this call does the same as
+C<no evil ':strict';> while also emitting a warning saying that this
+behaviour will change in a future version.
+
+=back
+
+=head1 AUTHOR
+
+Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2016 by Marius Gavrilescu
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.22.2 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
diff --git a/t/strict-die.t b/t/strict-die.t
new file mode 100644 (file)
index 0000000..4d7aa28
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+use Test::More tests => 4;
+
+require_ok 't::t1::Evil';
+require_ok 't::t1::Direct';
+require_ok 't::t1::Indirect';
+ok !eval { require t::t1::Unrelated }, 'Unrelated dies';
+
diff --git a/t/strict-safe.t b/t/strict-safe.t
new file mode 100644 (file)
index 0000000..4c3b826
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/perl
+use Test::More tests => 1;
+
+require_ok 't::t1::Unrelated';
diff --git a/t/t1/Direct.pm b/t/t1/Direct.pm
new file mode 100644 (file)
index 0000000..b6e41ed
--- /dev/null
@@ -0,0 +1,3 @@
+package t::t1::Direct;
+use t::t1::Evil;
+1;
diff --git a/t/t1/Evil.pm b/t/t1/Evil.pm
new file mode 100644 (file)
index 0000000..ed9e20e
--- /dev/null
@@ -0,0 +1,3 @@
+package t::t1::Evil;
+use evil;
+1;
diff --git a/t/t1/Indirect.pm b/t/t1/Indirect.pm
new file mode 100644 (file)
index 0000000..8b1a20b
--- /dev/null
@@ -0,0 +1,3 @@
+package t::t1::Indirect;
+use t::t1::Direct;
+1;
diff --git a/t/t1/Unrelated.pm b/t/t1/Unrelated.pm
new file mode 100644 (file)
index 0000000..78d2ca5
--- /dev/null
@@ -0,0 +1,3 @@
+package t::t1::Unrelated;
+no evil ':strict';
+1;
This page took 0.017899 seconds and 4 git commands to generate.