Skip to content

How to setup

MatejKastak edited this page Aug 10, 2022 · 5 revisions

This document will guide you through installation of yls onto your system. The whole process is divided into 2 parts:

  1. yls binary installation
  2. Editor configuration

For a quick tutorial checkout the following video: https://user-images.githubusercontent.com/26434056/183893630-b3474a51-9a44-4998-a7a6-10fb87da5139.mp4

1️⃣ Installation

The goal of this step is to ensure you have yls installed on your machine.

  • you must ensure that you have a supported python version: python 3.8+ 🐍
  • you must ensure that you have requirements to install yara-python
  • you must ensure that you have requirements to install Yaramod on Linux (Windows packages are pre-built wheels)

Global installation - yls must be present in PATH

pip install -U yls-yara

NOTE:

  • since the installation is global it can interfere with your current version of yara-python and YARA
  • if you have currently installed yara-python and you would like to keep the version, please follow the steps bellow and install YLS into virtual environment

Virtual Environment installation

NOTE: In the configuration steps you will need to provide an absolute path to the yls executable either in the editor plugin (VsCode) or in the editor LSP client configuration (vim). In the Linux example the absolute path was /home/user/yls/env/bin/yls.

Following snippets show example installation steps.

Windows

:: Pick and create a suitable directory for your yls installation
mkdir yls
cd yls
python -m venv env
env\Scripts\activate.bat
pip install -U yls-yara

:: To get the absolute path of the yls executable
dir /S /b "env\Scripts\yls.exe"

Linux

# Pick and create a suitable directory for your yls installation
mkdir -p ~/yls
cd ~/yls
python -m venv env
. env/bin/activate
pip install -U yls-yara

# To get the absolute path of the yls executable
realpath env/bin/yls

2️⃣ Editor configuration

The goal of this step is to configure your favorite editor to support yls. This procedure is typically required only for the first time and the new updates are rare.

Install the following extension, depending on the used marketplace. You can search it directly from the Visual Studio Code UI.

  • associate yara filetype with file extensions
autocmd BufNewFile,BufRead *.yar,*.yara setlocal filetype=yara
  • in order to install syntax highlighting declare it with your plugin manager (for example vim-plug)
Plug 's3rvac/vim-syntax-yara'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
{
	"languageserver": {
		"yara": {
			"command": "yls",
			"args": ["-vv"],
			"filetypes": ["yara"]
		}
	}
}
Plug 'prabirshrestha/vim-lsp'
autocmd User lsp_setup call lsp#register_server({
    \ 'name': 'yls',
    \ 'cmd': {server_info->['yls']},
    \ 'whitelist': ['yara'],
})

Will be ready in future releases.

Will be ready in future releases.