crits/crits — pull request #188 by wxsBSD (2014-08-11 17:25:39+00:00)
Title: Better handling of downloads.

Make sure downloading works correctly. Prior to this change all binaries were
incorrectly converted to stix in their raw format, which obviously doesn't
work.

It is best to illustrate how downloads work by an example. Let's say I have
a sample (A) with 2 relationships (sample B and indicator C). If I choose
to download (A) with a depth of 0, result format is zip and binary format is
raw I should get a zip file whose contents are (A) with no binary conversion.

If I choose to download (A) in STIX format the binary format must be either
zlib or base64. The form will default to base64 and not allow it to be changed.
I should get a STIX document who'se contents contain both the metadata for (A)
and also the base64 blob.

If I choose to download (A) in STIX format without the binary then I should get
a STIX document with only the metadata for (A).

If I choose to include relationships (via the depth form field), result format
is zip and binary format is raw, I should get a zip file containing the two
samples (A and B) in raw format and (C) in STIX format.

If I choose to include relationships but pick STIX then I should get a zip file
with 3 STIX documents inside it (A, B and C).

If I choose to include relationships but pick STIX without binaries I should
get a zip file with 3 STIX documents inside it (A, B and C) with only metadata.

In all cases, zip files are always protected with the default password.

Note: Starting from a PCAP or certificate is a completely different piece
of code which doesn't have options like this. At some point we should consider
consolidating those downloads into this format.

Fixes #185.