Commit Graph
76 Commits
Author SHA1 Message Date
Ana María Martínez GómezandGitHub c547519ee4 Merge pull request #537 from Ana06/master-py2-1_6_3 2021-04-29 14:13:20 +02:00
Ana María Martínez GómezandGitHub eea0e1e738 Merge pull request #527 from Ana06/v1-6-2 2021-04-13 17:21:31 +02:00
Ana María Martínez GómezandGitHub 407ecab162 Merge pull request #515 from Ana06/v1-6-1 2021-04-07 18:03:56 +02:00
Ana María Martínez GómezandGitHub 31fc5a31d6 Merge pull request #513 from Ana06/ping-dependencies
setup: pin dependencies
2021-04-07 10:19:04 +02:00
Ana María Martínez GómezandGitHub c36ed71353 Merge pull request #470 from fireeye/ci/test-windows 2021-04-07 09:38:34 +02:00
Ana María Martínez GómezandGitHub 1062ba995e doc: add milestones link to release checklist
This makes it a bit easier to check if all milestoned issues/PRs are addressed, or reassign to a new milestone.

I am committing directly to master as this is a minor change which doesn't need review.
2021-04-06 10:21:43 +02:00
Ana María Martínez GómezandGitHub 7f93bd5b59 Merge pull request #512 from fireeye/williballenthin-patch-2
setup: bump viv to v1.0.1
2021-04-06 10:17:44 +02:00
Ana María Martínez GómezandGitHub 6f289d1b8e Merge pull request #476 from Ana06/tag-workflow 2021-03-23 09:54:59 +01:00
Ana María Martínez GómezandGitHub ab7dbcd2e4 Merge pull request #491 from fireeye/williballenthin-patch-3 2021-03-22 19:16:49 +01:00
Ana María Martínez GómezandGitHub 030893e125 Merge pull request #475 from Ana06/incompatible-viv
changelog: document incompatibility of viv files
2021-03-15 17:30:17 +01:00
Ana María Martínez GómezandGitHub 7a8c0572e9 Merge pull request #455 from Ana06/v1-6-0 2021-03-09 10:48:01 +01:00
Ana María Martínez GómezandGitHub dd3deb2358 Merge pull request #454 from fireeye/mr-tz-patch-1
setup: bump viv to 0.2.1
2021-03-08 11:36:18 +01:00
Ana María Martínez GómezandGitHub 829274cd5e Merge pull request #421 from Ana06/viv-py3 2021-03-03 21:40:08 +01:00
Ana María Martínez Gómez a39e3cca79 ci: test all supported Python versions
I assume once we migrate to Python3, we want to support Python 3.6-9.
Python 3.5 will stop receiving security fixes next month, so I don't
think we need to support it.

As running the test as many times as we want is free, run them for all
supported versions to ensure capa work in all of them.
2020-08-21 15:39:13 +02:00
Ana María Martínez Gómez ad011b08f6 ci: use matrix in tests workflow to avoid duplication
Use a matrix with the Python version to avoid duplication when testing
different Python versions.
2020-08-21 15:00:06 +02:00
Ana María Martínez Gómez a2da55fb6f Add version number to zip in build workflow
Relay in `github.ref` (the release tag).
2020-08-17 11:59:04 +02:00
Ana María Martínez Gómez f7925c2990 Fix pypinstaller to version 3 in build workflow
pyinstaller 4 doesn't support Python 2.7. Without a version, it takes
the last version making the workflow fail.
2020-08-15 12:28:51 +02:00
Ana María Martínez Gómez b94f665d4b Zip release binaries
Update `build` workflow to zip the binaries before upload them. Use
linux to zip all the binaries.
2020-08-15 12:28:48 +02:00
Ana María Martínez Gómez 68f27dfea4 Fix indentation of build workflow
Correct indentation to make it easier to read.
2020-08-15 09:11:18 +02:00
Ana María Martínez Gómez 35226e1e4e Use GitHub default repo token in build action
As we this workflow modifies only the same repo, no extra token
(`CAPA_TOKEN`) is needed and we can use the default `GITHUB TOKEN`
instead.
2020-08-15 09:11:16 +02:00
Ana María Martínez Gómez adaac03d1d extractor: remove characteristic(switch)
Get rid of the `characteristic(switch)` feature as any of our rules use
it and its analysis is not very easy. Analysis results most likely
differ across backends, leading to inconsistency.
2020-08-13 16:47:01 +02:00
Ana María Martínez GómezandGitHub 56f258dd46 Merge pull request #213 from Ana06/update-hooks 2020-07-29 20:35:15 +02:00
Ana María Martínez Gómez f9abbbe9ba hooks: change from post- to pre-commit
Avoid erroneous commits. The pre-commit can be skipped with the
`--no-verify` option, which is not available with the post-commit.
Note that `pre-commit` doesn't run when rebase while post-commit did.

This allows to have a single script which is run by both hooks. This
scripts can also be used independently to run the CI setup locally.
2020-07-29 20:25:03 +02:00
Ana María Martínez Gómez 8ff9e339f5 hooks: improve comment in setup-hooks.sh
Previously the `setup-hooks.sh` took care of more things. Consequently
the comments needed to be separated. This is not needed anymore and it
looks weird.
2020-07-29 20:16:58 +02:00
Ana María Martínez Gómez 6d00ae26ae hooks: do not repeat #!/usr/bin/env bash
The comment claims that:
> doesn't matter if `#!/usr/bin/env bash` gets repeated later on in a hooks file

However it is a convetion that there is only one comment like that and
the `setup-hooks.sh` script already takes care of adding it if the file
didn't exist.

Alternatively, we could leave the extra comment and remove the related
code in `setup-hooks.sh`. Currently two comments are added even if the
file didn't exist.
2020-07-29 20:16:56 +02:00
Ana María Martínez Gómez 22fd52ccb9 hooks: do not render git stash output
The `-q` options hides most of the output, but not everything.
2020-07-29 20:16:55 +02:00
Ana María Martínez Gómez 70dda980e8 hooks: update style checkers in hooks
Run `isort` and `black` in the hooks. Run them with the `--check` option
to not modify files which could be committed by accident.

Note that the changes in `.gitignore` are not needed as `.log` is
already excluded in the Django's section. We add those file to this
section in case `.log` is removed in the future.
2020-07-29 20:16:52 +02:00
Ana María Martínez Gómez 61818bbe04 tests: Test statement nodes descriptions
Add statement descriptions to `test_rule_yaml_descriptions` to ensure
rules with statement descriptions are parsed and extracted correctly.
2020-07-28 15:58:55 +02:00
Ana María Martínez Gómez 56bf6a8d79 Render description in vverbose mode for for statement nodes
Implement it similarly as how it is rendered for features.
2020-07-28 15:58:38 +02:00
Ana María Martínez Gómez b3c89acda7 render: refactor render_statement in vverbose
Avoid code repetition to make modifying this code easier.
2020-07-28 15:58:37 +02:00
Ana María Martínez Gómez bee91583e5 Enable descriptions for statement nodes
Enable descriptions for statement nodes such as and and or.

Use of case in: fireeye/capa-rules/pull/51

Documentation should be added in capa-rules.
2020-07-28 15:58:24 +02:00
Ana María Martínez Gómez a74ab922a3 Get rid of * for Statement
They are not needed and complicate the code and make more difficult to
add more parameters to the initialization of Statements.

This produces many changes in the tests. The alternative would be to add
a parameter None in all of them, which are also a lot of changes.
2020-07-28 14:20:13 +02:00
Ana María Martínez Gómez 6060397944 render: Refactor convert_statement_to_result_document
Avoid repeating code and make easier to modify.
2020-07-28 14:20:11 +02:00
Ana María Martínez Gómez 3e3fb18deb black: Fix typo in import-to-bn.py
Tests are broken in master
2020-07-27 18:41:15 +02:00
Ana María Martínez GómezandGitHub e566095a85 Merge pull request #195 from fireeye/fix/no-progress-on-quiet
fix: disable progress when run in quiet mode
2020-07-24 11:38:59 +02:00
Ana María Martínez GómezandGitHub 41a8199770 Merge pull request #187 from Ana06/documentation 2020-07-24 10:32:32 +02:00
Ana María Martínez Gómez f3e2abf467 doc: Improve issue templates
Add some useful information, correct small mistakes and simplify the
templates. Make also both templates consistent.
2020-07-24 10:24:35 +02:00
Ana María Martínez Gómez 0665873b00 doc: Improve cloning capa source code documentation
Move the cloning all submodule option to the beginning as when using
capa in development this is the most common option. Test files are
needed to run the tests locally. Simplify the rest of the submodules
documentation, as it is easier for people to look the submodule
documentation than for us to maintain a copy. The submodule init step
shouldn't be needed to clone the rules directory.
2020-07-24 10:24:34 +02:00
Ana María Martínez Gómez aa2eb7771c doc: Document supported Linux distributions
Document for which Linux distributions the standalone Linux binary
works.
2020-07-24 10:24:31 +02:00
Ana María Martínez Gómez 85ff03215e Update CI badge in README
- Give it a better name after rule linter and tests have been added to
CI.
- Change the URL to only show result of commits pushed to master
2020-07-22 19:36:54 +02:00
Ana María Martínez Gómez def4ad68c3 ci: Run tests in master and PRs
Add the tests to the CI GitHub action. Only run the tests if code style
and rule linter succeed, as tests take some time to run.

A similar actions should be added to `capa-testfiles`.
2020-07-22 19:36:51 +02:00
Ana María Martínez Gómez 7d58d3244c setup: Add vivisect installation to setup.py
Vivisect is not available on PyPI. Tell `pip` in `setup.py` where to
find it so that it is not needed to do it as a separate step.
2020-07-20 22:19:31 +02:00
Ana María Martínez Gómez e744652999 Run rules linter in master and PRs
Add the rule linter to the CI GitHub action. A similar actions should be
added to `capa-rules` as well.
2020-07-17 14:20:37 +02:00
Ana María Martínez Gómez ab1dc3b804 Fix rule linter
Prevent the linter to raise an exception if `examples` is `None`, as it
for example currently happens in:
`capa-rules/nursery/hash-data-using-murmur2.yml`

We could also remove the `examples` tag in those cases, but the linter
shouldn't break in any case.
2020-07-17 14:01:07 +02:00
Ana María Martínez GómezandGitHub 9701d611f2 Merge pull request #151 from fireeye/ana-ci-badge 2020-07-16 23:00:36 +02:00
Ana María Martínez Gómez 81f943d39f Add CI status badge to README
Add a GitHub action status badge for `CI` to README.
2020-07-16 22:57:11 +02:00
Ana María Martínez GómezandGitHub ef44e7e813 Merge pull request #150 from fireeye/ana-code-style 2020-07-16 22:19:51 +02:00
Ana María Martínez Gómez 4ab97ec910 ci: Add GitHub action for style checkers
Run isort and black for every pull request or push.
2020-07-16 22:05:17 +02:00
Ana María Martínez Gómez 07764fb31f Use isort 5
Run `isort --profile black --length-sort --line-width 120 .`

Update documentation as well.
2020-07-16 22:02:53 +02:00
Ana María Martínez GómezandGitHub e7a6e31a8e Merge pull request #161 from fireeye/ana-license-badge 2020-07-16 17:22:06 +02:00
Ana María Martínez Gómez 0a0de53fe4 Add license badge to README
Use https://shields.io/category/license
2020-07-16 16:29:52 +02:00
Ana María Martínez Gómez 80ba19a466 Do not initialize Regex match
It is not used until it has a value.
2020-07-15 23:02:06 +02:00
Ana María Martínez Gómez 78dae308c2 Add test for RegExp descriptions
Now that RegExp are a feature, ensure that descriptions are working.
2020-07-15 22:37:38 +02:00
Ana María Martínez Gómez 6fe56f6224 Make Regex a Feature
This enables description for regular expressions and simplifies the code.
2020-07-15 22:37:35 +02:00
Ana María Martínez GómezandGitHub a28baf09d6 Merge pull request #153 from fireeye/fix/version-option 2020-07-15 16:40:24 +02:00
Ana María Martínez Gómez b123463a9c Add rules number badge to README
This number will be updated when synchronizing the rules submodule using
a GitHub action.
2020-07-14 16:02:55 +02:00
Ana María Martínez GómezandGitHub 3acfc413bf Merge pull request #118 from fireeye/ana-fix-style 2020-07-07 19:00:04 +02:00
Ana María Martínez Gómez 6dacab9848 Fix description
```
s = 'number: 4 = I am a description with an = yes'
s.rpartition(' = ') => ('4 = I am a description with an', ' = ', 'yes')
s.partition(' = ') => ('4', ' = ', 'I am a description with an = yes')
s.split(' = ', 1) => ['4', 'I am a description with an = yes']
```
2020-07-07 18:54:36 +02:00
Ana María Martínez Gómez 3dc3e083a9 Remove args from Features
`args` and `value` are a duplication for most of the features:
`args = [value]`
get rid of `args` and introduce `value` for `Feature` (the main class
instead of the subclasses). This makes the code simpler.

Refactoring the `freeze_serialize` function to not use an array would
simplify the code a bit more, but that needs a bit more of work.
2020-07-07 18:06:30 +02:00
Ana María Martínez Gómez a6ddd044c7 Fix style offenses
pycodestyle is failing in master.
2020-07-07 15:50:09 +02:00
Ana María Martínez Gómez 6a9842f44f Fix misplaced type annotation
A misplaced type annotation in `capa/main.py` causes that black fails to
solve offenses in this file. It may also make capa fail in newer Python
versions. Replace type by `schema` as we don't use type checker tools.
2020-07-06 08:28:24 +02:00
Ana María Martínez Gómez 26d2f12038 Add Python3 requirement for black
When installing the development dependencies with Python2, it fails as
black is not available for Python2.
2020-07-03 11:38:21 +02:00
Ana María Martínez Gómez 2f78c681e4 Document how to install development dependencies
Introduced in:
https://github.com/fireeye/capa/commit/d1dd997b7bb58aedb059cdcd68b74117543c6088
2020-07-03 11:30:39 +02:00
Ana María Martínez GómezandGitHub f6b54beb02 Merge pull request #39 from fireeye/ana-description 2020-07-02 17:07:04 +02:00
Ana María Martínez Gómez 152129cc25 Add tests for description feature
Test if the parsing of feature succeeds with every time of description.
2020-07-02 16:50:28 +02:00
Ana María Martínez Gómez 81741b49f7 Support inline descriptions for count
```
count(number(2 = AF_INET/SOCK_DGRAM)): 2
```
2020-07-02 16:50:22 +02:00
Ana María Martínez GómezandWilliam Ballenthin 64124c0b64 Remove True from Characteristic rules and output
Get rid of `True` in characteristic (rules, output and json) as it is
implicit. This way, the same syntax is used for characteristic as for
the rest of the features.

Co-authored-by: William Ballenthin <william.ballenthin@fireeye.com>
2020-07-02 16:50:15 +02:00
Ana María Martínez Gómez 681feebf35 Adapt description implementation to new output
As the `__str__` method is not used anymore in the output, the
description implementation needs to be adapted.
2020-07-02 16:50:07 +02:00
Ana María Martínez Gómez 767a76d814 Allow to add a description for every feature
Enable associate context for all features. This was called symbol before
and only enabled for `number`, `offset` and `bytes`.

This is not enabled for strings with regular expressions, as they are
not a feature.
2020-07-02 11:31:31 +02:00
Ana María Martínez Gómez f8cfb67d02 Fix KeyError in Range#evaluate()
If the key doesn't exist, `evaluate` raises a `KeyError` Exception,
making the tests fail.
2020-07-02 11:28:47 +02:00
Ana María Martínez Gómez a80f38ec75 Fix get_features rule linter
To support matching namespaces `get_features()` get an extra parameters
which was missing in the rule linter.
2020-07-02 09:24:51 +02:00
Ana María Martínez Gómez 24792cd160 Fix unrestored stashed changes in post-commit hook
If the style checker of the rule linter failed, the stashed changes were
not restored. There is no reason to exist with an error code in a post
hook. In pre hooks this causes the action to be aborted.
2020-07-01 13:59:06 +02:00
Ana María Martínez Gómez 8e78d8de53 Fix KeyError when deleting nonexistent keys
`hidden_meta` saves not only the existing hidden meta keys, but also
those who don't exist with value `None`. For example:
```
{'capa/path': None, 'capa/nursery': None}
```

Deleting nonexistent keys raises a `KeyError` exception.
2020-06-30 14:24:06 +02:00
Ana María Martínez Gómez 72b6ee5cf3 Remove Build Status from README
This should have been removed as part of the migration. The build status
in the README will be reimplemented using GitHub Actions and
https://shields.io
2020-06-24 12:31:01 +02:00
Ana María Martínez Gómez 96ad823e35 Add hooks for running linters and tests
Add the `scripts/setup-hooks.sh` script which sets the following hooks
up:
- The `post-commit` hook runs the linter after every `git commit`,
  letting you know if there are code style or rule linter offenses you
  need to fix.
- The `pre-push` hook runs the linter and the tests and block the `git
  push` if they do not succeed.
  This way you realise if everything is alright without the need of
  sending a PR.
2020-06-22 11:35:45 +02:00
Ana María Martínez Gómez 7e1e9e6618 Get rid of the Element class
The `Element` class is just used for testing. By using `Element` we are
not testing the actual code. Also, every time we implement a new feature
for the `Feature` class, we need to implement it for `Element` as well.
Replace `Element` by `Integer`.
2020-06-24 18:05:52 +02:00