Skip to contentSkip to conversation

package/libhtp: new package

PATCH New Fabrice Fontaine 2 participants 5 messages Mar 14, 2019 – Apr 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/libhtp: new package

LibHTP is a security-aware parser for the HTTP protocol and the related bits and pieces.

https://github.com/OISF/libhtp

---
 DEVELOPERS                                         |  1 +
 package/Config.in                                  |  1 +
 .../0001-fix-build-without-GNU-libiconv.patch      | 60 ++++++++++++++++++++++
 package/libhtp/Config.in                           |  9 ++++
 package/libhtp/libhtp.hash                         |  3 ++
 package/libhtp/libhtp.mk                           | 20 ++++++++
 6 files changed, 94 insertions(+)
 create mode 100644 package/libhtp/0001-fix-build-without-GNU-libiconv.patch
 create mode 100644 package/libhtp/Config.in
 create mode 100644 package/libhtp/libhtp.hash
 create mode 100644 package/libhtp/libhtp.mk
DEVELOPERS +1 -0
index 36e2295d2d..24737b858f 100644
@@ -784,6 +784,7 @@ F:	package/libgee/
 F:	package/libglib2/
 F:	package/libgtk2/
 F:	package/libgtk3/
+F:	package/libhtp/
 F:	package/libidn/
 F:	package/libidn2/
 F:	package/libjpeg/
package/Config.in +1 -0
index 85a37f2c0b..bb57afab08 100644
@@ -1534,6 +1534,7 @@ menu "Networking"
 	source "package/libeXosip2/Config.in"
 	source "package/libfcgi/Config.in"
 	source "package/libgsasl/Config.in"
+	source "package/libhtp/Config.in"
 	source "package/libhttpparser/Config.in"
 	source "package/libidn/Config.in"
 	source "package/libidn2/Config.in"
package/libhtp/0001-fix-build-without-GNU-libiconv.patch new file +60 -0

60 lines not on this page · raw message

package/libhtp/Config.in new file +9 -0
new file mode 100644
index 0000000000..98b9e2adea
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_LIBHTP
+	bool "libhtp"
+	select BR2_PACKAGE_LIBICONV if !BR2_ENABLE_LOCALE
+	select BR2_PACKAGE_ZLIB
+	help
+	  LibHTP is a security-aware parser for the HTTP protocol and
+	  the related bits and pieces.
+
+	  https://github.com/OISF/libhtp
package/libhtp/libhtp.hash new file +3 -0
new file mode 100644
index 0000000000..be68547be2
@@ -0,0 +1,3 @@
+# Locally computed:
+sha256	7384f8461ad0431e9247c49b37a73929b284f39408d1f11b80949b188069b638	libhtp-0.5.30.tar.gz
+sha256	87c93904e5434c81622ea690c2b90097b9f162aaa92a96542649a157dbf98d15	LICENSE
package/libhtp/libhtp.mk new file +20 -0
new file mode 100644
index 0000000000..7606684b31
@@ -0,0 +1,20 @@
+################################################################################
+#
+# libhtp
+#
+################################################################################
+
+LIBHTP_VERSION = 0.5.30
+LIBHTP_SITE = $(call github,OISF,libhtp,$(LIBHTP_VERSION))
+LIBHTP_LICENSE = BSD-3-Clause
+LIBHTP_LICENSE_FILES = LICENSE 
+LIBHTP_DEPENDENCIES = \
+	$(if $(BR2_PACKAGE_LIBICONV),libiconv) \
+	zlib
+LIBHTP_INSTALL_STAGING = YES
+# From git
+LIBHTP_AUTORECONF = YES
+
+LIBHTP_CONF_ENV = NO_STACK_PROTECTOR=$(if $(BR2_TOOLCHAIN_HAS_SSP),no,true)
+
+$(eval $(autotools-package))
Signature · 1 line
2.14.1
#1 lore raw

PATCH 2/2 package/suricata: new package

Suricata is a free and open source, mature, fast and robust network threat detection engine.

The Suricata engine is capable of real time intrusion detection (IDS), inline intrusion prevention (IPS), network security monitoring (NSM) and offline pcap processing.

https://suricata-ids.org

---
 DEVELOPERS                        |   1 +
 package/Config.in                 |   1 +
 package/suricata/Config.in        |  22 +++++++
 package/suricata/S99suricata      |  39 ++++++++++++
 package/suricata/suricata.hash    |   6 ++
 package/suricata/suricata.mk      | 131 ++++++++++++++++++++++++++++++++++++++
 package/suricata/suricata.service |  13 ++++
 7 files changed, 213 insertions(+)
 create mode 100644 package/suricata/Config.in
 create mode 100644 package/suricata/S99suricata
 create mode 100644 package/suricata/suricata.hash
 create mode 100644 package/suricata/suricata.mk
 create mode 100644 package/suricata/suricata.service
DEVELOPERS +1 -0
index 24737b858f..a9bec63849 100644
@@ -818,6 +818,7 @@ F:	package/oprofile/
 F:	package/pcmanfm/
 F:	package/rygel/
 F:	package/safeclib/
+F:	package/suricata/
 F:	package/tinycbor/
 F:	package/tinydtls/
 F:	package/tinymembench/
package/Config.in +1 -0
index bb57afab08..4538ac8307 100644
@@ -2018,6 +2018,7 @@ endif
 	source "package/sslh/Config.in"
 	source "package/strongswan/Config.in"
 	source "package/stunnel/Config.in"
+	source "package/suricata/Config.in"
 	source "package/tcpdump/Config.in"
 	source "package/tcping/Config.in"
 	source "package/tcpreplay/Config.in"
package/suricata/Config.in new file +22 -0
new file mode 100644
index 0000000000..2add34956e
@@ -0,0 +1,22 @@
+config BR2_PACKAGE_SURICATA
+	bool "suricata"
+	depends on BR2_USE_MMU # fork()
+	depends on BR2_USE_WCHAR
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	select BR2_PACKAGE_LIBHTP
+	select BR2_PACKAGE_LIBPCAP
+	select BR2_PACKAGE_LIBYAML
+	select BR2_PACKAGE_PCRE
+	help
+	  Suricata is a free and open source, mature, fast and robust
+	  network threat detection engine.
+
+	  The Suricata engine is capable of real time intrusion
+	  detection (IDS), inline intrusion prevention (IPS), network
+	  security monitoring (NSM) and offline pcap processing.
+
+	  https://suricata-ids.org
+
+comment "suricata needs a toolchain w/ wchar, threads"
+	depends on BR2_USE_MMU
+	depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS
package/suricata/S99suricata new file +39 -0
new file mode 100644
index 0000000000..35a034b179
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+NAME=suricata
+PIDFILE=/var/run/$NAME.pid
+DAEMON=/usr/bin/$NAME
+DAEMON_ARGS="-c /etc/suricata/suricata.yaml -i eth0"
+
+start() {
+	printf "Starting $NAME: "
+	mkdir -p /var/log/suricata
+	start-stop-daemon -S -q -m -b -p $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
+	[ $? = 0 ] && echo "OK" || echo "FAIL"
+}
+stop() {
+	printf "Stopping $NAME: "
+	start-stop-daemon -K -q -p $PIDFILE
+	[ $? = 0 ] && echo "OK" || echo "FAIL"
+}
+restart() {
+	stop
+	start
+}
+
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  restart|reload)
+	restart
+	;;
+  *)
+	echo "Usage: $0 {start|stop|restart}"
+	exit 1
+esac
+
+exit $?
package/suricata/suricata.hash new file +6 -0
new file mode 100644
index 0000000000..44ada0115a
@@ -0,0 +1,6 @@
+# Locally computed:
+sha256 6cda6c80b753ce36483c6be535358b971f3890b9aa27a58c2d2f7e89dd6c6aa0  suricata-4.1.3.tar.gz
+
+# Hash for license files:
+sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643  COPYING
+sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643  LICENSE
package/suricata/suricata.mk new file +131 -0

131 lines not on this page · raw message

package/suricata/suricata.service new file +13 -0
new file mode 100644
index 0000000000..ca0be02dae
@@ -0,0 +1,13 @@
+[Unit]
+Description=Suricata Intrusion Detection Service
+After=network.target
+
+[Service]
+ExecStartPre=/bin/rm -f /var/run/suricata.pid
+ExecStartPre=/usr/bin/mkdir -p /var/log/suricata
+ExecStart=/usr/bin/suricata -c /etc/suricata/suricata.yaml -i eth0 --pidfile /var/run/suricata.pid
+ExecReload=/bin/kill -USR2 $MAINPID
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/2 package/suricata: new package

Hello Fabrice,

Quoted 10 lines · On Thu, 14 Mar 2019 22:26:00 +0100 Fabrice Fontaine…

Suricata is a free and open source, mature, fast and robust network threat detection engine.

The Suricata engine is capable of real time intrusion detection (IDS), inline intrusion prevention (IPS), network security monitoring (NSM) and offline pcap processing.

https://suricata-ids.org

Overall looks good. I was about to commit, but I have some doubts about the systemd unit, and therefore will take advantage of those doubts to also make a few comments about other aspects.

package/suricata/S99suricata

Quoted 5 lines
package/suricata/S99suricata new file +0 -0
new file mode 100644
index 0000000000..35a034b179

In terms of init scripts, package/busybox/S02klogd is now the "reference". I recommend following this example.

package/suricata/S99suricata line 6

Quoted 7 lines
package/suricata/S99suricata new file +6 -0
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+NAME=suricata
+PIDFILE=/var/run/$NAME.pid
+DAEMON=/usr/bin/$NAME
+DAEMON_ARGS="-c /etc/suricata/suricata.yaml -i eth0"

You clearly want to include a /etc/default/${DAEMON} file. DAEMON should be just the name of the program, see S02klogd.

package/suricata/S99suricata line 36

Quoted 13 lines
package/suricata/S99suricata new file +13 -0
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  restart|reload)
+	restart
+	;;
+  *)
+	echo "Usage: $0 {start|stop|restart}"
+	exit 1

Please follow the indentation style of S02klogd.

package/suricata/S99suricata line 25

Quoted 6 lines
package/suricata/S99suricata new file +6 -0
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+SURICATA_CONF_OPTS += --enable-python
+SURICATA_DEPENDENCIES += python
+else
+SURICATA_CONF_OPTS += --disable-python
+endif

So only Python 2.x is supported ?

package/suricata/S99suricata line 30

Quoted 5 lines
package/suricata/S99suricata new file +5 -0
+ifeq ($(BR2_TOOLCHAIN_HAS_SSP),y)
+SURICATA_CONF_OPTS += --enable-gccprotect
+else
+SURICATA_CONF_OPTS += --disable-gccprotect
+endif

We should unconditionally use --disable-gccprotect and let our gcc/wrapper pass the appropriate SSP/hardening options.

Quoted 6 lines
package/suricata/suricata.service new file +0 -0
new file mode 100644
index 0000000000..ca0be02dae

package/suricata/suricata.service line 9

Quoted 9 lines
package/suricata/suricata.service new file +9 -0
@@ -0,0 +1,13 @@
+[Unit]
+Description=Suricata Intrusion Detection Service
+After=network.target
+
+[Service]
+ExecStartPre=/bin/rm -f /var/run/suricata.pid
+ExecStartPre=/usr/bin/mkdir -p /var/log/suricata
+ExecStart=/usr/bin/suricata -c /etc/suricata/suricata.yaml -i eth0 --pidfile /var/run/suricata.pid
+ExecReload=/bin/kill -USR2 $MAINPID

I am a bit skeptical about the PID file handling. How is systemd going to know that the PID file is /var/run/suricata.pid ? Is this useful in the context of systemd ?

I'm by no means not a systemd expert, but this seems weird to me. If a systemd-person could give more details about this, it would be nice.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 2/2 package/suricata: new package

Hello Thomas,

Le sam. 13 avr. 2019 ? 22:53, Thomas Petazzoni
<[email protected]> a ?crit :

Quoted 21 lines

Hello Fabrice,

Quoted 10 lines · On Thu, 14 Mar 2019 22:26:00 +0100 Fabrice Fontaine…

Suricata is a free and open source, mature, fast and robust network threat detection engine.

The Suricata engine is capable of real time intrusion detection (IDS), inline intrusion prevention (IPS), network security monitoring (NSM) and offline pcap processing.

https://suricata-ids.org

Overall looks good. I was about to commit, but I have some doubts about the systemd unit, and therefore will take advantage of those doubts to also make a few comments about other aspects.

Quoted 8 lines

package/suricata/S99suricata

Quoted 5 lines
package/suricata/S99suricata new file +0 -0
new file mode 100644
index 0000000000..35a034b179

In terms of init scripts, package/busybox/S02klogd is now the "reference". I recommend following this example.

OK, updated in v2

Quoted 26 lines

package/suricata/S99suricata line 6

Quoted 8 lines
package/suricata/S99suricata new file +6 -0
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+NAME=suricata
+PIDFILE=/var/run/$NAME.pid
+DAEMON=/usr/bin/$NAME
+DAEMON_ARGS="-c /etc/suricata/suricata.yaml -i eth0"

You clearly want to include a /etc/default/${DAEMON} file. DAEMON should be just the name of the program, see S02klogd.

package/suricata/S99suricata line 36

Quoted 13 lines
package/suricata/S99suricata new file +13 -0
+case "$1" in
+  start)
+     start
+     ;;
+  stop)
+     stop
+     ;;
+  restart|reload)
+     restart
+     ;;
+  *)
+     echo "Usage: $0 {start|stop|restart}"
+     exit 1
Quoted 1 line

Please follow the indentation style of S02klogd.

OK

Quoted 10 lines

package/suricata/S99suricata line 25

Quoted 8 lines
package/suricata/S99suricata new file +6 -0
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+SURICATA_CONF_OPTS += --enable-python
+SURICATA_DEPENDENCIES += python
+else
+SURICATA_CONF_OPTS += --disable-python
+endif

So only Python 2.x is supported ?

python3 is also supported, I updated v2.

Quoted 9 lines

package/suricata/S99suricata line 30

Quoted 6 lines
package/suricata/S99suricata new file +5 -0
+ifeq ($(BR2_TOOLCHAIN_HAS_SSP),y)
+SURICATA_CONF_OPTS += --enable-gccprotect
+else
+SURICATA_CONF_OPTS += --disable-gccprotect
+endif

We should unconditionally use --disable-gccprotect and let our gcc/wrapper pass the appropriate SSP/hardening options.

OK

Quoted 12 lines
Quoted 12 lines
package/suricata/suricata.service new file +5 -0
new file mode 100644
index 0000000000..ca0be02dae
@@ -0,0 +1,13 @@
+[Unit]
+Description=Suricata Intrusion Detection Service
+After=network.target
+
+[Service]
Quoted 8 lines

package/suricata/suricata.service line 9

Quoted 4 lines
package/suricata/suricata.service new file +4 -0
+ExecStartPre=/bin/rm -f /var/run/suricata.pid
+ExecStartPre=/usr/bin/mkdir -p /var/log/suricata
+ExecStart=/usr/bin/suricata -c /etc/suricata/suricata.yaml -i eth0 --pidfile /var/run/suricata.pid
+ExecReload=/bin/kill -USR2 $MAINPID

I am a bit skeptical about the PID file handling. How is systemd going to know that the PID file is /var/run/suricata.pid ? Is this useful in the context of systemd ?

I followed the template given by upstream in
https://github.com/OISF/suricata/blob/ec77632e84a106ddbcd0baef4e4368b4fe5c5f9e/etc/suricata.service.in

I updated v2 to add an EnvironmentFile to /etc/default/suricata. Concerning the PID, it works because $MAINPID is an internal systemd variable that save the same value than the /var/run/suricata.pid file because we didn't ask systemd to fork suricata.

Quoted 11 lines

I'm by no means not a systemd expert, but this seems weird to me. If a systemd-person could give more details about this, it would be nice.

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#4 lore raw

PATCH 1/2 package/libhtp: new package

In reply to Fabrice Fontaine

Hello Fabrice,

package/libhtp/libhtp.mk line 10

Quoted 4 lines · On Thu, 14 Mar 2019 22:25:59 +0100 Fabrice Fontaine…
package/libhtp/libhtp.mk new file +4 -0
+LIBHTP_VERSION = 0.5.30
+LIBHTP_SITE = $(call github,OISF,libhtp,$(LIBHTP_VERSION))
+LIBHTP_LICENSE = BSD-3-Clause
+LIBHTP_LICENSE_FILES = LICENSE 

There was a trailing white space on this line.

package/libhtp/libhtp.mk line 18

Quoted 8 lines
package/libhtp/libhtp.mk new file +8 -0
+LIBHTP_DEPENDENCIES = \
+	$(if $(BR2_PACKAGE_LIBICONV),libiconv) \
+	zlib
+LIBHTP_INSTALL_STAGING = YES
+# From git
+LIBHTP_AUTORECONF = YES
+
+LIBHTP_CONF_ENV = NO_STACK_PROTECTOR=$(if $(BR2_TOOLCHAIN_HAS_SSP),no,true)

I changed to:

LIBHTP_CONF_ENV = NO_STACK_PROTECTOR=true

indeed, our policy is that we prefer to have our gcc/wrapper handle SSP support by passing the appropriate flags.

Applied with those changes. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com