semgrep / semgrep-vscode

Semgrep extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=semgrep.semgrep
GNU Lesser General Public License v2.1
53 stars 24 forks source link
semgrep visual-studio-code vscode vscode-extension

Semgrep Visual Studio Code extension

Semgrep is a fast, static analysis tool powered by an open-source engine for finding bugs, detecting vulnerabilities, and enforcing code standards. Semgrep Visual Studio Code extension scans lines when you change or open files or all files in your workspace. It offers:

Prerequisites

Quickstart

  1. Install the Semgrep extension in Visual Studio Code.
  2. Use Ctrl+⇧Shift+P or ⌘Command+⇧Shift+P (macOS) to launch the Command Palette, and run the following to sign in to Semgrep Cloud Platform:
    Semgrep: Sign in

    You can use the extension without signing in, but doing so enables better results since you benefit from Semgrep Code and its Pro rules.

  3. Launch the Command Palette using Ctrl+⇧Shift+P or ⌘Command+⇧Shift+P (macOS), and scan your files by running:
    Semgrep: Scan all files in workspace
  4. To see detailed vulnerability information, hover over the code that's underlined in yellow. You can also see the findings identified by Semgrep using ⇧Shift+Ctrl+M or ⌘Command+⇧Shift+M (macOS) and opening the Problems tab.

Use the full potential of Semgrep

Try Autofix.

https://github.com/returntocorp/semgrep-vscode/assets/626337/3b6a730d-57e9-48a4-8065-9fa52388d77a

Add and update new rules to expand Semgrep extension capabilities.

https://github.com/returntocorp/semgrep-vscode/assets/626337/fed6b6ec-e0b5-495b-a488-4f3c805dd58b

Fine-tune and customize the rules Semgrep uses to improve your scan results:

  1. Go to Semgrep Registry. Ensure that you are signed in.
  2. Explore the Semgrep Registry. When you find a rule you want to add, click the plus sign to expand the rule. Click Add to Policy, and select your mode. You can view and manage all of your rules in Policies.
  3. Rescan your code. Use Ctrl+⇧Shift+P or ⌘Command+⇧Shift+P (macOS) to launch the Command Palette, then run Semgrep: Update rules.

Language support

Semgrep supports 30+ languages, including:

Apex · Bash · C · C++ · C# · Clojure · Dart · Dockerfile · Elixir · HTML · Go · Java · JavaScript · JSX · JSON · Julia · Jsonnet · Kotlin · Lisp · Lua · OCaml · PHP · Python · R · Ruby · Rust · Scala · Scheme · Solidity · Swift · Terraform · TypeScript · TSX · YAML · XML · Generic (ERB, Jinja, etc.)

Configure the extension

To configure the Semgrep extension, open its Extension Settings page:

  1. Use ⇧Shift+Ctrl+X or ⇧Shift+⌘Command+X (macOS) to open the Extensions view.
  2. Select Semgrep.
  3. Click the gear and select Extension Settings.

Configuration options

Experimental configuration options:

The following experimental features should only be used upon recommendation by Semgrep:

Commands

Run Semgrep extension commands through the Visual Studio Code Command Palette. You can access the Command Palette using Ctrl+⇧Shift+P or ⌘Command+⇧Shift+P (macOS). The following list includes all available Semgrep extension commands:

Tip: You can click the Semgrep icon in the Visual Studio Code to access all available commands quickly.

Support

If you need our support, join the Semgrep community Slack workspace and tell us about any problems you encounter.