Fwctl/Services/http.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 83 CC 5 SCAR 18.9
CC
5
Cov
0%
accept_rules
12.0
account_rules
12.0
new
2.0
CRAP 6.6
1 #
2 # http.pm: Fwctl service module to handle the http protocol.
3 #
4 # This file is part of Fwctl.
5 #
6 # Author: Francis J. Lacoste <francis@iNsu.COM>
7 #
8 # Copyright (c) 1999,2000 iNsu Innovations Inc.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 package Fwctl::Services::http;
16  
17 use strict;
18  
19 use Fwctl::RuleSet qw(:tcp_rulesets :masq :ports);
20 use IPChains;
21  
22 sub new {
23 my $proto = shift;
24 my $class = ref $proto || $proto;
25 bless { port => "80" }, $class;
26 }
27  
28 sub prototypes {
29 my ($self,$target,$options) = @_;
30  
31 # Build prototype rule
32 (
33 IPChains->new(
34 Rule => $target,
35 Prot => 'tcp',
36 SourcePort => UNPRIVILEGED_PORTS,
37 %{$options->{ipchains}},
38 ),
39 );
40 }
41  
42 sub block_rules {
43 my $self = shift;
44 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
45  
46 my $port = $options->{port} || $self->{port};
47  
48 my ($http) = $self->prototypes( $target, $options );
49 for (split /,/, $port ) {
50 $http->attribute( DestPort => $_ );
51 block_tcp_ruleset( $http, $src, $src_if, $dst, $dst_if );
52 }
53 }
54  
55 sub accept_rules {
56 my $self = shift;
57 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
58  
59 my $port = $options->{port} || $self->{port};
60  
61 my ($http) = $self->prototypes( $target, $options );
62 my $masq = defined $options->{portfw} ? PORTFW :
63 $options->{masq} ? MASQ : NOMASQ;
64 for (split /,/, $port ) {
65 $http->attribute( DestPort => $_ );
66 accept_tcp_ruleset( $http, $src, $src_if, $dst, $dst_if,
67 $masq, $options->{portfw} );
68 }
69 }
70  
71 sub account_rules {
72 my $self = shift;
73 my ( $target, $src, $src_if, $dst, $dst_if, $options ) = @_;
74  
75 my $port = $options->{port} || $self->{port};
76 my $masq = defined $options->{portfw} ? PORTFW :
77 $options->{masq} ? MASQ : NOMASQ;
78  
79 my ($http) = $self->prototypes( $target, $options );
80 for (split /,/, $port ) {
81 $http->attribute( DestPort => $_ );
82 acct_tcp_ruleset( $http, $src, $src_if, $dst, $dst_if, $masq );
83 }
84 }
85  
86 sub valid_options {
87 my $self = shift;
88 ( "port=s" );
89 }
90  
91 1;
92  
93 =pod
94  
95 =head1 NAME
96  
97 Fwctl::Services::http - Fwctl module to handle HTTP protocol.
98  
99 =head1 SYNOPSIS
100  
101 accept http -src INTERNAL_NET -dst PROXY
102 deny http -dst MICROSOFT --nolog --account
103 account http -src PROXY -dst INTERNET
104  
105 =head1 DESCRIPTION
106  
107 The http module is used to control traffic which should be part of
108 an HTTP connection. It use the option I<port> which should contains
109 a comma separated list of port which are open for TCP connections.
110 Defaults to 80.
111  
112 THIS IS NOT A PROXY. It only open a bunch of TCP port to which
113 connection can be attempted. You have been warned.
114  
115 =head1 AUTHOR
116  
117 Francis J. Lacoste <francis.lacoste@iNsu.COM>
118  
119 =head1 COPYRIGHT
120  
121 Copyright (c) 1999,2000 iNsu Innovations Inc.
122 All rights reserved.
123  
124 This program is free software; you can redistribute it and/or modify
125 it under the terms of the GNU General Public License as published by
126 the Free Software Foundation; either version 2 of the License, or
127 (at your option) any later version.
128  
129 =head1 SEE ALSO
130  
131 fwctl(8) Fwctl(3) Fwctl::RuleSet(3)
132  
133 =cut
134