Skip to content

Commit

Permalink
Add deptry support (#2085)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
s-ff and s-ff committed May 31, 2024
1 parent 0ac21f0 commit 2e5da3e
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ jobs:
- name: Lint with flake8
run: pre-commit run flake8 --hook-stage manual
- 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:
runs-on: ubuntu-20.04
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ repos:
- "--ignore=tests/test_scripts.py"
always_run: true
pass_filenames: false

- repo: local
hooks:
- id: deptry
name: deptry
stages: [push, manual]
language: system
entry: deptry .
always_run: true
pass_filenames: false
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
- add deptry support #1497 @s-ff

### Raw diffs
- [capa v7.0.1...master](https://github.com/mandiant/capa/compare/v7.0.1...master)
Expand Down
75 changes: 74 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ dependencies = [
"dnfile==0.14.1",
"dncil==1.0.2",
"pydantic==2.7.1",
"rich==13.4.2",
"humanize==4.9.0",
"protobuf==5.27.0",
"rich==13.4.2"
]
dynamic = ["version"]

Expand Down Expand Up @@ -95,13 +96,85 @@ dev = [
"types-psutil==5.8.23",
"types_requests==2.32.0.20240523",
"types-protobuf==5.26.0.20240422",
"deptry==0.14"
]
build = [
"pyinstaller==6.7.0",
"setuptools==69.5.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]
Homepage = "https://github.com/mandiant/capa"
Repository = "https://github.com/mandiant/capa.git"
Expand Down

0 comments on commit 2e5da3e

Please sign in to comment.