Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(infisto): remove bincode #1570

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rust/infisto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ edition.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bincode = { version = "2.0.0-rc.3", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
rand = "0"
chacha20 = "0"
Expand Down
8 changes: 2 additions & 6 deletions rust/infisto/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ impl IndexedFileStorer {

fn store_index(&self, index: &[Index], id: &str) -> Result<(), Error> {
let fn_name = format!("{}.idx", id);
let config = bincode::config::standard();
let to_store =
bincode::serde::encode_to_vec(index, config).map_err(|_| Error::Serialize)?;
let to_store = rmp_serde::to_vec(index).map_err(|_e| Error::Serialize)?;

let path = Path::new(&self.base).join(fn_name);
let mut file = std::fs::OpenOptions::new()
Expand Down Expand Up @@ -219,9 +217,7 @@ impl IndexedFileStorer {
.map_err(|e| e.kind())
.map_err(Error::Read)?;

let config = bincode::config::standard();
let (index, _) =
bincode::serde::decode_from_slice(&buffer, config).map_err(|_| Error::Serialize)?;
let index = rmp_serde::from_slice(&buffer).map_err(|_e| Error::Serialize)?;
Ok(index)
}

Expand Down
112 changes: 0 additions & 112 deletions rust/infisto/src/bincode.rs

This file was deleted.

1 change: 0 additions & 1 deletion rust/infisto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
#![warn(missing_docs)]

pub mod base;
pub mod bincode;
pub mod crypto;
pub mod serde;
6 changes: 1 addition & 5 deletions rust/models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ license = "GPL-2.0-or-later"

[dependencies]
serde = {version = "1", features = ["derive"], optional = true}
bincode = {version = "2.0.0-rc.3", optional = true }

[features]
default = ["serde_support", "bincode_support"]
default = ["serde_support"]
serde_support = ["serde"]
bincode_support = ["bincode"]

[dev-dependencies]
serde_json = "1"
# required for credentials
bincode = "2.0.0-rc.3"
3 changes: 0 additions & 3 deletions rust/models/src/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct Credential {
/// Service to use for accessing a host
pub service: Service,
Expand Down Expand Up @@ -61,7 +60,6 @@ impl Default for Credential {
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub enum Service {
#[cfg_attr(feature = "serde_support", serde(rename = "ssh"))]
/// SSH, supports [UP](CredentialType::UP) and [USK](CredentialType::USK) as credential types
Expand Down Expand Up @@ -93,7 +91,6 @@ impl AsRef<str> for Service {
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
/// Enum representing the type of credentials.
pub enum CredentialType {
#[cfg_attr(feature = "serde_support", serde(rename = "up"))]
Expand Down
1 change: 0 additions & 1 deletion rust/models/src/host_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct HostInfo {
/// Number of all hosts, that are contained in a target
pub all: u32,
Expand Down
5 changes: 1 addition & 4 deletions rust/models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ mod tests {
}
"#;
// tests that it doesn't panic when parsing the json
let s: Scan = serde_json::from_str(json_str).unwrap();

let _b = bincode::encode_to_vec(s, bincode::config::standard()).unwrap();
//let _: Target = bincode::deserialize(&b).unwrap();
let _: Scan = serde_json::from_str(json_str).unwrap();
}
}
1 change: 0 additions & 1 deletion rust/models/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
/// Represents a parameter for a VTS configuration.
pub struct Parameter {
/// The ID of the parameter.
Expand Down
3 changes: 0 additions & 3 deletions rust/models/src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::fmt::Display;
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct Port {
#[cfg_attr(
feature = "serde_support",
Expand All @@ -27,7 +26,6 @@ pub struct Port {
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct PortRange {
/// The required start port.
///
Expand Down Expand Up @@ -59,7 +57,6 @@ impl Display for PortRange {
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
#[cfg_attr(feature = "serde_support", serde(rename_all = "lowercase"))]
pub enum Protocol {
UDP,
Expand Down
1 change: 0 additions & 1 deletion rust/models/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use super::{scanner_preference::ScannerPreference, target::Target, vt::VT};
derive(serde::Serialize, serde::Deserialize),
serde(deny_unknown_fields)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct Scan {
#[cfg_attr(feature = "serde_support", serde(default))]
/// Unique ID of a scan
Expand Down
1 change: 0 additions & 1 deletion rust/models/src/scanner_preference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct ScannerPreference {
/// The ID of the scanner preference.
pub id: String,
Expand Down
2 changes: 0 additions & 2 deletions rust/models/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use super::host_info::HostInfo;
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct Status {
/// Timestamp for the start of a scan
pub start_time: Option<u32>,
Expand Down Expand Up @@ -41,7 +40,6 @@ impl Status {
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde_support", serde(rename_all = "snake_case"))]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub enum Phase {
/// A scan has been stored but not started yet
#[default]
Expand Down
2 changes: 0 additions & 2 deletions rust/models/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use super::{credential::Credential, port::Port};
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct Target {
/// List of hosts to scan
pub hosts: Vec<String>,
Expand Down Expand Up @@ -40,7 +39,6 @@ pub struct Target {
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
#[cfg_attr(feature = "serde_support", serde(rename_all = "snake_case"))]
pub enum AliveTestMethods {
Icmp,
Expand Down
1 change: 0 additions & 1 deletion rust/models/src/vt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use super::parameter::Parameter;
feature = "serde_support",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))]
pub struct VT {
/// The ID of the VT to execute
pub oid: String,
Expand Down
1 change: 0 additions & 1 deletion rust/openvasd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
serde_json = "1.0.96"
serde = { version = "1.0.163", features = ["derive"] }
bincode = "1"
uuid = { version = "1", features = ["v4", "fast-rng", "serde"] }
rustls = {version = "0.22"}
tokio-rustls = "0.25"
Expand Down
Loading
Loading