Add deptry support (#2085)

* Add deptry support

This commit resolves #1497.

Note: known_first_party refers to modules that are supposed to be
local, i.e. idaapi, ghidra, java, binaryninja, ... etc.

* adjust running stages for deptry hook

* adjust deptry exclusions, and humanize dependency

---------

Co-authored-by: Soufiane Fariss <soufiane.fariss@um5s.net.ma>
This commit is contained in:
Fariss
2024-05-31 09:43:10 +02:00
committed by GitHub
parent 0ac21f036c
commit 2e5da3e2bd
4 changed files with 88 additions and 2 deletions

View File

@@ -45,7 +45,9 @@ jobs:
- name: Lint with flake8 - name: Lint with flake8
run: pre-commit run flake8 --hook-stage manual run: pre-commit run flake8 --hook-stage manual
- name: Check types with mypy - name: Check types with mypy
run: pre-commit run mypy --hook-stage manual run: pre-commit run mypy --hook-stage manual
- name: Check imports against dependencies
run: pre-commit run deptry --hook-stage manual
rule_linter: rule_linter:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@@ -127,3 +127,13 @@ repos:
- "--ignore=tests/test_scripts.py" - "--ignore=tests/test_scripts.py"
always_run: true always_run: true
pass_filenames: false pass_filenames: false
- repo: local
hooks:
- id: deptry
name: deptry
stages: [push, manual]
language: system
entry: deptry .
always_run: true
pass_filenames: false

View File

@@ -42,6 +42,7 @@
- ci: update github workflows to use latest version of actions that were using a deprecated version of node #1967 #2003 capa-rules#883 @sjha2048 @Ana06 - ci: update github workflows to use latest version of actions that were using a deprecated version of node #1967 #2003 capa-rules#883 @sjha2048 @Ana06
- ci: update binja version to stable 4.0 #2016 @xusheng6 - ci: update binja version to stable 4.0 #2016 @xusheng6
- ci: update github workflows to reflect the latest ghidrathon installation and bumped up jep, ghidra versions #2020 @psahithireddy - ci: update github workflows to reflect the latest ghidrathon installation and bumped up jep, ghidra versions #2020 @psahithireddy
- add deptry support #1497 @s-ff
### Raw diffs ### Raw diffs
- [capa v7.0.1...master](https://github.com/mandiant/capa/compare/v7.0.1...master) - [capa v7.0.1...master](https://github.com/mandiant/capa/compare/v7.0.1...master)

View File

@@ -48,8 +48,9 @@ dependencies = [
"dnfile==0.14.1", "dnfile==0.14.1",
"dncil==1.0.2", "dncil==1.0.2",
"pydantic==2.7.1", "pydantic==2.7.1",
"rich==13.4.2",
"humanize==4.9.0",
"protobuf==5.27.0", "protobuf==5.27.0",
"rich==13.4.2"
] ]
dynamic = ["version"] dynamic = ["version"]
@@ -95,6 +96,7 @@ dev = [
"types-psutil==5.8.23", "types-psutil==5.8.23",
"types_requests==2.32.0.20240523", "types_requests==2.32.0.20240523",
"types-protobuf==5.26.0.20240422", "types-protobuf==5.26.0.20240422",
"deptry==0.14"
] ]
build = [ build = [
"pyinstaller==6.7.0", "pyinstaller==6.7.0",
@@ -102,6 +104,77 @@ build = [
"build==1.2.1" "build==1.2.1"
] ]
[tool.deptry]
extend_exclude = [
"sigs",
"tests"
]
# dependencies marked as first party, to inform deptry that they are local
known_first_party = [
"backports",
"binaryninja",
"flirt",
"ghidra",
"ida_bytes",
"ida_entry",
"ida_funcs",
"ida_kernwin",
"ida_loader",
"ida_nalt",
"ida_segment",
"idaapi",
"idautils",
"idc",
"java",
"netnode",
"PyQt5"
]
[tool.deptry.per_rule_ignores]
# dependencies defined but not used in the codebase
DEP002 = [
"black",
"build",
"deptry",
"flake8",
"flake8-bugbear",
"flake8-comprehensions",
"flake8-copyright",
"flake8-encodings",
"flake8-logging-format",
"flake8-no-implicit-concat",
"flake8-print",
"flake8-simplify",
"flake8-todos",
"flake8-use-pathlib",
"isort",
"mypy",
"mypy-protobuf",
"pre-commit",
"pyinstaller",
"pytest",
"pytest-cov",
"pytest-instafail",
"pytest-sugar",
"ruff",
"setuptools",
"types-backports",
"types-colorama",
"types-protobuf",
"types-psutil",
"types-PyYAML",
"types-tabulate",
"types-termcolor",
"types_requests",
"wcwidth"
]
# dependencies imported but missing from definitions
DEP003 = [
"typing_extensions" # TODO(s-ff): remove when Python 3.9 is deprecated, see #1699
]
[project.urls] [project.urls]
Homepage = "https://github.com/mandiant/capa" Homepage = "https://github.com/mandiant/capa"
Repository = "https://github.com/mandiant/capa.git" Repository = "https://github.com/mandiant/capa.git"