Skip to content

Commit a811e16

Browse files
committedAug 2, 2024·
Fixed some security issues
1 parent 9a9a236 commit a811e16

File tree

7 files changed

+15
-31
lines changed

7 files changed

+15
-31
lines changed
 

‎.coveragerc

-15
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,8 @@ omit =
1212
[report]
1313
exclude_lines =
1414
pragma: no cover
15-
# Python2/3 incompatibilities if/elif/else blocks
16-
(?m)(?P<indent>(?:\s+))if.*?PY(?:THON)?3.*?\:((?P=indent)\s+.*?)+(((?P=indent)else|elif).*?\:((?P=indent)\s+.*?)+)*$
17-
(if|and) (?:not )?PY(?:THON)?3:?
18-
if sys\.version_info \< \(3\,\)\:
19-
if pdf_generation:
20-
pdf_generation
2115
# __main__ logics
2216
if\s+__name__\s+==\s+(?P<q>(?:[\'\"]))__main__(?P=q)\s+:
23-
import ConfigParser
24-
except ImportError:
25-
except NameError:
2617
# sudo when using 'initialize'
2718
if sudo and not is_admin():
2819
# 'interact' module - remote interaction
@@ -34,17 +25,11 @@ exclude_lines =
3425
if WINDOWS:
3526
raise NotImplementedError
3627
except NotImplementedError:
37-
# virtualenv package install
38-
elif line.startswith\(\"Successfully installed\"\):
39-
for top_level in __install
40-
def __deprecated
4128
def hotkeys(hotkeys, silent=True):
4229
super\(NewClass\, self\)\.__init__
4330
# optional packages not installed or different platform or cumbersome to test
4431
if not hotkeys_enabled:
45-
try: # Windows
4632
def stdin_pipe\(\):
4733
Xlib.error.DisplayConnectionError
4834
def send_mail
4935
except KeyboardInterrupt:
50-
re.sre_parse

‎pyproject.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ dependencies = [
5252
"markdown2>=2.4.0",
5353
"netaddr",
5454
"netifaces",
55+
"packaging",
5556
"patchy",
5657
"pathlib2",
5758
"pip>=24.0",
5859
"plyer>=2.0.0",
60+
"pydyf>=0.8.0,<0.11.0; python_version=='3.8'",
5961
"pygments>=2.8.1",
6062
"pyminizip",
6163
"pynput",
@@ -64,14 +66,14 @@ dependencies = [
6466
"python-magic",
6567
"python-slugify",
6668
"pyyaml>=5.3.1",
67-
"requests",
69+
"requests>=2.32.2",
6870
"rich",
6971
"setuptools>=70.2.0",
7072
"terminaltables",
7173
"toml",
7274
"tqdm",
7375
"virtualenv>=20.26.3",
74-
"weasyprint",
76+
"weasyprint>=60.2",
7577
"xmltodict",
7678
]
7779
dynamic = ["version"]

‎requirements.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ lazy_object_proxy>=1.9.0
1313
markdown2>=2.4.0
1414
netaddr
1515
netifaces
16+
packaging
1617
patchy
1718
pathlib2
1819
pip>=24.0
@@ -25,15 +26,16 @@ pypiwin32; sys_platform=='windows'
2526
python-magic
2627
python-slugify
2728
pyyaml>=5.3.1
28-
requests
29+
requests>=2.32.2
2930
rich
3031
setuptools>=70.2.0
3132
terminaltables
3233
toml
3334
tqdm
3435
virtualenv>=20.26.3
35-
weasyprint
36+
weasyprint>=60.2
3637
xmltodict
3738
# Snyk false alarms
3839
pillow>=10.2.0 # solved with asciistuff>=1.3.0
40+
urllib3>=2.2.2 # solved with requests>=2.32.2
3941
zipp>=3.19.1

‎src/tinyscript/VERSION.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.30.15
1+
1.30.16

‎src/tinyscript/argreparse.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
from argparse import *
1212
from argparse import _ActionsContainer, _ArgumentGroup, _MutuallyExclusiveGroup, _AttributeHolder, _SubParsersAction, \
1313
Action, _UNRECOGNIZED_ARGS_ATTR, Namespace as BaseNamespace, ArgumentParser as BaseArgumentParser
14+
from configparser import ConfigParser, NoOptionError, NoSectionError
1415
from inspect import currentframe
1516
from os import environ
1617
from os.path import abspath, basename, dirname, sep, splitext
1718
from shutil import which
1819
from stat import S_IXUSR
19-
try:
20-
from configparser import ConfigParser, NoOptionError, NoSectionError
21-
except ImportError:
22-
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
2320

2421
from .features.loglib import logger
2522
from .helpers.inputs import user_input
@@ -96,8 +93,6 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
9693

9794
@staticmethod
9895
def reset():
99-
global parser_calls
100-
parser_calls = []
10196
ArgumentParser.reset()
10297

10398

@@ -415,7 +410,7 @@ def _check_requirements(self, requires):
415410
environ['SETUPTOOLS_USE_DISTUTILS'] = "stdlib"
416411
# importlib.metadata is available only from Python 3.8
417412
from importlib.metadata import version as get_version
418-
from setuptools.extern.packaging.version import Version
413+
from packaging.version import Version
419414
errors = []
420415
requires = requires or {}
421416
if not isinstance(requires, dict):

‎src/tinyscript/helpers/data/types/network.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
__all__ = __features__ = []
1010

11-
lazy_load_module("email", alias="emaillib")
1211
for _m in ["netaddr", "netifaces"]:
1312
lazy_load_module(_m)
1413

@@ -70,9 +69,10 @@ def __domain_name(name, dotted=False, fail=True):
7069

7170
def __email_address(email, fail=True):
7271
""" Email address validation. """
72+
from email.utils import parseaddr
7373
# reference: https://stackoverflow.com/questions/8022530/
7474
if len(email) <= 320 and re.match(r"^[^@]+@[^@]+$", email) and \
75-
is_hostname(email.split("@")[1]) and emaillib.utils.parseaddr(email)[1] != "":
75+
is_hostname(email.split("@")[1]) and parseaddr(email)[1] != "":
7676
return email
7777
if fail:
7878
raise ValueError("Bad email address")

‎src/tinyscript/helpers/inputs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ def stdin_flush():
205205
Source: https://rosettacode.org/wiki/Keyboard_input/Flush_the_keyboard_buffer#Python
206206
"""
207207
try:
208-
try: # Windows
208+
if WINDOWS:
209209
from msvcrt import getch, kbhit
210210
while kbhit(): getch()
211-
except ImportError: # Linux/Unix
211+
else:
212212
from termios import tcflush, TCIOFLUSH
213213
tcflush(sys.stdin, TCIOFLUSH)
214214
except Exception:

0 commit comments

Comments
 (0)
Please sign in to comment.