Replace quickstart with pkg quickstart
This commit is contained in:
@@ -47,10 +47,10 @@ def main(tempdir, binary):
|
||||
|
||||
print('[*] installing modules')
|
||||
sn0int(tempdir, binary, [
|
||||
'mod install kpcyrd/ctlogs',
|
||||
'mod install kpcyrd/dns-resolve',
|
||||
'mod install kpcyrd/url-scan',
|
||||
'mod install kpcyrd/geoip',
|
||||
'pkg install kpcyrd/ctlogs',
|
||||
'pkg install kpcyrd/dns-resolve',
|
||||
'pkg install kpcyrd/url-scan',
|
||||
'pkg install kpcyrd/geoip',
|
||||
])
|
||||
|
||||
print('[*] running ctlogs')
|
||||
|
||||
@@ -27,12 +27,12 @@ number of recommended modules::
|
||||
[+] Downloading "GeoLite2-City.mmdb"
|
||||
[+] Downloading "GeoLite2-ASN.mmdb"
|
||||
[+] Loaded 0 modules
|
||||
[*] No modules found, run quickstart to install default modules
|
||||
[*] No modules found, run pkg quickstart to install default modules
|
||||
[sn0int][default] >
|
||||
|
||||
Typing ``quickstart`` is going to get you a fair number of featured modules::
|
||||
Typing ``pkg quickstart`` is going to get you a fair number of featured modules::
|
||||
|
||||
[sn0int][default] > quickstart
|
||||
[sn0int][default] > pkg quickstart
|
||||
[+] Installing kpcyrd/asn
|
||||
[+] Installing kpcyrd/ctlogs
|
||||
[+] Installing kpcyrd/dns-resolve
|
||||
@@ -105,7 +105,7 @@ Running a module
|
||||
Now that we have something to get started with, we can run our first module.
|
||||
First lets list all modules we have::
|
||||
|
||||
[sn0int][demo] > mod list
|
||||
[sn0int][demo] > pkg list
|
||||
kpcyrd/asn (0.1.0)
|
||||
Run a asn lookup for an ip address
|
||||
kpcyrd/ctlogs (0.1.0)
|
||||
|
||||
@@ -16,9 +16,8 @@ pub fn run(_rl: &mut Shell, _args: &[String]) -> Result<()> {
|
||||
help("autoscope", "Manage rules to automatically add entities to scope");
|
||||
help("delete", "Delete entities from the database");
|
||||
help("keyring", "Manage saved credentials");
|
||||
help("mod", "Manage installed modules");
|
||||
help("pkg", "Manage installed modules");
|
||||
help("noscope", "Exclude entities from scope");
|
||||
help("quickstart", "Install all featured modules");
|
||||
help("run", "Run the currently selected module");
|
||||
help("scope", "Include entities in the scope again");
|
||||
help("select", "Select entities from the database");
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use crate::errors::*;
|
||||
|
||||
use crate::args::Install;
|
||||
use crate::api::Client;
|
||||
use crate::args;
|
||||
use crate::config::Config;
|
||||
use crate::cmd::{Cmd, LiteCmd};
|
||||
use crate::engine::Library;
|
||||
use crate::registry::{self, UpdateTask, Updater};
|
||||
use crate::registry::{self, InstallTask, UpdateTask, Updater};
|
||||
use crate::shell::Shell;
|
||||
use crate::update::AutoUpdater;
|
||||
use crate::worker;
|
||||
@@ -47,6 +49,9 @@ pub enum SubCommand {
|
||||
/// Uninstall a module
|
||||
#[structopt(name="uninstall")]
|
||||
Uninstall(Uninstall),
|
||||
/// Install all featured modules
|
||||
#[structopt(name="quickstart")]
|
||||
Quickstart,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
@@ -156,6 +161,34 @@ fn run_subcommand(subcommand: SubCommand, library: &Library, config: &Config) ->
|
||||
// trigger reload
|
||||
Ok(ModuleReload::Yes)
|
||||
},
|
||||
SubCommand::Quickstart => {
|
||||
let client = Client::new(&config)?;
|
||||
let updater = Arc::new(Updater::new(&config)?);
|
||||
let mut autoupdate = AutoUpdater::load()?;
|
||||
|
||||
let modules = client.quickstart()?
|
||||
.into_iter()
|
||||
.map(|module| {
|
||||
InstallTask::new(Install {
|
||||
module: ModuleID {
|
||||
author: module.author,
|
||||
name: module.name,
|
||||
},
|
||||
version: None,
|
||||
force: false,
|
||||
}, updater.clone())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
worker::spawn_multi(modules, |name| {
|
||||
autoupdate.updated(&name);
|
||||
}, 3)?;
|
||||
|
||||
autoupdate.save()?;
|
||||
|
||||
// trigger reload
|
||||
Ok(ModuleReload::Yes)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
use crate::errors::*;
|
||||
|
||||
use crate::args::Install;
|
||||
use crate::api::Client;
|
||||
use crate::registry::{InstallTask, Updater};
|
||||
use crate::cmd::Cmd;
|
||||
use crate::cmd::pkg_cmd::{ArgsInteractive as PkgArgs, SubCommand, SubCommandInteractive};
|
||||
use crate::shell::Shell;
|
||||
use crate::update::AutoUpdater;
|
||||
use crate::worker;
|
||||
use std::sync::Arc;
|
||||
use crate::term;
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use sn0int_common::ModuleID;
|
||||
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
@@ -19,34 +15,11 @@ pub struct Args {
|
||||
|
||||
pub fn run(rl: &mut Shell, args: &[String]) -> Result<()> {
|
||||
let _args = Args::from_iter_safe(args)?;
|
||||
let config = rl.config().clone();
|
||||
|
||||
let client = Client::new(&config)?;
|
||||
let updater = Arc::new(Updater::new(&config)?);
|
||||
let mut autoupdate = AutoUpdater::load()?;
|
||||
term::warn("The \x1b[1mquickstart\x1b[0m command is deprecated, use \x1b[1mpkg quickstart\x1b[0m");
|
||||
|
||||
let modules = client.quickstart()?
|
||||
.into_iter()
|
||||
.map(|module| {
|
||||
InstallTask::new(Install {
|
||||
module: ModuleID {
|
||||
author: module.author,
|
||||
name: module.name,
|
||||
},
|
||||
version: None,
|
||||
force: false,
|
||||
}, updater.clone())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
worker::spawn_multi(modules, |name| {
|
||||
autoupdate.updated(&name);
|
||||
}, 3)?;
|
||||
|
||||
autoupdate.save()?;
|
||||
|
||||
// trigger reload
|
||||
rl.reload_modules()?;
|
||||
|
||||
Ok(())
|
||||
let args = PkgArgs {
|
||||
subcommand: SubCommandInteractive::Base(SubCommand::Quickstart),
|
||||
};
|
||||
args.run(rl)
|
||||
}
|
||||
|
||||
@@ -202,6 +202,7 @@ impl Completer for CmdCompleter {
|
||||
"reload",
|
||||
"update",
|
||||
"uninstall",
|
||||
"quickstart",
|
||||
], &cmd[1]))
|
||||
}
|
||||
},
|
||||
|
||||
@@ -506,12 +506,12 @@ pub fn init<'a>(args: &Args, config: &'a Config, verbose_init: bool) -> Result<S
|
||||
let keyring = KeyRing::init()?;
|
||||
|
||||
if verbose_init && library.list().is_empty() {
|
||||
term::success("No modules found, run quickstart to install default modules");
|
||||
term::success("No modules found, run \x1b[1mpkg quickstart\x1b[0m to install default modules");
|
||||
}
|
||||
|
||||
let autoupdate = AutoUpdater::load()?;
|
||||
if autoupdate.outdated() > 0 {
|
||||
term::warn(&format!("{} modules are outdated, run: mod update", autoupdate.outdated()));
|
||||
term::warn(&format!("{} modules are outdated, run: \x1b[1mpkg update\x1b[0m", autoupdate.outdated()));
|
||||
}
|
||||
autoupdate.check_background(&config, library.list());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user