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

Staging #145

Merged
merged 7 commits into from
Jan 11, 2024
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install poetry
poetry env use ${{ matrix.python-version }}
poetry install
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion plugins/yls-yara/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "MIT"
include = ["py.typed", "LICENSE"]

[tool.poetry.dependencies]
python = ">=3.8,<3.12"
python = "^3.8"
yara-python = "^4.2.0"
yls = "^1.4.0"

Expand Down
200 changes: 57 additions & 143 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pytest-black = "^0.3.12"
pytest-cov = "^3.0.0"
pytest-mock = "^3.7.0"
pytest-mypy = "^0.9.1"
pytest-pylint = "0.19.0"
pytest-pylint = "^0.21.0"
pytest-yls = {path = "./pytest-yls", develop = true}

[tool.black]
Expand Down Expand Up @@ -56,10 +56,10 @@ test = "pytest -vvv --mypy --black --pylint --pylint-rcfile=pyproject.toml --cov
yls = 'yls.server:main'

[tool.poetry.dependencies]
python = ">=3.8,<3.12"
python = "^3.8"
pygls = "^1.1.2"
yaramod = "^3.21.0"
yari-py = "^0.1.6"
yari-py = "^0.2.1"
pluggy = "^1.0.0"

[build-system]
Expand Down
2 changes: 1 addition & 1 deletion pytest-yls/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include = ["py.typed", "LICENSE"]

[tool.poetry.dependencies]
pytest = "^7.2.2"
python = ">=3.8,<3.12"
python = "^3.8"
tenacity = "^8.0.1"

[tool.poetry.plugins.pytest11]
Expand Down
144 changes: 72 additions & 72 deletions yls/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,120 +337,120 @@ def extract(self, expr: yaramod.Expression) -> None:
self.expr = expr

# pylint: disable-next=invalid-name
def visit_FunctionCallExpression(self, expr: yaramod.FunctionCallExpression) -> None: # type: ignore
self.extract(expr)
def visit_FunctionCallExpression(self, arg0: yaramod.FunctionCallExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_IdExpression(self, expr: yaramod.IdExpression) -> None: # type: ignore
self.extract(expr)
def visit_IdExpression(self, arg0: yaramod.IdExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_StructAccessExpression(self, expr: yaramod.StructAccessExpression) -> None: # type: ignore
self.extract(expr)
def visit_StructAccessExpression(self, arg0: yaramod.StructAccessExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_ArrayAccessExpression(self, expr: yaramod.ArrayAccessExpression) -> None: # type: ignore
self.extract(expr)
def visit_ArrayAccessExpression(self, arg0: yaramod.ArrayAccessExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_StringExpression(self, expr: yaramod.StringExpression) -> None: # type: ignore
self.extract(expr)
def visit_StringExpression(self, arg0: yaramod.StringExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_StringCountExpression(self, expr: yaramod.StringCountExpression) -> None: # type: ignore
self.extract(expr)
def visit_StringCountExpression(self, arg0: yaramod.StringCountExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_StringOffsetExpression(self, expr: yaramod.StringOffsetExpression) -> None: # type: ignore
self.extract(expr)
def visit_StringOffsetExpression(self, arg0: yaramod.StringOffsetExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_StringLengthExpression(self, expr: yaramod.StringLengthExpression) -> None: # type: ignore
self.extract(expr)
def visit_StringLengthExpression(self, arg0: yaramod.StringLengthExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_OfExpression(self, expr: yaramod.OfExpression) -> None: # type: ignore
self.extract(expr)
def visit_OfExpression(self, arg0: yaramod.OfExpression) -> None: # type: ignore
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_ForExpression(self, expr: yaramod.ForExpression) -> None:
self.extract(expr)
def visit_ForExpression(self, arg0: yaramod.ForExpression) -> None:
self.extract(arg0)

# pylint: disable-next=invalid-name
def visit_IequalsExpression(self, expr: yaramod.IequalsExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_IequalsExpression(self, arg0: yaramod.IequalsExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_LtExpression(self, expr: yaramod.LtExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_LtExpression(self, arg0: yaramod.LtExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_GtExpression(self, expr: yaramod.GtExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_GtExpression(self, arg0: yaramod.GtExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_LeExpression(self, expr: yaramod.LeExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_LeExpression(self, arg0: yaramod.LeExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_GeExpression(self, expr: yaramod.GeExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_GeExpression(self, arg0: yaramod.GeExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_EqExpression(self, expr: yaramod.EqExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_EqExpression(self, arg0: yaramod.EqExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_NeqExpression(self, expr: yaramod.NeqExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_NeqExpression(self, arg0: yaramod.NeqExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_AndExpression(self, expr: yaramod.AndExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_AndExpression(self, arg0: yaramod.AndExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_OrExpression(self, expr: yaramod.OrExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_OrExpression(self, arg0: yaramod.OrExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_NotExpression(self, expr: yaramod.NotExpression) -> None: # type: ignore
self.extract(expr)
expr.operand.accept(self)
def visit_NotExpression(self, arg0: yaramod.NotExpression) -> None: # type: ignore
self.extract(arg0)
arg0.operand.accept(self)

# pylint: disable-next=invalid-name
def visit_DefinedExpression(self, expr: yaramod.DefinedExpression) -> None: # type: ignore
self.extract(expr)
expr.operand.accept(self)
def visit_DefinedExpression(self, arg0: yaramod.DefinedExpression) -> None: # type: ignore
self.extract(arg0)
arg0.operand.accept(self)

# pylint: disable-next=invalid-name
def visit_ContainsExpression(self, expr: yaramod.ContainsExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_ContainsExpression(self, arg0: yaramod.ContainsExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)

# pylint: disable-next=invalid-name
def visit_MatchesExpression(self, expr: yaramod.MatchesExpression) -> None: # type: ignore
self.extract(expr)
expr.left_operand.accept(self)
expr.right_operand.accept(self)
def visit_MatchesExpression(self, arg0: yaramod.MatchesExpression) -> None: # type: ignore
self.extract(arg0)
arg0.left_operand.accept(self)
arg0.right_operand.accept(self)


def cursor_expression(
Expand Down Expand Up @@ -705,9 +705,9 @@ def indirectly_affected(self, yara_file: yaramod.YaraFile, root_rule: str) -> se

return self.discovered_rules

def visit_IdExpression(self, expr: yaramod.IdExpression) -> None: # type: ignore
def visit_IdExpression(self, arg0: yaramod.IdExpression) -> None: # type: ignore
if self.last_rule and self.last_rule.name in self.discovered_rules:
self.discovered_rules.add(expr.symbol.name)
self.discovered_rules.add(arg0.symbol.name)


def extract_rule_context_from_yarafile(yara_file: yaramod.YaraFile, rule: yaramod.Rule) -> str:
Expand Down