Skip to content

Commit d1d237b

Browse files
committed
Feat: Add search() and get_domain() methods
- Add search(query, scope, page) for simple query string syntax - Add get_domain() endpoint for domain lookups - Bump version to 0.2.0
1 parent d8100be commit d1d237b

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

leakix/client.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from leakix.domain import L9Subdomain
1111
from leakix.plugin import APIResult
12-
from leakix.query import EmptyQuery, Query
12+
from leakix.query import EmptyQuery, Query, RawQuery
1313
from leakix.response import (
1414
AbstractResponse,
1515
ErrorResponse,
@@ -243,3 +243,43 @@ def bulk_service(self, queries: list[Query] | None = None) -> AbstractResponse:
243243
return ErrorResponse(response=r, response_json=[], status_code=200)
244244
else:
245245
return ErrorResponse(response=r, response_json=r.json())
246+
247+
def get_domain(self, domain: str) -> AbstractResponse:
248+
"""
249+
Returns the list of services and associated leaks for a given domain.
250+
"""
251+
url = f"{self.base_url}/domain/{domain}"
252+
r = self.__get(url, params=None)
253+
if r.is_success():
254+
response_json = r.json()
255+
formatted_result = HostResult.from_dict(response_json)
256+
response_json = {
257+
"services": formatted_result.Services,
258+
"leaks": formatted_result.Leaks,
259+
}
260+
r.response_json = response_json
261+
return r
262+
263+
def search(self, query: str, scope: str = "leak", page: int = 0) -> AbstractResponse:
264+
"""
265+
Simple search using a query string.
266+
267+
This is a convenience method that accepts a raw query string like on the website.
268+
For example: "+plugin:GitConfigHttpPlugin +country:FR"
269+
270+
Args:
271+
query: The search query string (same syntax as the website)
272+
scope: Either "leak" or "service" (default: "leak")
273+
page: Page number for pagination (default: 0)
274+
275+
Returns:
276+
A response object with the search results.
277+
278+
Example:
279+
>>> client.search("+plugin:GitConfigHttpPlugin", scope="leak")
280+
>>> client.search("+country:FR +port:22", scope="service")
281+
"""
282+
queries = [RawQuery(query)]
283+
if scope == "service":
284+
return self.get_service(queries=queries, page=page)
285+
return self.get_leak(queries=queries, page=page)

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[tool.poetry]
22
name = "leakix"
3-
version = "0.1.10"
3+
version = "0.2.0"
44
description = "Official python client for LeakIX (https://leakix.net)"
5-
authors = ["Danny Willems <danny@leakix.net>"]
5+
authors = [
6+
"Danny Willems <danny@leakix.net>",
7+
"Valentin Lobstein <valentin@leakix.net>",
8+
]
69

710
[tool.poetry.dependencies]
811
python = "^3.13"

0 commit comments

Comments
 (0)