-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcops_filter
84 lines (75 loc) · 2.12 KB
/
cops_filter
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#
# cops_filter
#
# An awk program to help filter out spurious warning messages. Similar
# to "carp.anlz", but instead of filtering out things on a network
# level (or at least multi-host), as carp does, it filters out individual
# host warnings. Also, carp.anlz filters post facto and doesn't modify
# the report files; this filters before the report is printed and influences
# the final cops report. See readme.cops_filter for more information.
#
#
# EXCEPTION LIST:
/Warning!/ {
# if (warning) print "FIRST:", warning_msg
if (warning) print warning_msg
warning = skip_next = 0
#
# You can clump all the warnings together, which can be a pain
# to keep track of matching parens, backslashes, and curly braces
# (especially if you're changing the first or last entry in the long
# if statement...):
#
# if (($0 ~ /Warning! \/usr\/spool\/mail is _World_ writable!/) || \
# ($0 ~ /Warning! \/etc\/mtab is _World_ writable!/) || \
# ($0 ~ /Warning! YPassword/) || \
# ($0 ~ /Warning! \/etc\/tmp is _World_ writable!/) || \
# ($0 ~ /Warning! \/etc\/utmp is _World_ writable!/) || \
# ($0 ~ /Warning! \/usr\/adm\/snm is _World_ writable!/)) {
# skip_next = 1
# next
# }
if (/Warning! \/usr\/adm\/snm is _World_ writable!/) {
skip_next = 1
next
}
# Alternately, you can do each one separately:
#
# if ($0 ~ /Warning! \/usr\/spool\/mail is _World_ writable!/) {
# skip_next = 1
# next
# }
# if ($0 ~ /Warning! \/etc\/sm.* is _World_ writable!/) {
# skip_next = 1
# next
# }
# if ($0 ~ /Warning! ypadmin should be in \/etc\/ftpusers!/) {
# skip_next = 1
# next
# }
warning = 1
warning_msg = $0
}
# this catches the second line of multi line warnings
! /Warning!/ {
# if it's the second line, print the first line (caught above)
if (warning)
print warning_msg
warning = 0
# print the second line or just normal lines
if (!skip_next && $0 !~ /\*\*\*\*/)
print $0
}
# don't want to blow away verbose information headers
/\*\*\*\*/ {
print $0
}
END {
# in case at end of file and last warning not yet printed
if (warning)
print warning_msg
warning = 0
}
END {
if (warning) print warning_msg
}