mirror of
https://github.com/mandiant/capa.git
synced 2025-12-05 20:40:05 -08:00
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.
44 lines
1.4 KiB
INI
44 lines
1.4 KiB
INI
[flake8]
|
|
max-line-length = 120
|
|
|
|
extend-ignore =
|
|
# E203: whitespace before ':' (black does this)
|
|
E203,
|
|
# F401: `foo` imported but unused (prefer ruff)
|
|
F401,
|
|
# F811 Redefinition of unused `foo` (prefer ruff)
|
|
F811,
|
|
# E501 line too long (prefer black)
|
|
E501,
|
|
# E701 multiple statements on one line (colon) (prefer black, see https://github.com/psf/black/issues/4173)
|
|
E701,
|
|
# B010 Do not call setattr with a constant attribute value
|
|
B010,
|
|
# G200 Logging statement uses exception in arguments
|
|
G200,
|
|
# SIM102 Use a single if-statement instead of nested if-statements
|
|
# doesn't provide a space for commenting or logical separation of conditions
|
|
SIM102,
|
|
# SIM114 Use logical or and a single body
|
|
# makes logic trees too complex
|
|
SIM114,
|
|
# SIM117 Use 'with Foo, Bar:' instead of multiple with statements
|
|
# makes lines too long
|
|
SIM117
|
|
|
|
per-file-ignores =
|
|
# T201 print found.
|
|
#
|
|
# scripts are meant to print output
|
|
scripts/*: T201
|
|
# capa.exe is meant to print output
|
|
capa/main.py: T201
|
|
# IDA tests emit results to output window so need to print
|
|
tests/test_ida_features.py: T201
|
|
# utility used to find the Binary Ninja API via invoking python.exe
|
|
capa/features/extractors/binja/find_binja_api.py: T201
|
|
|
|
copyright-check = True
|
|
copyright-min-file-size = 1
|
|
copyright-regexp = Copyright \d{4} Google LLC
|