Skip to contentSkip to conversation

package/nginx: Add naxsi module option.

PATCH Superseded Adam Duskett 2 participants 3 messages Jul 14, 2016 – Jul 15, 2016

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/nginx: Add naxsi module option.

Naxsi is a third party nginx module reads a small subset of simple rules containing a list of known patterns involved in website vulnerabilities. This module behaves like a DROP-by-default firewall for nginx.

The reason for the changes to the make file was because naxsi is listed on github, and even though there is a option to specify a url for a 3rd party module, this option only seems to work for a local file url.

As such a new comment was added to the menu for external modules, and a new package that downloads and extracts the module was added under package/nginx-naxsi. This is then used with a pre-configure hook to create a soft symbolic link to the source inside of the nginx-source tree.

---
Changes:

v1 - v2:
- Moved naxsi module into a seperate package.

 package/nginx-naxsi/Config.in        |  4 ++++
 package/nginx-naxsi/nginx-naxsi.hash |  1 +
 package/nginx-naxsi/nginx-naxsi.mk   |  5 +++++
 package/nginx/Config.in              |  3 +++
 package/nginx/nginx.mk               | 10 ++++++++++
 5 files changed, 23 insertions(+)
 create mode 100644 package/nginx-naxsi/Config.in
 create mode 100644 package/nginx-naxsi/nginx-naxsi.hash
 create mode 100644 package/nginx-naxsi/nginx-naxsi.mk
package/nginx-naxsi/Config.in new file +4 -0
new file mode 100644
index 0000000..8d88833
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_NGINX_NAXSI
+	bool "ngx_http_naxsi_module"
+	help
+	  Enable ngx_http_naxsi_module
package/nginx-naxsi/nginx-naxsi.hash new file +1 -0
new file mode 100644
index 0000000..dd7f5cd
@@ -0,0 +1 @@
+sha256	9cc2c09405bc71f78ef26a8b6d70afcea3fccbe8125df70cb0cfc480133daba5	0.54.tar.gz
package/nginx-naxsi/nginx-naxsi.mk new file +5 -0
new file mode 100644
index 0000000..9a284ff
@@ -0,0 +1,5 @@
+NGINX_NAXSI_VERSION = 0.54
+NGINX_NAXSI_SOURCE = $(NGINX_NAXSI_VERSION).tar.gz
+NGINX_NAXSI_SITE = $(call github,nbs-system,naxsi,$(NGINX_NAXSI_SOURCE))
+
+$(eval $(generic-package))
package/nginx/Config.in +3 -0
index e6f2d96..c1a3394 100644
@@ -380,4 +380,7 @@ config BR2_PACKAGE_NGINX_ADD_MODULES
 	help
 	  Space separated list of urls of the additional modules
 
+comment "external modules"
+	source "package/nginx-naxsi/Config.in"
+
 endif
package/nginx/nginx.mk +10 -0
index 5eb5488..bc895fe 100644
@@ -156,6 +156,12 @@ else
 NGINX_CONF_OPTS += --without-http_gzip_module
 endif
 
+ifeq ($(BR2_PACKAGE_NGINX_NAXSI),y)
+NGINX_DEPENDENCIES += nginx-naxsi
+NGINX_PRE_CONFIGURE_HOOKS += NGINX_NAXSI_LINK
+NGINX_CONF_OPTS += $(addprefix --add-module=,$(call qstrip,$(@D)/nginx-naxsi-$(NGINX_NAXSI_VERSION)/naxsi_src))
+endif
+
 ifeq ($(BR2_PACKAGE_NGINX_HTTP_REWRITE_MODULE),y)
 NGINX_DEPENDENCIES += pcre
 else
@@ -241,6 +247,10 @@ define NGINX_DISABLE_WERROR
 	$(SED) 's/-Werror//g' -i $(@D)/auto/cc/*
 endef
 
+define NGINX_NAXSI_LINK
+	ln -fs $(BUILD_DIR)/nginx-naxsi-$(NGINX_NAXSI_VERSION)/ $(@D)
+endef
+
 NGINX_PRE_CONFIGURE_HOOKS += NGINX_DISABLE_WERROR
 
 define NGINX_CONFIGURE_CMDS
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 package/nginx: Add naxsi module option.

Adam,

Quoted 36 lines · Adam Duskett

Naxsi is a third party nginx module reads a small subset of simple rules containing a list of known patterns involved in website vulnerabilities. This module behaves like a DROP-by-default firewall for nginx.

The reason for the changes to the make file was because naxsi is listed on github, and even though there is a option to specify a url for a 3rd party module, this option only seems to work for a local file url.

As such a new comment was added to the menu for external modules, and a new package that downloads and extracts the module was added under package/nginx-naxsi. This is then used with a pre-configure hook to create a soft symbolic link to the source inside of the nginx-source tree.

---
Changes:

v1 - v2:
- Moved naxsi module into a seperate package.

 package/nginx-naxsi/Config.in        |  4 ++++
 package/nginx-naxsi/nginx-naxsi.hash |  1 +
 package/nginx-naxsi/nginx-naxsi.mk   |  5 +++++
 package/nginx/Config.in              |  3 +++
 package/nginx/nginx.mk               | 10 ++++++++++
 5 files changed, 23 insertions(+)
 create mode 100644 package/nginx-naxsi/Config.in
 create mode 100644 package/nginx-naxsi/nginx-naxsi.hash
 create mode 100644 package/nginx-naxsi/nginx-naxsi.mk
package/nginx-naxsi/Config.in new file +0 -0
new file mode 100644
index 0000000..8d88833

package/nginx-naxsi/Config.in line 4

Quoted 4 lines
package/nginx-naxsi/Config.in new file +4 -0
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_NGINX_NAXSI
+       bool "ngx_http_naxsi_module"
+       help
+         Enable ngx_http_naxsi_module

No URL to https://github.com/nbs-system/naxsi ?

Quoted 13 lines
package/nginx-naxsi/nginx-naxsi.hash new file +1 -0
new file mode 100644
index 0000000..dd7f5cd
@@ -0,0 +1 @@
+sha256 9cc2c09405bc71f78ef26a8b6d70afcea3fccbe8125df70cb0cfc480133daba5        0.54.tar.gz
package/nginx-naxsi/nginx-naxsi.mk new file +0 -0
new file mode 100644
index 0000000..9a284ff

package/nginx-naxsi/nginx-naxsi.mk line 3

Quoted 3 lines
package/nginx-naxsi/nginx-naxsi.mk new file +3 -0
@@ -0,0 +1,5 @@
+NGINX_NAXSI_VERSION = 0.54
+NGINX_NAXSI_SOURCE = $(NGINX_NAXSI_VERSION).tar.gz
+NGINX_NAXSI_SITE = $(call github,nbs-system,naxsi,$(NGINX_NAXSI_SOURCE))

No title comment?

Licensing? I'm thinking:

NGINX_NAXSI_LICENSE = GPLv3
NGINX_NAXSI_LICENSE_FILES = LICENSE

Quoted 32 lines
package/nginx-naxsi/nginx-naxsi.mk new file +2 -0
+
+$(eval $(generic-package))
package/nginx/Config.in +3 -0
index e6f2d96..c1a3394 100644
@@ -380,4 +380,7 @@ config BR2_PACKAGE_NGINX_ADD_MODULES
        help
          Space separated list of urls of the additional modules
 
+comment "external modules"
+       source "package/nginx-naxsi/Config.in"
+
 endif
package/nginx/nginx.mk +6 -0
index 5eb5488..bc895fe 100644
@@ -156,6 +156,12 @@ else
 NGINX_CONF_OPTS += --without-http_gzip_module
 endif
 
+ifeq ($(BR2_PACKAGE_NGINX_NAXSI),y)
+NGINX_DEPENDENCIES += nginx-naxsi
+NGINX_PRE_CONFIGURE_HOOKS += NGINX_NAXSI_LINK
+NGINX_CONF_OPTS += $(addprefix --add-module=,$(call qstrip,$(@D)/nginx-naxsi-$(NGINX_NAXSI_VERSION)/naxsi_src))
+endif
+
 ifeq ($(BR2_PACKAGE_NGINX_HTTP_REWRITE_MODULE),y)
 NGINX_DEPENDENCIES += pcre
 else

package/nginx/nginx.mk define NGINX_DISABLE_WERROR · line 253

Quoted 7 lines
package/nginx/nginx.mk +4 -0
@@ -241,6 +247,10 @@ define NGINX_DISABLE_WERROR
        $(SED) 's/-Werror//g' -i $(@D)/auto/cc/*
 endef
 
+define NGINX_NAXSI_LINK
+       ln -fs $(BUILD_DIR)/nginx-naxsi-$(NGINX_NAXSI_VERSION)/ $(@D)
+endef
+

We have several ngx_* packages (ngx_echo, ngx_lua, ngx_devel), and were able to add them this way, without a symlink:

ifeq ($(BR2_PACKAGE_NGINX_NAXSI),y) NGINX_DEPENDENCIES += nginx-naxsi NGINX_CONF_OPTS += --add-module=$(NGINX_NAXSI_DIR) endif

That is, using the ${PKG}_DIR automatically supplied by generic-package.

Regards,
Danomi -

Quoted 10 lines
package/nginx/nginx.mk +0 -1
 NGINX_PRE_CONFIGURE_HOOKS += NGINX_DISABLE_WERROR
 
 define NGINX_CONFIGURE_CMDS
--

2.7.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#2 lore raw

PATCH v2 1/1 package/nginx: Add naxsi module option.

Quoted 33 lines · Danomi Manchego

Adam,

Quoted 30 lines · Adam Duskett

Naxsi is a third party nginx module reads a small subset of simple rules containing a list of known patterns involved in website vulnerabilities. This module behaves like a DROP-by-default firewall for nginx.

The reason for the changes to the make file was because naxsi is listed on github, and even though there is a option to specify a url for a 3rd party module, this option only seems to work for a local file url.

As such a new comment was added to the menu for external modules, and a new package that downloads and extracts the module was added under package/nginx-naxsi. This is then used with a pre-configure hook to create a soft symbolic link to the source inside of the nginx-source tree.

---
Changes:

v1 - v2:
- Moved naxsi module into a seperate package.

 package/nginx-naxsi/Config.in        |  4 ++++
 package/nginx-naxsi/nginx-naxsi.hash |  1 +
 package/nginx-naxsi/nginx-naxsi.mk   |  5 +++++
 package/nginx/Config.in              |  3 +++
 package/nginx/nginx.mk               | 10 ++++++++++
 5 files changed, 23 insertions(+)
 create mode 100644 package/nginx-naxsi/Config.in
 create mode 100644 package/nginx-naxsi/nginx-naxsi.hash
 create mode 100644 package/nginx-naxsi/nginx-naxsi.mk
Quoted 12 lines

package/nginx-naxsi/Config.in line 4

Quoted 10 lines
package/nginx-naxsi/Config.in new file +4 -0
new file mode 100644
index 0000000..8d88833
@@ -0,0 +1,4 @@
+config BR2_PACKAGE_NGINX_NAXSI
+       bool "ngx_http_naxsi_module"
+       help
+         Enable ngx_http_naxsi_module

No URL to https://github.com/nbs-system/naxsi ?

Fair enough, I will fix this.

Quoted 20 lines
Quoted 14 lines
package/nginx-naxsi/nginx-naxsi.hash new file +1 -0
new file mode 100644
index 0000000..dd7f5cd
@@ -0,0 +1 @@
+sha256 9cc2c09405bc71f78ef26a8b6d70afcea3fccbe8125df70cb0cfc480133daba5        0.54.tar.gz
package/nginx-naxsi/nginx-naxsi.mk new file +0 -0
new file mode 100644
index 0000000..9a284ff

package/nginx-naxsi/nginx-naxsi.mk line 3

Quoted 3 lines
package/nginx-naxsi/nginx-naxsi.mk new file +3 -0
@@ -0,0 +1,5 @@
+NGINX_NAXSI_VERSION = 0.54
+NGINX_NAXSI_SOURCE = $(NGINX_NAXSI_VERSION).tar.gz
+NGINX_NAXSI_SITE = $(call github,nbs-system,naxsi,$(NGINX_NAXSI_SOURCE))

No title comment?

Quoted 5 lines

Licensing? I'm thinking:

NGINX_NAXSI_LICENSE = GPLv3
NGINX_NAXSI_LICENSE_FILES = LICENSE

This would be correct, I will fix that as well.

Quoted 44 lines
Quoted 33 lines
package/nginx-naxsi/nginx-naxsi.mk new file +2 -0
+
+$(eval $(generic-package))
package/nginx/Config.in +3 -0
index e6f2d96..c1a3394 100644
@@ -380,4 +380,7 @@ config BR2_PACKAGE_NGINX_ADD_MODULES
        help
          Space separated list of urls of the additional modules
 
+comment "external modules"
+       source "package/nginx-naxsi/Config.in"
+
 endif
package/nginx/nginx.mk +6 -0
index 5eb5488..bc895fe 100644
@@ -156,6 +156,12 @@ else
 NGINX_CONF_OPTS += --without-http_gzip_module
 endif
 
+ifeq ($(BR2_PACKAGE_NGINX_NAXSI),y)
+NGINX_DEPENDENCIES += nginx-naxsi
+NGINX_PRE_CONFIGURE_HOOKS += NGINX_NAXSI_LINK
+NGINX_CONF_OPTS += $(addprefix --add-module=,$(call qstrip,$(@D)/nginx-naxsi-$(NGINX_NAXSI_VERSION)/naxsi_src))
+endif
+
 ifeq ($(BR2_PACKAGE_NGINX_HTTP_REWRITE_MODULE),y)
 NGINX_DEPENDENCIES += pcre
 else

package/nginx/nginx.mk define NGINX_DISABLE_WERROR · line 253

Quoted 7 lines
package/nginx/nginx.mk +4 -0
@@ -241,6 +247,10 @@ define NGINX_DISABLE_WERROR
        $(SED) 's/-Werror//g' -i $(@D)/auto/cc/*
 endef
 
+define NGINX_NAXSI_LINK
+       ln -fs $(BUILD_DIR)/nginx-naxsi-$(NGINX_NAXSI_VERSION)/ $(@D)
+endef
+

We have several ngx_* packages (ngx_echo, ngx_lua, ngx_devel), and were able to add them this way, without a symlink:

Quoted 7 lines

ifeq ($(BR2_PACKAGE_NGINX_NAXSI),y) NGINX_DEPENDENCIES += nginx-naxsi NGINX_CONF_OPTS += --add-module=$(NGINX_NAXSI_DIR) endif

That is, using the ${PKG}_DIR automatically supplied by generic-package.

I will look into this.
As for

Quoted 14 lines

Regards,
Danomi -

Quoted 10 lines
package/nginx/nginx.mk +0 -1
 NGINX_PRE_CONFIGURE_HOOKS += NGINX_DISABLE_WERROR
 
 define NGINX_CONFIGURE_CMDS
--

2.7.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot