Skip to content

Commit

Permalink
Merge pull request #250 from kpcyrd/update
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
kpcyrd committed Sep 8, 2023
2 parents fe588f3 + 64d59c6 commit f9abd33
Show file tree
Hide file tree
Showing 30 changed files with 1,394 additions and 1,056 deletions.
916 changes: 491 additions & 425 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions Cargo.toml
Expand Up @@ -36,7 +36,7 @@ sn0int-common = { version="0.13.0", path="sn0int-common" }
sn0int-std = { version="=0.25.0", path="sn0int-std" }
rustyline = "10.0"
log = "0.4"
env_logger = "0.9"
env_logger = "0.10"
hlua-badtouch = "0.4"
clap = { version = "4.3.11", features = ["derive", "env"] }
clap_complete = "4.3.2"
Expand All @@ -60,22 +60,21 @@ serde_urlencoded = "0.7"
serde_json = "1.0"
crossbeam-channel = "0.5"
ctrlc = "3.1"
opener = "0.5"
opener = "0.6"
separator = "0.4"
maplit = "1.0.1"
sloppy-rfc4880 = "0.2"
regex = "1.0"
toml = "0.5"
toml = "0.7"
threadpool = "1.7"
atty = "0.2"
semver = "1"
bytes = "0.4"
bytesize = "1.0"
ipnetwork = "0.18"
strum = "0.24"
strum_macros = "0.24"
ipnetwork = "0.20"
strum = "0.25"
strum_macros = "0.25"
embedded-triple = "0.1.0"
humansize = "1.1.0"
humansize = "2"

digest = "0.10"
md-5 = "0.10"
Expand All @@ -93,7 +92,7 @@ os-version = "0.2"
caps = "0.5"
#syscallz = { path="../syscallz-rs" }
syscallz = "0.16"
nix = "0.24"
nix = { version = "0.27", features = ["fs"] }

[target.'cfg(target_os="openbsd")'.dependencies]
pledge = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
@@ -1,4 +1,4 @@
FROM rust:alpine3.15
FROM rust:alpine3.18
ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN apk add --no-cache musl-dev sqlite-dev libseccomp-dev libsodium-dev
WORKDIR /usr/src/sn0int
Expand All @@ -10,7 +10,7 @@ RUN --mount=type=cache,target=/var/cache/buildkit \
cp -v /var/cache/buildkit/target/release/sn0int /
RUN strip /sn0int

FROM alpine:3.15
FROM alpine:3.18
RUN apk add --no-cache libgcc sqlite-libs libseccomp libsodium
COPY --from=0 /sn0int /usr/local/bin/sn0int
VOLUME ["/data", "/cache"]
Expand Down
33 changes: 18 additions & 15 deletions sn0int-common/src/id.rs
Expand Up @@ -18,15 +18,15 @@ pub fn valid_name(name: &str) -> Result<()> {
}

fn module(s: &str) -> nom::IResult<&str, ModuleID> {
let (input, (author, _, name)) = nom::sequence::tuple((
token,
nom::bytes::complete::tag("/"),
token,
))(s)?;
Ok((input, ModuleID {
author: author.to_string(),
name: name.to_string(),
}))
let (input, (author, _, name)) =
nom::sequence::tuple((token, nom::bytes::complete::tag("/"), token))(s)?;
Ok((
input,
ModuleID {
author: author.to_string(),
name: name.to_string(),
},
))
}

#[inline]
Expand All @@ -50,8 +50,8 @@ impl FromStr for ModuleID {
type Err = Error;

fn from_str(s: &str) -> Result<ModuleID> {
let (trailing, module) = module(s)
.map_err(|err| anyhow!("Failed to parse module id: {:?}", err))?;
let (trailing, module) =
module(s).map_err(|err| anyhow!("Failed to parse module id: {:?}", err))?;
if !trailing.is_empty() {
bail!("Trailing data in module id");
}
Expand Down Expand Up @@ -85,10 +85,13 @@ mod tests {
#[test]
fn verify_valid() {
let result = ModuleID::from_str("kpcyrd/foo").expect("parse");
assert_eq!(result, ModuleID {
author: "kpcyrd".to_string(),
name: "foo".to_string(),
});
assert_eq!(
result,
ModuleID {
author: "kpcyrd".to_string(),
name: "foo".to_string(),
}
);
}

#[test]
Expand Down
148 changes: 82 additions & 66 deletions sn0int-common/src/metadata/mod.rs
Expand Up @@ -158,8 +158,7 @@ impl FromStr for Metadata {
type Err = Error;

fn from_str(code: &str) -> Result<Metadata> {
let (_, lines) = metalines(code)
.map_err(|_| format_err!("Failed to parse header"))?;
let (_, lines) = metalines(code).map_err(|_| format_err!("Failed to parse header"))?;

let mut data = NewMetadata::default();

Expand Down Expand Up @@ -194,24 +193,26 @@ pub struct NewMetadata<'a> {

impl<'a> NewMetadata<'a> {
fn try_from(self) -> Result<Metadata> {
let description = self.description.ok_or_else(|| format_err!("Description is required"))?;
let version = self.version.ok_or_else(|| format_err!("Version is required"))?;
let description = self
.description
.ok_or_else(|| format_err!("Description is required"))?;
let version = self
.version
.ok_or_else(|| format_err!("Version is required"))?;
let source = match self.source {
Some(x) => Some(x.parse()?),
_ => None,
};
let keyring_access = self.keyring_access.into_iter()
.map(String::from)
.collect();
let keyring_access = self.keyring_access.into_iter().map(String::from).collect();
let stealth = match self.stealth {
Some(x) => x.parse()?,
_ => Stealth::Normal,
};
let authors = self.authors.into_iter()
.map(String::from)
.collect();
let authors = self.authors.into_iter().map(String::from).collect();
let repository = self.repository.map(String::from);
let license = self.license.ok_or_else(|| format_err!("License is required"))?;
let license = self
.license
.ok_or_else(|| format_err!("License is required"))?;
let license = license.parse()?;

Ok(Metadata {
Expand All @@ -229,10 +230,7 @@ impl<'a> NewMetadata<'a> {

fn metaline(input: &str) -> IResult<&str, (EntryType, &str)> {
let (input, _) = tag("-- ")(input)?;
let (input, name) = map_res(
take_until(": "),
EntryType::from_str
)(input)?;
let (input, name) = map_res(take_until(": "), EntryType::from_str)(input)?;
let (input, _) = tag(": ")(input)?;
let (input, value) = take_until("\n")(input)?;
let (input, _) = tag("\n")(input)?;
Expand All @@ -241,14 +239,10 @@ fn metaline(input: &str) -> IResult<&str, (EntryType, &str)> {
}

fn metalines(input: &str) -> IResult<&str, Vec<(EntryType, &str)>> {
let (input, lines) = fold_many0(
metaline,
Vec::new,
|mut acc: Vec<_>, item| {
acc.push(item);
acc
}
)(input)?;
let (input, lines) = fold_many0(metaline, Vec::new, |mut acc: Vec<_>, item| {
acc.push(item);
acc
})(input)?;
let (input, _) = tag("\n")(input)?;

Ok((input, lines))
Expand All @@ -260,27 +254,34 @@ mod tests {

#[test]
fn verify_simple() {
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
let metadata = Metadata::from_str(
r#"-- Description: Hello world, this is my description
-- Version: 1.0.0
-- Source: domains
-- License: WTFPL
"#).expect("parse");
assert_eq!(metadata, Metadata {
description: "Hello world, this is my description".to_string(),
version: "1.0.0".to_string(),
license: License::WTFPL,
source: Some(Source::Domains),
stealth: Stealth::Normal,
authors: vec![],
repository: None,
keyring_access: Vec::new(),
});
"#,
)
.expect("parse");
assert_eq!(
metadata,
Metadata {
description: "Hello world, this is my description".to_string(),
version: "1.0.0".to_string(),
license: License::WTFPL,
source: Some(Source::Domains),
stealth: Stealth::Normal,
authors: vec![],
repository: None,
keyring_access: Vec::new(),
}
);
}

#[test]
fn verify_much_metadata() {
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
let metadata = Metadata::from_str(
r#"-- Description: Hello world, this is my description
-- Version: 1.0.0
-- Source: domains
-- Stealth: passive
Expand All @@ -289,59 +290,74 @@ mod tests {
-- Repository: https://github.com/kpcyrd/sn0int
-- License: WTFPL
"#).expect("parse");
assert_eq!(metadata, Metadata {
description: "Hello world, this is my description".to_string(),
version: "1.0.0".to_string(),
license: License::WTFPL,
source: Some(Source::Domains),
stealth: Stealth::Passive,
authors: vec![
"kpcyrd <git at rxv dot cc>".to_string(),
"kpcyrd's cat".to_string(),
],
repository: Some("https://github.com/kpcyrd/sn0int".to_string()),
keyring_access: Vec::new(),
});
"#,
)
.expect("parse");
assert_eq!(
metadata,
Metadata {
description: "Hello world, this is my description".to_string(),
version: "1.0.0".to_string(),
license: License::WTFPL,
source: Some(Source::Domains),
stealth: Stealth::Passive,
authors: vec![
"kpcyrd <git at rxv dot cc>".to_string(),
"kpcyrd's cat".to_string(),
],
repository: Some("https://github.com/kpcyrd/sn0int".to_string()),
keyring_access: Vec::new(),
}
);
}

#[test]
fn verify_no_source() {
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
let metadata = Metadata::from_str(
r#"-- Description: Hello world, this is my description
-- Version: 1.0.0
-- License: WTFPL
"#).expect("parse");
assert_eq!(metadata, Metadata {
description: "Hello world, this is my description".to_string(),
version: "1.0.0".to_string(),
license: License::WTFPL,
source: None,
stealth: Stealth::Normal,
authors: vec![],
repository: None,
keyring_access: Vec::new(),
});
"#,
)
.expect("parse");
assert_eq!(
metadata,
Metadata {
description: "Hello world, this is my description".to_string(),
version: "1.0.0".to_string(),
license: License::WTFPL,
source: None,
stealth: Stealth::Normal,
authors: vec![],
repository: None,
keyring_access: Vec::new(),
}
);
}

#[test]
fn verify_require_license() {
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
let metadata = Metadata::from_str(
r#"-- Description: Hello world, this is my description
-- Version: 1.0.0
-- Source: domains
"#);
"#,
);
assert!(metadata.is_err());
}

#[test]
fn verify_require_opensource_license() {
let metadata = Metadata::from_str(r#"-- Description: Hello world, this is my description
let metadata = Metadata::from_str(
r#"-- Description: Hello world, this is my description
-- Version: 1.0.0
-- Source: domains
-- License: Proprietary
"#);
"#,
);
assert!(metadata.is_err());
}

Expand Down
9 changes: 2 additions & 7 deletions sn0int-common/src/metadata/stealth.rs
@@ -1,5 +1,5 @@
use clap::ValueEnum;
use crate::errors::*;
use clap::ValueEnum;
use serde::{Deserialize, Serialize};
use std::str::FromStr;

Expand All @@ -14,12 +14,7 @@ pub enum Stealth {
impl Stealth {
#[inline]
pub fn variants() -> &'static [&'static str] {
&[
"loud",
"normal",
"passive",
"offline",
]
&["loud", "normal", "passive", "offline"]
}

#[inline(always)]
Expand Down
8 changes: 4 additions & 4 deletions sn0int-std/Cargo.toml
Expand Up @@ -27,7 +27,7 @@ ct-logs = "0.7"
chrootable-https = "0.16"
http = "0.2"
bufstream = "0.1.4"
pem = "1"
pem = "3"
url = "2.0"
tungstenite = { version = "0.13", default-features = false }
kuchiki = "0.8.0"
Expand All @@ -36,7 +36,7 @@ x509-parser = "0.13"
der-parser = "8"
publicsuffix = { version="2", default-features=false }
xml-rs = "0.8"
geo = "0.23"
geo = "0.25"
bytes = "0.4"
chrono = { version = "0.4", features = ["serde"] }
mqtt-protocol = "0.11"
Expand All @@ -46,12 +46,12 @@ image = "0.23"
kamadak-exif = "0.5.1"
img_hash_median = "4.0.0"

bs58 = "0.4"
bs58 = "0.5"
digest = "0.10"
blake2 = "0.10"
data-encoding = "2.3.3"
thiserror = "1.0.38"

[dev-dependencies]
env_logger = "0.9"
env_logger = "0.10"
maplit = "1.0.1"

0 comments on commit f9abd33

Please sign in to comment.