mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 20:54:26 +08:00
Add Yara yls support (#4886)
This adds Yara support to ALE using Avast's language server for Yara: https://avast.github.io/yls/ A ".git" folder is used to determine the project_root so this means the Yara rules must be in a git repo for the integration to work. The server only have 1 optional argument (-v, --verbose). Since this is the case, no additional configuration options are available. --------- Co-authored-by: w0rp <w0rp@users.noreply.github.com>
This commit is contained in:
18
ale_linters/yara/yls.vim
Normal file
18
ale_linters/yara/yls.vim
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
" 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'),
|
||||||
|
\})
|
||||||
@@ -737,6 +737,8 @@ Notes:
|
|||||||
* `yq`
|
* `yq`
|
||||||
* YANG
|
* YANG
|
||||||
* `yang-lsp`
|
* `yang-lsp`
|
||||||
|
* Yara
|
||||||
|
* `yls`
|
||||||
* Zeek
|
* Zeek
|
||||||
* `zeek`!!
|
* `zeek`!!
|
||||||
* Zig
|
* Zig
|
||||||
|
|||||||
22
doc/ale-yara.txt
Normal file
22
doc/ale-yara.txt
Normal file
@@ -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:
|
||||||
@@ -3525,6 +3525,8 @@ documented in additional help files.
|
|||||||
yq....................................|ale-yaml-yq|
|
yq....................................|ale-yaml-yq|
|
||||||
yang....................................|ale-yang-options|
|
yang....................................|ale-yang-options|
|
||||||
yang-lsp..............................|ale-yang-lsp|
|
yang-lsp..............................|ale-yang-lsp|
|
||||||
|
yara....................................|ale-yara-options|
|
||||||
|
yls...................................|ale-yara-yls|
|
||||||
zeek....................................|ale-zeek-options|
|
zeek....................................|ale-zeek-options|
|
||||||
zeek..................................|ale-zeek-zeek|
|
zeek..................................|ale-zeek-zeek|
|
||||||
zig.....................................|ale-zig-options|
|
zig.....................................|ale-zig-options|
|
||||||
|
|||||||
@@ -746,6 +746,8 @@ formatting.
|
|||||||
* [yq](https://github.com/mikefarah/yq)
|
* [yq](https://github.com/mikefarah/yq)
|
||||||
* YANG
|
* YANG
|
||||||
* [yang-lsp](https://github.com/theia-ide/yang-lsp)
|
* [yang-lsp](https://github.com/theia-ide/yang-lsp)
|
||||||
|
* Yara
|
||||||
|
* [yls](https://github.com/avast/yls)
|
||||||
* Zeek
|
* Zeek
|
||||||
* [zeek](http://zeek.org) :floppy_disk:
|
* [zeek](http://zeek.org) :floppy_disk:
|
||||||
* Zig
|
* Zig
|
||||||
|
|||||||
13
test/linter/test_yara_yls.vader
Normal file
13
test/linter/test_yara_yls.vader
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
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') . ' -v'
|
||||||
|
|
||||||
|
Execute(The project root should be detected correctly):
|
||||||
|
call ale#test#SetFilename('../test-files/yara/dummy.yar')
|
||||||
|
|
||||||
|
AssertLSPProject ale#path#Simplify(g:dir . '/../..')
|
||||||
5
test/test-files/yara/dummy.yar
Normal file
5
test/test-files/yara/dummy.yar
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
rule dummy
|
||||||
|
{
|
||||||
|
condition:
|
||||||
|
false
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user