portune 0.1.8__tar.gz → 0.1.10__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.

Potentially problematic release.


This version of portune might be problematic. Click here for more details.

@@ -1,38 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: portune
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Author: Franck Jouvanceau
6
6
  Maintainer: Franck Jouvanceau
7
- License: MIT License
8
-
9
- Copyright (c) 2025 joknarf
10
-
11
- Permission is hereby granted, free of charge, to any person obtaining a copy
12
- of this software and associated documentation files (the "Software"), to deal
13
- in the Software without restriction, including without limitation the rights
14
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- copies of the Software, and to permit persons to whom the Software is
16
- furnished to do so, subject to the following conditions:
17
-
18
- The above copyright notice and this permission notice shall be included in all
19
- copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- SOFTWARE.
28
-
7
+ License-Expression: MIT
29
8
  Project-URL: Homepage, https://github.com/joknarf/portune
30
9
  Project-URL: Documentation, https://github.com/joknarf/portune/blob/main/README.md
31
10
  Project-URL: Repository, https://github.com/joknarf/portune.git
32
11
  Keywords: port,scanner,html_report
33
12
  Classifier: Development Status :: 5 - Production/Stable
34
13
  Classifier: Intended Audience :: System Administrators
35
- Classifier: License :: OSI Approved :: MIT License
36
14
  Classifier: Operating System :: POSIX
37
15
  Classifier: Operating System :: Unix
38
16
  Classifier: Operating System :: MacOS
@@ -24,6 +24,7 @@ import time
24
24
  import subprocess
25
25
  from concurrent.futures import ThreadPoolExecutor, as_completed
26
26
  from collections import defaultdict
27
+ import json
27
28
  from html import escape
28
29
  import smtplib
29
30
  from email.mime.text import MIMEText
@@ -619,7 +620,7 @@ class ProgressBar:
619
620
  sys.stderr.write('\n')
620
621
  sys.stderr.flush()
621
622
 
622
- def parse_input_file(filename: str) -> List[Tuple[str, List[int]]]:
623
+ def parse_input_file(filename: str, info_command: Optional[str] = None) -> List[Tuple[str, List[int]]]:
623
624
  """Parse the input file containing host and port information.
624
625
 
625
626
  Reads a text file where each line contains a hostname and optionally a list of ports.
@@ -660,17 +661,29 @@ def parse_input_file(filename: str) -> List[Tuple[str, List[int]]]:
660
661
  fqdn = words[0].lower()
661
662
  ports = words[1] if len(words) > 1 else '22'
662
663
  port_list = [int(p) for p in ports.split(',')]
663
- desc = ' '.join(words[2:]).strip() if len(words) > 2 else ''
664
+ desc = ' '.join(words[2:]).strip().split('|') if len(words) > 2 else []
664
665
  if fqdn in host_dict:
665
666
  existing_ports, existing_desc = host_dict[fqdn]
666
667
  host_dict[fqdn] = (list(set(existing_ports + port_list)), existing_desc or desc)
667
668
  else:
668
- host_dict[fqdn] = (port_list, desc)
669
+ host_dict[fqdn] = (port_list, desc)
670
+ desc_titles = []
671
+ if info_command:
672
+ res = subprocess.run(info_command, shell=True, input='\n'.join(host_dict.keys())+'\n', text=True, capture_output=True)
673
+ lines = res.stdout.splitlines()
674
+ desc_titles = lines[0].strip().split('\t')[1:] # Get the description titles from the first line
675
+ lines.pop(0) # Remove the first line with titles
676
+ for line in lines:
677
+ info = line.strip().split('\t')
678
+ fqdn = info[0].lower()
679
+ info.pop(0) # Remove the hostname from the info list
680
+ if fqdn in host_dict:
681
+ host_dict[fqdn] = (host_dict[fqdn][0], info)
669
682
  hosts = []
670
683
  for fqdn in host_dict:
671
684
  ports, desc = host_dict[fqdn]
672
685
  hosts.append((fqdn, sorted(ports), desc))
673
- return hosts
686
+ return (hosts, desc_titles)
674
687
 
675
688
  def ping_host(ip: str, timeout: float = 2.0) -> bool:
676
689
  """Test if a host responds to ICMP ping.
@@ -807,7 +820,7 @@ def ping_hosts(hosts: List[Tuple[str, List[int], str]],
807
820
  def check_port(hostname: str,
808
821
  port: int,
809
822
  host_info: Dict[str, Union[str, bool]],
810
- desc: str,
823
+ desc: list,
811
824
  timeout: float = 2.0) -> Tuple[str, str, int, str, bool]:
812
825
  """Check if a specific TCP port is accessible on a host.
813
826
 
@@ -1236,7 +1249,7 @@ def generate_html_report(
1236
1249
  # Write detailed results table
1237
1250
  if not desc_titles:
1238
1251
  _, _, _, _, _, desc = results[0]
1239
- desc_titles = ["Description" for d in desc.split("|")]
1252
+ desc_titles = ["Description" for d in desc]
1240
1253
  f.write(f'''
1241
1254
  <div class="table-container" id="result-container">
1242
1255
  <table id="commandTable">
@@ -1270,7 +1283,7 @@ def generate_html_report(
1270
1283
  <td style="text-align: right;">{port}</td>
1271
1284
  <td style="text-align: center;"><span class="{status_class} status">{escape(status)}</span></td>
1272
1285
  <td style="text-align: center;"><span class="{ping_class} ping">{ping_status}</span></td>
1273
- {"\n".join([f'<td class="desc">{escape(str(d))}</td>' for d in desc.split("|")])}
1286
+ {"\n".join([f'<td class="desc">{escape(str(d))}</td>' for d in desc])}
1274
1287
  </tr>
1275
1288
  ''')
1276
1289
 
@@ -1457,6 +1470,7 @@ def main():
1457
1470
  parser.add_argument('-d', '--desc_titles', type=str, nargs='*', help='List of custom description titles for hosts (optional)')
1458
1471
  parser.add_argument('-f', '--filter', type=str, help='default status filter for html report (optional)',
1459
1472
  choices=['CONNECTED', 'REFUSED', 'TIMEOUT', 'UNREACHABLE', 'RESOLVE_FAIL'], default='')
1473
+ parser.add_argument('-i', '--info_command', type=str, help='Exernal command to get hosts information (optional)',)
1460
1474
 
1461
1475
  # Email related arguments
1462
1476
  email_group = parser.add_argument_group('Email Options')
@@ -1474,7 +1488,7 @@ def main():
1474
1488
  if not os.path.exists(args.input_file):
1475
1489
  print(f"Input file '{args.input_file}' does not exist.", file=sys.stderr)
1476
1490
  sys.exit(1)
1477
- hosts = parse_input_file(args.input_file)
1491
+ (hosts, desc_titles) = parse_input_file(args.input_file, args.info_command)
1478
1492
  if not hosts:
1479
1493
  print(f"No valid hosts found in input file '{args.input_file}'.", file=sys.stderr)
1480
1494
  sys.exit(1)
@@ -1524,7 +1538,7 @@ def main():
1524
1538
  args.noping,
1525
1539
  stats,
1526
1540
  args.input_file,
1527
- args.desc_titles,
1541
+ args.desc_titles or desc_titles or [],
1528
1542
  args.filter,
1529
1543
  )
1530
1544
 
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.1.8'
21
- __version_tuple__ = version_tuple = (0, 1, 8)
20
+ __version__ = version = '0.1.10'
21
+ __version_tuple__ = version_tuple = (0, 1, 10)
@@ -1,38 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: portune
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Author: Franck Jouvanceau
6
6
  Maintainer: Franck Jouvanceau
7
- License: MIT License
8
-
9
- Copyright (c) 2025 joknarf
10
-
11
- Permission is hereby granted, free of charge, to any person obtaining a copy
12
- of this software and associated documentation files (the "Software"), to deal
13
- in the Software without restriction, including without limitation the rights
14
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- copies of the Software, and to permit persons to whom the Software is
16
- furnished to do so, subject to the following conditions:
17
-
18
- The above copyright notice and this permission notice shall be included in all
19
- copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- SOFTWARE.
28
-
7
+ License-Expression: MIT
29
8
  Project-URL: Homepage, https://github.com/joknarf/portune
30
9
  Project-URL: Documentation, https://github.com/joknarf/portune/blob/main/README.md
31
10
  Project-URL: Repository, https://github.com/joknarf/portune.git
32
11
  Keywords: port,scanner,html_report
33
12
  Classifier: Development Status :: 5 - Production/Stable
34
13
  Classifier: Intended Audience :: System Administrators
35
- Classifier: License :: OSI Approved :: MIT License
36
14
  Classifier: Operating System :: POSIX
37
15
  Classifier: Operating System :: Unix
38
16
  Classifier: Operating System :: MacOS
@@ -12,13 +12,12 @@ dependencies = [
12
12
  ]
13
13
  dynamic=["version"]
14
14
  readme = "README.md"
15
- license = {file = "LICENSE"}
15
+ license = "MIT"
16
16
  requires-python = ">= 3.9"
17
17
  keywords = ["port", "scanner", "html_report"]
18
18
  classifiers = [
19
19
  "Development Status :: 5 - Production/Stable",
20
20
  "Intended Audience :: System Administrators",
21
- "License :: OSI Approved :: MIT License",
22
21
  "Operating System :: POSIX",
23
22
  "Operating System :: Unix",
24
23
  "Operating System :: MacOS",
File without changes
File without changes
File without changes
File without changes
File without changes