Skip to content

Commit 88a4e5e

Browse files
committed
Feature: Return the absolute path (additional files)
Thus avoiding, I hope!, patches from Sophie Brun (https://www.kali.org/about-us/) and, in the future, from Dario Camonita (https://parrotsec.org/team/) for each version of 'humble'. Thanks to both of you!.
1 parent cd287bc commit 88a4e5e

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<a target="_blank" href="https://www.python.org/downloads/" title="Minimum Python version required to run this tool"><img src="https://img.shields.io/badge/Python-%3E%3D3.9-blue?labelColor=343b41"></a>
77
<a target="_blank" href="LICENSE" title="License of this tool"><img src="https://img.shields.io/badge/License-MIT-blue.svg?labelColor=343b41"></a>
88
<a target="_blank" href="https://github.com/rfc-st/humble/releases" title="Latest release of this tool"><img src="https://img.shields.io/github/v/release/rfc-st/humble?display_name=release&label=Latest%20Release&labelColor=343b41"></a>
9-
<a target="_blank" href="https://github.com/rfc-st/humble/commits/master" title="Latest commit of this tool"><img src="https://img.shields.io/badge/Latest_Commit-2024--09--21-blue.svg?labelColor=343b41"></a>
9+
<a target="_blank" href="https://github.com/rfc-st/humble/commits/master" title="Latest commit of this tool"><img src="https://img.shields.io/badge/Latest_Commit-2024--09--27-blue.svg?labelColor=343b41"></a>
1010
<a target="_blank" href="https://github.com/rfc-st/humble/actions?query=workflow%3ACodeQL" title="Results of the last analysis of this tool with CodeQL"><img src="https://github.com/rfc-st/humble/workflows/CodeQL/badge.svg"></a>
1111
<a target="_blank" href="https://owasp.org/www-project-secure-headers/#div-technical" title="Official tool in OWASP Secure Headers Project"><img src="https://img.shields.io/badge/OWASP-Tool-blue?labelColor=343b41"></a>
1212
<a target="_blank" href="https://pkg.kali.org/pkg/humble" title="Official tool in Kali Linux"><img src="https://img.shields.io/badge/Kali%20Linux-Tool-blue?labelColor=343b41"></a>

humble.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from urllib.parse import urlparse
4949
from subprocess import PIPE, Popen
5050
from os import linesep, path, remove
51+
from os.path import dirname, abspath
5152
from collections import Counter, defaultdict
5253
from argparse import ArgumentParser, RawDescriptionHelpFormatter
5354
import re
@@ -90,6 +91,7 @@
9091
'lic_es.txt')
9192
# https://data.iana.org/TLD/tlds-alpha-by-domain.txt
9293
NON_RU_TLD = ('CYMRU', 'GURU', 'PRU')
94+
OS_PATH = dirname(abspath(__file__))
9395
RE_PATTERN = (r'\[(.*?)\]',
9496
(r'^(?:\d{1,3}\.){3}\d{1,3}$|'
9597
r'^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'),
@@ -115,7 +117,7 @@
115117
URL_STRING = ('rfc-st', ' URL : ', 'caniuse')
116118

117119
current_time = datetime.now().strftime("%Y/%m/%d - %H:%M:%S")
118-
local_version = datetime.strptime('2024-09-21', '%Y-%m-%d').date()
120+
local_version = datetime.strptime('2024-09-27', '%Y-%m-%d').date()
119121

120122

121123
class SSLContextAdapter(requests.adapters.HTTPAdapter):
@@ -157,7 +159,7 @@ def check_updates(local_version):
157159
def fng_statistics_top():
158160
print(f"\n{STYLE[0]}{get_detail('[fng_stats]', replace=True)}\
159161
{STYLE[4]}{get_detail('[fng_source]', replace=True)}\n")
160-
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
162+
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
161163
encoding='utf8') as fng_f:
162164
fng_lines = fng_f.readlines()
163165
fng_incl = sum(1 for _ in islice(fng_lines, SLICE_INT[0], None))
@@ -186,7 +188,7 @@ def fng_statistics_top_result(fng_top_groups, fng_incl):
186188
def fng_statistics_term(fng_term):
187189
print(f"\n{STYLE[0]}{get_detail('[fng_stats]', replace=True)}\
188190
{STYLE[4]}{get_detail('[fng_source]', replace=True)}\n")
189-
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
191+
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
190192
encoding='utf8') as fng_source:
191193
fng_lines = fng_source.readlines()
192194
fng_incl = list(islice(fng_lines, SLICE_INT[0], None))
@@ -227,7 +229,7 @@ def fng_statistics_term_sorted(fng_incl, fng_term, fng_groups):
227229

228230
def print_grades_guide(args):
229231
grade_l10n = HUMBLE_FILES[11] if args.lang == 'es' else HUMBLE_FILES[10]
230-
with open(path.join(HUMBLE_DIRS[1], grade_l10n), 'r',
232+
with open(path.join(OS_PATH, HUMBLE_DIRS[1], grade_l10n), 'r',
231233
encoding='utf8') as grades_source:
232234
for line in islice(grades_source, SLICE_INT[3], None):
233235
print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\
@@ -237,7 +239,7 @@ def print_grades_guide(args):
237239

238240
def print_license(args):
239241
license_l10n = HUMBLE_FILES[13] if args.lang == 'es' else HUMBLE_FILES[12]
240-
with open(path.join(HUMBLE_DIRS[1], license_l10n), 'r',
242+
with open(path.join(OS_PATH, HUMBLE_DIRS[1], license_l10n), 'r',
241243
encoding='utf8') as license_source:
242244
for line in license_source:
243245
print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\
@@ -247,7 +249,7 @@ def print_license(args):
247249

248250
def print_security_guides():
249251
print_detail('[security_guides]')
250-
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[3]), 'r',
252+
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[3]), 'r',
251253
encoding='utf8') as guides_source:
252254
for line in islice(guides_source, SLICE_INT[3], None):
253255
print(f" {STYLE[0]}{line}" if line.startswith('[') else f"\
@@ -283,8 +285,8 @@ def testssl_analysis(testssl_command):
283285

284286

285287
def get_l10n_content():
286-
l10n_path = path.join(HUMBLE_DIRS[1], HUMBLE_FILES[4] if args.lang == 'es'
287-
else HUMBLE_FILES[5])
288+
l10n_path = path.join(OS_PATH, HUMBLE_DIRS[1], HUMBLE_FILES[4]
289+
if args.lang == 'es' else HUMBLE_FILES[5])
288290
with open(l10n_path, 'r', encoding='utf8') as l10n_source:
289291
return l10n_source.readlines()
290292

@@ -790,15 +792,15 @@ def print_error_detail(id_mode):
790792

791793

792794
def get_epilog_content(id_mode):
793-
epilog_file_path = path.join(HUMBLE_DIRS[1], HUMBLE_FILES[5])
795+
epilog_file_path = path.join(OS_PATH, HUMBLE_DIRS[1], HUMBLE_FILES[5])
794796
with open(epilog_file_path, 'r', encoding='utf8') as epilog_source:
795797
epilog_lines = epilog_source.readlines()
796798
epilog_idx = epilog_lines.index(id_mode + '\n')
797799
return ''.join(epilog_lines[epilog_idx+1:epilog_idx+12])
798800

799801

800802
def get_fingerprint_headers():
801-
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
803+
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[2]), 'r',
802804
encoding='utf8') as fng_source:
803805
l_fng_ex = [line.strip() for line in
804806
islice(fng_source, SLICE_INT[0], None) if line.strip()]
@@ -943,7 +945,7 @@ def nourl_user_agent(user_agent_id):
943945

944946

945947
def get_user_agent(user_agent_id):
946-
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[6]), 'r',
948+
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[6]), 'r',
947949
encoding='utf8') as ua_source:
948950
user_agents = [line.strip() for line in islice(ua_source, SLICE_INT[1],
949951
None)]
@@ -966,7 +968,8 @@ def print_user_agents(user_agents):
966968

967969
def get_insecure_checks():
968970
headers_name = set()
969-
with open(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[7]), "r") as ins_source:
971+
with open(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[7]), "r") as \
972+
ins_source:
970973
insecure_checks = islice(ins_source, SLICE_INT[2], None)
971974
for line in insecure_checks:
972975
insecure_header = line.split(':')[0]
@@ -1147,7 +1150,8 @@ def set_pdf_color(pdf, line):
11471150

11481151

11491152
def generate_html():
1150-
copyfile(path.join(HUMBLE_DIRS[0], HUMBLE_FILES[8]), final_filename)
1153+
copyfile(path.join(OS_PATH, HUMBLE_DIRS[0], HUMBLE_FILES[8]),
1154+
final_filename)
11511155
html_replace = {"html_title": get_detail('[pdf_meta_subject]'),
11521156
"html_desc": get_detail('[pdf_meta_title]'),
11531157
"html_keywords": get_detail('[pdf_meta_keywords]'),

0 commit comments

Comments
 (0)