Don't treat error reply as a proper JDWP handshake 86/87486/1
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 10 May 2019 20:43:10 +0000 (22:43 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 10 May 2019 20:50:16 +0000 (22:50 +0200)
As it turned out thanks to Yan Yang some ONAP services tend to
return a propr JDWP handshake as a part of their error message.

Let's filter out those services by checking number of lines returned
by the server. We expect that proper JDWP handshake won't be longer
than a single line.

Issue-ID: SECCOM-231
Change-Id: I4b8950ebdf5fe118ec5f2dd5f4de583211784fb2
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
test/security/check_for_jdwp.sh

index 0facbff..e79f712 100755 (executable)
@@ -49,7 +49,8 @@ do_jdwp_handshake() {
 
        # 10s timeout to avoid hangs when service doesn't answer at all
        local response=`nc -w 10 $ip $port <<<$jdwp_challenge | tr '\0' '\n'`
-       if [[ $response == *"$jdwp_response"* ]]; then
+       local n_response_lines=`echo "$response" | wc -l`
+       if [[ "$n_response_lines" -le 1 ]] && [[ $response == *"$jdwp_response"* ]]; then
                return 0
        fi