class Sslyze < Formula include Language::Python::Virtualenv desc "SSL scanner" homepage "https://github.com/nabla-c0d3/sslyze" stable do url "https://github.com/nabla-c0d3/sslyze/archive/1.1.2.tar.gz" sha256 "a77aea29beb0cf30b9371e9b5d5ddc8ef5616b411ac62603c914ce576b1bc9af" resource "nassl" do url "https://github.com/nabla-c0d3/nassl/archive/0.16.3.tar.gz" sha256 "2b9cdc4462a673b4884ead7dd1b258ba69edf126bb7555c52c0bb0a3a55e4ecb" end resource "openssl" do url "https://github.com/PeterMosmans/openssl.git", :revision => "c9ba19c8b7fd131137373dbd1fccd6a8bb0628be" end end bottle do cellar :any_skip_relocation sha256 "8af9e3b558946bba0012554881ad2420578aed17c64e83284406a2d622899120" => :sierra sha256 "a814dd9ea8899140c7bbcf83eec7d6a915aaefa2f5c193405b6a7c3e9b651f55" => :el_capitan sha256 "919b21de6bccb73685f198e2ac2e626fd53b9d62cf71cef3f74e54f5b3a9dc71" => :yosemite end head do url "https://github.com/nabla-c0d3/sslyze.git" resource "nassl" do url "https://github.com/nabla-c0d3/nassl.git" end resource "openssl" do url "https://github.com/PeterMosmans/openssl.git", :branch => "1.0.2-chacha" end end depends_on :arch => :x86_64 depends_on :python if MacOS.version <= :snow_leopard resource "asn1crypto" do url "https://files.pythonhosted.org/packages/67/14/5d66588868c4304f804ebaff9397255f6ec5559e46724c2496e0f26e68d6/asn1crypto-0.22.0.tar.gz" sha256 "cbbadd640d3165ab24b06ef25d1dca09a3441611ac15f6a6b452474fdf0aed1a" end resource "cffi" do url "https://files.pythonhosted.org/packages/5b/b9/790f8eafcdab455bcd3bd908161f802c9ce5adbf702a83aa7712fcc345b7/cffi-1.10.0.tar.gz" sha256 "b3b02911eb1f6ada203b0763ba924234629b51586f72a21faacc638269f4ced5" end resource "cryptography" do url "https://files.pythonhosted.org/packages/2a/0c/31bd69469e90035381f0197b48bf71032991d9f07a7e444c311b4a23a3df/cryptography-1.9.tar.gz" sha256 "5518337022718029e367d982642f3e3523541e098ad671672a90b82474c84882" end resource "enum34" do url "https://files.pythonhosted.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz" sha256 "8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" end resource "idna" do url "https://files.pythonhosted.org/packages/d8/82/28a51052215014efc07feac7330ed758702fc0581347098a81699b5281cb/idna-2.5.tar.gz" sha256 "3cb5ce08046c4e3a560fc02f138d0ac63e00f8ce5901a56b32ec8b7994082aab" end resource "ipaddress" do url "https://files.pythonhosted.org/packages/4e/13/774faf38b445d0b3a844b65747175b2e0500164b7c28d78e34987a5bfe06/ipaddress-1.0.18.tar.gz" sha256 "5d8534c8e185f2d8a1fda1ef73f2c8f4b23264e8e30063feeb9511d492a413e1" end resource "pycparser" do url "https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz" sha256 "99a8ca03e29851d96616ad0404b4aad7d9ee16f25c9f9708a11faf2810f7b226" end resource "six" do url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz" sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a" end resource "tls-parser" do url "https://files.pythonhosted.org/packages/c9/30/5d43c474e014f3f069b3c440eec332be3e9d2032693bc000aac71522754e/tls_parser-1.0.0.zip" sha256 "ec1026656454da87f5a3b7f53a3a60a06d501044b2c1f664043436241657f84d" end resource "typing" do url "https://files.pythonhosted.org/packages/17/75/3698d7992a828ad6d7be99c0a888b75ed173a9280e53dbae67326029b60e/typing-3.6.1.tar.gz" sha256 "c36dec260238e7464213dcd50d4b5ef63a507972f5780652e835d0228d0edace" end resource "zlib" do url "https://zlib.net/zlib-1.2.11.tar.gz" mirror "https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz" sha256 "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1" end def install venv = virtualenv_create(libexec) res = resources.map(&:name).to_set - %w[cryptography nassl openssl zlib] res.each do |r| venv.pip_install resource(r) end ENV.prepend_path "PYTHONPATH", libexec/"lib/python2.7/site-packages" resource("nassl").stage do nassl_path = Pathname.pwd # openssl fails on parallel build. Related issues: # - https://rt.openssl.org/Ticket/Display.html?id=3736&user=guest&pass=guest # - https://rt.openssl.org/Ticket/Display.html?id=3737&user=guest&pass=guest ENV.deparallelize do mv "bin/openssl/include", "nassl_openssl_include" rm_rf "bin" # make sure we don't use the prebuilt binaries (nassl_path/"bin/openssl").install "nassl_openssl_include" => "include" (nassl_path/"zlib-#{resource("zlib").version}").install resource("zlib") (nassl_path/"openssl").install resource("openssl") # Upstream issue "ocsp_response_tests.py intermittent failure" # Reported 22 Jul 2017 https://github.com/nabla-c0d3/nassl/issues/16 inreplace "build_from_scratch.py", "perform_build_task('NASSL Tests', NASSL_TEST_TASKS)", "" system "python", "build_from_scratch.py" end venv.pip_install nassl_path ENV.prepend "CPPFLAGS", "-I#{nassl_path}/openssl/include" ENV.prepend "LDFLAGS", "-L#{nassl_path}/openssl" venv.pip_install resource("cryptography") end venv.pip_install_and_link buildpath end test do assert_match "SCAN COMPLETED", shell_output("#{bin}/sslyze --regular google.com") end end