ipilot 1.36.2__tar.gz → 1.38.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ipilot-1.36.2 → ipilot-1.38.0}/PKG-INFO +1 -1
- {ipilot-1.36.2 → ipilot-1.38.0}/app/args.py +2 -4
- {ipilot-1.36.2 → ipilot-1.38.0}/app/ip_info.py +17 -16
- {ipilot-1.36.2 → ipilot-1.38.0}/app/main.py +7 -6
- {ipilot-1.36.2 → ipilot-1.38.0}/app/print_table.py +0 -2
- {ipilot-1.36.2 → ipilot-1.38.0}/app/query_normalisation.py +0 -2
- {ipilot-1.36.2 → ipilot-1.38.0}/pyproject.toml +2 -4
- {ipilot-1.36.2 → ipilot-1.38.0}/tests/test_ip_info.py +2 -4
- {ipilot-1.36.2 → ipilot-1.38.0}/tests/test_print_table.py +0 -2
- {ipilot-1.36.2 → ipilot-1.38.0}/tests/test_query_normalisation.py +0 -2
- {ipilot-1.36.2 → ipilot-1.38.0}/README.md +0 -0
- {ipilot-1.36.2 → ipilot-1.38.0}/app/__init__.py +0 -0
- {ipilot-1.36.2 → ipilot-1.38.0}/tests/__init__.py +0 -0
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#!/usr/local/env python3
|
|
2
|
-
|
|
3
1
|
"""MODULE: Provides CLI arguments to the application."""
|
|
4
2
|
|
|
5
3
|
import argparse
|
|
@@ -9,10 +7,10 @@ from app.query_normalisation import get_public_ip
|
|
|
9
7
|
|
|
10
8
|
def parse_args() -> argparse.Namespace: # pragma: no cover
|
|
11
9
|
"""Get arguments from user via the command line.
|
|
12
|
-
|
|
10
|
+
|
|
13
11
|
Args:
|
|
14
12
|
None
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
Returns:
|
|
17
15
|
argparse.Namespace: parsed arguments
|
|
18
16
|
"""
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
1
|
"""MODULE: Provides functions to call various APIs to retrieve IP/prefix information."""
|
|
4
2
|
|
|
5
|
-
from typing import Optional
|
|
6
|
-
|
|
7
3
|
import ipaddress
|
|
4
|
+
|
|
8
5
|
import requests
|
|
9
6
|
|
|
10
7
|
|
|
11
|
-
def get_ip_information(ipv4_address: ipaddress.IPv4Address) ->
|
|
8
|
+
def get_ip_information(ipv4_address: ipaddress.IPv4Address) -> dict | None:
|
|
12
9
|
"""Retrieves information about a given IPv4 address from IP-API.com.
|
|
13
|
-
|
|
10
|
+
|
|
14
11
|
Args:
|
|
15
12
|
ipv4_address (ipaddress.IPv4Address): IPv4 address to query
|
|
16
|
-
|
|
13
|
+
|
|
17
14
|
Returns:
|
|
18
|
-
|
|
15
|
+
dict | None: API response
|
|
19
16
|
"""
|
|
20
17
|
api_endpoint: str = f"http://ip-api.com/json/{ipv4_address}"
|
|
21
18
|
try:
|
|
22
19
|
resp: requests.Response = requests.get(api_endpoint, timeout=10)
|
|
23
20
|
resp.raise_for_status()
|
|
24
|
-
ret: dict | None =
|
|
21
|
+
ret: dict | None = (
|
|
22
|
+
resp.json() if resp.json().get("status") == "success" else None
|
|
23
|
+
)
|
|
25
24
|
except (requests.exceptions.JSONDecodeError, requests.exceptions.HTTPError):
|
|
26
25
|
ret = None
|
|
27
26
|
return ret
|
|
@@ -29,10 +28,10 @@ def get_ip_information(ipv4_address: ipaddress.IPv4Address) -> Optional[dict]:
|
|
|
29
28
|
|
|
30
29
|
def get_autonomous_system_number(as_info: str) -> str:
|
|
31
30
|
"""Parses AS number from provided AS information.
|
|
32
|
-
|
|
31
|
+
|
|
33
32
|
Args:
|
|
34
33
|
as_info (str): AS information
|
|
35
|
-
|
|
34
|
+
|
|
36
35
|
Returns:
|
|
37
36
|
str: AS number
|
|
38
37
|
"""
|
|
@@ -40,16 +39,18 @@ def get_autonomous_system_number(as_info: str) -> str:
|
|
|
40
39
|
return as_number
|
|
41
40
|
|
|
42
41
|
|
|
43
|
-
def get_prefix_information(autonomous_system: str) ->
|
|
42
|
+
def get_prefix_information(autonomous_system: str) -> list | None:
|
|
44
43
|
"""Retrieves prefix information about a given autonomous system.
|
|
45
|
-
|
|
44
|
+
|
|
46
45
|
Args:
|
|
47
46
|
autonomous_system (str): autonomous system to query, e.g. AS123
|
|
48
|
-
|
|
47
|
+
|
|
49
48
|
Returns:
|
|
50
|
-
|
|
49
|
+
list | None: API response
|
|
51
50
|
"""
|
|
52
|
-
api_endpoint: str =
|
|
51
|
+
api_endpoint: str = (
|
|
52
|
+
f"https://api.hackertarget.com/aslookup/?q={autonomous_system!s}"
|
|
53
|
+
)
|
|
53
54
|
try:
|
|
54
55
|
resp: requests.Response = requests.get(api_endpoint, timeout=10)
|
|
55
56
|
resp.raise_for_status()
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#!/usr/local/bin/python3
|
|
2
|
-
|
|
3
1
|
"""MODULE: Main application module."""
|
|
4
2
|
|
|
5
3
|
import sys
|
|
@@ -16,15 +14,16 @@ from app.query_normalisation import is_ip_address, resolve_domain_name
|
|
|
16
14
|
HEADER = """-----------------------------------------------
|
|
17
15
|
| IP Address Information Lookup Tool (iPilot) |
|
|
18
16
|
| By Luke Tainton (@luketainton) |
|
|
19
|
-
|
|
17
|
+
-----------------------------------------------
|
|
18
|
+
"""
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
def main() -> None:
|
|
23
22
|
"""Main function.
|
|
24
|
-
|
|
23
|
+
|
|
25
24
|
Args:
|
|
26
25
|
None
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
Returns:
|
|
29
28
|
None
|
|
30
29
|
"""
|
|
@@ -33,7 +32,9 @@ def main() -> None:
|
|
|
33
32
|
print(HEADER)
|
|
34
33
|
|
|
35
34
|
# Set IP to passed IP address, or resolve passed domain name to IPv4
|
|
36
|
-
ip_address =
|
|
35
|
+
ip_address = (
|
|
36
|
+
resolve_domain_name(args.query) if not is_ip_address(args.query) else args.query
|
|
37
|
+
)
|
|
37
38
|
|
|
38
39
|
# If not given an IPv4, and can't resolve to IPv4, then throw error and exit
|
|
39
40
|
if not ip_address:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ipilot"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.38.0"
|
|
4
4
|
description = "IP Information Lookup Tool"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -17,10 +17,8 @@ app = "app.main:main"
|
|
|
17
17
|
|
|
18
18
|
[dependency-groups]
|
|
19
19
|
dev = [
|
|
20
|
-
"black<26.5.2,>=26.5.1",
|
|
21
20
|
"coverage<8.0.0,>=7.5.0",
|
|
22
|
-
"
|
|
23
|
-
"pylint-exit<2.0.0,>=1.2.0",
|
|
21
|
+
"ruff>=0.12.0",
|
|
24
22
|
"pytest<9.1.2,>=9.1.1",
|
|
25
23
|
"requests-mock<2.0.0,>=1.12.1",
|
|
26
24
|
]
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
1
|
"""MODULE: Provides test cases for app/ip_info.py."""
|
|
4
2
|
|
|
5
3
|
import requests_mock
|
|
@@ -55,7 +53,7 @@ def test_get_prefix_information_broken_api_response() -> None:
|
|
|
55
53
|
autonomous_system = "AS109"
|
|
56
54
|
with requests_mock.Mocker() as mocker:
|
|
57
55
|
mocker.get(
|
|
58
|
-
f"https://api.hackertarget.com/aslookup/?q={
|
|
56
|
+
f"https://api.hackertarget.com/aslookup/?q={autonomous_system!s}",
|
|
59
57
|
text="error",
|
|
60
58
|
)
|
|
61
59
|
resp = get_prefix_information(autonomous_system)
|
|
@@ -67,7 +65,7 @@ def test_get_prefix_information_bad_response() -> None:
|
|
|
67
65
|
autonomous_system = "AS109"
|
|
68
66
|
with requests_mock.Mocker() as mocker:
|
|
69
67
|
mocker.get(
|
|
70
|
-
f"https://api.hackertarget.com/aslookup/?q={
|
|
68
|
+
f"https://api.hackertarget.com/aslookup/?q={autonomous_system!s}",
|
|
71
69
|
status_code=404,
|
|
72
70
|
)
|
|
73
71
|
resp = get_prefix_information(autonomous_system)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|