130 lines
5.4 KiB
Ruby
130 lines
5.4 KiB
Ruby
class Semgrep < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Easily detect and prevent bugs and anti-patterns in your codebase"
|
|
homepage "https://semgrep.live"
|
|
url "https://github.com/returntocorp/semgrep.git",
|
|
:tag => "v0.12.0",
|
|
:revision => "080eca69c9d03067dda2796af5acf52baefc1988"
|
|
head "https://github.com/returntocorp/semgrep.git", :branch => "develop"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "debbcdc08799d1f3e2f82e2ccb7f2513871ebafcafbc03cfb92097f21716fa30" => :catalina
|
|
sha256 "586fd611ebde3fcad997b50c541b7b50804a4692e786982dbbab4af28aa059cb" => :mojave
|
|
sha256 "0bbb196095c048f8830c8bc1dab3d0f6b463675f442a41b15e254ebf1c9baa0b" => :high_sierra
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "coreutils"=> :build
|
|
depends_on "ocaml" => :build
|
|
depends_on "opam" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "python@3.8"
|
|
|
|
resource "certifi" do
|
|
url "https://files.pythonhosted.org/packages/b8/e2/a3a86a67c3fc8249ed305fc7b7d290ebe5e4d46ad45573884761ef4dea7b/certifi-2020.4.5.1.tar.gz"
|
|
sha256 "51fcb31174be6e6664c5f69e3e1691a2d72a1a12e90f872cbdb1567eb47b6519"
|
|
end
|
|
|
|
resource "chardet" do
|
|
url "https://files.pythonhosted.org/packages/fc/bb/a5768c230f9ddb03acc9ef3f0d4a3cf93462473795d18e9535498c8f929d/chardet-3.0.4.tar.gz"
|
|
sha256 "84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"
|
|
end
|
|
|
|
resource "colorama" do
|
|
url "https://files.pythonhosted.org/packages/82/75/f2a4c0c94c85e2693c229142eb448840fba0f9230111faa889d1f541d12d/colorama-0.4.3.tar.gz"
|
|
sha256 "e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"
|
|
end
|
|
|
|
resource "idna" do
|
|
url "https://files.pythonhosted.org/packages/ad/13/eb56951b6f7950cadb579ca166e448ba77f9d24efc03edd7e55fa57d04b7/idna-2.8.tar.gz"
|
|
sha256 "c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407"
|
|
end
|
|
|
|
resource "PyYAML" do
|
|
url "https://files.pythonhosted.org/packages/3d/d9/ea9816aea31beeadccd03f1f8b625ecf8f645bd66744484d162d84803ce5/PyYAML-5.3.tar.gz"
|
|
sha256 "e9f45bd5b92c7974e59bcd2dcc8631a6b6cc380a904725fce7bc08872e691615"
|
|
end
|
|
|
|
resource "requests" do
|
|
url "https://files.pythonhosted.org/packages/01/62/ddcf76d1d19885e8579acb1b1df26a852b03472c0e46d2b959a714c90608/requests-2.22.0.tar.gz"
|
|
sha256 "11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4"
|
|
end
|
|
|
|
resource "urllib3" do
|
|
url "https://files.pythonhosted.org/packages/09/06/3bc5b100fe7e878d3dee8f807a4febff1a40c213d2783e3246edde1f3419/urllib3-1.25.8.tar.gz"
|
|
sha256 "87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc"
|
|
end
|
|
|
|
resource "attrs" do
|
|
url "https://files.pythonhosted.org/packages/98/c3/2c227e66b5e896e15ccdae2e00bbc69aa46e9a8ce8869cc5fa96310bf612/attrs-19.3.0.tar.gz"
|
|
sha256 "f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"
|
|
end
|
|
|
|
resource "ruamel.yaml" do
|
|
url "https://files.pythonhosted.org/packages/16/8b/54a26c1031595e5edd0e616028b922d78d8ffba8bc775f0a4faeada846cc/ruamel.yaml-0.16.10.tar.gz"
|
|
sha256 "099c644a778bf72ffa00524f78dd0b6476bca94a1da344130f4bf3381ce5b954"
|
|
end
|
|
|
|
resource "ruamel.yaml.clib" do
|
|
url "https://files.pythonhosted.org/packages/92/28/612085de3fae9f82d62d80255d9f4cf05b1b341db1e180adcf28c1bf748d/ruamel.yaml.clib-0.2.0.tar.gz"
|
|
sha256 "b66832ea8077d9b3f6e311c4a53d06273db5dc2db6e8a908550f3c14d67e718c"
|
|
end
|
|
|
|
resource "tqdm" do
|
|
url "https://files.pythonhosted.org/packages/a9/03/df1d77e852dd697c0ff7b7b1b9888739517e5f97dfbd2cf7ebd13234084c/tqdm-4.46.1.tar.gz"
|
|
sha256 "cd140979c2bebd2311dfb14781d8f19bd5a9debb92dcab9f6ef899c987fcf71f"
|
|
end
|
|
|
|
resource "packaging" do
|
|
url "https://files.pythonhosted.org/packages/55/fd/fc1aca9cf51ed2f2c11748fa797370027babd82f87829c7a8e6dbe720145/packaging-20.4.tar.gz"
|
|
sha256 "4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8"
|
|
end
|
|
|
|
resource "pyparsing" do
|
|
url "https://files.pythonhosted.org/packages/a2/56/0404c03c83cfcca229071d3c921d7d79ed385060bbe969fde3fd8f774ebd/pyparsing-2.4.6.tar.gz"
|
|
sha256 "4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/21/9f/b251f7f8a76dec1d6651be194dfba8fb8d7781d10ab3987190de8391d08e/six-1.14.0.tar.gz"
|
|
sha256 "236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"
|
|
end
|
|
|
|
def install
|
|
ENV.deparallelize
|
|
Dir.mktmpdir("opamroot") do |opamroot|
|
|
ENV["OPAMROOT"] = opamroot
|
|
ENV["OPAMYES"] = "1"
|
|
system "opam", "init", "--no-setup", "--disable-sandboxing"
|
|
ENV.deparallelize { system "opam", "switch", "create", "ocaml-base-compiler.4.10.0" }
|
|
system "opam", "install", "./pfff"
|
|
cd "semgrep-core" do
|
|
system "opam", "install", "--deps-only", "-y", "."
|
|
system "opam", "exec", "--", "make", "all"
|
|
system "opam", "exec", "--", "make", "install"
|
|
bin.install "_build/default/bin/Main.exe" => "semgrep-core"
|
|
end
|
|
end
|
|
|
|
python_path = "semgrep"
|
|
cd python_path do
|
|
venv = virtualenv_create(libexec, Formula["python@3.8"].bin/"python3.8")
|
|
venv.pip_install resources
|
|
venv.pip_install_and_link buildpath/python_path
|
|
end
|
|
end
|
|
|
|
test do
|
|
system "#{bin}/semgrep", "--help"
|
|
(testpath/"script.py").write <<~EOS
|
|
def silly_eq(a, b):
|
|
return a + b == a + b
|
|
EOS
|
|
|
|
output = shell_output("#{bin}/semgrep script.py -l python -e '$X == $X'")
|
|
assert_match "a + b == a + b", output
|
|
end
|
|
end
|