lib/App/Greple/pgp.pm

filter: Statementstmt 66.6% 14 / 21 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 47.3% 18 / 38 CC 5 SCAR 27.5
CC
5
Cov
48%
filter
30.0
activate
2.0
BEGIN
1.0
CRAP 15.6
« lib/App/Greple/Pattern/Holder.pm ↑ Summary lib/App/Greple/select.pm »
1 =head1 NAME
2  
3 pgp - Greple module to handle PGP encrypted files
4  
5 =head1 SYNOPSIS
6  
7 greple -Mpgp pattern *.gpg
8  
9 greple -Mpgp --pgppass 'passphrase' pattern file.gpg
10  
11 =head1 DESCRIPTION
12  
13 Enables searching within PGP/GPG encrypted files. Files with
14 I<.pgp>, I<.gpg>, or I<.asc> extensions are automatically decrypted.
15 Passphrase is requested interactively once and cached for subsequent
16 files.
17  
18 =head1 REQUIREMENTS
19  
20 This module requires the B<gpg> (GnuPG) command to be installed and
21 available in PATH.
22  
23 =head1 OPTIONS
24  
25 =over 7
26  
27 =item B<--pgppass> I<passphrase>
28  
29 Specify the PGP passphrase directly. B<Not recommended> for security
30 reasons as the passphrase may be visible in process listings or shell
31 history. Use interactive input instead when possible.
32  
33 =back
34  
35 =head1 SECURITY NOTES
36  
37 =over 4
38  
39 =item *
40  
41 The passphrase is stored in memory during execution and cleared when
42 no longer needed.
43  
44 =item *
45  
46 Decrypted content is processed through pipes and not written to disk.
47  
48 =item *
49  
50 Avoid using B<--pgppass> option in scripts or command history.
51  
52 =back
53  
54 =head1 SEE ALSO
55  
56 L<App::Greple>, L<gpg(1)>
57  
58 =cut
59  
60 package App::Greple::pgp;
61  
62 1 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
65  
66 1 ▶use App::Greple::PgpDecryptor;
Subroutine BEGIN: called CC=1 SCAR=0.0
67  
68 1 my $pgp;
69 1 our $opt_pgppass;
70  
71 0 ▶sub activate {
Subroutine activate: not called CC=1 SCAR=6.9
Pod undocumented
72 0 ($pgp = App::Greple::PgpDecryptor->new)
73 ->initialize({passphrase => $opt_pgppass});
74 }
75  
76 0 ▶sub filter {
Subroutine filter: not called CC=5 SCAR=34.0
Pod undocumented
77 0 ▶ activate if not defined $pgp;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pgp 0 0 0
78 0 $pgp->reset;
79 0 ▶ my $pid = open(STDIN, '-|') // croak "process fork failed";
Condition0%0/2
open(STDIN, "-|") // croak("process fork failed")
l!l
00
MC/DC0%0/1
open(STDIN, "-|") // croak("process fork failed")
open(STDIN, "-|")
Truth table0%0/2
A
A= open(STDIN, "-|")
Aresult
11
00
80 0 ▶ if ($pid == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid == 0) 0 0 0
81 0 ▶ exec $pgp->decrypt_command or die $!;
Branch: 1 branch
BranchTrueFalseTotal
exec $pgp->decrypt_command or die $! 0 0 0
82 }
83 0 $pid;
84 }
85  
86 1 1;
87  
88 __DATA__
« lib/App/Greple/Pattern/Holder.pm ↑ Summary lib/App/Greple/select.pm »