From 5ab62a3514e68651375f669ffb9be18e66ef396a Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Mon, 27 Apr 2020 13:46:16 +0530 Subject: [PATCH] sgrep/semgrep: Updgrade and rename sgrep to semgrep. With its new upgrade, sgrep has been renamed to semgrep. Rename sgrep.yml to semgrep.yml --- tools/lib/provision.py | 4 ++-- tools/lint | 8 ++++---- tools/{sgrep.yml => semgrep.yml} | 2 +- tools/setup/install-semgrep | 22 ++++++++++++++++++++++ tools/setup/install-sgrep | 23 ----------------------- version.py | 2 +- 6 files changed, 30 insertions(+), 31 deletions(-) rename tools/{sgrep.yml => semgrep.yml} (82%) create mode 100755 tools/setup/install-semgrep delete mode 100755 tools/setup/install-sgrep diff --git a/tools/lib/provision.py b/tools/lib/provision.py index 8b2972bccc..cad8d47504 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -378,8 +378,8 @@ def main(options: argparse.Namespace) -> "NoReturn": # Install shellcheck. run_as_root(["tools/setup/install-shellcheck"]) - # Install sgrep. - run_as_root(["tools/setup/install-sgrep"]) + # Install semgrep. + run_as_root(["tools/setup/install-semgrep"]) setup_venvs.main() diff --git a/tools/lint b/tools/lint index a38e28d1bd..9d0d069d47 100755 --- a/tools/lint +++ b/tools/lint @@ -89,10 +89,10 @@ def run() -> None: description="Checks commit messages for common formatting errors." "(config: .gitlint)") - sgrep_command = ["sgrep-lint", "--config=./tools/sgrep.yml", "--error"] - linter_config.external_linter('sgrep-py', [*sgrep_command, "--lang=python"], ['py'], - description="Syntactic Grep (sgrep) Code Search Tool " - "(config: ./tools/sgrep.yml)") + semgrep_command = ["semgrep", "--config=./tools/semgrep.yml", "--error"] + linter_config.external_linter('semgrep-py', [*semgrep_command, "--lang=python"], ['py'], + description="Syntactic Grep (semgrep) Code Search Tool " + "(config: ./tools/semgrep.yml)") @linter_config.lint def custom_py() -> int: diff --git a/tools/sgrep.yml b/tools/semgrep.yml similarity index 82% rename from tools/sgrep.yml rename to tools/semgrep.yml index e99823e67d..287f2ad185 100644 --- a/tools/sgrep.yml +++ b/tools/semgrep.yml @@ -1,4 +1,4 @@ -# See https://github.com/returntocorp/sgrep/blob/develop/docs/config.md for sgrep rule format +# See https://github.com/returntocorp/semgrep/blob/develop/docs/config.md for semgrep rule format rules: - id: deprecated-render-usage diff --git a/tools/setup/install-semgrep b/tools/setup/install-semgrep new file mode 100755 index 0000000000..062c9247a2 --- /dev/null +++ b/tools/setup/install-semgrep @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e + +version=0.5.0-dev.2 +tarball=semgrep-v$version-ubuntu-16.04.tgz +sha256=3959f79b15c900d29567b6cb846831eb7da4c0a10969ffc98a1c9364ea377545 +tarball_url=https://github.com/returntocorp/semgrep/releases/download/v$version/$tarball + +check_version () { + out="$(semgrep --version 2>/dev/null)" && [ "$out" = "$version" ] +} + +if ! check_version; then + tmpdir="$(mktemp -d)" + trap 'rm -r "$tmpdir"' EXIT + cd "$tmpdir" + wget -nv "$tarball_url" + sha256sum -c <<< "$sha256 $tarball" + tar -xzf "$tarball" -C /usr/local/lib/ + ln -sf /usr/local/lib/semgrep-files/semgrep /usr/local/bin/semgrep + ln -sf /usr/local/lib/semgrep-files/semgrep-core /usr/local/bin/semgrep-core +fi diff --git a/tools/setup/install-sgrep b/tools/setup/install-sgrep deleted file mode 100755 index 6fde97e61f..0000000000 --- a/tools/setup/install-sgrep +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -set -e - -version=0.4.9b5 -tarball=sgrep-$version-ubuntu-16.04.tgz -sha256=9e57323fd0eb9133b7ff301a6be8361c073c3bfe6e6959ca1b622e5abc176e03 -tarball_url=https://github.com/returntocorp/sgrep/releases/download/v$version/$tarball - -check_version () { - out="$(sgrep-lint --version 2>/dev/null)" && [ "$out" = "$version" ] -} - -if ! check_version; then - tmpdir="$(mktemp -d)" - trap 'rm -r "$tmpdir"' EXIT - cd "$tmpdir" - wget -nv "$tarball_url" - sha256sum -c <<< "$sha256 $tarball" - tar -xzf "$tarball" -C /usr/local/lib/ - ln -sf /usr/local/lib/sgrep-lint-files/sgrep-lint /usr/local/bin/sgrep-lint - ln -sf /usr/local/lib/sgrep-lint-files/sgrep /usr/local/bin/sgrep - check_version -fi diff --git a/version.py b/version.py index 3787b14bac..dbd38e2310 100644 --- a/version.py +++ b/version.py @@ -44,4 +44,4 @@ API_FEATURE_LEVEL = 2 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = '81.2' +PROVISION_VERSION = '81.3'