Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yara yls support #4886

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ale_linters/yara/yls.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
" Author: TcM1911
" Description: A language server for Yara.

call ale#Set('yara_yls_executable', 'yls')

function! ale_linters#yara#yls#FindProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git')
return !empty(l:project_root) ? (ale#path#Upwards(l:project_root)[1]) : ''
endfunction

call ale#linter#Define('yara', {
\ 'name': 'yls',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'yara_yls_executable')},
\ 'command': '%e -v',
\ 'project_root': function('ale_linters#yara#yls#FindProjectRoot'),
\})
2 changes: 2 additions & 0 deletions doc/ale-supported-languages-and-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ Notes:
* `yamlfix`
* `yamlfmt`
* `yamllint`
* Yara
* `yls`
* YANG
* `yang-lsp`
* Zeek
Expand Down
22 changes: 22 additions & 0 deletions doc/ale-yara.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
===============================================================================
ALE Yara Integration *ale-yara-options*
*ale-integration-yara*

===============================================================================
Integration Information

Currently, the only supported linter for yara is yls.


===============================================================================
yls *ale-yara-yls*

g:ale_yara_yls_executable *g:ale_yara_yls_executable*
*b:ale_yara_yls_executable*
Type: |String|
Default: `'yls'`

This variable can be modified to change the executable path for `yls`.

===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
2 changes: 2 additions & 0 deletions supported-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ formatting.
* [yamllint](https://yamllint.readthedocs.io/)
* YANG
* [yang-lsp](https://github.com/theia-ide/yang-lsp)
* Yara
* [yls](https://github.com/avast/yls)
* Zeek
* [zeek](http://zeek.org) :floppy_disk:
* Zig
Expand Down
15 changes: 15 additions & 0 deletions test/linter/test_yara_yls.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Before:
call ale#assert#SetUpLinterTest('yara', 'yls')

After:
call ale#assert#TearDownLinterTest()

Execute(The default executable path should be correct):
AssertLinter 'yls', ale#Escape('yls')

Execute(The project root should be detected correctly):
AssertLSPProject ''

call ale#test#SetFilename('../test-files/yara/dummy.yar')

AssertLSPProject ale#path#Simplify(g:dir . '/../..')
5 changes: 5 additions & 0 deletions test/test-files/yara/dummy.yar
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rule dummy
{
condition:
false
}