qa: fix suricatasc path

pull/12685/head
Jason Ish 2 months ago committed by Victor Julien
parent a0089190df
commit fc2824a9f7

@ -28,9 +28,14 @@ if [ -f eve.json ]; then
rm eve.json rm eve.json
fi fi
if [ -e ./rust/target/release/suricatasc ]; then
SURICATASC=./rust/target/release/suricatasc
else
SURICATASC=./rust/target/debug/suricatasc
fi
RES=0 RES=0
export PYTHONPATH=python/
# Get listen interface and "ping" target address # Get listen interface and "ping" target address
IFACE=$(ip r|grep default|awk '{print $5}') IFACE=$(ip r|grep default|awk '{print $5}')
echo $IFACE echo $IFACE
@ -75,7 +80,7 @@ if [ $CHECK -ne 1 ]; then
echo "ERROR alerts count off for sid 222 (datasets)" echo "ERROR alerts count off for sid 222 (datasets)"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -v -c "dataset-clear ipv4-list ipv4" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -v -c "dataset-clear ipv4-list ipv4" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
sleep 5 sleep 5
@ -91,41 +96,41 @@ echo "SURIPID $SURIPID PINGPID $PINGPID"
cp .github/workflows/live/icmp2.rules suricata.rules cp .github/workflows/live/icmp2.rules suricata.rules
# trigger the reload # trigger the reload
JSON=$(python3 python/bin/suricatasc -c "iface-list" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "iface-list" /var/run/suricata/suricata-command.socket)
PIFACE=$(echo $JSON | jq -r .message.ifaces[0]) PIFACE=$(echo $JSON | jq -r .message.ifaces[0])
JSON=$(python3 python/bin/suricatasc -c "iface-stat $PIFACE") JSON=$(${SURICATASC} -c "iface-stat $PIFACE")
STATSCHECK=$(echo $JSON | jq '.message.pkts > 0') STATSCHECK=$(echo $JSON | jq '.message.pkts > 0')
if [ $STATSCHECK = false ]; then if [ $STATSCHECK = false ]; then
echo "ERROR unix socket stats check failed" echo "ERROR unix socket stats check failed"
RES=1 RES=1
fi fi
python3 python/bin/suricatasc -c "reload-rules" /var/run/suricata/suricata-command.socket ${SURICATASC} -c "reload-rules" /var/run/suricata/suricata-command.socket
JSON=$(python3 python/bin/suricatasc -c "iface-bypassed-stat" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "iface-bypassed-stat" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
JSON=$(python3 python/bin/suricatasc -c "capture-mode" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "capture-mode" /var/run/suricata/suricata-command.socket)
if [ "$(echo $JSON | jq -r .message)" != "AF_PACKET_DEV" ]; then if [ "$(echo $JSON | jq -r .message)" != "AF_PACKET_DEV" ]; then
echo "ERROR unix socket capture mode check failed" echo "ERROR unix socket capture mode check failed"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "dump-counters" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "dump-counters" /var/run/suricata/suricata-command.socket)
STATSCHECK=$(echo $JSON | jq '.message.uptime >= 15') STATSCHECK=$(echo $JSON | jq '.message.uptime >= 15')
if [ $STATSCHECK = false ]; then if [ $STATSCHECK = false ]; then
echo "ERROR unix socket dump-counters uptime check failed" echo "ERROR unix socket dump-counters uptime check failed"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "memcap-list" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "memcap-list" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
JSON=$(python3 python/bin/suricatasc -c "running-mode" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "running-mode" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
if [ "$(echo $JSON | jq -r .message)" != "$RUNMODE" ]; then if [ "$(echo $JSON | jq -r .message)" != "$RUNMODE" ]; then
echo "ERROR unix socket runmode check failed" echo "ERROR unix socket runmode check failed"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "version" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "version" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
JSON=$(python3 python/bin/suricatasc -c "uptime" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "uptime" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
STATSCHECK=$(echo $JSON | jq '.message >= 15') STATSCHECK=$(echo $JSON | jq '.message >= 15')
if [ $STATSCHECK = false ]; then if [ $STATSCHECK = false ]; then
@ -133,7 +138,7 @@ if [ $STATSCHECK = false ]; then
RES=1 RES=1
fi fi
sleep 15 sleep 15
JSON=$(python3 python/bin/suricatasc -c "add-hostbit $GW test 60" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "add-hostbit $GW test 60" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
sleep 15 sleep 15
@ -148,17 +153,17 @@ if [ $SID2CHECK = false ]; then
echo "ERROR no alerts for sid 2" echo "ERROR no alerts for sid 2"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "list-hostbit $GW" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "list-hostbit $GW" /var/run/suricata/suricata-command.socket)
CHECK=$(echo $JSON|jq -r .message.hostbits[0].name) CHECK=$(echo $JSON|jq -r .message.hostbits[0].name)
if [ "$CHECK" != "test" ]; then if [ "$CHECK" != "test" ]; then
echo "ERROR hostbit listing failed" echo "ERROR hostbit listing failed"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "remove-hostbit $GW test" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "remove-hostbit $GW test" /var/run/suricata/suricata-command.socket)
kill -INT $PINGPID kill -INT $PINGPID
wait $PINGPID wait $PINGPID
python3 python/bin/suricatasc -c "shutdown" /var/run/suricata/suricata-command.socket ${SURICATASC} -c "shutdown" /var/run/suricata/suricata-command.socket
wait $SURIPID wait $SURIPID
echo "done: $RES" echo "done: $RES"

@ -21,6 +21,12 @@ if [ -f eve.json ]; then
rm eve.json rm eve.json
fi fi
if [ -e ./rust/target/release/suricatasc ]; then
SURICATASC=./rust/target/release/suricatasc
else
SURICATASC=./rust/target/debug/suricatasc
fi
RES=0 RES=0
# set first rule file # set first rule file
@ -47,8 +53,7 @@ echo "SURIPID $SURIPID"
cp .github/workflows/live/icmp2.rules suricata.rules cp .github/workflows/live/icmp2.rules suricata.rules
# trigger the reload # trigger the reload
export PYTHONPATH=python/ ${SURICATASC} -c "reload-rules" /var/run/suricata/suricata-command.socket
python3 python/bin/suricatasc -c "reload-rules" /var/run/suricata/suricata-command.socket
sleep 15 sleep 15
@ -59,7 +64,7 @@ if [ $STATSCHECK = false ]; then
RES=1 RES=1
fi fi
python3 python/bin/suricatasc -c "shutdown" /var/run/suricata/suricata-command.socket ${SURICATASC} -c "shutdown" /var/run/suricata/suricata-command.socket
wait $SURIPID wait $SURIPID
echo "done: $RES" echo "done: $RES"

@ -26,6 +26,12 @@ if [ -f eve.json ]; then
rm eve.json rm eve.json
fi fi
if [ -e ./rust/target/release/suricatasc ]; then
SURICATASC=./rust/target/release/suricatasc
else
SURICATASC=./rust/target/debug/suricatasc
fi
RES=0 RES=0
export PYTHONPATH=python/ export PYTHONPATH=python/
@ -65,7 +71,7 @@ if [ $CHECK -ne 1 ]; then
echo "ERROR alerts count off for sid 222 (datasets)" echo "ERROR alerts count off for sid 222 (datasets)"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -v -c "dataset-clear ipv4-list ipv4" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -v -c "dataset-clear ipv4-list ipv4" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
sleep 5 sleep 5
@ -75,7 +81,7 @@ if [ $CHECK -ne 2 ]; then
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "dataset-add ipv6-list ip 192.168.1.1" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "dataset-add ipv6-list ip 192.168.1.1" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
if [ "$(echo $JSON | jq -r .message)" != "data added" ]; then if [ "$(echo $JSON | jq -r .message)" != "data added" ]; then
echo "ERROR unix socket dataset add failed" echo "ERROR unix socket dataset add failed"
@ -83,7 +89,7 @@ if [ "$(echo $JSON | jq -r .message)" != "data added" ]; then
fi fi
# look it up in IPv4 in IPv6 notation # look it up in IPv4 in IPv6 notation
JSON=$(python3 python/bin/suricatasc -c "dataset-lookup ipv6-list ip ::ffff:c0a8:0101" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "dataset-lookup ipv6-list ip ::ffff:c0a8:0101" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
if [ "$(echo $JSON | jq -r .message)" != "item found in set" ]; then if [ "$(echo $JSON | jq -r .message)" != "item found in set" ]; then
echo "ERROR unix socket dataset lookup failed" echo "ERROR unix socket dataset lookup failed"
@ -91,7 +97,7 @@ if [ "$(echo $JSON | jq -r .message)" != "item found in set" ]; then
fi fi
# fail to add junk # fail to add junk
JSON=$(python3 python/bin/suricatasc -c "dataset-add ipv6-list ip ::ffff:c0a8:0z0z" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "dataset-add ipv6-list ip ::ffff:c0a8:0z0z" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
if [ "$(echo $JSON | jq -r .message)" != "failed to add data" ]; then if [ "$(echo $JSON | jq -r .message)" != "failed to add data" ]; then
echo "ERROR unix socket dataset added junk" echo "ERROR unix socket dataset added junk"
@ -104,41 +110,41 @@ echo "SURIPID $SURIPID PINGPID $PINGPID"
cp .github/workflows/live/icmp2.rules suricata.rules cp .github/workflows/live/icmp2.rules suricata.rules
# trigger the reload # trigger the reload
JSON=$(python3 python/bin/suricatasc -c "iface-list" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "iface-list" /var/run/suricata/suricata-command.socket)
PIFACE=$(echo $JSON | jq -r .message.ifaces[0]) PIFACE=$(echo $JSON | jq -r .message.ifaces[0])
JSON=$(python3 python/bin/suricatasc -c "iface-stat $PIFACE") JSON=$(${SURICATASC} -c "iface-stat $PIFACE")
STATSCHECK=$(echo $JSON | jq '.message.pkts > 0') STATSCHECK=$(echo $JSON | jq '.message.pkts > 0')
if [ $STATSCHECK = false ]; then if [ $STATSCHECK = false ]; then
echo "ERROR unix socket stats check failed" echo "ERROR unix socket stats check failed"
RES=1 RES=1
fi fi
python3 python/bin/suricatasc -c "reload-rules" /var/run/suricata/suricata-command.socket ${SURICATASC} -c "reload-rules" /var/run/suricata/suricata-command.socket
JSON=$(python3 python/bin/suricatasc -c "iface-bypassed-stat" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "iface-bypassed-stat" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
JSON=$(python3 python/bin/suricatasc -c "capture-mode" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "capture-mode" /var/run/suricata/suricata-command.socket)
if [ "$(echo $JSON | jq -r .message)" != "PCAP_DEV" ]; then if [ "$(echo $JSON | jq -r .message)" != "PCAP_DEV" ]; then
echo "ERROR unix socket capture mode check failed" echo "ERROR unix socket capture mode check failed"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "dump-counters" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "dump-counters" /var/run/suricata/suricata-command.socket)
STATSCHECK=$(echo $JSON | jq '.message.uptime >= 15') STATSCHECK=$(echo $JSON | jq '.message.uptime >= 15')
if [ $STATSCHECK = false ]; then if [ $STATSCHECK = false ]; then
echo "ERROR unix socket dump-counters uptime check failed" echo "ERROR unix socket dump-counters uptime check failed"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "memcap-list" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "memcap-list" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
JSON=$(python3 python/bin/suricatasc -c "running-mode" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "running-mode" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
if [ "$(echo $JSON | jq -r .message)" != "$RUNMODE" ]; then if [ "$(echo $JSON | jq -r .message)" != "$RUNMODE" ]; then
echo "ERROR unix socket runmode check failed" echo "ERROR unix socket runmode check failed"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "version" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "version" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
JSON=$(python3 python/bin/suricatasc -c "uptime" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "uptime" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
STATSCHECK=$(echo $JSON | jq '.message >= 15') STATSCHECK=$(echo $JSON | jq '.message >= 15')
if [ $STATSCHECK = false ]; then if [ $STATSCHECK = false ]; then
@ -146,7 +152,7 @@ if [ $STATSCHECK = false ]; then
RES=1 RES=1
fi fi
sleep 15 sleep 15
JSON=$(python3 python/bin/suricatasc -c "add-hostbit $GW test 60" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "add-hostbit $GW test 60" /var/run/suricata/suricata-command.socket)
echo $JSON echo $JSON
sleep 15 sleep 15
@ -161,17 +167,17 @@ if [ $SID2CHECK = false ]; then
echo "ERROR no alerts for sid 2" echo "ERROR no alerts for sid 2"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "list-hostbit $GW" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "list-hostbit $GW" /var/run/suricata/suricata-command.socket)
CHECK=$(echo $JSON|jq -r .message.hostbits[0].name) CHECK=$(echo $JSON|jq -r .message.hostbits[0].name)
if [ "$CHECK" != "test" ]; then if [ "$CHECK" != "test" ]; then
echo "ERROR hostbit listing failed" echo "ERROR hostbit listing failed"
RES=1 RES=1
fi fi
JSON=$(python3 python/bin/suricatasc -c "remove-hostbit $GW test" /var/run/suricata/suricata-command.socket) JSON=$(${SURICATASC} -c "remove-hostbit $GW test" /var/run/suricata/suricata-command.socket)
kill -INT $PINGPID kill -INT $PINGPID
wait $PINGPID wait $PINGPID
python3 python/bin/suricatasc -c "shutdown" /var/run/suricata/suricata-command.socket ${SURICATASC} -c "shutdown" /var/run/suricata/suricata-command.socket
wait $SURIPID wait $SURIPID
echo "done: $RES" echo "done: $RES"

@ -20,7 +20,8 @@ VERBOSE=""
UnixCommand () { UnixCommand () {
COMMAND=$1 COMMAND=$1
PYTHONPATH=python/ python3 python/bin/suricatasc -c "${COMMAND}" ${USOCKET} #PYTHONPATH=python/ python3 python/bin/suricatasc -c "${COMMAND}" ${USOCKET}
./rust/target/release/suricatasc -c "${COMMAND}" ${USOCKET}
} }
Start () { Start () {

Loading…
Cancel
Save