Skip to content

Commit ce4326e

Browse files
committed
build fixes
1 parent 12adfbb commit ce4326e

File tree

13 files changed

+176
-158
lines changed

13 files changed

+176
-158
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ jobs:
102102
run: cargo audit
103103

104104
- name: Install cargo-deny
105-
run: cargo install cargo-deny
105+
run: cargo install cargo-deny --locked
106106

107-
- name: Run cargo-deny
107+
- name: Run cargo-deny check
108108
run: cargo deny check
109109

110110
coverage:

deny.toml

Lines changed: 16 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
# cargo-deny configuration for ClamReef Agent
2-
# See https://embarkstudios.github.io/cargo-deny/ for more information
2+
# Compatible with recent cargo-deny versions
33

44
[graph]
5-
# If true, metadata will be collected with `--all-features`. Note that this can't
6-
# be toggled off if true, if you want to conditionally enable it, set it to false
7-
# here and pass `--all-features` to cargo-deny on the command line.
5+
# If true, metadata will be collected with `--all-features`
86
all-features = true
9-
# If set, these feature flags will be passed when collecting metadata. This list
10-
# will be extended if you supply additional feature flags on the command line
11-
features = []
12-
# If set, disables the default features for a crate
13-
no-default-features = false
147

158
[advisories]
16-
# The lint level for security vulnerabilities
9+
# Lint level for security vulnerabilities
1710
vulnerability = "deny"
18-
# The lint level for unmaintained crates
11+
# Lint level for unmaintained crates
1912
unmaintained = "warn"
20-
# The lint level for crates that have been yanked from their source registry
13+
# Lint level for yanked crates
2114
yanked = "warn"
22-
# The lint level for crates with security notices.
15+
# Lint level for crates with security notices
2316
notice = "warn"
24-
# A list of advisory IDs to ignore. Note that ignored advisories will still
25-
# output a note when they are encountered.
26-
ignore = [
27-
#"RUSTSEC-0000-0000",
28-
]
17+
# Advisory IDs to ignore
18+
ignore = []
2919

3020
[licenses]
31-
# The lint level for crates which do not have a detectable license
32-
unlicensed = "deny"
21+
# Confidence threshold for detecting a license from license text
22+
confidence-threshold = 0.8
3323
# List of explicitly allowed licenses
3424
allow = [
3525
"MIT",
@@ -50,57 +40,18 @@ deny = [
5040
]
5141
# Lint level for when multiple versions of the same license are detected
5242
copyleft = "warn"
53-
# Confidence threshold for detecting a license from license text.
54-
confidence-threshold = 0.8
55-
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
56-
# aren't accepted for every possible crate as with the normal allow list
57-
exceptions = [
58-
# Each entry is the crate and version constraint, and its the license
59-
{ allow = ["OpenSSL"], name = "ring" },
60-
]
61-
62-
[[licenses.clarify]]
63-
# The name of the crate the clarification applies to
64-
name = "ring"
65-
# The optional version constraint for the crate
66-
version = "*"
67-
# The SPDX expression for the license requirements of the crate
68-
expression = "MIT AND ISC AND OpenSSL"
69-
# One or more files in the crate's source used as the "source of truth" for
70-
# the license expression. If the files are missing, or their checksums do not
71-
# match, the clarification will fail
72-
license-files = [
73-
{ path = "LICENSE", hash = 0xbd0eed23 }
74-
]
43+
# The default lint level for licenses not explicitly allowed or denied
44+
default = "deny"
7545

7646
[bans]
7747
# Lint level for when multiple versions of the same crate are detected
7848
multiple-versions = "warn"
7949
# Lint level for when a crate version requirement is `*`
8050
wildcards = "allow"
81-
# The graph highlighting used when creating dotgraphs for crates
82-
# with multiple versions
83-
highlight = "all"
84-
# List of crates that are allowed to have multiple versions
85-
allow = [
86-
#{ name = "ansi_term", version = "=0.11.0" },
87-
]
51+
# List of crates that are allowed. Use with care!
52+
allow = []
8853
# List of crates to deny
89-
deny = [
90-
# Each entry the name of a crate and a version range. If version is
91-
# not specified, all versions will be matched.
92-
#{ name = "ansi_term", version = "=0.11.0" },
93-
]
94-
# Certain crates/versions that will be skipped when doing duplicate detection.
95-
skip = [
96-
#{ name = "ansi_term", version = "=0.11.0" },
97-
]
98-
# Similarly to `skip` allows you to skip certain crates from duplicate
99-
# detection. Unlike skip, it also includes the entire tree of transitive
100-
# dependencies starting from the specified crate, up to a certain depth.
101-
skip-tree = [
102-
#{ name = "ansi_term", version = "=0.11.0", depth = 20 },
103-
]
54+
deny = []
10455

10556
[sources]
10657
# Lint level for what to happen when a crate from a crate registry that is
@@ -109,8 +60,7 @@ unknown-registry = "warn"
10960
# Lint level for what to happen when a crate from a git repository that is not
11061
# in the allow list is encountered
11162
unknown-git = "warn"
112-
# List of URLs for allowed crate registries. Defaults to the crates.io index
113-
# if not specified. If it is specified but empty, no registries are allowed.
63+
# List of URLs for allowed crate registries
11464
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
11565
# List of URLs for allowed Git repositories
11666
allow-git = []

src/clamav/client.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use tokio::net::{TcpStream, UnixStream};
66
use tokio::time::timeout;
77
use tracing::debug;
88

9-
use crate::error::{Error, Result};
109
use super::parser::Parser;
1110
use super::types::{ScanResult, Stats, Version};
11+
use crate::error::{Error, Result};
1212

1313
#[derive(Debug, Clone)]
1414
pub enum ClamAVConnection {
@@ -45,36 +45,32 @@ impl ClamAVClientImpl {
4545

4646
async fn send_command(&self, command: &str) -> Result<String> {
4747
match &self.connection {
48-
ClamAVConnection::Unix { path } => {
49-
self.send_unix_command(path, command).await
50-
}
48+
ClamAVConnection::Unix { path } => self.send_unix_command(path, command).await,
5149
ClamAVConnection::Tcp { host, port } => {
5250
self.send_tcp_command(host, *port, command).await
5351
}
5452
}
5553
}
5654

5755
async fn send_unix_command(&self, path: &str, command: &str) -> Result<String> {
58-
let mut stream = timeout(
59-
self.timeout,
60-
UnixStream::connect(path)
61-
).await
56+
let mut stream = timeout(self.timeout, UnixStream::connect(path))
57+
.await
6258
.map_err(|_| Error::Timeout(format!("Connection to {} timed out", path)))?
6359
.map_err(|e| Error::Connection(format!("Failed to connect to {}: {}", path, e)))?;
6460

6561
debug!("Sending command to ClamAV: {}", command);
6662

6763
let cmd = format!("z{}\0", command);
68-
stream.write_all(cmd.as_bytes()).await
64+
stream
65+
.write_all(cmd.as_bytes())
66+
.await
6967
.map_err(|e| Error::Io(e))?;
7068

7169
let mut response = Vec::new();
7270
let mut reader = BufReader::new(stream);
7371

74-
timeout(
75-
self.timeout,
76-
reader.read_until(b'\0', &mut response)
77-
).await
72+
timeout(self.timeout, reader.read_until(b'\0', &mut response))
73+
.await
7874
.map_err(|_| Error::Timeout("Read response timed out".to_string()))?
7975
.map_err(|e| Error::Io(e))?;
8076

@@ -89,26 +85,24 @@ impl ClamAVClientImpl {
8985

9086
async fn send_tcp_command(&self, host: &str, port: u16, command: &str) -> Result<String> {
9187
let addr = format!("{}:{}", host, port);
92-
let mut stream = timeout(
93-
self.timeout,
94-
TcpStream::connect(&addr)
95-
).await
88+
let mut stream = timeout(self.timeout, TcpStream::connect(&addr))
89+
.await
9690
.map_err(|_| Error::Timeout(format!("Connection to {} timed out", addr)))?
9791
.map_err(|e| Error::Connection(format!("Failed to connect to {}: {}", addr, e)))?;
9892

9993
debug!("Sending command to ClamAV: {}", command);
10094

10195
let cmd = format!("z{}\0", command);
102-
stream.write_all(cmd.as_bytes()).await
96+
stream
97+
.write_all(cmd.as_bytes())
98+
.await
10399
.map_err(|e| Error::Io(e))?;
104100

105101
let mut response = Vec::new();
106102
let mut reader = BufReader::new(stream);
107103

108-
timeout(
109-
self.timeout,
110-
reader.read_until(b'\0', &mut response)
111-
).await
104+
timeout(self.timeout, reader.read_until(b'\0', &mut response))
105+
.await
112106
.map_err(|_| Error::Timeout("Read response timed out".to_string()))?
113107
.map_err(|e| Error::Io(e))?;
114108

@@ -155,7 +149,10 @@ impl ClamAVClient for ClamAVClientImpl {
155149
if response.trim() == "RELOADING" {
156150
Ok(())
157151
} else {
158-
Err(Error::ClamAV(format!("Unexpected reload response: {}", response)))
152+
Err(Error::ClamAV(format!(
153+
"Unexpected reload response: {}",
154+
response
155+
)))
159156
}
160157
}
161158
}
@@ -177,4 +174,4 @@ mod tests {
177174
async fn reload(&self) -> Result<()>;
178175
}
179176
}
180-
}
177+
}

src/clamav/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ pub mod parser;
33
pub mod types;
44

55
pub use client::{ClamAVClient, ClamAVClientImpl, ClamAVConnection};
6-
pub use types::{ScanResult, ScanStatus, Stats, Version};
6+
pub use types::{ScanResult, ScanStatus, Stats, Version};

src/clamav/parser.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use chrono::Utc;
22
use regex::Regex;
33

4-
use crate::error::{Error, Result};
54
use super::types::{
65
DatabaseInfo, MemoryStats, QueueStats, ScanResult, ScanStatus, Stats, ThreadStats, Version,
76
};
7+
use crate::error::{Error, Result};
88

99
pub struct Parser;
1010

@@ -13,11 +13,15 @@ impl Parser {
1313
// Example: ClamAV 0.103.8/26827/Mon Mar 13 08:20:48 2023
1414
let parts: Vec<&str> = response.trim().split('/').collect();
1515
if parts.len() < 3 {
16-
return Err(Error::Parse(format!("Invalid version response: {}", response)));
16+
return Err(Error::Parse(format!(
17+
"Invalid version response: {}",
18+
response
19+
)));
1720
}
1821

1922
let clamav = parts[0].replace("ClamAV ", "");
20-
let database = parts[1].parse::<u32>()
23+
let database = parts[1]
24+
.parse::<u32>()
2125
.map_err(|_| Error::Parse(format!("Invalid database version: {}", parts[1])))?;
2226
let database_date = parts[2].to_string();
2327

@@ -31,9 +35,17 @@ impl Parser {
3135
pub fn parse_stats(response: &str) -> Result<Stats> {
3236
let mut pools = 0;
3337
let mut state = String::new();
34-
let mut threads = ThreadStats { live: 0, idle: 0, max: 0 };
38+
let mut threads = ThreadStats {
39+
live: 0,
40+
idle: 0,
41+
max: 0,
42+
};
3543
let mut queue = QueueStats { items: 0, max: 0 };
36-
let mut mem_stats = MemoryStats { heap: 0.0, mmap: 0.0, used: 0.0 };
44+
let mut mem_stats = MemoryStats {
45+
heap: 0.0,
46+
mmap: 0.0,
47+
used: 0.0,
48+
};
3749
let mut database = DatabaseInfo {
3850
version: 0,
3951
sigs: 0,
@@ -124,7 +136,10 @@ impl Parser {
124136
let error_msg = response.replace("ERROR: ", "");
125137
(ScanStatus::Error(error_msg.clone()), None)
126138
} else {
127-
(ScanStatus::Error(format!("Unexpected response: {}", response)), None)
139+
(
140+
ScanStatus::Error(format!("Unexpected response: {}", response)),
141+
None,
142+
)
128143
};
129144

130145
Ok(ScanResult {
@@ -165,4 +180,4 @@ mod tests {
165180
assert_eq!(result.status, ScanStatus::Infected);
166181
assert_eq!(result.threat, Some("Win.Trojan.Generic".to_string()));
167182
}
168-
}
183+
}

src/clamav/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ pub struct Version {
6060
pub clamav: String,
6161
pub database: u32,
6262
pub database_date: String,
63-
}
63+
}

0 commit comments

Comments
 (0)