File: nginx-tests-cvt.pl

package info (click to toggle)
libnginx-mod-http-modsecurity 1.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 428 kB
  • sloc: perl: 1,819; ansic: 1,515; sh: 26; makefile: 3
file content (39 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl

#
# Script to adjust nginx tests to include ModSecurity directives.  It enables
# us to passively test nginx functionality with ModSecurity module enabled.
#

# sh command line variations:
#
# for i in *.t; do cp -n $i $i.orig; perl nginx-tests-cvt.pl < $i.orig > $i; done
# for i in *.t; do perl nginx-tests-cvt.pl < $i.orig > $i; done
# for i in *.t; do cp $i.orig $i; done

my $ignore = 0;
while (<STDIN>) {
	print $_;

	$ignore = 1	if (/^mail {/);					# skip mail_*.t mail blocks
	$ignore = 0	if (/^http {/);

	next		if ($ignore);

	if (/^ *server_name .*;$/) {

		next if (/^ *server_name *below;/);			# skip duplication on refresh.t
		next if (/^ *server_name *many4.example.com;/);		# skip duplication on http_server_name.t

		print "
        modsecurity on;
        modsecurity_rules '
        SecRuleEngine On
        SecDebugLogLevel 9
        SecRule ARGS \"\@streq whee\" \"id:10,phase:2\"
        SecRule ARGS \"\@streq whee\" \"id:11,phase:2\"
        ';
";

	}
}