Skip to content

Commit 746be3f

Browse files
committed
Merge branch 'master' into staging
2 parents a637ad1 + b4124a5 commit 746be3f

File tree

9 files changed

+90
-31
lines changed

9 files changed

+90
-31
lines changed

.github/copilot-instructions.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copilot Instructions for CAPEv2
2+
3+
## General Architecture
4+
- CAPEv2 is an automated malware analysis platform, based on Cuckoo Sandbox, with extensions for dynamic, static, and network analysis.
5+
- The backend is mainly Python, using SQLAlchemy for the database and Django/DRF for the web API.
6+
- Main components include:
7+
- `lib/cuckoo/core/database.py`: database logic and ORM.
8+
- `web/apiv2/views.py`: REST API endpoints (Django REST Framework).
9+
- `lib/cuckoo/common/`: shared utilities, configuration, helpers.
10+
- `storage/`: analysis results and temporary files.
11+
- Typical flow: sample upload → DB registration → VM assignment → analysis → result storage → API query.
12+
13+
## Conventions and Patterns
14+
- Heavy use of SQLAlchemy 2.0 ORM, with explicit sessions and nested transactions (`begin_nested`).
15+
- Database models (Sample, Task, Machine, etc.) are always managed via `Database` object methods.
16+
- API endpoints always return a dict with `error`, `data`, and, if applicable, `error_value` keys.
17+
- Validation and request argument parsing is centralized in helpers (`parse_request_arguments`, etc.).
18+
- Integrity errors (e.g., duplicates) are handled with `try/except IntegrityError` and recovery of the existing object.
19+
- Tags are managed as comma-separated strings and normalized before associating to models.
20+
- Code avoids mutable global variables; configuration is accessed via `Config` objects.
21+
22+
## Developer Workflows
23+
- No Makefile or standard build scripts; dependency management is usually via `poetry` or `pip`.
24+
- For testing, use virtual environments and run scripts manually.
25+
- Typical backend startup is via Django (`manage.py runserver`), and analysis workers are launched separately.
26+
- Database changes require manual migrations (see Alembic comments in `database.py`).
27+
28+
## Integrations and Dependencies
29+
- Optional integration with MongoDB and Elasticsearch, controlled by configuration (`reporting.conf`).
30+
- The system can use different compression tools (zlib, 7zip) depending on config.
31+
- Sample analysis may invoke external utilities (e.g., Sflock, PE parsers).
32+
33+
## Key Pattern Examples
34+
- IntegrityError handling example:
35+
```python
36+
try:
37+
with self.session.begin_nested():
38+
self.session.add(sample)
39+
except IntegrityError:
40+
sample = self.session.scalar(select(Sample).where(Sample.md5 == file_md5))
41+
```
42+
- API response example:
43+
```python
44+
return Response({"error": False, "data": result})
45+
```
46+
- Tag assignment example:
47+
```python
48+
tags = ",".join(set(_tags))
49+
```
50+
51+
## Key Files
52+
- `lib/cuckoo/core/database.py`: database logic, sample/task registration, machine management.
53+
- `web/apiv2/views.py`: REST endpoints, validation, high-level business logic.
54+
- `lib/cuckoo/common/`: utilities, helpers, configuration.
55+
56+
---
57+
58+
If you introduce new endpoints, helpers, or models, follow the validation, error handling, and standard response patterns. See the files above for implementation examples.

data/yara/CAPE/Lumma.yar

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ rule Lumma
1010
$decode1 = {C1 (E9|EA) 02 [0-3] 0F B6 (44|4C) ?? FF 83 (F8|F9) 3D 74 05 83 (F8|F9) 2E 75 01 (49|4A) [0-30] 2E 75}
1111
$decode2 = {B0 40 C3 B0 3F C3 89 C8 04 D0 3C 09 77 06 80 C1 04 89 C8 C3 89 C8 04 BF 3C}
1212
$decode3 = {B0 40 C3 B0 3F C3 80 F9 30 72 ?? 80 F9 39 77 06 80 C1 04 89 C8 C3}
13+
$decode4 = {89 C8 04 D0 3C 09 77 ?? [3-11] 89 C8 [0-1] C3 89 C8 04 BF 3C 1A 72 ?? 89 C8 04 9F 3C}
1314
condition:
1415
uint16(0) == 0x5a4d and any of them
1516
}

docs/book/src/installation/guest/requirements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Python is a strict requirement for the CAPE guest component (*analyzer*) to run
1818
version of Python can be 64-bit (x64).
1919

2020
You can download the proper `Windows`_ / `Linux`_ installer from the `official website`_.
21-
Python versions > 3.6 are preferred.
21+
Python versions > 3.10 and < 3.13 are preferred.
2222

2323
.. important::
2424
When installing Python, it is recommended to select the `Add Python <version> to PATH` option. And remove from that PATH `%USERPROFILE%\AppData\Local\Microsoft\WindowsApps`

installer/cape2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ EOL
691691
function install_suricata() {
692692
echo '[+] Installing Suricata'
693693
sudo add-apt-repository -y ppa:oisf/suricata-stable
694-
sudo apt-get install -y suricata suricata-update
694+
sudo apt-get -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install -y suricata suricata-update
695695
touch /etc/suricata/threshold.config
696696

697697
# Download etupdate to update Emerging Threats Open IDS rules:

installer/kvm-qemu.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,10 @@ function cloning() {
12021202
<dnsmasq:option value='dhcp-option=46,8'/>
12031203
<!--Send an empty WPAD option. This may be REQUIRED to get windows 7 to behave.-->
12041204
<dnsmasq:option value='dhcp-option=252,"\n"'/>
1205+
<!--Prevent DNS rebinding to internal hosts.-->
1206+
<dnsmasq:option value='stop-dns-rebind'/>
1207+
<!-- To allow rebinding for specific domains, uncomment and modify the following line. -->
1208+
<!-- <dnsmasq:option value='rebind-domain-ok=/example.com/'/> -->
12051209
</dnsmasq:options>
12061210
</network>
12071211
EOF

modules/machinery/az.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ def _get_relevant_machines(self, tag):
12151215
"""
12161216
# The number of relevant machines are those from the list of locked and unlocked machines
12171217
# that have the correct tag in their name
1218-
return [machine for machine in self.db.list_machines([tag])]
1218+
return self.db.list_machines(tags=[tag])
12191219

12201220
@staticmethod
12211221
def _wait_for_concurrent_operations_to_complete(timeout=AZURE_TIMEOUT):

poetry.lock

Lines changed: 20 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ requests-file = ">=1.5.1"
2929
orjson = ">=3.9.15"
3030
# maec = "4.1.0.17"
3131
# regex = "2021.7.6"
32-
SFlock2 = {version = ">=0.3.66", extras = ["shellcode","linux"]}
32+
SFlock2 = {version = ">=0.3.76", extras = ["shellcode","linux"]}
3333
# volatility3 = "2.11.0"
3434
# XLMMacroDeobfuscator = "0.2.7"
3535
pyzipper = "0.3.6"

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,9 +1816,9 @@ setproctitle==1.3.2 ; python_version >= "3.10" and python_version < "4.0" \
18161816
setuptools==78.1.1 ; python_version >= "3.10" and python_version < "4.0" \
18171817
--hash=sha256:c3a9c4211ff4c309edb8b8c4f1cbfa7ae324c4ba9f91ff254e3d305b9fd54561 \
18181818
--hash=sha256:fcc17fd9cd898242f6b4adfaca46137a9edef687f43e6f78469692a5e70d851d
1819-
sflock2==0.3.69 ; python_version >= "3.10" and python_version < "4.0" \
1820-
--hash=sha256:3f140ad380a51eb9f3ff5e436fa17c50daf365d845a5a40339896522291ef935 \
1821-
--hash=sha256:fb1ecbe635c776a15de92817c002a2fbc9c06d84168a0bde8e96f16fe5c81fb2
1819+
sflock2==0.3.76 ; python_version >= "3.10" and python_version < "4.0" \
1820+
--hash=sha256:3d989d142fc49ebd049f75eb8d402451fcd20148cf27aaa20c540ac95a9c81ff \
1821+
--hash=sha256:eed75b32adf3c82a60d9339fda63a151355f9be7639d7d583de8f43ea6604e4c
18221822
six==1.17.0 ; python_version >= "3.10" and python_version < "4.0" \
18231823
--hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274 \
18241824
--hash=sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81

0 commit comments

Comments
 (0)