mirror of
https://github.com/mandiant/capa.git
synced 2026-02-05 11:26:31 -08:00
Merge pull request #166 from Ana06/rules-linter
Fix rule linter and run it in the CI GitHub action
This commit is contained in:
17
.github/workflows/tests.yml
vendored
17
.github/workflows/tests.yml
vendored
@@ -23,3 +23,20 @@ jobs:
|
||||
- name: Lint with black
|
||||
run: black -l 120 --check .
|
||||
|
||||
rule_linter:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout capa with rules submodule
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
# We don't need vivisect, so we can install capa using Python3
|
||||
- name: Install capa
|
||||
run: pip install -e .
|
||||
- name: Run rule linter
|
||||
run: python scripts/lint.py rules/
|
||||
|
||||
|
||||
@@ -136,10 +136,12 @@ class MissingExampleOffset(Lint):
|
||||
|
||||
def check_rule(self, ctx, rule):
|
||||
if rule.meta.get("scope") in ("function", "basic block"):
|
||||
for example in rule.meta.get("examples", []):
|
||||
if example and ":" not in example:
|
||||
logger.debug("example: %s", example)
|
||||
return True
|
||||
examples = rule.meta.get("examples")
|
||||
if isinstance(examples, list):
|
||||
for example in examples:
|
||||
if example and ":" not in example:
|
||||
logger.debug("example: %s", example)
|
||||
return True
|
||||
|
||||
|
||||
class ExampleFileDNE(Lint):
|
||||
|
||||
Reference in New Issue
Block a user