/usr/share/sanitizer/testcases/sanitizer.filenames.t is in sanitizer 1.76-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | #!/bin/sh
[ "$1" = "-h" ] && cat <<tac
This example tests the following features of the sanitizer:
- Selection of default file names based on mime-types.
- Filename truncation (should be truncated from the right)
- Simple application of the drop, save, mangle, defang and accept
policies. The exclamation-policies are also tested.
tac
BINFALSE=/bin/false
[ -x /usr/bin/false ] && BINFALSE=/usr/bin/false || true
export BINFALSE
rm -f ./.tmp.*
# 'file_characters = A-Za-z0-9 ÁÉÍÓÚÝáéíóúý' \
$ANOMY/bin/sanitizer -nofprot $SAN_CONF \
'feat_force_name = 1' \
'file_list_rules = 11' \
"file_list_1_scanner = 0::1:$BINFALSE" \
'file_list_1_policy = unknown^10:unknown:unknown^10:unknown' \
'file_list_1 = .txt$' \
'file_list_2_policy = save' \
'file_list_2_scanner = 0' \
'file_list_2 = red.txt' \
'file_list_3_policy = mangle' \
'file_list_3_scanner = 0' \
'file_list_3 = orange.txt' \
'file_list_4_policy = defang' \
'file_list_4_scanner = 0' \
'file_list_4 = yellów.txt' \
'file_list_5_policy = accept' \
'file_list_5_scanner = 0' \
'file_list_5 = green.txt' \
'file_list_6_policy = drop' \
'file_list_6_scanner = 0' \
'file_list_6 = winmail.dat' \
'file_list_7_policy = warn^8' \
'file_list_7_scanner = 0' \
'file_list_7 = strange.txt' \
'file_list_8_policy = accept' \
'file_list_8_scanner = 0' \
'file_list_8 = strange.txt' \
'file_list_9_policy = unknown^11' \
'file_list_9_scanner = 0' \
'file_list_9 = .' \
'file_list_10_policy = unknown^2' \
'file_list_10_scanner = 0' \
'file_list_10 = .' \
'file_list_11_policy = accept:drop:drop:drop' \
'file_list_11_scanner = 0:1::./sanitizer.filenames.hlp %FILENAME %ATTNAME' \
'file_list_11 = replace.me' \
'file_default_policy = defang!' \
'file_default_filename = yellów.txt' \
'file_name_tpl = ./.tmp.$$$' \
'header_rev = 0' \
'feat_testing = 1' \
'feat_log_inline = 1' \
'feat_log_stderr = 0' <<EOF 2>test.log >test.out
From xxx@example.com Thu Aug 3 07:32:10 2000
Return-Path: <xxx@example.com>
Received: from example.com (root@example.com [149.144.245.5])
by example.com (8.9.3/8.9.3) with ESMTP id HAA01305
for <bre@example.com>; Thu, 3 Aug 2000 07:32:03 GMT
From: xxx@example.com
Date: Thu, 3 Aug 2000 06:39:59 GMT
Message-Id: <200008030639.GAA23780@example.com>
MIME-Version: 1.0
Sender: xxx@example.com
Subject: this is a very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long subject which looks a bit like a file name.txt with more than one extension.exe
To: fake@example.com
Content-Type: multipart/mixed; boundary="=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV"
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: application/ms-tnef; charset="evil"
Content-Disposition: attachment
Content-Transfer-Encoding: 8bit
this is a very evil file.
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: application/x-snort-snort; charset="iso-8859-1"
Content-Disposition: attachment
Content-Transfer-Encoding: 8bit
this is an unnamed file, which should be treated as if it were yellow
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment;
filename="aaaaaaaaa0aaaaaaaaa1aaaaaaaaa2aaaaaaaaa3aaaaaaaaa4aaaaaaaaa5aaaaaaaaa6aaaaaaaaa7aaaaaaaa.vbs.txt"
Content-Transfer-Encoding: 8bit
this is also a very evil file.
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="red.txt"
Content-Transfer-Encoding: 8bit
this file is rather evil
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="orange.txt"
Content-Transfer-Encoding: 8bit
this file is pretty yucky
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="yellów.txt"
Content-Transfer-Encoding: 8bit
this file is somewhat suspicious
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="green.txt"
Content-Transfer-Encoding: 8bit
this file is nice
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="strange.txt"
Content-Transfer-Encoding: 8bit
this file is strange
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="scan me silly.txt"
Content-Transfer-Encoding: base64
L2Jpbi9mYWxzZSBtZSE=
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="scan me happy.txt"
Content-Transfer-Encoding: 8bit
Yeah baby.
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="replace.me"
Content-Transfer-Encoding: 8bit
Yeah baby.
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV
Content-Type: text/plain; charset="iso-8859-1"; name="other.name.boo"; filename="fee.boo"
Content-Disposition: attachment; filename="some.other.name.blrg"; name="rah.boo"
Content-Description: Some fake filename .boo
Content-ID: Alphabet.blrg
Content-Transfer-Encoding: 8bit
This file should get renamed, and since it has two name/filename
attributes, both should get modified.
--=ABACAB:=_0006@@UtD0uere5ZCIrVlOp0vV--
EOF
echo "*** Exit code was $? ***" >>test.out
cat test.out |sed -e "s,$BINFALSE,/bin/false,g" >test2.out
mv -f test2.out test.out
echo ./.tmp.* >>test.out 2>&1
rm ./.tmp.* >>test.out 2>&1
exit 0
|