From 98c4ac2fa5a3917804d5824b7e6ca66b19327733 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Sat, 26 May 2018 10:55:25 -0700 Subject: [PATCH 1/3] php: 7.2.5 -> 7.2.6 Semi-automatic update generated by https://github.com/ryantm/nixpkgs-update tools. This update was made based on information from https://repology.org/metapackage/php/versions. These checks were done: - built on NixOS - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/phar.phar passed the binary check. - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/phar passed the binary check. - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/php passed the binary check. - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/phpdbg passed the binary check. - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/php-cgi passed the binary check. - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/pear passed the binary check. - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/peardev passed the binary check. - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/pecl passed the binary check. - /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6/bin/php-fpm passed the binary check. - 9 of 9 passed binary check by having a zero exit code. - 0 of 9 passed binary check by having the new version present in output. - found 7.2.6 with grep in /nix/store/25l2hz7njpg9glpmslcadkgqwai5f77s-php-7.2.6 - directory tree listing: https://gist.github.com/409d2cfaa7e805714825281fbaba0d0f - du listing: https://gist.github.com/7fbd8e3d56524f70b3dfb94c045fccd2 --- pkgs/development/interpreters/php/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/interpreters/php/default.nix b/pkgs/development/interpreters/php/default.nix index 94e1e5f1b69..0e161b0e3f7 100644 --- a/pkgs/development/interpreters/php/default.nix +++ b/pkgs/development/interpreters/php/default.nix @@ -353,7 +353,7 @@ in { }; php72 = generic { - version = "7.2.5"; - sha256 = "0cb0g64mzkir81js27vjwqr8vh043f62ynqvds5n4ygsivx0x0pk"; + version = "7.2.6"; + sha256 = "1hzj1z6v1ij4f4zjl1giix9qinf20wyn9gf8s29x5fc0va53wpdf"; }; } From f12f058a85b8bb1e48d4f7fec69637b93cea747d Mon Sep 17 00:00:00 2001 From: Michiel Leenaars Date: Wed, 30 May 2018 18:10:36 +0200 Subject: [PATCH 2/3] morty: init -> 0.2.0 --- pkgs/servers/web-apps/morty/default.nix | 41 ++++++++++++++++++ pkgs/servers/web-apps/morty/deps.nix | 57 +++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 100 insertions(+) create mode 100644 pkgs/servers/web-apps/morty/default.nix create mode 100644 pkgs/servers/web-apps/morty/deps.nix diff --git a/pkgs/servers/web-apps/morty/default.nix b/pkgs/servers/web-apps/morty/default.nix new file mode 100644 index 00000000000..eeb19f81c54 --- /dev/null +++ b/pkgs/servers/web-apps/morty/default.nix @@ -0,0 +1,41 @@ +{ stdenv, buildGoPackage, fetchgit }: + +buildGoPackage rec { + name = "morty-${version}"; + version = "0.2.0"; + + goPackagePath = "github.com/asciimoo/morty"; + + src = fetchgit { + rev = "v${version}"; + url = "https://github.com/asciimoo/morty"; + sha256 = "1wvrdlwbpzizfg7wrcfyf1x6qllp3aw425n88z516wc9jalfqrrm"; + }; + + goDeps = ./deps.nix; + + meta = with stdenv.lib; { + homepage = "https://github.com/asciimoo/morty"; + maintainers = with maintainers; [ leenaars ]; + description = "Privacy aware web content sanitizer proxy as a service"; + longDescription = '' + Morty is a web content sanitizer proxy as a service. It rewrites web + pages to exclude malicious HTML tags and attributes. It also replaces + external resource references to prevent third party information leaks. + + The main goal of morty is to provide a result proxy for searx, but it + can be used as a standalone sanitizer service too. + + Features: + + * HTML sanitization + * Rewrites HTML/CSS external references to locals + * JavaScript blocking + * No Cookies forwarded + * No Referrers + * No Caching/Etag + * Supports GET/POST forms and IFrames + * Optional HMAC URL verifier key to prevent service abuse +''; + }; +} diff --git a/pkgs/servers/web-apps/morty/deps.nix b/pkgs/servers/web-apps/morty/deps.nix new file mode 100644 index 00000000000..643fc5bb763 --- /dev/null +++ b/pkgs/servers/web-apps/morty/deps.nix @@ -0,0 +1,57 @@ +# This file was generated by https://github.com/kamilchm/go2nix v1.2.1 +[ + { + goPackagePath = "github.com/klauspost/compress"; + fetch = { + type = "git"; + url = "https://github.com/klauspost/compress"; + rev = "5698df94daded084fa836b7df2ffbf6cbd3dd63a"; + sha256 = "1jligmzsyv08dysdaih3r95ki0dqnay9wlzganl4r0mamwhq22wz"; + }; + } + { + goPackagePath = "github.com/klauspost/cpuid"; + fetch = { + type = "git"; + url = "https://github.com/klauspost/cpuid"; + rev = "ae832f27941af41db13bd6d8efd2493e3b22415a"; + sha256 = "1h46y0lbzx0zjdnwbh0znf2ghgbvpzk1p269kkn7v8645xk3apk9"; + }; + } + { + goPackagePath = "github.com/valyala/bytebufferpool"; + fetch = { + type = "git"; + url = "https://github.com/valyala/bytebufferpool"; + rev = "e746df99fe4a3986f4d4f79e13c1e0117ce9c2f7"; + sha256 = "01lqzjddq6kz9v41nkky7wbgk7f1cw036sa7ldz10d82g5klzl93"; + }; + } + { + goPackagePath = "github.com/valyala/fasthttp"; + fetch = { + type = "git"; + url = "https://github.com/valyala/fasthttp"; + rev = "e5f51c11919d4f66400334047b897ef0a94c6f3c"; + sha256 = "0g24gys7xk449jd9ja89vr33i3amcb12jnmhsrmd5r2q8byv3l09"; + }; + } + { + goPackagePath = "golang.org/x/net"; + fetch = { + type = "git"; + url = "https://go.googlesource.com/net"; + rev = "f5dfe339be1d06f81b22525fe34671ee7d2c8904"; + sha256 = "01y9j7pjnnld4ipmzjvs0hls0hh698f2sga8cxaw5y6r5j7igaah"; + }; + } + { + goPackagePath = "golang.org/x/text"; + fetch = { + type = "git"; + url = "https://go.googlesource.com/text"; + rev = "4e4a3210bb54bb31f6ab2cdca2edcc0b50c420c1"; + sha256 = "10505r4xw1njnr2ns1s5r62s4pwif0kfaa30xxpgpz6qxrrmw15s"; + }; + } +] diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 34fd1a7672b..12ad09e88b2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12639,6 +12639,8 @@ with pkgs; mlmmj = callPackage ../servers/mail/mlmmj { }; + morty = callPackage ../servers/web-apps/morty { }; + myserver = callPackage ../servers/http/myserver { }; nas = callPackage ../servers/nas { }; From e9ff80d24a14d786e68141cf18e40edcc8e58fa8 Mon Sep 17 00:00:00 2001 From: Michiel Leenaars Date: Wed, 30 May 2018 18:13:16 +0200 Subject: [PATCH 3/3] morty: init as service --- nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/morty.nix | 98 +++++++++++++++++++++ nixos/release.nix | 1 + nixos/tests/morty.nix | 32 +++++++ 4 files changed, 132 insertions(+) create mode 100644 nixos/modules/services/networking/morty.nix create mode 100644 nixos/tests/morty.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 65b4cfd7e0b..3c6277a2af5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -514,6 +514,7 @@ ./services/networking/miniupnpd.nix ./services/networking/mosquitto.nix ./services/networking/monero.nix + ./services/networking/morty.nix ./services/networking/miredo.nix ./services/networking/mstpd.nix ./services/networking/murmur.nix diff --git a/nixos/modules/services/networking/morty.nix b/nixos/modules/services/networking/morty.nix new file mode 100644 index 00000000000..b31bec9a862 --- /dev/null +++ b/nixos/modules/services/networking/morty.nix @@ -0,0 +1,98 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.morty; + + configFile = cfg.configFile; + +in + +{ + + ###### interface + + options = { + + services.morty = { + + enable = mkEnableOption + "Morty proxy server. See https://github.com/asciimoo/morty"; + + ipv6 = mkOption { + type = types.bool; + default = true; + description = "Allow IPv6 HTTP requests?"; + defaultText = "Allow IPv6 HTTP requests."; + }; + + key = mkOption { + type = types.string; + default = ""; + description = "HMAC url validation key (hexadecimal encoded). + Leave blank to disable. Without validation key, anyone can + submit proxy requests. Leave blank to disable."; + defaultText = "No HMAC url validation. Generate with echo -n somevalue | openssl dgst -sha1 -hmac somekey"; + }; + + timeout = mkOption { + type = types.int; + default = 2; + description = "Request timeout in seconds."; + defaultText = "A resource now gets 2 seconds to respond."; + }; + + package = mkOption { + type = types.package; + default = pkgs.morty; + defaultText = "pkgs.morty"; + description = "morty package to use."; + }; + + port = mkOption { + type = types.int; + default = 3000; + description = "Listing port"; + }; + + listenAddress = mkOption { + type = types.string; + default = "127.0.0.1"; + description = "The address on which the service listens"; + defaultText = "127.0.0.1 (localhost)"; + }; + + }; + + }; + + ###### Service definition + + config = mkIf config.services.morty.enable { + + users.extraUsers.morty = + { description = "Morty user"; + createHome = true; + home = "/var/lib/morty"; + }; + + systemd.services.morty = + { + description = "Morty sanitizing proxy server."; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "morty"; + ExecStart = ''${cfg.package}/bin/morty \ + -listen ${cfg.listenAddress}:${toString cfg.port} \ + ${optionalString cfg.ipv6 "-ipv6"} \ + ${optionalString (cfg.key != "") "-key " + cfg.key} \ + ''; + }; + }; + environment.systemPackages = [ cfg.package ]; + + }; +} diff --git a/nixos/release.nix b/nixos/release.nix index 8d9202e87b0..15e52022032 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -406,6 +406,7 @@ in rec { tests.xss-lock = callTest tests/xss-lock.nix {}; tests.yabar = callTest tests/yabar.nix {}; tests.zookeeper = callTest tests/zookeeper.nix {}; + tests.morty = callTest tests/morty.nix { }; /* Build a bunch of typical closures so that Hydra can keep track of the evolution of closure sizes. */ diff --git a/nixos/tests/morty.nix b/nixos/tests/morty.nix new file mode 100644 index 00000000000..e052ee98806 --- /dev/null +++ b/nixos/tests/morty.nix @@ -0,0 +1,32 @@ +import ./make-test.nix ({ pkgs, ... }: + +{ + name = "morty"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ leenaars ]; + }; + + nodes = + { mortyProxyWithKey = + + { config, pkgs, ... }: + { services.morty = { + enable = true; + key = "78a9cd0cfee20c672f78427efb2a2a96036027f0"; + port = 3001; + }; + }; + + }; + + testScript = + { nodes , ... }: + '' + startAll; + + $mortyProxyWithKey->waitForUnit("morty"); + $mortyProxyWithKey->succeed("curl -L 127.0.0.1:3001 | grep MortyProxy"); + + ''; + +})