Skip to content

Commit b695a63

Browse files
committed
feat: initial Assemblyline support
Signed-off-by: Richard Zak <[email protected]>
1 parent d305958 commit b695a63

File tree

8 files changed

+84
-1
lines changed

8 files changed

+84
-1
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build = "build.rs"
1515
default = []
1616
admin = ["dep:dialoguer", "dep:flate2", "malwaredb-server/admin", "dep:chrono", "dep:walkdir", "dep:zip"]
1717
admin-gui = ["malwaredb-server/admin", "dep:slint", "dep:slint-build", "futures/executor"]
18+
assemblyline = ["malwaredb-server/assemblyline"]
1819
sqlite = ["malwaredb-server/sqlite"]
1920
vt = ["malwaredb-server/vt", "dep:malwaredb-virustotal"]
2021

@@ -99,6 +100,7 @@ aes-gcm = { version = "0.10.3", default-features = false }
99100
anyhow = { version = "1.0", default-features = false }
100101
app-memory-usage-fetcher = { version = "0.2.1", default-features = false }
101102
argon2 = { version = "0.5.3", default-features = false }
103+
assemblyline-markings = { version = "0.1.10", default-features = false }
102104
axum = { version = "0.8.4", default-features = false }
103105
axum-server = { version = "0.7.2", default-features = false }
104106
base64 = { version = "0.22.1", default-features = false }

crates/api/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ description = "Common API endpoints and data types for MalwareDB components."
1010
keywords.workspace = true
1111
categories = ["api-bindings", "data-structures"]
1212

13+
[features]
14+
default = []
15+
assemblyline = ["dep:assemblyline-markings"]
16+
1317
[dependencies]
18+
assemblyline-markings = { workspace = true, optional = true }
1419
chrono = { workspace = true, features = ["serde"] }
1520
hex = { workspace = true, features = ["alloc"] }
1621
serde = { workspace = true, features = ["derive", "std"] }

crates/api/src/assemblyline.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use assemblyline_markings::config::ClassificationMarking;
2+
use serde::{Deserialize, Serialize};
3+
4+
/// API endpoint for uploading a sample, POST, Authenticated for use by Assemblyline
5+
pub const UPLOAD_SAMPLE: &str = "/v1/assemblyline/samples/upload";
6+
7+
/// New file sample being sent to `MalwareDB`
8+
#[derive(Clone, Debug, Deserialize, Serialize)]
9+
pub struct NewSample {
10+
/// The original file name, might not be known
11+
pub file_name: String,
12+
13+
/// ID of the source for this sample
14+
pub source_id: u32,
15+
16+
/// Base64 encoding of the binary file
17+
pub file_contents_b64: String,
18+
19+
/// SHA-256 of the sample being sent, for server-side validation
20+
pub sha256: String,
21+
22+
/// Security control for Assemblyline integration based on <https://www.first.org/tlp/>
23+
pub assemblyline_tlp: ClassificationMarking,
24+
25+
/// Assemblyline's analysis data
26+
pub assemblyline_data: serde_json::Map<String, serde_json::Value>,
27+
}

crates/api/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#![deny(clippy::pedantic)]
77
#![forbid(unsafe_code)]
88

9+
/// Data types and API endpoints for Assemblyline integration
10+
#[cfg(feature = "assemblyline")]
11+
pub mod assemblyline;
912
/// Wrapper for fixed-size hash digests from hex strings
1013
pub mod digest;
1114

crates/server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ build = "build.rs"
1414
[features]
1515
default = []
1616
admin = []
17+
assemblyline = ["malwaredb-api/assemblyline"]
1718
sqlite = ["dep:rusqlite"]
1819
vt = ["dep:malwaredb-virustotal", "postgres/with-serde_json-1"]
1920

crates/server/src/db/malwaredb_pg.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ CREATE TABLE file (
3030
nonce bytea[],
3131
key int REFERENCES encryptionkey(id),
3232
parent bigint REFERENCES file(id),
33+
assemblyline_data json,
34+
assemblyline_tlp text,
3335
PRIMARY KEY (id)
3436
);
3537

crates/server/src/db/malwaredb_sqlite.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ CREATE TABLE file (
4747
confirmedmalicious integer, -- boolean
4848
nonce text, -- hex bytes
4949
key int REFERENCES encryptionkey(id),
50-
parent int REFERENCES file(id)
50+
parent int REFERENCES file(id),
51+
assemblyline_data text, -- JSON
52+
assemblyline_tlp text
5153
);
5254

5355

0 commit comments

Comments
 (0)