42 Commits
Author SHA1 Message Date
Ricardo van Zutphen fd3adafba4 Read mysql dump per command
The MySQLdb driver seems to have issues with compound statements.
Importing an SQL file counts as this. Reading per command solves this.
2019-06-14 14:31:50 +02:00
ihatecsv 52dc77569c Fixed valid docstrings to comply with PEP 257 2019-05-13 18:09:51 +02:00
Jurriaan Bremer b843d1438f replace cuckoo.compat.magic by sflock.magic
Since version 0.3.4 sflock features 64-bit Windows support for magic(5).
Now that we no longer need this compatibility layer (which was
equivalent to the one in sflock) we simply get rid of it.
It was required earlier because Cuckoo wasn't capable of requiring
updated libraries in the pre-Python package era.
2018-06-03 02:39:00 +02:00
Jurriaan Bremer a6604bee46 code cleanup 2018-03-15 12:39:33 +01:00
Daan Spitz c805fa3905 use unique machine label in database test 2018-03-15 12:39:33 +01:00
Daan Spitz 2d06af6eca add test for setting machine rcparams 2018-03-15 12:39:32 +01:00
Jurriaan Bremer 7662e0c360 recursively walk and load yara rules on startup
Rather than creating the index_*.yar files during "cuckoo -d" and then
loading those when running "cuckoo process", we'll from now on always
enumerate the available Yara rules recursively and load 'em on-the-go.

This simplifies life when updating Yara rules and re-running "cuckoo
process -r". Furthermore this commit adds recursive walking support as
well as following symbolic links.

Currently there's a limitation in the usage of Yara rules, though, as at
the moment it isn't possible to use "include" statements in the rules
(with relative paths, anyway). We may be able to fix that by temporarily
os.chdir()'ing into the yara/category/ directory.

This commit resolves #773 and provides a stepping stone for #776 & #512.
2017-06-24 04:40:25 +02:00
Jurriaan Bremer 3f518216d8 add macosx unit testing to travis ci 2017-06-03 08:27:25 +02:00
Jurriaan Bremer 76f8e80a15 do not error if file-type is empty #1517 (thanks Daniel Perrie)
Resolves issue where it is impossible to add a Sample to the database on
64-bit Windows environments as support for magic filetypes is missing in
that environment.
This somewhat works around that, however, unless a package is provided
during submission, in some cases not much will happen during the actual
analysis as the file type guessing won't work and Cuckoo has to rely
solely on the sample file extension.
2017-05-03 16:14:31 +02:00
Jurriaan Bremer 221cdb252f more properly propagate machine.options #1381 #1392
For unknown reasons nobody ran into this issue before the 2.0.0 release,
however, on a clean Cuckoo setup with newly created configuration, the
machine.options field would always be set to None rather than an empty
string or list, resulting in various exceptions around the Core code.

This commit more improves the handling of this 'special' list type and
ensures the machine.options field will always be at least an empty list.
This counts for both the data retrieved from the configuration as well
as the database handling part.

Thanks to CSIRTUK and pinksawtooth for reporting and doomedraven for
providing an ad hoc solution.
2017-04-12 00:36:43 +02:00
Jurriaan Bremer c789c6ed08 turn x sql queries for postsubmit poll to just one
When submitting, e.g., 100 samples as part of just one submit, then the
postsubmit page would make never-ending XHR's. Move away from X
view_task() queries to a singular view_tasks() with X task IDs.
2017-03-28 18:46:52 +02:00
Jurriaan Bremer 6d1422485c once again fixup processing of an empty analysis 2017-03-23 11:54:51 +01:00
Jurriaan Bremer e146c439c6 move yara compilation to startup and crash hard on errors
By compiling all of the Yara rules at Cuckoo's startup we avoid the
issue that we've been having up until now: finding out about Yara
problems at runtime. Naturally this simplifies some Yara-related code,
resolves an issue where, in case one of the referenced Yara rules has a
syntax error, no Yara rule matches are performed & get_yara() returns
None (i.e., silently not doing any Yara magic & later on crashing hard
due to the silent thing), and some accompanying unit tests.
2017-03-20 03:48:28 +01:00
Jurriaan Bremer f5fc8d09ea initialize distributed cuckoo database unit test 2017-03-05 12:36:26 +01:00
Jurriaan Bremer 7b345c73e9 more thorough interaction with users regarding error/action
* Gets rid of unused action.json log.
* Introduces special handling & error logging for "critical timeout"
  issues that occur way too often among our users.
* Add "action" column to the Error table so we can instruct users to
  undertake certain actions.
* More properly pass along errors & action information upon analysis
  export and correctly handle those when importing an analysis.
* When an action is found, the Web Interface will now show possible
  solutions and/or workarounds that a user should follow.
2017-02-24 16:52:43 +01:00
Jurriaan Bremer b31014c4de fixup sqlite3 ordering issues (on windows) 2017-02-23 04:37:15 +01:00
Jurriaan Bremer 18d7ed4980 make submit columns nullable to accommodate recent use-cases
Since we're also using the submit table for reboot analysis, analysis
resubmits, and importing existing analyses it's preferable to make the
submit table a little bit less strict. Also changes an existing database
migration, which is not so nice, but that's fine for now.
2017-02-23 03:50:47 +01:00
Jurriaan Bremer 3a3e861cbf part one on web interface modernization
In no particular order:
* Sort emitted analysis options by alphabat.
* Allow assignment of analysis options by string and dict.
* Allow assignment of analysis tags by string and tuple/list.
* Further analysis options <> Web Interface options translation.
* Simplify and improve correctness of analysis import functionality.
* Remove plenty of outdated code / templates / etc.
* Attempt to pass analysis options & errors to /filetree.
* Reimplement resubmit & reboot analysis using new submit.
* Low/medium/high priority are {1..3}, not {0..2} in Web Interface.
* Fixed up various "missing variable" templating issues.
* Made /submit/api/submit input & unit tests up-to-date.
* Code refactoring, cleanup, and unit tests.

Following the one-liner to more properly indent & sort dictionary keys
alphabetically for the /submit input JSON data (so that future changes
are more clear than our current changes - which not only made the input
data more up-to-date but also altered some fields).

import json, sys
print json.dumps(json.load(sys.stdin), indent=4, sort_keys=True)
2017-02-23 03:43:44 +01:00
Jurriaan Bremer 99eb7bd9b0 replace postsubmit page to take just the submit-id
Before the postsubmit page would take a list of task IDs in the URL (as
part of the GET request). Aside from the fact that this is rather ugly,
this also doesn't scale in the sense that URLs are limited to 2-4kb in
length. Fix this by adding a relationship between Task and Submit and
showing that relation in the postsubmit page.
2017-02-20 23:29:27 +01:00
Jurriaan Bremer 4bdd8e6e66 database migrations for extending task.options and task.custom
It's quite likely that we're going to require these changes soon enough
with, at the very least, our new build matrix, but most likely also for
other use-cases.
2017-02-18 17:40:00 +01:00
Jurriaan Bremer df3b4b697c repurpose process -r to allow multiple task ids #1221 (thanks SparkyNZL)
With these changes it's now possible to invoke "cuckoo process -r 1,2,3"
to reprocess analysis 1 up to 3. Similarly one may use a range of tasks
as follows "cuckoo process -r 1-3" to achieve that same goal.
2017-02-15 13:01:26 +01:00
Jurriaan Bremer 0581b24f02 unit test database migrations from cuckoo 1.1
So the database migration for tasks/tags table were missing from our 0.6
release towards the 1.1 release, this doesn't mean, however, that we
should still apply those migrations for later setups (i.e., 1.1 and
upwards). Also note that Cuckoo 1.1 was shipping the incorrect schema
version (the one for 0.6 instead of 1.1) so some shuffling around of
revision nummbers was required.
2017-02-08 01:01:49 +01:00
Jurriaan Bremer b87cae2d29 convert config usage in database wrapper 2017-01-14 17:59:51 +01:00
Jurriaan Bremer 0da4e287e7 only connect to database once for cuckoo processing instances 2017-01-13 17:02:03 +01:00
Jurriaan Bremer a932da74d5 set django settings module env variable only once 2016-11-28 13:44:58 +01:00
Jurriaan Bremer e9365b8ed9 only apply dateutil parser if values are set at all 2016-11-19 14:10:37 +01:00
Jurriaan Bremer 9071d0932c Merge remote-tracking branch 'origin/package' into internal/master
Conflicts:
	cuckoo/data-private/cwd/conf/reporting.conf
	setup.py
	tests/test_database.py
2016-11-19 02:17:17 +01:00
Jurriaan Bremer fc48af7adc first release on regular/archive submission functionality
Reimplements earlier archive-based submission logic on top of the
regular file submission logic. Provides additional unit test and
improves some code here and there as well.
2016-11-19 02:06:57 +01:00
Jurriaan Bremer 5fcb7ec284 wip on extending the error.message column 2016-11-18 14:27:28 +01:00
Jurriaan Bremer 877a515f09 turn resultserver_port into an integer 2016-11-18 13:28:24 +01:00
Jurriaan Bremer e967fd7076 finish up on database migration unit tests
Among other changes, only run them on Linux-based OSs. For now there are
still some issues with MySQL support on Windows. Upgrade alembic.
2016-11-18 11:16:40 +01:00
Jurriaan Bremer 693c27e7dd ignore rows from earlier unit test runs 2016-11-17 23:05:31 +01:00
Jurriaan Bremer 0cf6a69d89 and finally make mysql from cuckoo 0.6.0 work too 2016-11-17 03:22:19 +01:00
Jurriaan Bremer 1aa5734dbe make migrations from 0.6.0 with sqlite3 work as well 2016-11-17 02:34:17 +01:00
Jurriaan Bremer 27463b8eb9 properly migrate from 0.6.0 to latest in postgresql
We had some broken parts in the database migrations for PostgreSQL.
Those issues have now been resolved.
2016-11-17 01:34:35 +01:00
Jurriaan Bremer 336269e151 do not automatically create and populate the db during migrations
There was a time, before Cuckoo 1.1'ish, that we didn't have the
alembic_version table. This commit ensures that Cuckoo won't
automatically create it and set it to the latest available version
if it's missing - preventing migrations from 0.6 to go through.
2016-11-16 17:49:12 +01:00
Jurriaan Bremer ea81bd7fd8 unit test tweaks 2016-11-16 13:15:49 +01:00
Jurriaan Bremer 688a8322b1 setup unit testing for postgresql and mysql
Let's no longer do a drop database unit test, as PostgreSQL and MySQL
don't like that so much - and why would we anyway. Also note that we're
not installing PostgreSQL as that's already installed on Travis CI by
default.
2016-10-29 15:32:57 +02:00
Jurriaan Bremer bf3bc89e7c temporary workaround for limited-character error table
Yes, indeed, there is an issue in error handling where errors that are
too long are not logged due to string length constraints in the error
table of our database. To be properly solved with a database migration.
2016-10-28 16:55:13 +02:00
Jurriaan Bremer 5366a17a73 fix copy paste fail 2016-10-23 20:19:20 +02:00
Jurriaan Bremer 1467883b8c unit test for #1128 2016-10-14 03:46:49 +02:00
Jurriaan Bremer afe8077162 rewrite the tests so they use pytest
Also reintroduce the capability to provide a custom connection string to
the Database (which is possible now that making the connection is no
longer part of __init__).
2016-08-23 02:10:14 +02:00