Skip to content

Commit 2492298

Browse files
committed
Add RawQuery
1 parent 40377e6 commit 2492298

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

example/example_client.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import decouple
22
from leakix import Client
3-
from leakix.query import MustQuery, MustNotQuery
3+
from leakix.query import MustQuery, MustNotQuery, RawQuery
44
from leakix.field import PluginField, CountryField
55
from leakix.plugin import Plugin
66

@@ -52,8 +52,22 @@ def example_get_leaks_multiple_filter_plugins_must_not():
5252
)
5353

5454

55+
def example_get_leak_raw_query():
56+
raw_query = '+plugin:HttpNTLM +country:"France"'
57+
query = RawQuery(raw_query)
58+
response = CLIENT.get_leak(queries=[query])
59+
assert response.status_code() == 200
60+
assert all(
61+
(
62+
i.geoip.country_name == "France" and i.tags == ["ntlm"]
63+
for i in response.json()
64+
)
65+
)
66+
67+
5568
if __name__ == "__main__":
5669
example_get_host_filter_plugin()
5770
example_get_service_filter_plugin()
5871
example_get_leaks_filter_multiple_plugins()
5972
example_get_leaks_multiple_filter_plugins_must_not()
73+
example_get_leak_raw_query()

leakix/query.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ def serialize(self) -> str:
3232
class ShouldQuery(Query):
3333
def serialize(self) -> str:
3434
return "%s" % self.field.serialize()
35+
36+
37+
class RawQuery(AbstractQuery):
38+
def __init__(self, raw_q: str):
39+
self.raw_q = raw_q
40+
41+
def serialize(self) -> str:
42+
return self.raw_q

0 commit comments

Comments
 (0)