Acme-SafetyGoggles

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

Acme-SafetyGoggles

Is some module you imported using source filtering? If the
answer is yes, or if the answer is "I don't know", then
you can't trust the code in front of your own eyes! 

That's why you should always use patent-pending 
Acme::SafetyGoggles in your untrusted Perl code! 
Acme::SafetyGoggles  compares your original source file
with the code that is actually going to be run, and
alerts you to any differences. 

Protect the programmer's seventh most important
attribute --  his/her eyes -- with the Acme::SafetyGoggles
module.


INSTALLATION

lib/Acme/SafetyGoggles.pm  view on Meta::CPAN

  if ($file eq '-e') {
    carp "Acme::SafetyGoggles cannot protect against code in an '-e' construction";
    return;
  }

  my $vh;
  unless (open $vh, '<', $file) {
    carp "Acme::SafetyGoggles: cannot read source file $file ! $!\n";
    return;
  }
  my $original = '';
  my $original2 = '';
  while (my $line = <$vh>) {
    last if $line =~ /^__END__$/;
    $original .= $line;
    $original2 .= $line;
    $original2 = "" if $line =~ /^use\s+Acme::SafetyGoggles\b/;
  }
  close $vh;

  $diff = Text::Diff::diff(\$original2, \$current, { STYLE => 'OldStyle' } );
  $diff &&= Text::Diff::diff(\$original, \$current, { STYLE => 'OldStyle' } );

  # it is ok if the original file contains extra lines at the top, ending
  # with the call to the source filter.
  #
  #   Example:
  #
  #   1,3d0
  #   < #!/usr/bin/perl
  #   < # this is my program with source filtering
  #   < use The::Source::Filter;

  $diff =~ s{

lib/Acme/SafetyGoggles.pm  view on Meta::CPAN

    $ perl -MAcme::SafetyGoggles possibly_dangerous_script.pl

=head1 DESCRIPTION

Is some module you imported using source filtering? If the
answer is yes, or if the answer is "I don't know", then
you can't trust the code in front of your own eyes! 

That's why you should always use patent-pending 
C<Acme::SafetyGoggles> in your untrusted Perl code. 
C<Acme::SafetyGoggles> compares your original source file
with the code that is actually going to be run, and
alerts you to any differences. 

=head1 SUBROUTINES/METHODS

=head2 state

=head2 Acme::SafetyGoggles->state

Returns this module's assessment of whether the source code

lib/Acme/SafetyGoggles.pm  view on Meta::CPAN


    trustable_code();
    {
        use The::Source::Filter;
        some_code_you_cant_trust();
    }
    more_trustable_code();

=cut

# How would we handle this case?  Match a section of $original beginning
# after a  "use Some::Filter;"  statement and before a  "no Some::Filter;"
# statement?

=pod

This module really only works on source filters that already use
the L<Filter::Simple> mechanism. Even then, there are probably
still a lot of ways to source filter the code so that it won't be
detected by this module. 



( run in 0.311 second using v1.01-cache-2.11-cpan-1c8d708658b )