From faaee67199b7ac4d170fd8383166e9ce5ddc6da7 Mon Sep 17 00:00:00 2001 From: Mason Simon Date: Tue, 29 May 2018 10:22:10 -0700 Subject: [PATCH] Support for checking for updates --- Makefile | 3 +++ README.md | 10 ++++++++-- script/check-up-to-date.sh | 12 ++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 script/check-up-to-date.sh diff --git a/Makefile b/Makefile index 2899844..ebd4dfb 100644 --- a/Makefile +++ b/Makefile @@ -61,3 +61,6 @@ run-demo: docker build -t ipscrub . docker build -t ipscrub-demo-client demo/ docker-compose up --abort-on-container-exit + +check-up-to-date: script/check-up-to-date.sh + $< diff --git a/README.md b/README.md index 5893498..104f495 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Scenario (2) is defended against because the server operator does not know the s `ipscrub` can be built statically with nginx or as a [dynamic module](https://www.nginx.com/blog/compiling-dynamic-modules-nginx-plus/). See the `Makefile` for examples of both ways. -### Configuration +#### Configuration In your `nginx.conf`, @@ -52,10 +52,16 @@ In your `nginx.conf`, **NOTE**: nginx may still leak IP addresses in the error log. If this is a concern, disable error logging or wipe the log regularly. -### Running Tests +#### Running Tests `make test` +#### Checking for Updates + +`make check-up-to-date` + +This will have a non-zero exit code if you aren't up-to-date, so you can automate regular checks. + ### Changelog - 1.0.1 fixed vulnerability to unmasking hashed IPs (thanks to [@marcan](https://github.com/marcan)) diff --git a/script/check-up-to-date.sh b/script/check-up-to-date.sh new file mode 100755 index 0000000..a15e09a --- /dev/null +++ b/script/check-up-to-date.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +echo "Checking..." +latest=`curl "https://api.github.com/repos/masonicboom/ipscrub/releases/latest" 2>/dev/null | grep --extended-regexp -o "\"tag_name\":\s+\".*\"" | cut -d '"' -f 4` +current=`git tag | sort | tail -n 1` + +if [ $current != $latest ]; then + echo "Current version is $current; latest is $latest. Check https://github.com/masonicboom/ipscrub/releases to see if you should update." + exit 1 +else + echo "You are on the latest version of ipscrub ($current)." +fi \ No newline at end of file