Commit Graph
15 Commits
Author SHA1 Message Date
Willi BallenthinandGitHub ccf3a87e83 tests: add snapshot tests for feature extraction (#3069)
Introduces data-driven snapshot tests that regenerate capa freeze files
for a curated set of samples in the tests/data submodule and compare the
bytes against committed fixtures under tests/fixtures/freezes/. Any
change that perturbs feature extraction surfaces as a test failure with
a feature-count delta and a truncated unified diff.
2026-06-09 23:28:49 +02:00
Willi BallenthinandWilli Ballenthin 2604c91668 fix: lints 2026-05-11 11:14:28 +02:00
Willi BallenthinandWilli Ballenthin 018e5b45e5 tests: cleanup tests and fixtures 2026-05-11 11:14:28 +02:00
Willi BallenthinandWilli Ballenthin b505ba7621 fix: remove unused imports and un-suppress F401
closes #2996
2026-05-08 17:58:07 +02:00
Willi BallenthinandWilli Ballenthin ad538f7ac3 fix: remove unused imports from test_freeze_dynamic.py
Remove capa.helpers, capa.features.basicblock (never referenced), and
redundant bare capa.features.extractors.base_extractor (covered by the
from-import on the next line).

Closes SURF-78
2026-05-08 17:58:07 +02:00
Willi BallenthinandWilli Ballenthin 89a365fa3d fix: address Optional member access and type mismatch in tests (chunk 6)
- test_binexport_accessors.py: type: ignore on .expression accesses guarded by test assertions
- test_freeze_dynamic.py: assert isinstance DynamicFeatureExtractor before compare_extractors
- test_binja_features.py: type: ignore on binaryninja guarded by skipif decorator
2026-04-23 16:11:58 +03:00
Mike HunhoffandGitHub ed7e0cd77d lint: replace black/isort/flake8 with ruff (#2992)
* lint: replace isort/flake8 with ruff

* update ruff links

* remove stale isort reference

* update CHANGELOG

* address review

* remove unused imports

* remove unnecessary list comprehension

* remove quotes from type annotation

* use dict.get instead of if-else block

* remove unnecessary utf-8 encoding declaration

* Revert "remove unused imports"

This reverts commit 18ba50a22b.

* skip check for unused imports

* fix UP036 Version block is outdated for minimum Python version

* add TODO comment for unused imports

* replace black with ruff

* address review comments
2026-04-07 12:10:41 -06:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>MoritzCapa Bot
7b23834d8e build(deps-dev): bump black from 25.12.0 to 26.3.0 (#2902)
* build(deps-dev): bump black from 25.12.0 to 26.3.0

Bumps [black](https://github.com/psf/black) from 25.12.0 to 26.3.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/25.12.0...26.3.0)

---
updated-dependencies:
- dependency-name: black
  dependency-version: 26.3.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* style: auto-format with black and isort

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Moritz <mr-tz@users.noreply.github.com>
Co-authored-by: Capa Bot <capa-dev@mandiant.com>
2026-03-13 15:46:13 +01:00
Willi BallenthinandWilli Ballenthin 8d17319128 capabilities: use dataclasses to represent complicated return types
foo
2025-01-29 02:25:06 -07:00
Ana Maria Martinez GomezandWilli Ballenthin 3cd97ae9f2 [copyright + license] Fix headers
Replace the header from source code files using the following script:
```Python
for dir_path, dir_names, file_names in os.walk("capa"):
    for file_name in file_names:
        # header are only in `.py` and `.toml` files
        if file_name[-3:] not in (".py", "oml"):
            continue
        file_path = f"{dir_path}/{file_name}"
        f = open(file_path, "rb+")
        content = f.read()
        m = re.search(OLD_HEADER, content)
        if not m:
            continue
        print(f"{file_path}: {m.group('year')}")
        content = content.replace(m.group(0), NEW_HEADER % m.group("year"))
        f.seek(0)
        f.write(content)
```

Some files had the copyright headers inside a `"""` comment and needed
manual changes before applying the script. `hook-vivisect.py` and
`pyinstaller.spec` didn't include the license in the header and also
needed manual changes.

The old header had the confusing sentence `All rights reserved`, which
does not make sense for an open source license. Replace the header by
the default Google header that corrects this issue and keep capa
consistent with other Google projects.

Adapt the linter to work with the new header.

Replace also the copyright text in the `web/public/index.html` file for
consistency.
2025-01-15 08:52:42 -07:00
mr-tz 2987eeb0ac update type annotations
tmp
2024-10-22 09:38:25 +00:00
Willi Ballenthin 9e6919f33c layout: capture call names
so that they can be rendered to output
2023-10-20 14:21:13 +00:00
Willi Ballenthin ee4f02908c layout: capture process name 2023-10-20 12:38:35 +00:00
Willi Ballenthin bfecf414fb freeze: add dynamic tests 2023-10-20 06:59:34 +00:00
Willi Ballenthin 8b0ba1e656 tests: rename freeze tests 2023-10-19 09:24:18 +00:00