osbot-utils 2.58.0__py3-none-any.whl → 2.59.0__py3-none-any.whl
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.
- osbot_utils/helpers/ast/Ast_Base.py +5 -5
- osbot_utils/helpers/safe_str/http/Safe_Str__Http__Content_Type.py +12 -0
- osbot_utils/helpers/safe_str/http/Safe_Str__Http__ETag.py +10 -0
- osbot_utils/helpers/safe_str/http/Safe_Str__Http__Last_Modified.py +10 -0
- osbot_utils/helpers/safe_str/http/Safe_Str__Http__Text.py +35 -0
- osbot_utils/utils/Functions.py +7 -6
- osbot_utils/version +1 -1
- {osbot_utils-2.58.0.dist-info → osbot_utils-2.59.0.dist-info}/METADATA +2 -2
- {osbot_utils-2.58.0.dist-info → osbot_utils-2.59.0.dist-info}/RECORD +12 -8
- /osbot_utils/helpers/safe_str/{Safe_Str__Html.py → http/Safe_Str__Html.py} +0 -0
- {osbot_utils-2.58.0.dist-info → osbot_utils-2.59.0.dist-info}/LICENSE +0 -0
- {osbot_utils-2.58.0.dist-info → osbot_utils-2.59.0.dist-info}/WHEEL +0 -0
@@ -1,11 +1,11 @@
|
|
1
1
|
import ast
|
2
2
|
import inspect
|
3
3
|
|
4
|
-
from osbot_utils.utils.Dev
|
5
|
-
from osbot_utils.utils.Exceptions
|
6
|
-
from osbot_utils.utils.Files
|
7
|
-
from osbot_utils.utils.Objects
|
8
|
-
from osbot_utils.utils.Str
|
4
|
+
from osbot_utils.utils.Dev import pprint, jprint
|
5
|
+
from osbot_utils.utils.Exceptions import syntax_error
|
6
|
+
from osbot_utils.utils.Files import is_file, file_contents
|
7
|
+
from osbot_utils.utils.Objects import obj_data, obj_info
|
8
|
+
from osbot_utils.utils.Str import str_dedent
|
9
9
|
|
10
10
|
|
11
11
|
class Ast_Base:
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.helpers.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
TYPE_SAFE_STR__HTTP__CONTENT_TYPE__REGEX = re.compile(r'[^a-zA-Z0-9/\-+.;= ]')
|
5
|
+
TYPE_SAFE_STR__HTTP__CONTENT_TYPE__MAX_LENGTH = 256
|
6
|
+
|
7
|
+
class Safe_Str__Http__Content_Type(Safe_Str):
|
8
|
+
regex = TYPE_SAFE_STR__HTTP__CONTENT_TYPE__REGEX
|
9
|
+
max_length = TYPE_SAFE_STR__HTTP__CONTENT_TYPE__MAX_LENGTH
|
10
|
+
allow_empty = False
|
11
|
+
trim_whitespace = True
|
12
|
+
allow_all_replacement_char = False
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.helpers.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
TYPE_SAFE_STR__HTTP__ETAG__REGEX = re.compile(r'[^a-zA-Z0-9"\/\-_.:]') # Allow alphanumerics, quotes, slashes, hyphens, underscores, periods, colons
|
5
|
+
TYPE_SAFE_STR__HTTP__ETAG__MAX_LENGTH = 128
|
6
|
+
|
7
|
+
class Safe_Str__Http__ETag(Safe_Str):
|
8
|
+
regex = TYPE_SAFE_STR__HTTP__ETAG__REGEX
|
9
|
+
max_length = TYPE_SAFE_STR__HTTP__ETAG__MAX_LENGTH
|
10
|
+
trim_whitespace = True
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.helpers.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
TYPE_SAFE_STR__HTTP__LAST_MODIFIED__REGEX = re.compile(r'[^a-zA-Z0-9:, -]')
|
5
|
+
TYPE_SAFE_STR__HTTP__LAST_MODIFIED__MAX_LENGTH = 64
|
6
|
+
|
7
|
+
class Safe_Str__Http__Last_Modified(Safe_Str):
|
8
|
+
regex = TYPE_SAFE_STR__HTTP__LAST_MODIFIED__REGEX
|
9
|
+
max_length = TYPE_SAFE_STR__HTTP__LAST_MODIFIED__MAX_LENGTH
|
10
|
+
trim_whitespace = True
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import re
|
2
|
+
from osbot_utils.helpers.safe_str.Safe_Str import Safe_Str
|
3
|
+
|
4
|
+
|
5
|
+
TYPE_SAFE_STR__TEXT__MAX_LENGTH = 1048576 # Define the size constant - 1 megabyte in bytes
|
6
|
+
|
7
|
+
# A more permissive regex that primarily filters out:
|
8
|
+
# - NULL byte (U+0000)
|
9
|
+
# - Control characters (U+0001 to U+0008, U+000B to U+000C, U+000E to U+001F)
|
10
|
+
# - Some potentially problematic characters in various contexts
|
11
|
+
# But allows:
|
12
|
+
# - All standard printable ASCII characters
|
13
|
+
# - Tab (U+0009), Line Feed (U+000A), and Carriage Return (U+000D)
|
14
|
+
# - A wide range of punctuation, symbols, and Unicode characters for international text
|
15
|
+
|
16
|
+
TYPE_SAFE_STR__HTTP__TEXT__REGEX = re.compile(r'[\x00\x01-\x08\x0B\x0C\x0E-\x1F\x7F]')
|
17
|
+
|
18
|
+
class Safe_Str__Http__Text(Safe_Str):
|
19
|
+
"""
|
20
|
+
Safe string class for general text content with a 1MB limit.
|
21
|
+
Allows a wide range of characters suitable for natural language text,
|
22
|
+
including international characters, while filtering out control characters
|
23
|
+
and other potentially problematic sequences.
|
24
|
+
"""
|
25
|
+
max_length = TYPE_SAFE_STR__TEXT__MAX_LENGTH
|
26
|
+
regex = TYPE_SAFE_STR__HTTP__TEXT__REGEX
|
27
|
+
trim_whitespace = True # Trim leading/trailing whitespace
|
28
|
+
normalize_newlines = True # Option to normalize different newline styles
|
29
|
+
|
30
|
+
def __new__(cls, value=None):
|
31
|
+
|
32
|
+
if cls.normalize_newlines and value is not None and isinstance(value, str): # Handle newline normalization before passing to parent class
|
33
|
+
value = value.replace('\r\n', '\n').replace('\r', '\n') # Normalize different newline styles to \n
|
34
|
+
|
35
|
+
return super().__new__(cls, value) # Now call the parent implementation
|
osbot_utils/utils/Functions.py
CHANGED
@@ -25,13 +25,13 @@ def function_name(function):
|
|
25
25
|
if isinstance(function, types.FunctionType):
|
26
26
|
return function.__name__
|
27
27
|
|
28
|
-
def function_source_code(
|
29
|
-
if isinstance(
|
30
|
-
source_code = inspect.getsource(
|
28
|
+
def function_source_code(target):
|
29
|
+
if isinstance(target, (types.FunctionType, types.MethodType)):
|
30
|
+
source_code = inspect.getsource(target)
|
31
31
|
source_code = textwrap.dedent(source_code).strip()
|
32
32
|
return source_code
|
33
|
-
elif isinstance(
|
34
|
-
return
|
33
|
+
elif isinstance(target, str): # todo: see if we really need this logic (or we just return none when "target" is a str)
|
34
|
+
return target
|
35
35
|
return None
|
36
36
|
|
37
37
|
def get_line_number(function):
|
@@ -110,4 +110,5 @@ def type_file(target):
|
|
110
110
|
|
111
111
|
|
112
112
|
function_line_number = get_line_number
|
113
|
-
method_line_number = get_line_number
|
113
|
+
method_line_number = get_line_number
|
114
|
+
method_source_code = function_source_code
|
osbot_utils/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v2.
|
1
|
+
v2.59.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.59.0
|
4
4
|
Summary: OWASP Security Bot - Utils
|
5
5
|
License: MIT
|
6
6
|
Author: Dinis Cruz
|
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
|
|
23
23
|
|
24
24
|
Powerful Python util methods and classes that simplify common apis and tasks.
|
25
25
|
|
26
|
-

|
27
27
|
[](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
|
28
28
|
|
29
29
|
|
@@ -51,7 +51,7 @@ osbot_utils/helpers/Type_Registry.py,sha256=Ajk3SyMSKDi2g9SJYUtTgg7PZkAgydaHcpbG
|
|
51
51
|
osbot_utils/helpers/Zip_Bytes.py,sha256=Bf17NPS_yxrzI_4FsCxkjlhS9ELJK3kisY-jHQPQVgw,4287
|
52
52
|
osbot_utils/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
53
|
osbot_utils/helpers/ast/Ast.py,sha256=lcPQOSxXI6zgmMnIVF9WM6ISqViWX-sq4d_UC0CDG8s,1155
|
54
|
-
osbot_utils/helpers/ast/Ast_Base.py,sha256=
|
54
|
+
osbot_utils/helpers/ast/Ast_Base.py,sha256=x3UGJsxkIkMlkzt59eZYZG9NmvvODO5jaRBEeiqSaSA,3740
|
55
55
|
osbot_utils/helpers/ast/Ast_Data.py,sha256=EL-6lkNDMe_BKBwFP1sJW-Y8t6TXYYv0uGdlxix4Tyg,697
|
56
56
|
osbot_utils/helpers/ast/Ast_Load.py,sha256=ZO2QjhQ13j1m4MwAVbbdAoQ4UoUfzuU6E_RobkhZVpI,2100
|
57
57
|
osbot_utils/helpers/ast/Ast_Merge.py,sha256=An_u2E906DrMlAl83VyTNLKBSc0uEm25RWLRZsci2rk,848
|
@@ -245,11 +245,15 @@ osbot_utils/helpers/safe_str/Safe_Str.py,sha256=xkc0XhDWcln-3-yENqpQcPgiDewq-l4s
|
|
245
245
|
osbot_utils/helpers/safe_str/Safe_Str__File__Name.py,sha256=ncjkQ2hAhw0a3UulrCuQsA9ytrFwg5CT1XRJIGChMpY,289
|
246
246
|
osbot_utils/helpers/safe_str/Safe_Str__File__Path.py,sha256=K0yBcvH_Ncqiw7tMqjGqaNyWQh1Zs9qxZ-TR8nEIAow,550
|
247
247
|
osbot_utils/helpers/safe_str/Safe_Str__Hash.py,sha256=Tb2QeVpVDNWpCJGHNFjZPCQ_ZTaI7Z5BDzi19LiO_cI,952
|
248
|
-
osbot_utils/helpers/safe_str/Safe_Str__Html.py,sha256=4_UxGEIkqV_Zeh77nXoO2OUy5SS6gvN3xSwA32DyWs0,662
|
249
248
|
osbot_utils/helpers/safe_str/Safe_Str__Text.py,sha256=QxuWqF8hNYdOPDn3Yac86h_1ZaX-THbTBDakberiJcs,313
|
250
249
|
osbot_utils/helpers/safe_str/Safe_Str__Text__Dangerous.py,sha256=6-fkXBuWgjz70eQicD07f38eEuKqNzJzaFFY6hozhNQ,388
|
251
250
|
osbot_utils/helpers/safe_str/Safe_Str__Url.py,sha256=4l46AAe5Dy_P_W6d-_3pwtXuehG_Wczq1dC5sOOzg_g,549
|
252
251
|
osbot_utils/helpers/safe_str/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
252
|
+
osbot_utils/helpers/safe_str/http/Safe_Str__Html.py,sha256=4_UxGEIkqV_Zeh77nXoO2OUy5SS6gvN3xSwA32DyWs0,662
|
253
|
+
osbot_utils/helpers/safe_str/http/Safe_Str__Http__Content_Type.py,sha256=HURT4n17LmKbcqODsNwhu_D0lI5LpUL8I5t9aqGAZhQ,516
|
254
|
+
osbot_utils/helpers/safe_str/http/Safe_Str__Http__ETag.py,sha256=5cAfIqebraUnVKZJq3CzXzsFdHGy06TznO36Dc6b5A0,477
|
255
|
+
osbot_utils/helpers/safe_str/http/Safe_Str__Http__Last_Modified.py,sha256=FBcPM4h3ldN0F_cSISGZgdidWpjKLCOOPq9sWVGUCzg,438
|
256
|
+
osbot_utils/helpers/safe_str/http/Safe_Str__Http__Text.py,sha256=w0UPkVnQz41BN9asgDUZ4q6pSQUtzNa-4Sjcl56WTCM,1788
|
253
257
|
osbot_utils/helpers/sqlite/Capture_Sqlite_Error.py,sha256=GSuRYgs1yKQjxMszPoaI7fsfMfuUqhb64AaIysRE6Cs,1747
|
254
258
|
osbot_utils/helpers/sqlite/Sqlite__Cursor.py,sha256=4Im0pCOiERX6Nnf6iagRlSvTR3CPjyPVkdx4NMQV0P0,3342
|
255
259
|
osbot_utils/helpers/sqlite/Sqlite__Database.py,sha256=ORjRUD-xSvf89kDMQ70q7wBlbV5pdKtDerjE6gDN_fg,5616
|
@@ -389,7 +393,7 @@ osbot_utils/utils/Dev.py,sha256=eaQ87ZcMRRcxgzA-f7OO8HjjWhbE6L_edwvXiwFZvIQ,1291
|
|
389
393
|
osbot_utils/utils/Env.py,sha256=rBksAy6k-J5oAJp-S_JedVlcj1b2VK8V3zsQbacopMc,6076
|
390
394
|
osbot_utils/utils/Exceptions.py,sha256=KyOUHkXQ_6jDTq04Xm261dbEZuRidtsM4dgzNwSG8-8,389
|
391
395
|
osbot_utils/utils/Files.py,sha256=YwfXMeU1jfDzYvZJGy0bWHvvduTuTnftBNlAnpsXDzw,23013
|
392
|
-
osbot_utils/utils/Functions.py,sha256=
|
396
|
+
osbot_utils/utils/Functions.py,sha256=VoTrAbCHt6hulz6hVz3co8w2xoOS8wE04wyHc5_cC1c,3671
|
393
397
|
osbot_utils/utils/Http.py,sha256=pLDwq0Jd4Zmpps0gEzXTbeycSFRXMN8W-DprNpYq9A0,8189
|
394
398
|
osbot_utils/utils/Int.py,sha256=PmlUdU4lSwf4gJdmTVdqclulkEp7KPCVUDO6AcISMF4,116
|
395
399
|
osbot_utils/utils/Json.py,sha256=TvfDoXwOkWzWH-9KMnme5C7iFsMZOleAeue92qmkH6g,8831
|
@@ -408,8 +412,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
|
|
408
412
|
osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
|
409
413
|
osbot_utils/utils/Zip.py,sha256=pR6sKliUY0KZXmqNzKY2frfW-YVQEVbLKiyqQX_lc-8,14052
|
410
414
|
osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
411
|
-
osbot_utils/version,sha256=
|
412
|
-
osbot_utils-2.
|
413
|
-
osbot_utils-2.
|
414
|
-
osbot_utils-2.
|
415
|
-
osbot_utils-2.
|
415
|
+
osbot_utils/version,sha256=40FnRbd_Wb-10Zx2X8DLs9eqcz8E66OXD5yjt1qxfG8,8
|
416
|
+
osbot_utils-2.59.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
417
|
+
osbot_utils-2.59.0.dist-info/METADATA,sha256=ht0TSoKubcj9hMOYaCrTcph1ORn7om7wZW5ZLsM_nn4,1329
|
418
|
+
osbot_utils-2.59.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
419
|
+
osbot_utils-2.59.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|