blob: dc6de33be0d824980d7fcbb2f43bde6b1a3a78b8 (
plain)
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
|
#!/usr/bin/env bash
set -xeuo pipefail
SCRIPT_NAME=$(basename "$0")
function usage()
{
cat <<EOF
${SCRIPT_NAME}: Launch and validate a shadow simulation to test arti
Usage:
${SCRIPT_NAME} : Launch and validate a shadow simulation
Options:
-h: Print this message.
-s <seed>: Integer PRNG seed
EOF
}
SEED=1
while getopts "hs:" opt ; do
case "$opt" in
h) usage
exit 0
;;
s) SEED="$OPTARG"
;;
*) echo "Unknown option. (Run $0 -h for usage)"
exit 1
;;
esac
done
# Remove output of previous run
rm -rf shadow.data
export RUST_BACKTRACE=1
# Fix permissions on hidden service dir to prevent tor from bailing.
# TODO: isn't there a way to set the permissions in the git repo? Tried `git
# update-index --chmod`, but it refuses to set permissions on a directory.
chmod 700 shadow.data.template/hosts/fileserver-onion/hs
chmod 700 shadow.data.template/hosts/fileserver-onion-auth/hs
chmod 700 shadow.data.template/hosts/fileserver-onion-arti-auth/authorized_clients
chmod 700 shadow.data.template/hosts/fileserver-onion-arti-auth-ctor/ctor-store
chmod 700 shadow.data.template/hosts/articlient-onion-artiserver-auth-ctor/ctor-store
# Run the simulation
shadow \
--log-level=info \
--template-directory=./shadow.data.template \
--progress=true \
--use-memory-manager=false \
--use-worker-spinning=false \
--seed="$SEED" \
shadow.yaml \
> shadow.log
# Check whether file transfers via arti inside the simulation succeeded
for HOST in articlient articlient-extra articlient-bridge articlient-bridge-obfs4; do
successes="$(grep -c stream-success shadow.data/hosts/$HOST/tgen.*.stdout || true)"
if [ "$successes" = 10 ]
then
echo "Simulation successful"
else
echo "Failed. Only got $successes successful streams."
exit 1
fi
done
# Look for any non-empty stderr files. In particular rust panics sometimes end
# up showing up here (even though we try to log them properly).
nonempty_stderr=$(find shadow.data/hosts/ -name '*.stderr' -size +0 -print -quit)
if [ -n "$nonempty_stderr" ]; then
echo "Found non-empty stderr file $nonempty_stderr:"
cat "$nonempty_stderr"
exit 1
fi
# Look for errors in arti logs.
# TODO: Maybe fail on warnings, too? There currently are a few, though.
arti_errs=$(find shadow.data/hosts/ -name 'arti.log.txt' -exec grep --with-filename '\bERROR\b' \{\} \;)
if [ -n "$arti_errs" ]; then
echo "Found arti errors:"
echo "$arti_errs"
exit 1
fi
HOSTS=(
articlient-onion
articlient-onion-auth
articlient-onion-artiserver
articlient-onion-artiserver-full-vanguards
articlient-onion-artiserver-auth
articlient-onion-artiserver-auth-2
articlient-onion-artiserver-auth-ctor
torclient-onion-artiserver
torclient-onion-artiserver-full-vanguards
)
for HOST in "${HOSTS[@]}"; do
successes="$(grep -c stream-success shadow.data/hosts/"$HOST"/tgen.*.stdout || true)"
# NOTE: For the HS client tests we only require half of the streams to succeed
# to work around the issue described in:
# * https://github.com/shadow/shadow/issues/2544
# * https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1399#note_2921505
# * https://gitlab.torproject.org/tpo/core/arti/-/issues/1986
if [ "$successes" -ge 1 ]
then
echo "Simulation successful"
else
echo "Failed. Only got $successes successful streams."
exit 1
fi
done
HOSTS=(
articlient-onion
articlient-onion-auth
articlient-onion-artiserver
articlient-onion-artiserver-full-vanguards
articlient-onion-auth
articlient-onion-artiserver-auth-ctor
fileserver-onion-arti
fileserver-onion-arti-full-vanguards
fileserver-onion-arti-auth
fileserver-onion-arti-auth-ctor
)
for HOST in "${HOSTS[@]}"; do
# There should be only one such file per host.
file=(shadow.data/hosts/"$HOST"/arti.log.txt)
# TODO: this is a temporary measure until we implement other ways of testing
# that the circuits we've built have the desired properties.
bugs="$(grep -c Bug "${file[*]}" || true)"
if [ "$bugs" -eq 0 ]
then
echo "Simulation successful"
else
echo "Failed. Found $bugs internal errors in ${file[*]}."
exit 1
fi
done
pushd shadow.data/hosts/articlient-bridge/
for PCAP in *.pcap; do
# verify all connection are either from/to the bridge, or local.
LEAK=$(tshark -r "$PCAP" 'ip.src != 100.0.0.2 && ip.dst != 100.0.0.2 && ip.dst != 127.0.0.0/8')
if [ "$LEAK" ]; then
echo "Found tcp leaks in PCAP: $PCAP"
echo "$LEAK"
exit 1
fi
done
DNS_LEAK=$(grep -l shadow_hostname_to_addr_ipv4 arti.*.strace || true)
if [ "$DNS_LEAK" ]; then
echo "Found DNS leaks in $DNS_LEAK"
exit 1
fi
popd
|