| 1 | # | ||
| 2 | # $Id$ | ||
| 3 | # | ||
| 4 | # binjitsu::checksec Brik | ||
| 5 | # | ||
| 6 | package Metabrik::Binjitsu::Checksec; | ||
| 7 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | ▶ | use base qw(Metabrik::Shell::Command); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | sub brik_properties { | ||
| 13 | return { | ||
| 14 | revision => '$Revision$', | ||
| 15 | tags => [ qw(unstable) ], | ||
| 16 | author => 'GomoR <GomoR[at]metabrik.org>', | ||
| 17 | license => 'http://opensource.org/licenses/BSD-3-Clause', | ||
| 18 | commands => { | ||
| 19 | file => [ qw(input) ], | ||
| 20 | }, | ||
| 21 | require_binaries => { | ||
| 22 | checksec => [ ], | ||
| 23 | }, | ||
| 24 | }; | ||
| 25 | } | ||
| 26 | |||
| 27 | sub file { | ||
| 28 | my $self = shift; | ||
| 29 | my ($file) = @_; | ||
| 30 | |||
| 31 | $self->brik_help_run_undef_arg('file', $file) or return; | ||
| 32 | my $ref = $self->brik_help_run_invalid_arg('file', $file, 'ARRAY', 'SCALAR') | ||
| 33 | or return; | ||
| 34 | |||
| 35 | if ($ref eq 'ARRAY') { | ||
| 36 | my @result = (); | ||
| 37 | for my $this (@$file) { | ||
| 38 | my $r = $self->file($this) or next; | ||
| 39 | push @result, $r; | ||
| 40 | } | ||
| 41 | return \@result; | ||
| 42 | } | ||
| 43 | else { | ||
| 44 | my $cmd = "checksec --file \"$file\""; | ||
| 45 | my $buf = $self->capture($cmd) or return; | ||
| 46 | my %r = (); | ||
| 47 | for my $line (@$buf) { | ||
| 48 | if ($line =~ /^\s+(\S+):\s+(.*)\s*$/) { | ||
| 49 | $r{lc($1)} = $2; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | return \%r; | ||
| 53 | } | ||
| 54 | |||
| 55 | return; | ||
| 56 | } | ||
| 57 | |||
| 58 | 1; | ||
| 59 | |||
| 60 | __END__ | ||