MCPcopy
hub / github.com/vulnersCom/getsploit / download_database

Function download_database

getsploit/__init__.py:44–65  ·  view source on GitHub ↗
(ctx: Context)

Source from the content-addressed store, hash-verified

42
43
44def download_database(ctx: Context) -> None:
45 click.echo("Downloading getsploit database archive. Please wait...")
46 with tempfile.TemporaryDirectory() as tmpdir:
47 path = pathlib.Path(tmpdir) / "getsploit.db.zip"
48 with (
49 ctx.client.stream("GET", "v3/archive/getsploit", follow_redirects=True) as resp,
50 ):
51 try:
52 resp.raise_for_status()
53 except httpx.HTTPStatusError as e:
54 raise click.ClickException(str(e))
55 with (
56 click.progressbar(
57 length=int(resp.headers["Content-Length"]), label="Reading archive"
58 ) as bar,
59 path.open("wb") as output,
60 ):
61 for chunk in resp.iter_bytes():
62 output.write(chunk)
63 bar.update(len(chunk))
64 with zipfile.ZipFile(path, "r") as archive:
65 archive.extractall(ctx.home_path)
66
67
68def search_exploit_local(ctx: Context, query: str, limit: int) -> Iterable[Mapping[str, Any]]:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected