mirror of https://github.com/kpcyrd/sn0int.git
parent
1eeb1508e5
commit
88cb8b55f0
File diff suppressed because it is too large
Load Diff
|
@ -38,7 +38,8 @@ rustyline = "10.0"
|
|||
log = "0.4"
|
||||
env_logger = "0.9"
|
||||
hlua-badtouch = "0.4"
|
||||
structopt = "0.3"
|
||||
clap = { version = "4.3.11", features = ["derive", "env"] }
|
||||
clap_complete = "4.3.2"
|
||||
failure = "0.1"
|
||||
rand = "0.8"
|
||||
colored = "2"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#[macro_use] extern crate boxxy;
|
||||
extern crate sn0int;
|
||||
#[macro_use]
|
||||
extern crate boxxy;
|
||||
extern crate env_logger;
|
||||
extern crate sn0int;
|
||||
|
||||
fn stage1(sh: &mut boxxy::Shell, _args: Vec<String>) -> Result<(), boxxy::Error> {
|
||||
shprintln!(sh, "[*] starting stage1");
|
||||
|
@ -14,8 +15,6 @@ fn main() {
|
|||
|
||||
println!("stage1 activate sandbox");
|
||||
|
||||
let toolbox = boxxy::Toolbox::new().with(vec![
|
||||
("stage1", stage1),
|
||||
]);
|
||||
let toolbox = boxxy::Toolbox::new().with(vec![("stage1", stage1)]);
|
||||
boxxy::Shell::new(toolbox).run()
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
use clap::Parser;
|
||||
use sn0int::errors::*;
|
||||
use sn0int::geoip::{AsnDB, GeoIP, Maxmind};
|
||||
use sn0int::paths;
|
||||
use std::net::IpAddr;
|
||||
use std::path::Path;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum Args {
|
||||
#[structopt(name="asn")]
|
||||
#[command(name = "asn")]
|
||||
Asn(AsnArgs),
|
||||
#[structopt(name="geoip")]
|
||||
#[command(name = "geoip")]
|
||||
GeoIP(GeoIPArgs),
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AsnArgs {
|
||||
ip: IpAddr,
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ impl AsnArgs {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct GeoIPArgs {
|
||||
ip: IpAddr,
|
||||
}
|
||||
|
@ -47,9 +47,8 @@ impl GeoIPArgs {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fn run() -> Result<()> {
|
||||
let args = Args::from_args();
|
||||
let args = Args::parse();
|
||||
debug!("{:?}", args);
|
||||
let cache_dir = paths::cache_dir()?;
|
||||
match args {
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
use clap::Parser;
|
||||
use sn0int::term::{Spinner, StackedSpinners, SPINNERS};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use sn0int::term::{SPINNERS, Spinner, StackedSpinners};
|
||||
use structopt::StructOpt;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum Args {
|
||||
#[structopt(name="single")]
|
||||
#[command(name = "single")]
|
||||
Single(Single),
|
||||
#[structopt(name="stacked")]
|
||||
#[command(name = "stacked")]
|
||||
Stacked(Stacked),
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Single {
|
||||
idx: usize,
|
||||
#[structopt(long="ticks", default_value="100")]
|
||||
#[structopt(long = "ticks", default_value = "100")]
|
||||
ticks: usize,
|
||||
}
|
||||
|
||||
|
@ -32,9 +31,8 @@ impl Single {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct Stacked {
|
||||
}
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Stacked {}
|
||||
|
||||
impl Stacked {
|
||||
fn run(&self) {
|
||||
|
@ -59,7 +57,7 @@ impl Stacked {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::from_args();
|
||||
let args = Args::parse();
|
||||
match args {
|
||||
Args::Single(args) => args.run(),
|
||||
Args::Stacked(args) => args.run(),
|
||||
|
|
|
@ -13,3 +13,4 @@ serde = { version = "1.0", features=["derive"] }
|
|||
rocket_failure_errors = "0.2"
|
||||
anyhow = "1.0"
|
||||
nom = "7.0"
|
||||
clap = { version = "4.3.11", features = ["derive"] }
|
||||
|
|
|
@ -34,7 +34,7 @@ fn token(s: &str) -> nom::IResult<&str, &str> {
|
|||
nom::bytes::complete::take_while1(valid_char)(s)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ModuleID {
|
||||
pub author: String,
|
||||
pub name: String,
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
use clap::ValueEnum;
|
||||
use crate::errors::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, PartialOrd, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Eq, PartialEq, PartialOrd, Clone, ValueEnum, Serialize, Deserialize)]
|
||||
pub enum Stealth {
|
||||
Loud,
|
||||
Normal,
|
||||
|
|
118
src/args.rs
118
src/args.rs
|
@ -1,18 +1,20 @@
|
|||
use clap::{CommandFactory, Parser};
|
||||
use clap_complete::Shell;
|
||||
use crate::cmd;
|
||||
use crate::errors::*;
|
||||
use crate::options;
|
||||
use crate::workspaces::Workspace;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::{AppSettings, Shell};
|
||||
use sn0int_common::ModuleID;
|
||||
use std::io;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(version)]
|
||||
pub struct Args {
|
||||
/// Select a different workspace instead of the default
|
||||
#[structopt(short="w", long="workspace", env="SN0INT_WORKSPACE")]
|
||||
#[arg(short = 'w', long="workspace", env="SN0INT_WORKSPACE")]
|
||||
pub workspace: Option<Workspace>,
|
||||
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
pub subcommand: Option<SubCommand>,
|
||||
}
|
||||
|
||||
|
@ -22,49 +24,49 @@ impl Args {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum SubCommand {
|
||||
/// Run a module directly
|
||||
#[structopt(name="run")]
|
||||
#[command(name="run")]
|
||||
Run(Run),
|
||||
/// For internal use
|
||||
#[structopt(name="sandbox")]
|
||||
#[command(name="sandbox")]
|
||||
Sandbox(Sandbox),
|
||||
/// Login to the registry for publishing
|
||||
#[structopt(name="login")]
|
||||
#[command(name="login")]
|
||||
Login(Login),
|
||||
/// Create a new module
|
||||
#[structopt(name="new")]
|
||||
#[command(name="new")]
|
||||
New(New),
|
||||
/// Publish a script to the registry
|
||||
#[structopt(name="publish")]
|
||||
#[command(name="publish")]
|
||||
Publish(Publish),
|
||||
/// Install a module from the registry
|
||||
#[structopt(name="install")]
|
||||
#[command(name="install")]
|
||||
Install(Install),
|
||||
/// Search in the registry
|
||||
#[structopt(name="search")]
|
||||
#[command(name="search")]
|
||||
Search(Search),
|
||||
/// The sn0int package manager
|
||||
#[structopt(name="pkg")]
|
||||
#[command(name="pkg")]
|
||||
Pkg(cmd::pkg_cmd::Args),
|
||||
/// Insert into the database
|
||||
#[structopt(name="add")]
|
||||
#[command(name="add")]
|
||||
Add(cmd::add_cmd::Args),
|
||||
/// Select from the database
|
||||
#[structopt(name="select")]
|
||||
#[command(name="select")]
|
||||
Select(cmd::select_cmd::Args),
|
||||
/// Delete from the database
|
||||
#[structopt(name="delete")]
|
||||
#[command(name="delete")]
|
||||
Delete(cmd::delete_cmd::Args),
|
||||
/// Query logged activity
|
||||
#[structopt(name="activity")]
|
||||
#[command(name="activity")]
|
||||
Activity(cmd::activity_cmd::Args),
|
||||
/// Include entities in the scope
|
||||
#[structopt(name="scope")]
|
||||
#[command(name="scope")]
|
||||
Scope(cmd::scope_cmd::Args),
|
||||
/// Exclude entities from scope
|
||||
#[structopt(name="noscope")]
|
||||
#[command(name="noscope")]
|
||||
Noscope(cmd::noscope_cmd::Args),
|
||||
/// Manage autoscope rules
|
||||
Autoscope(cmd::autoscope_cmd::Args),
|
||||
|
@ -73,111 +75,123 @@ pub enum SubCommand {
|
|||
/// Rescope all entities based on autonoscope rules
|
||||
Rescope(cmd::rescope_cmd::Args),
|
||||
/// Manage workspaces
|
||||
#[structopt(name="workspace")]
|
||||
#[command(name="workspace")]
|
||||
Workspace(cmd::workspace_cmd::Args),
|
||||
/// Calendar
|
||||
#[structopt(name="cal")]
|
||||
#[command(name="cal")]
|
||||
Cal(cmd::cal_cmd::Args),
|
||||
/// Notify
|
||||
#[structopt(name="notify")]
|
||||
#[command(name="notify")]
|
||||
Notify(cmd::notify_cmd::Args),
|
||||
/// Verify blob storage for corrupt and dangling blobs
|
||||
#[structopt(name="fsck")]
|
||||
#[command(name="fsck")]
|
||||
Fsck(cmd::fsck_cmd::Args),
|
||||
/// Export a workspace for external processing
|
||||
#[structopt(name="export")]
|
||||
#[command(name="export")]
|
||||
Export(cmd::export_cmd::Args),
|
||||
/// Show statistics about your current workspace
|
||||
#[structopt(name="stats")]
|
||||
#[command(name="stats")]
|
||||
Stats(cmd::stats_cmd::Args),
|
||||
/// Run a lua repl
|
||||
#[structopt(name="repl")]
|
||||
#[command(name="repl")]
|
||||
Repl,
|
||||
/// Show paths of various file system locations
|
||||
#[structopt(name="paths")]
|
||||
#[command(name="paths")]
|
||||
Paths,
|
||||
/// Generate shell completions
|
||||
#[structopt(name="completions")]
|
||||
#[command(name="completions")]
|
||||
Completions(Completions),
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Run {
|
||||
#[structopt(flatten)]
|
||||
#[command(flatten)]
|
||||
pub run: cmd::run_cmd::Args,
|
||||
/// Run a module from a path
|
||||
#[structopt(short="f", long="file")]
|
||||
#[arg(short = 'f', long="file")]
|
||||
pub file: bool,
|
||||
/// Expose stdin to modules
|
||||
#[structopt(long="stdin")]
|
||||
#[arg(long="stdin")]
|
||||
pub stdin: bool,
|
||||
/// Automatically grant access to a keyring namespace
|
||||
#[structopt(long="grant")]
|
||||
#[arg(long="grant")]
|
||||
pub grants: Vec<String>,
|
||||
/// Automatically grant access to all requested keys
|
||||
#[structopt(long="grant-full-keyring")]
|
||||
#[arg(long="grant-full-keyring")]
|
||||
pub grant_full_keyring: bool,
|
||||
/// Automatically deny access to all requested keys
|
||||
#[structopt(long="deny-keyring")]
|
||||
#[arg(long="deny-keyring")]
|
||||
pub deny_keyring: bool,
|
||||
/// Exit on first error and set exit code
|
||||
#[structopt(short="x", long="exit-on-error")]
|
||||
#[arg(short = 'x', long="exit-on-error")]
|
||||
pub exit_on_error: bool,
|
||||
/// Set an option
|
||||
#[structopt(short="o", long="option")]
|
||||
#[arg(short = 'o', long="option")]
|
||||
pub options: Vec<options::Opt>,
|
||||
/// Narrow down targeted entities
|
||||
#[structopt(short="t", long="target")]
|
||||
#[arg(short = 't', long="target")]
|
||||
pub target: Option<String>,
|
||||
/// Dump the sandbox init message to stdout instead of running a child process
|
||||
#[structopt(long="dump-sandbox-init-msg")]
|
||||
#[arg(long="dump-sandbox-init-msg")]
|
||||
pub dump_sandbox_init_msg: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Sandbox {
|
||||
/// This value is only used for process listings
|
||||
_label: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Login {
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct New {
|
||||
/// Path to the new file
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Publish {
|
||||
/// The scripts to publish
|
||||
#[structopt(required = true)]
|
||||
#[arg(required = true)]
|
||||
pub paths: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Install {
|
||||
/// The script to install
|
||||
pub module: ModuleID,
|
||||
/// Specify the version, defaults to the latest version
|
||||
pub version: Option<String>,
|
||||
#[structopt(short="f", long="force")]
|
||||
#[arg(short = 'f', long="force")]
|
||||
pub force: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Search {
|
||||
/// Only show modules that aren't installed yet
|
||||
#[structopt(long="new")]
|
||||
#[arg(long="new")]
|
||||
pub new: bool,
|
||||
/// The search query
|
||||
pub query: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
/// Generate shell completions
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Completions {
|
||||
#[structopt(possible_values=&Shell::variants())]
|
||||
pub shell: Shell,
|
||||
}
|
||||
|
||||
impl Completions {
|
||||
pub fn generate(&self) -> Result<()> {
|
||||
clap_complete::generate(
|
||||
self.shell,
|
||||
&mut Args::command(),
|
||||
"sn0int",
|
||||
&mut io::stdout(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ impl RuleSet {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum RuleType {
|
||||
Domain,
|
||||
Ip,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::errors::*;
|
||||
use std::str::FromStr;
|
||||
|
||||
pub mod date;
|
||||
pub mod time;
|
||||
|
||||
#[derive(Debug)]
|
||||
use crate::errors::*;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum DateArg {
|
||||
Month(u32),
|
||||
Num(i32),
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use crate::cmd::Cmd;
|
||||
use crate::shell::Shell;
|
||||
use crate::models::*;
|
||||
use chrono::{Utc, NaiveDateTime, NaiveTime, Duration};
|
||||
use clap::Parser;
|
||||
use crate::cmd::Cmd;
|
||||
use crate::errors::*;
|
||||
use crate::models::*;
|
||||
use crate::shell::Shell;
|
||||
use regex::Regex;
|
||||
use std::convert::TryFrom;
|
||||
use std::io;
|
||||
use std::str::FromStr;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TimeSpec {
|
||||
datetime: NaiveDateTime,
|
||||
}
|
||||
|
@ -64,23 +62,22 @@ impl FromStr for TimeSpec {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
/// Only query events for a given topic
|
||||
#[structopt(short="t", long="topic")]
|
||||
#[arg(short = 't', long="topic")]
|
||||
topic: Option<String>,
|
||||
/// Only query events starting from that datetime
|
||||
#[structopt(long="since")]
|
||||
#[arg(long="since")]
|
||||
since: Option<TimeSpec>,
|
||||
/// Only query events until this datetime
|
||||
#[structopt(long="until")]
|
||||
#[arg(long="until")]
|
||||
until: Option<TimeSpec>,
|
||||
/// Try to select the previous event before --since as an initial state
|
||||
#[structopt(short="i", long="initial")]
|
||||
#[arg(short = 'i', long="initial")]
|
||||
initial: bool,
|
||||
/// Only query events that are tied to a location
|
||||
#[structopt(short="l", long="location")]
|
||||
#[arg(short = 'l', long="location")]
|
||||
location: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use crate::blobs::Blob;
|
||||
use crate::cmd::Cmd;
|
||||
use crate::db::DbChange;
|
||||
use crate::gfx;
|
||||
use crate::models::*;
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
use crate::utils;
|
||||
use crate::term;
|
||||
use std::fmt::Debug;
|
||||
|
@ -18,62 +16,61 @@ use std::net::SocketAddr;
|
|||
use std::path::Path;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
subcommand: Target,
|
||||
/// Do not actually insert into database
|
||||
#[structopt(short="n", long="dry-run")]
|
||||
#[arg(short = 'n', long="dry-run")]
|
||||
dry_run: bool,
|
||||
/// Stream structs from stdin line by line
|
||||
#[structopt(long)]
|
||||
#[arg(long)]
|
||||
stdin: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum Target {
|
||||
/// Insert domain into the database
|
||||
#[structopt(name="domain")]
|
||||
#[command(name="domain")]
|
||||
Domain(AddDomain),
|
||||
/// Insert subdomain into the database
|
||||
#[structopt(name="subdomain")]
|
||||
#[command(name="subdomain")]
|
||||
Subdomain(AddSubdomain),
|
||||
/// Insert ip address into the database
|
||||
#[structopt(name="ipaddr")]
|
||||
#[command(name="ipaddr")]
|
||||
IpAddr(AddIpAddr),
|
||||
/// Insert url into the database
|
||||
#[structopt(name="url")]
|
||||
#[command(name="url")]
|
||||
Url(AddUrl),
|
||||
/// Insert email into the database
|
||||
#[structopt(name="email")]
|
||||
#[command(name="email")]
|
||||
Email(AddEmail),
|
||||
/// Insert phonenumber into the database
|
||||
#[structopt(name="phonenumber")]
|
||||
#[command(name="phonenumber")]
|
||||
PhoneNumber(AddPhoneNumber),
|
||||
/// Insert device into the database
|
||||
#[structopt(name="device")]
|
||||
#[command(name="device")]
|
||||
Device(AddDevice),
|
||||
/// Insert network into the database
|
||||
#[structopt(name="network")]
|
||||
#[command(name="network")]
|
||||
Network(AddNetwork),
|
||||
/// Insert account into the database
|
||||
#[structopt(name="account")]
|
||||
#[command(name="account")]
|
||||
Account(AddAccount),
|
||||
/// Insert breach into the database
|
||||
#[structopt(name="breach")]
|
||||
#[command(name="breach")]
|
||||
Breach(AddBreach),
|
||||
/// Insert images into the database
|
||||
#[structopt(name="image")]
|
||||
#[command(name="image")]
|
||||
Image(AddImage),
|
||||
/// Insert ip network into the database
|
||||
#[structopt(name="netblock")]
|
||||
#[command(name="netblock")]
|
||||
Netblock(AddNetblock),
|
||||
/// Insert port into the database
|
||||
#[structopt(name="port")]
|
||||
#[command(name="port")]
|
||||
Port(AddPort),
|
||||
/// Insert a crypto currency address into the database
|
||||
#[structopt(name="cryptoaddr")]
|
||||
#[command(name="cryptoaddr")]
|
||||
CryptoAddr(AddCryptoAddr),
|
||||
}
|
||||
|
||||
|
@ -153,7 +150,7 @@ trait IntoInsert: Sized {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddDomain {
|
||||
domain: Option<String>,
|
||||
}
|
||||
|
@ -185,7 +182,7 @@ impl InsertFromString for AddDomain {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddSubdomain {
|
||||
subdomain: Option<String>,
|
||||
}
|
||||
|
@ -222,7 +219,7 @@ impl InsertFromString for AddSubdomain {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddIpAddr {
|
||||
ipaddr: Option<net::IpAddr>,
|
||||
}
|
||||
|
@ -269,7 +266,7 @@ impl InsertFromString for AddIpAddr {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddUrl {
|
||||
url: Option<String>,
|
||||
}
|
||||
|
@ -323,7 +320,7 @@ impl InsertFromString for AddUrl {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddEmail {
|
||||
email: Option<String>,
|
||||
}
|
||||
|
@ -350,7 +347,7 @@ impl InsertFromString for AddEmail {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddPhoneNumber {
|
||||
phonenumber: Option<String>,
|
||||
name: Option<String>,
|
||||
|
@ -405,7 +402,7 @@ impl InsertFromString for AddPhoneNumber {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddDevice {
|
||||
mac: Option<String>,
|
||||
name: Option<String>,
|
||||
|
@ -435,7 +432,7 @@ impl IntoInsert for AddDevice {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddNetwork {
|
||||
network: Option<String>,
|
||||
latitude: Option<f32>,
|
||||
|
@ -464,7 +461,7 @@ impl IntoInsert for AddNetwork {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddAccount {
|
||||
service: Option<String>,
|
||||
username: Option<String>,
|
||||
|
@ -506,7 +503,7 @@ impl IntoInsert for AddAccount {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddBreach {
|
||||
name: Option<String>,
|
||||
}
|
||||
|
@ -525,7 +522,7 @@ impl IntoInsert for AddBreach {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddImage {
|
||||
paths: Vec<String>,
|
||||
}
|
||||
|
@ -624,7 +621,7 @@ impl IntoInsert for AddImage {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddNetblock {
|
||||
ipnet: Option<ipnetwork::IpNetwork>,
|
||||
}
|
||||
|
@ -655,7 +652,7 @@ impl IntoInsert for AddNetblock {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddPort {
|
||||
protocol: Option<String>,
|
||||
addr: Option<SocketAddr>,
|
||||
|
@ -730,7 +727,7 @@ impl InsertFromString for AddPort {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct AddCryptoAddr {
|
||||
address: Option<String>,
|
||||
}
|
||||
|
|
|
@ -1,37 +1,35 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use crate::autonoscope;
|
||||
use crate::cmd::Cmd;
|
||||
use crate::fmt::colors::*;
|
||||
use crate::shell::Shell;
|
||||
use std::fmt::Write;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
#[group(skip)]
|
||||
pub struct Args {
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
subcommand: Subcommand,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum Subcommand {
|
||||
#[structopt(name="add")]
|
||||
#[command(name="add")]
|
||||
Add(Add),
|
||||
#[structopt(name="delete")]
|
||||
#[command(name="delete")]
|
||||
Delete(Delete),
|
||||
#[structopt(name="list")]
|
||||
#[command(name="list")]
|
||||
List,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Add {
|
||||
object: autonoscope::RuleType,
|
||||
value: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Delete {
|
||||
object: autonoscope::RuleType,
|
||||
value: String,
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use clap::Parser;
|
||||
use crate::cmd::Cmd;
|
||||
use crate::cmd::autonoscope_cmd;
|
||||
use crate::errors::*;
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[structopt(flatten)]
|
||||
args: autonoscope_cmd::Args,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use chrono::Utc;
|
||||
use crate::cal::DateArg;
|
||||
use crate::cal::date::{DateContext, DateSpec};
|
||||
|
@ -7,21 +6,18 @@ use crate::cal::time::{DateTimeContext, DateTimeSpec};
|
|||
use crate::cmd::Cmd;
|
||||
use crate::models::*;
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
/// Show additional months for context
|
||||
#[structopt(short="C", long)]
|
||||
#[arg(short = 'C', long)]
|
||||
context: Option<u32>,
|
||||
/// Group events in 12 min slices
|
||||
#[structopt(short="T", long, group = "view")]
|
||||
#[arg(short = 'T', long, group = "view")]
|
||||
time: bool,
|
||||
/// Group events by hour
|
||||
#[structopt(short="H", long, group = "view")]
|
||||
#[arg(short = 'H', long, group = "view")]
|
||||
hourly: bool,
|
||||
args: Vec<DateArg>,
|
||||
}
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use crate::cmd::Cmd;
|
||||
use crate::filters::{Target, Filter};
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
use crate::models::*;
|
||||
use crate::term;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[structopt(subcommand)]
|
||||
subcommand: Target,
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use clap::Parser;
|
||||
use clap::ValueEnum;
|
||||
use crate::blobs::Blob;
|
||||
use crate::cmd::Cmd;
|
||||
use crate::db::ttl;
|
||||
use crate::errors::*;
|
||||
use crate::models::*;
|
||||
use crate::shell::Shell;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use std::io::{self, Write};
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use strum_macros::{EnumString, IntoStaticStr};
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
/// Specify the export format
|
||||
#[structopt(short="f", long="format", possible_values=Format::variants())]
|
||||
#[arg(short = 'f', long="format", value_enum)]
|
||||
format: Format,
|
||||
}
|
||||
|
||||
|
@ -37,7 +35,7 @@ fn export<T: ExportFormat + Serialize>(rl: &mut Shell) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, ValueEnum, Serialize, Deserialize)]
|
||||
#[derive(EnumString, IntoStaticStr)]
|
||||
#[strum(serialize_all = "kebab_case")]
|
||||
pub enum Format {
|
||||
|
@ -45,17 +43,6 @@ pub enum Format {
|
|||
JsonBlobs,
|
||||
}
|
||||
|
||||
impl Format {
|
||||
// TODO: this function should be generated by strum instead
|
||||
#[inline]
|
||||
fn variants() -> &'static [&'static str] {
|
||||
&[
|
||||
"json",
|
||||
"json-blobs",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
trait ExportFormat {
|
||||
fn load(rl: &mut Shell) -> Result<Box<Self>>;
|
||||
}
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use clap::{ArgAction, Parser};
|
||||
use crate::blobs::Blob;
|
||||
use crate::cmd::Cmd;
|
||||
use crate::errors::*;
|
||||
use crate::models::*;
|
||||
use crate::shell::Shell;
|
||||
use crate::term;
|
||||
use crate::worker;
|
||||
use crate::models::*;
|
||||
use std::collections::HashSet;
|
||||
use structopt::StructOpt;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
/// Verbose output
|
||||
#[structopt(short="v", long="verbose", parse(from_occurrences))]
|
||||
verbose: u64,
|
||||
#[arg(short = 'v', long="verbose", action(ArgAction::Count))]
|
||||
verbose: u8,
|
||||
/// Delete only dangling blobs
|
||||
#[structopt(long="gc")]
|
||||
#[arg(long="gc")]
|
||||
gc: bool,
|
||||
/// Delete dangling and corrupted blobs
|
||||
#[structopt(long="gc-all")]
|
||||
#[arg(long="gc-all")]
|
||||
gc_all: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,56 +1,47 @@
|
|||
use clap::Parser;
|
||||
use crate::errors::*;
|
||||
|
||||
use crate::keyring::{KeyName, KeyRing};
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use crate::utils;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum Args {
|
||||
#[structopt(name="add")]
|
||||
/// Add a new key to the keyring
|
||||
Add(KeyRingAdd),
|
||||
#[structopt(name="delete")]
|
||||
/// Delete a key from the keyring
|
||||
Delete(KeyRingDelete),
|
||||
#[structopt(name="get")]
|
||||
/// Get a key from the keyring
|
||||
Get(KeyRingGet),
|
||||
#[structopt(name="list")]
|
||||
/// List keys in the keyring
|
||||
List(KeyRingList),
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct KeyRingAdd {
|
||||
key: KeyName,
|
||||
secret: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct KeyRingDelete {
|
||||
key: KeyName,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct KeyRingGet {
|
||||
key: KeyName,
|
||||
#[structopt(short="q",
|
||||
long="quiet")]
|
||||
#[arg(short = 'q', long="quiet")]
|
||||
/// Only output secret key
|
||||
quiet: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct KeyRingList {
|
||||
namespace: Option<String>,
|
||||
}
|
||||
|
||||
pub fn run(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let args = Args::from_iter_safe(args)?;
|
||||
let args = Args::try_parse_from(args)?;
|
||||
match args {
|
||||
Args::Add(add) => keyring_add(rl, add),
|
||||
Args::Delete(delete) => keyring_delete(rl, delete),
|
||||
|
|
|
@ -2,17 +2,17 @@ use crate::errors::*;
|
|||
use crate::shell::Shell;
|
||||
use crate::config::Config;
|
||||
|
||||
pub trait Cmd: structopt::StructOpt + Sized {
|
||||
pub trait Cmd: clap::Parser + Sized {
|
||||
fn run(self, rl: &mut Shell) -> Result<()>;
|
||||
|
||||
#[inline]
|
||||
fn run_str(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let args = Self::from_iter_safe(args)?;
|
||||
let args = Self::try_parse_from(args)?;
|
||||
args.run(rl)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait LiteCmd: structopt::StructOpt + Sized {
|
||||
pub trait LiteCmd: clap::Parser + Sized {
|
||||
fn run(self, config: &Config) -> Result<()>;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use clap::Parser;
|
||||
use crate::cmd::Cmd;
|
||||
use crate::errors::*;
|
||||
use crate::filters::{Target, Filter};
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use crate::models::*;
|
||||
use crate::shell::Shell;
|
||||
use crate::term;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
subcommand: Target,
|
||||
}
|
||||
|
||||
|
@ -40,7 +36,7 @@ impl Cmd for Args {
|
|||
}
|
||||
|
||||
pub fn run(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let args = Args::from_iter_safe(args)?;
|
||||
let args = Args::try_parse_from(args)?;
|
||||
args.run(rl)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use clap::{ArgAction, Parser};
|
||||
use crate::cmd::Cmd;
|
||||
use crate::engine::Module;
|
||||
use crate::errors::*;
|
||||
use crate::notify::{self, Notification};
|
||||
use crate::options::{self, Opt};
|
||||
use crate::shell::Shell;
|
||||
use crate::term;
|
||||
use sn0int_std::ratelimits::Ratelimiter;
|
||||
use std::fmt::Write;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
subcommand: Subcommand,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum Subcommand {
|
||||
/// Manually add a notification to the outbox
|
||||
Send(SendArgs),
|
||||
|
@ -30,24 +27,24 @@ pub enum Subcommand {
|
|||
Deliver,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct SendArgs {
|
||||
/// Evaluate the routing rules, but do not actually send a notification
|
||||
#[structopt(short="n", long)]
|
||||
#[arg(short = 'n', long)]
|
||||
pub dry_run: bool,
|
||||
pub topic: String,
|
||||
#[structopt(flatten)]
|
||||
#[command(flatten)]
|
||||
pub notification: Notification,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct ExecArgs {
|
||||
pub module: String,
|
||||
#[structopt(short="o", long="option")]
|
||||
#[arg(short = 'o', long="option")]
|
||||
pub options: Vec<options::Opt>,
|
||||
#[structopt(short="v", long="verbose", parse(from_occurrences))]
|
||||
verbose: u64,
|
||||
#[structopt(flatten)]
|
||||
#[arg(short = 'v', long="verbose", action(ArgAction::Count))]
|
||||
verbose: u8,
|
||||
#[command(flatten)]
|
||||
pub notification: Notification,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use crate::args::Install;
|
||||
use crate::api::Client;
|
||||
use crate::args;
|
||||
|
@ -16,80 +15,76 @@ use sn0int_common::metadata::Stealth;
|
|||
use std::collections::HashSet;
|
||||
use std::fmt::Write;
|
||||
use std::sync::Arc;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
pub subcommand: SubCommand,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct ArgsInteractive {
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
pub subcommand: SubCommandInteractive,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum SubCommand {
|
||||
/// List installed modules
|
||||
#[structopt(name="list")]
|
||||
#[command(name="list")]
|
||||
List(List),
|
||||
/// Install module from registry
|
||||
#[structopt(name="install")]
|
||||
#[command(name="install")]
|
||||
Install(args::Install),
|
||||
/// Search modules in registry
|
||||
#[structopt(name="search")]
|
||||
#[command(name="search")]
|
||||
Search(args::Search),
|
||||
/// Update modules
|
||||
#[structopt(name="update")]
|
||||
#[command(name="update")]
|
||||
Update(Update),
|
||||
/// Uninstall a module
|
||||
#[structopt(name="uninstall")]
|
||||
#[command(name="uninstall")]
|
||||
Uninstall(Uninstall),
|
||||
/// Install all featured modules
|
||||
#[structopt(name="quickstart")]
|
||||
#[command(name="quickstart")]
|
||||
Quickstart,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum SubCommandInteractive {
|
||||
#[structopt(flatten)]
|
||||
#[command(flatten)]
|
||||
Base(SubCommand),
|
||||
/// Reload modules
|
||||
#[structopt(name="reload")]
|
||||
#[command(name="reload")]
|
||||
Reload(Reload),
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct List {
|
||||
/// Only show modules with a specific input source
|
||||
#[structopt(long="source")]
|
||||
#[arg(long="source")]
|
||||
pub source: Option<String>,
|
||||
/// List outdated modules
|
||||
#[structopt(long="outdated")]
|
||||
#[arg(long="outdated")]
|
||||
pub outdated_only: bool,
|
||||
/// Only show modules with equal or better stealth level
|
||||
#[structopt(long="stealth", possible_values=Stealth::variants())]
|
||||
#[arg(long="stealth", value_enum)]
|
||||
pub stealth: Option<Stealth>,
|
||||
/// Filter by pattern
|
||||
#[structopt(default_value="*")]
|
||||
#[arg(default_value="*")]
|
||||
pub pattern: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Reload {
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Update {
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Uninstall {
|
||||
module: ModuleID,
|
||||
}
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use crate::cmd::Cmd;
|
||||
use crate::cmd::pkg_cmd::{ArgsInteractive as PkgArgs, SubCommand, SubCommandInteractive};
|
||||
use crate::shell::Shell;
|
||||
use crate::term;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
}
|
||||
|
||||
pub fn run(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let _args = Args::from_iter_safe(args)?;
|
||||
let _args = Args::try_parse_from(args)?;
|
||||
|
||||
term::warn("The \x1b[1mquickstart\x1b[0m command is deprecated, use \x1b[1mpkg quickstart\x1b[0m");
|
||||
|
||||
|
|
|
@ -7,26 +7,24 @@ use crate::filters::{Filter, Target};
|
|||
use crate::shell::Shell;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
use crate::models::*;
|
||||
use crate::utils;
|
||||
use crate::term;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
/// Run rules interactively
|
||||
#[structopt(short, long)]
|
||||
#[arg(short, long)]
|
||||
interactive: bool,
|
||||
/// Automatically apply changes to database
|
||||
#[structopt(short="y", long)]
|
||||
#[arg(short='y', long)]
|
||||
auto_confirm: bool,
|
||||
/// Only show changes, do not apply them to the database
|
||||
#[structopt(short="n", long)]
|
||||
#[arg(short='n', long)]
|
||||
dry_run: bool,
|
||||
/// Only rescope entities matching specific filter
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
target: Option<Target>,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use chrootable_https::dns::Resolver;
|
||||
use clap::{ArgAction, Parser};
|
||||
use crate::args;
|
||||
use crate::blobs::{Blob, BlobStorage};
|
||||
use crate::cmd::Cmd;
|
||||
use crate::db::{ttl, Filter};
|
||||
use crate::engine::Module;
|
||||
use crate::errors::*;
|
||||
use crate::ipc::common::StartCommand;
|
||||
use crate::keyring::KeyRing;
|
||||
use crate::models::*;
|
||||
use crate::shell::Shell;
|
||||
use crate::keyring::KeyRing;
|
||||
use crate::term;
|
||||
use crate::utils;
|
||||
use crate::worker;
|
||||
|
@ -18,27 +18,23 @@ use sn0int_common::metadata::Source;
|
|||
use sn0int_std::ratelimits::Ratelimiter;
|
||||
use std::collections::HashMap;
|
||||
use std::net::SocketAddr;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
/// Execute a module that has been installed
|
||||
pub module: Option<String>,
|
||||
/// Run investigations concurrently
|
||||
#[structopt(short="j", default_value="1")]
|
||||
#[arg(short = 'j', default_value="1")]
|
||||
pub threads: usize,
|
||||
/// Verbose logging, once to print inserts even if they don't add new
|
||||
/// data, twice to activate the debug() function
|
||||
#[structopt(short="v", long, parse(from_occurrences))]
|
||||
pub verbose: u64,
|
||||
#[arg(short = 'v', long, action(ArgAction::Count))]
|
||||
pub verbose: u8,
|
||||
/// Set a specific socks5 proxy to use
|
||||
#[structopt(short="X", long)]
|
||||
#[arg(short = 'X', long)]
|
||||
pub proxy: Option<SocketAddr>,
|
||||
/// Set a different default user agent
|
||||
#[structopt(long)]
|
||||
#[arg(long)]
|
||||
pub user_agent: Option<String>,
|
||||
}
|
||||
|
||||
|
@ -46,7 +42,7 @@ pub struct Args {
|
|||
pub struct Params<'a> {
|
||||
pub module: Option<&'a String>,
|
||||
pub threads: usize,
|
||||
pub verbose: u64,
|
||||
pub verbose: u8,
|
||||
pub stdin: bool,
|
||||
pub grants: &'a [String],
|
||||
pub grant_full_keyring: bool,
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use crate::cmd::Cmd;
|
||||
use crate::filters::{Target, Filter};
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
use crate::models::*;
|
||||
use crate::term;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
subcommand: Target,
|
||||
}
|
||||
|
||||
|
@ -40,7 +36,7 @@ impl Cmd for Args {
|
|||
}
|
||||
|
||||
pub fn run(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let args = Args::from_iter_safe(args)?;
|
||||
let args = Args::try_parse_from(args)?;
|
||||
args.run(rl)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use clap::Parser;
|
||||
use crate::cmd::Cmd;
|
||||
use crate::db::ttl;
|
||||
use crate::errors::*;
|
||||
use crate::filters::{Target, Filter};
|
||||
use crate::models::*;
|
||||
use crate::shell::Shell;
|
||||
use serde::Serialize;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use crate::models::*;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[structopt(subcommand)]
|
||||
subcommand: Target,
|
||||
|
@ -25,7 +21,7 @@ pub struct Args {
|
|||
#[structopt(long, group="output")]
|
||||
paths: bool,
|
||||
/// Count rows returned
|
||||
#[structopt(short="c", group="output")]
|
||||
#[structopt(short = 'c', group="output")]
|
||||
count: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
use clap::Parser;
|
||||
use crate::errors::*;
|
||||
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
key: Option<String>,
|
||||
value: Option<String>,
|
||||
|
@ -15,7 +11,7 @@ pub struct Args {
|
|||
// TODO: maybe introduce global settings
|
||||
// TODO: maybe allow setting jobs here as well in addition to -j
|
||||
pub fn run(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let args = Args::from_iter_safe(args)?;
|
||||
let args = Args::try_parse_from(args)?;
|
||||
|
||||
let options = rl.options_mut()
|
||||
.ok_or_else(|| format_err!("Module needs to be selected first"))?;
|
||||
|
|
|
@ -10,23 +10,21 @@ use crate::workspaces;
|
|||
use humansize::{FileSize, file_size_opts};
|
||||
use separator::Separatable;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Debug, Clone, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Clone, Parser)]
|
||||
pub struct Args {
|
||||
/// Exclude blob storage
|
||||
#[structopt(short, long)]
|
||||
#[arg(short, long)]
|
||||
short: bool,
|
||||
/// Exclude categories that don't contain any structs
|
||||
#[structopt(short, long)]
|
||||
#[arg(short, long)]
|
||||
quiet: bool,
|
||||
/// Show workspace statistics in json
|
||||
#[structopt(short, long)]
|
||||
#[arg(short, long)]
|
||||
json: bool,
|
||||
/// Go through all workspaces
|
||||
#[structopt(short, long)]
|
||||
#[arg(short, long)]
|
||||
all: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -3,14 +3,12 @@ use crate::errors::*;
|
|||
use crate::db;
|
||||
use crate::shell::Shell;
|
||||
use sn0int_common::metadata::Source;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use clap::Parser;
|
||||
use crate::term;
|
||||
use crate::models::*;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
// TODO: target -p # print current filter
|
||||
// TODO: target -c # clear filter
|
||||
|
@ -19,7 +17,7 @@ pub struct Args {
|
|||
}
|
||||
|
||||
pub fn run(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let args = Args::from_iter_safe(args)?;
|
||||
let args = Args::try_parse_from(args)?;
|
||||
|
||||
let source = rl.module()
|
||||
.ok_or_else(|| format_err!("No module selected"))
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
use clap::Parser;
|
||||
use crate::errors::*;
|
||||
|
||||
use crate::shell::Shell;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
module: String,
|
||||
}
|
||||
|
||||
pub fn run(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let args = Args::from_iter_safe(args)?;
|
||||
let args = Args::try_parse_from(args)?;
|
||||
|
||||
let module = rl.library().get(&args.module)?.clone();
|
||||
rl.set_module(module);
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use clap::Parser;
|
||||
use crate::blobs::BlobStorage;
|
||||
use crate::cmd::{Cmd, LiteCmd};
|
||||
use crate::config::Config;
|
||||
use crate::db::Database;
|
||||
use crate::errors::*;
|
||||
use crate::shell::Shell;
|
||||
use crate::term;
|
||||
use crate::utils;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use crate::workspaces::{self, Workspace};
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
/// Delete a workspaceb
|
||||
#[structopt(long = "delete", group = "action")]
|
||||
#[arg(long = "delete", group = "action")]
|
||||
delete: bool,
|
||||
/// Show disk usage of workspace
|
||||
#[structopt(long = "usage", group = "action")]
|
||||
#[arg(long = "usage", group = "action")]
|
||||
usage: bool,
|
||||
/// Skip confirmation
|
||||
#[structopt(short = "f", long = "force")]
|
||||
#[arg(short = 'f', long = "force")]
|
||||
force: bool,
|
||||
workspaces: Vec<Workspace>,
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub trait State {
|
|||
|
||||
fn recv(&self) -> Result<serde_json::Value>;
|
||||
|
||||
fn verbose(&self) -> u64;
|
||||
fn verbose(&self) -> u8;
|
||||
|
||||
#[inline]
|
||||
fn info(&self, msg: String) {
|
||||
|
@ -208,7 +208,7 @@ pub struct LuaState {
|
|||
http_sessions: Mutex<HashMap<String, HttpSession>>,
|
||||
http_clients: Mutex<HashMap<String, Arc<chrootable_https::Client<Resolver>>>>,
|
||||
|
||||
verbose: u64,
|
||||
verbose: u8,
|
||||
keyring: Vec<KeyRingEntry>, // TODO: maybe hashmap
|
||||
dns_config: Resolver,
|
||||
psl: Mutex<Lazy<PslReader, Arc<Psl>>>,
|
||||
|
@ -247,7 +247,7 @@ impl State for LuaState {
|
|||
tx.recv()
|
||||
}
|
||||
|
||||
fn verbose(&self) -> u64 {
|
||||
fn verbose(&self) -> u8 {
|
||||
self.verbose
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ pub use sn0int_std::engine::structs;
|
|||
/// Data that is passed to every script
|
||||
#[derive(Debug)]
|
||||
pub struct Environment {
|
||||
pub verbose: u64,
|
||||
pub verbose: u8,
|
||||
pub keyring: Vec<KeyRingEntry>,
|
||||
pub dns_config: Resolver,
|
||||
pub proxy: Option<SocketAddr>,
|
||||
|
|
|
@ -1,52 +1,50 @@
|
|||
use crate::errors::*;
|
||||
|
||||
use crate::db;
|
||||
use structopt::StructOpt;
|
||||
use clap::Parser;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub enum Target {
|
||||
/// On domains
|
||||
#[structopt(name="domains")]
|
||||
#[command(name="domains")]
|
||||
Domains(Filter),
|
||||
/// On subdomains
|
||||
#[structopt(name="subdomains")]
|
||||
#[command(name="subdomains")]
|
||||
Subdomains(Filter),
|
||||
/// On ipaddrs
|
||||
#[structopt(name="ipaddrs")]
|
||||
#[command(name="ipaddrs")]
|
||||
IpAddrs(Filter),
|
||||
/// On urls
|
||||
#[structopt(name="urls")]
|
||||
#[command(name="urls")]
|
||||
Urls(Filter),
|
||||
/// On emails
|
||||
#[structopt(name="emails")]
|
||||
#[command(name="emails")]
|
||||
Emails(Filter),
|
||||
/// On phone numbers
|
||||
#[structopt(name="phonenumbers")]
|
||||
#[command(name="phonenumbers")]
|
||||
PhoneNumbers(Filter),
|
||||
/// On devices
|
||||
#[structopt(name="devices")]
|
||||
#[command(name="devices")]
|
||||
Devices(Filter),
|
||||
/// On networks
|
||||
#[structopt(name="networks")]
|
||||
#[command(name="networks")]
|
||||
Networks(Filter),
|
||||
/// On accounts
|
||||
#[structopt(name="accounts")]
|
||||
#[command(name="accounts")]
|
||||
Accounts(Filter),
|
||||
/// On breaches
|
||||
#[structopt(name="breaches")]
|
||||
#[command(name="breaches")]
|
||||
Breaches(Filter),
|
||||
/// On images
|
||||
#[structopt(name="images")]
|
||||
#[command(name="images")]
|
||||
Images(Filter),
|
||||
/// On ports
|
||||
#[structopt(name="ports")]
|
||||
#[command(name="ports")]
|
||||
Ports(Filter),
|
||||
/// On ipnets
|
||||
#[structopt(name="netblocks")]
|
||||
#[command(name="netblocks")]
|
||||
Netblocks(Filter),
|
||||
/// On crypto currency addresses
|
||||
#[structopt(name="cryptoaddrs")]
|
||||
#[command(name="cryptoaddrs")]
|
||||
CryptoAddrs(Filter),
|
||||
}
|
||||
|
||||
|
@ -100,7 +98,7 @@ impl Target {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Filter {
|
||||
args: Vec<String>,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::net::SocketAddr;
|
|||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct StartCommand {
|
||||
pub verbose: u64,
|
||||
pub verbose: u8,
|
||||
pub keyring: Vec<KeyRingEntry>,
|
||||
pub dns_config: Resolver,
|
||||
pub proxy: Option<SocketAddr>,
|
||||
|
@ -20,7 +20,7 @@ pub struct StartCommand {
|
|||
}
|
||||
|
||||
impl StartCommand {
|
||||
pub fn new(verbose: u64,
|
||||
pub fn new(verbose: u8,
|
||||
keyring: Vec<KeyRingEntry>,
|
||||
dns_config: Resolver,
|
||||
proxy: Option<SocketAddr>,
|
||||
|
|
|
@ -106,7 +106,7 @@ pub fn run(module: Module,
|
|||
tx: &EventSender,
|
||||
arg: serde_json::Value,
|
||||
keyring: Vec<KeyRingEntry>,
|
||||
verbose: u64,
|
||||
verbose: u8,
|
||||
has_stdin: bool,
|
||||
proxy: Option<SocketAddr>,
|
||||
user_agent: Option<String>,
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
|
|||
use sn0int_common::ModuleID;
|
||||
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct KeyName {
|
||||
pub namespace: String,
|
||||
pub name: String,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use env_logger::Env;
|
||||
use sn0int::args::{self, Args, SubCommand};
|
||||
use sn0int::auth;
|
||||
use clap::Parser;
|
||||
use sn0int::cmd::{self, LiteCmd};
|
||||
use sn0int::cmd::run_cmd::Params;
|
||||
use sn0int::config::Config;
|
||||
|
@ -15,8 +16,7 @@ use sn0int::psl::PslReader;
|
|||
use sn0int::registry;
|
||||
use sn0int::repl;
|
||||
use sn0int::sandbox;
|
||||
use sn0int::shell::{self, complete};
|
||||
use structopt::StructOpt;
|
||||
use sn0int::shell;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
@ -99,7 +99,7 @@ end
|
|||
}
|
||||
|
||||
fn run() -> Result<()> {
|
||||
let mut args = Args::from_args();
|
||||
let mut args = Args::parse();
|
||||
|
||||
if !args.is_sandbox() {
|
||||
sandbox::fasten_seatbelt()?;
|
||||
|
@ -142,7 +142,7 @@ fn run() -> Result<()> {
|
|||
Some(SubCommand::Stats(stats)) => run_cmd(&args, stats, &config),
|
||||
Some(SubCommand::Repl) => repl::run(&config),
|
||||
Some(SubCommand::Paths) => paths::run(&config),
|
||||
Some(SubCommand::Completions(completions)) => complete::run_generate(&completions),
|
||||
Some(SubCommand::Completions(completions)) => completions.generate(),
|
||||
None => shell::run(&args, &config),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
mod rules;
|
||||
|
||||
use crate::errors::*;
|
||||
use crate::cmd::run_cmd::prepare_keyring;
|
||||
use clap::Parser;
|
||||
use crate::cmd::run_cmd::Params;
|
||||
use crate::cmd::run_cmd::prepare_keyring;
|
||||
use crate::engine::Module;
|
||||
use crate::errors::*;
|
||||
use crate::options;
|
||||
use crate::shell::Shell;
|
||||
use crate::term::SpinLogger;
|
||||
use crate::worker;
|
||||
use self::rules::Glob;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use structopt::StructOpt;
|
||||
use sn0int_common::metadata::Source;
|
||||
use sn0int_std::blobs::Blob;
|
||||
use sn0int_std::ratelimits::Ratelimiter;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, StructOpt, Serialize)]
|
||||
#[derive(Debug, Parser, Serialize)]
|
||||
pub struct Notification {
|
||||
pub subject: String,
|
||||
pub body: Option<String>,
|
||||
|
@ -79,7 +79,7 @@ fn prepare_arg(notification: &Notification) -> Result<(serde_json::Value, Option
|
|||
Ok((arg, None, vec![]))
|
||||
}
|
||||
|
||||
pub fn exec(rl: &mut Shell, module: &Module, ratelimit: &mut Ratelimiter, options: HashMap<String, String>, verbose: u64, notification: &Notification) -> Result<usize> {
|
||||
pub fn exec(rl: &mut Shell, module: &Module, ratelimit: &mut Ratelimiter, options: HashMap<String, String>, verbose: u8, notification: &Notification) -> Result<usize> {
|
||||
let module_name = module.canonical();
|
||||
debug!("Setting up notification execution with {:?}", module_name);
|
||||
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
use crate::args::{Args, Completions};
|
||||
use crate::autonoscope::RuleType;
|
||||
use crate::errors::*;
|
||||
use rustyline::{self, Context};
|
||||
use rustyline::completion::Completer;
|
||||
use rustyline::highlight::Highlighter;
|
||||
use rustyline::hint::Hinter;
|
||||
use std::borrow::Cow::{self, Owned};
|
||||
use std::str::FromStr;
|
||||
use std::io::stdout;
|
||||
use structopt::StructOpt;
|
||||
use crate::shell::Command;
|
||||
use crate::workspaces;
|
||||
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct CmdCompleter {
|
||||
pub modules: Vec<String>,
|
||||
|
@ -318,8 +313,3 @@ impl Highlighter for CmdCompleter {
|
|||
|
||||
impl rustyline::Helper for CmdCompleter {}
|
||||
impl rustyline::validate::Validator for CmdCompleter {}
|
||||
|
||||
pub fn run_generate(args: &Completions) -> Result<()> {
|
||||
Args::clap().gen_completions_to("sn0int", args.shell, &mut stdout());
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ impl DatabaseEvent {
|
|||
Self::notify(rl, spinner, ratelimit, &topic, subject);
|
||||
}
|
||||
|
||||
fn on_activity<T: SpinLogger>(rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, object: &NewActivity, verbose: u64) {
|
||||
fn on_activity<T: SpinLogger>(rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, object: &NewActivity, verbose: u8) {
|
||||
Self::spinner_log_new_activity(spinner, object, verbose);
|
||||
|
||||
// TODO: we don't want to copy the match arms everywhere
|
||||
|
@ -211,7 +211,7 @@ impl DatabaseEvent {
|
|||
Self::notify(rl, spinner, ratelimit, &topic, subject);
|
||||
}
|
||||
|
||||
fn spinner_log_new_activity<T: SpinLogger>(spinner: &mut T, object: &NewActivity, verbose: u64) {
|
||||
fn spinner_log_new_activity<T: SpinLogger>(spinner: &mut T, object: &NewActivity, verbose: u8) {
|
||||
let mut log = format!("{:?} ", object.topic);
|
||||
if let Some(uniq) = &object.uniq {
|
||||
write!(log, "({:?}) ", uniq).expect("out of memory");
|
||||
|
@ -233,7 +233,7 @@ impl DatabaseEvent {
|
|||
spinner.log(&log);
|
||||
}
|
||||
|
||||
fn insert<T: SpinLogger>(rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, object: Insert, ttl: Option<i32>, tx: DbSender, verbose: u64) {
|
||||
fn insert<T: SpinLogger>(rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, object: Insert, ttl: Option<i32>, tx: DbSender, verbose: u8) {
|
||||
let db = rl.db();
|
||||
if verbose >= 1 {
|
||||
spinner.debug(&format!("Inserting: {:?}", object));
|
||||
|
@ -299,7 +299,7 @@ impl DatabaseEvent {
|
|||
}
|
||||
|
||||
|
||||
pub fn activity<T: SpinLogger>(rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, object: NewActivity, tx: DbSender, verbose: u64) {
|
||||
pub fn activity<T: SpinLogger>(rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, object: NewActivity, tx: DbSender, verbose: u8) {
|
||||
let db = rl.db();
|
||||
let result = db.insert_activity(object.clone());
|
||||
debug!("{:?} => {:?}", object, result);
|
||||
|
@ -320,7 +320,7 @@ impl DatabaseEvent {
|
|||
tx.send(result).expect("Failed to send db result to channel");
|
||||
}
|
||||
|
||||
pub fn update<T: SpinLogger>(rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, family: &str, value: &str, update: &Update, tx: DbSender, verbose: u64) {
|
||||
pub fn update<T: SpinLogger>(rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, family: &str, value: &str, update: &Update, tx: DbSender, verbose: u8) {
|
||||
let db = rl.db();
|
||||
if verbose >= 1 {
|
||||
spinner.debug(&format!("Updating: {:?}", update));
|
||||
|
@ -344,7 +344,7 @@ impl DatabaseEvent {
|
|||
tx.send(result).expect("Failed to send db result to channel");
|
||||
}
|
||||
|
||||
pub fn apply<T: SpinLogger>(self, rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, tx: DbSender, verbose: u64) {
|
||||
pub fn apply<T: SpinLogger>(self, rl: &mut Shell, spinner: &mut T, ratelimit: &mut Ratelimiter, tx: DbSender, verbose: u8) {
|
||||
match self {
|
||||
DatabaseEvent::Insert(object) => Self::insert(rl, spinner, ratelimit, object, None, tx, verbose),
|
||||
DatabaseEvent::InsertTtl((object, ttl)) => Self::insert(rl, spinner, ratelimit, object, Some(ttl), tx, verbose),
|
||||
|
|
Loading…
Reference in New Issue