| 66 | |
| 67 | |
| 68 | def search_exploit_local(ctx: Context, query: str, limit: int) -> Iterable[Mapping[str, Any]]: |
| 69 | if not ctx.database_path.exists(): |
| 70 | raise click.ClickException("There is no local database file. Run 'getsploit --update'") |
| 71 | conn = sqlite3.connect(ctx.database_path) |
| 72 | cursor = conn.cursor() |
| 73 | search_results = cursor.execute( |
| 74 | f"SELECT * FROM exploits WHERE exploits MATCH ? ORDER BY published LIMIT ?", |
| 75 | (query, limit), |
| 76 | ).fetchall() |
| 77 | fields = [d[0] for d in cursor.description] |
| 78 | for row in search_results: |
| 79 | yield dict(zip(fields, row)) |
| 80 | |
| 81 | |
| 82 | def search_exploit_online(ctx: Context, query: str, limit: int) -> Iterable[Mapping[str, Any]]: |