cavisson-pythonagent 0.0.1__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.
Files changed (180) hide show
  1. cavisson_pythonagent-0.0.1.dist-info/METADATA +32 -0
  2. cavisson_pythonagent-0.0.1.dist-info/RECORD +180 -0
  3. cavisson_pythonagent-0.0.1.dist-info/WHEEL +5 -0
  4. cavisson_pythonagent-0.0.1.dist-info/licenses/LICENSE +19 -0
  5. cavisson_pythonagent-0.0.1.dist-info/top_level.txt +1 -0
  6. pythonagent/__init__.py +22 -0
  7. pythonagent/agent/__init__.py +219 -0
  8. pythonagent/agent/internal/__init__.py +1 -0
  9. pythonagent/agent/internal/agent.py +1651 -0
  10. pythonagent/agent/internal/framesinfo.py +152 -0
  11. pythonagent/agent/internal/heap_dump.py +39 -0
  12. pythonagent/agent/internal/intercept_module.py +70 -0
  13. pythonagent/agent/internal/logs.py +122 -0
  14. pythonagent/agent/internal/metadata/__init__.py +0 -0
  15. pythonagent/agent/internal/metadata/agent_meta_data.py +276 -0
  16. pythonagent/agent/internal/proc_compat.py +75 -0
  17. pythonagent/agent/internal/profile.py +47 -0
  18. pythonagent/agent/internal/provider.py +83 -0
  19. pythonagent/agent/internal/thread_dump.py +85 -0
  20. pythonagent/agent/internal/udp.py +245 -0
  21. pythonagent/agent/internal/udp_message.py +800 -0
  22. pythonagent/agent/probes/Instrumentation/__init__.py +340 -0
  23. pythonagent/agent/probes/Instrumentation/find.py +243 -0
  24. pythonagent/agent/probes/Instrumentation/module_version_resolver.py +155 -0
  25. pythonagent/agent/probes/Instrumentation/new_parser.py +64 -0
  26. pythonagent/agent/probes/Instrumentation/parser.py +129 -0
  27. pythonagent/agent/probes/__init__.py +219 -0
  28. pythonagent/agent/probes/base.py +303 -0
  29. pythonagent/agent/probes/cache/__init__.py +51 -0
  30. pythonagent/agent/probes/cache/redis.py +119 -0
  31. pythonagent/agent/probes/cache/redis_asyncio.py +83 -0
  32. pythonagent/agent/probes/coroutines/__init__.py +1 -0
  33. pythonagent/agent/probes/coroutines/asyncio.py +63 -0
  34. pythonagent/agent/probes/elasticdb/__init__.py +7 -0
  35. pythonagent/agent/probes/elasticdb/aelastic.py +54 -0
  36. pythonagent/agent/probes/frameworks/__init__.py +27 -0
  37. pythonagent/agent/probes/frameworks/agentprofiler.py +105 -0
  38. pythonagent/agent/probes/frameworks/aiohttp_web.py +155 -0
  39. pythonagent/agent/probes/frameworks/aisess.py +151 -0
  40. pythonagent/agent/probes/frameworks/asgi.py +340 -0
  41. pythonagent/agent/probes/frameworks/bottle.py +27 -0
  42. pythonagent/agent/probes/frameworks/cherry.py +25 -0
  43. pythonagent/agent/probes/frameworks/django.py +128 -0
  44. pythonagent/agent/probes/frameworks/falcon.py +21 -0
  45. pythonagent/agent/probes/frameworks/fastapi.py +35 -0
  46. pythonagent/agent/probes/frameworks/flask.py +30 -0
  47. pythonagent/agent/probes/frameworks/pyramid.py +56 -0
  48. pythonagent/agent/probes/frameworks/test.py +108 -0
  49. pythonagent/agent/probes/frameworks/tornado_async_web.py +117 -0
  50. pythonagent/agent/probes/frameworks/tornado_web.py +133 -0
  51. pythonagent/agent/probes/frameworks/wsgi.py +353 -0
  52. pythonagent/agent/probes/grpc/__init__.py +76 -0
  53. pythonagent/agent/probes/grpc/client_interceptor.py +132 -0
  54. pythonagent/agent/probes/grpc/server_interceptor.py +129 -0
  55. pythonagent/agent/probes/havoc/__init__.py +0 -0
  56. pythonagent/agent/probes/havoc/custom_memory_stress.py +186 -0
  57. pythonagent/agent/probes/havoc/custom_thread_stress.py +187 -0
  58. pythonagent/agent/probes/havoc/havoc_constants.py +218 -0
  59. pythonagent/agent/probes/havoc/havoc_manager.py +981 -0
  60. pythonagent/agent/probes/http/__init__.py +49 -0
  61. pythonagent/agent/probes/http/aiohttp_client.py +59 -0
  62. pythonagent/agent/probes/http/boto.py +12 -0
  63. pythonagent/agent/probes/http/httplib.py +110 -0
  64. pythonagent/agent/probes/http/httpx_client.py +116 -0
  65. pythonagent/agent/probes/http/requests.py +15 -0
  66. pythonagent/agent/probes/http/tornado_httpclient.py +85 -0
  67. pythonagent/agent/probes/http/urllib3.py +16 -0
  68. pythonagent/agent/probes/langchain/__init__.py +21 -0
  69. pythonagent/agent/probes/langchain/base_tool.py +95 -0
  70. pythonagent/agent/probes/langchain/langchain_community.py +136 -0
  71. pythonagent/agent/probes/langchain/langchain_core.py +32 -0
  72. pythonagent/agent/probes/langchain/langchain_openai.py +110 -0
  73. pythonagent/agent/probes/logging/__init__.py +106 -0
  74. pythonagent/agent/probes/message_brokers/__init__.py +4 -0
  75. pythonagent/agent/probes/message_brokers/pika.py +126 -0
  76. pythonagent/agent/probes/mongodb/__init__.py +6 -0
  77. pythonagent/agent/probes/mongodb/pymongo.py +286 -0
  78. pythonagent/agent/probes/openai/__init__.py +3 -0
  79. pythonagent/agent/probes/openai/openai.py +797 -0
  80. pythonagent/agent/probes/span.py +101 -0
  81. pythonagent/agent/probes/sql/__init__.py +13 -0
  82. pythonagent/agent/probes/sql/botocores3.py +51 -0
  83. pythonagent/agent/probes/sql/dbapi.py +285 -0
  84. pythonagent/agent/probes/sql/dynamodb.py +90 -0
  85. pythonagent/agent/probes/sql/mysql_connector.py +24 -0
  86. pythonagent/agent/probes/sql/mysql_connector_cext.py +24 -0
  87. pythonagent/agent/probes/sql/mysqldb.py +43 -0
  88. pythonagent/agent/probes/sql/psycopg2.py +174 -0
  89. pythonagent/agent/probes/sql/pymysql.py +25 -0
  90. pythonagent/bootstrap/__init__.py +0 -0
  91. pythonagent/bootstrap/cav_gunicorn.py +26 -0
  92. pythonagent/bootstrap/cavagent_lambda_wrapper.py +291 -0
  93. pythonagent/bootstrap/run.py +47 -0
  94. pythonagent/bootstrap/sitecustomize.py +287 -0
  95. pythonagent/cavisson/netdiagnostics/CavAgent/instrumentationprofile.json +26 -0
  96. pythonagent/cavisson/netdiagnostics/CavAgent/interceptor_points.txt +29 -0
  97. pythonagent/cavisson/netdiagnostics/python/CavAgent/instrumentationprofile.json +42 -0
  98. pythonagent/cavisson/netdiagnostics/python/CavAgent/interceptor_points.txt +29 -0
  99. pythonagent/cavisson/netdiagnostics/python/config/ndsettings.conf +6 -0
  100. pythonagent/config.py +279 -0
  101. pythonagent/find.py +72 -0
  102. pythonagent/find_mod_cls_name.py +54 -0
  103. pythonagent/lang.py +131 -0
  104. pythonagent/lib.py +91 -0
  105. pythonagent/main/__init__.py +0 -0
  106. pythonagent/main/pytrace/__init__.py +79 -0
  107. pythonagent/main/pytrace/commands/__init__.py +0 -0
  108. pythonagent/main/pytrace/commands/auto_discovery.py +25 -0
  109. pythonagent/main/pytrace/commands/run.py +401 -0
  110. pythonagent/main/pytrace/pytrace.py +133 -0
  111. pythonagent/main/wsgi.py +6 -0
  112. pythonagent/main.py +27 -0
  113. pythonagent/run.py +46 -0
  114. pythonagent/sqins.py +8 -0
  115. pythonagent/test.py +73 -0
  116. pythonagent/utils.py +168 -0
  117. pythonagent/vendor/__init__.py +0 -0
  118. pythonagent/vendor/pympler/__init__.py +1 -0
  119. pythonagent/vendor/pympler/asizeof.py +2810 -0
  120. pythonagent/vendor/pympler/charts.py +62 -0
  121. pythonagent/vendor/pympler/classtracker.py +590 -0
  122. pythonagent/vendor/pympler/classtracker_stats.py +780 -0
  123. pythonagent/vendor/pympler/garbagegraph.py +80 -0
  124. pythonagent/vendor/pympler/mprofile.py +97 -0
  125. pythonagent/vendor/pympler/muppy.py +275 -0
  126. pythonagent/vendor/pympler/panels.py +115 -0
  127. pythonagent/vendor/pympler/process.py +238 -0
  128. pythonagent/vendor/pympler/py.typed +0 -0
  129. pythonagent/vendor/pympler/refbrowser.py +451 -0
  130. pythonagent/vendor/pympler/refgraph.py +350 -0
  131. pythonagent/vendor/pympler/summary.py +321 -0
  132. pythonagent/vendor/pympler/tracker.py +267 -0
  133. pythonagent/vendor/pympler/util/__init__.py +0 -0
  134. pythonagent/vendor/pympler/util/bottle.py +3809 -0
  135. pythonagent/vendor/pympler/util/compat.py +23 -0
  136. pythonagent/vendor/pympler/util/stringutils.py +77 -0
  137. pythonagent/vendor/pympler/web.py +346 -0
  138. pythonagent/vendor/werkzeug/__init__.py +20 -0
  139. pythonagent/vendor/werkzeug/_compat.py +228 -0
  140. pythonagent/vendor/werkzeug/_internal.py +473 -0
  141. pythonagent/vendor/werkzeug/_reloader.py +341 -0
  142. pythonagent/vendor/werkzeug/datastructures.py +3120 -0
  143. pythonagent/vendor/werkzeug/debug/__init__.py +498 -0
  144. pythonagent/vendor/werkzeug/debug/console.py +218 -0
  145. pythonagent/vendor/werkzeug/debug/repr.py +297 -0
  146. pythonagent/vendor/werkzeug/debug/tbtools.py +628 -0
  147. pythonagent/vendor/werkzeug/exceptions.py +829 -0
  148. pythonagent/vendor/werkzeug/filesystem.py +64 -0
  149. pythonagent/vendor/werkzeug/formparser.py +584 -0
  150. pythonagent/vendor/werkzeug/http.py +1307 -0
  151. pythonagent/vendor/werkzeug/local.py +420 -0
  152. pythonagent/vendor/werkzeug/middleware/__init__.py +25 -0
  153. pythonagent/vendor/werkzeug/middleware/dispatcher.py +66 -0
  154. pythonagent/vendor/werkzeug/middleware/http_proxy.py +219 -0
  155. pythonagent/vendor/werkzeug/middleware/lint.py +408 -0
  156. pythonagent/vendor/werkzeug/middleware/profiler.py +132 -0
  157. pythonagent/vendor/werkzeug/middleware/proxy_fix.py +169 -0
  158. pythonagent/vendor/werkzeug/middleware/shared_data.py +293 -0
  159. pythonagent/vendor/werkzeug/posixemulation.py +117 -0
  160. pythonagent/vendor/werkzeug/routing.py +2210 -0
  161. pythonagent/vendor/werkzeug/security.py +249 -0
  162. pythonagent/vendor/werkzeug/serving.py +1117 -0
  163. pythonagent/vendor/werkzeug/test.py +1123 -0
  164. pythonagent/vendor/werkzeug/testapp.py +241 -0
  165. pythonagent/vendor/werkzeug/urls.py +1138 -0
  166. pythonagent/vendor/werkzeug/useragents.py +202 -0
  167. pythonagent/vendor/werkzeug/utils.py +778 -0
  168. pythonagent/vendor/werkzeug/wrappers/__init__.py +36 -0
  169. pythonagent/vendor/werkzeug/wrappers/accept.py +50 -0
  170. pythonagent/vendor/werkzeug/wrappers/auth.py +33 -0
  171. pythonagent/vendor/werkzeug/wrappers/base_request.py +673 -0
  172. pythonagent/vendor/werkzeug/wrappers/base_response.py +700 -0
  173. pythonagent/vendor/werkzeug/wrappers/common_descriptors.py +341 -0
  174. pythonagent/vendor/werkzeug/wrappers/cors.py +100 -0
  175. pythonagent/vendor/werkzeug/wrappers/etag.py +304 -0
  176. pythonagent/vendor/werkzeug/wrappers/json.py +145 -0
  177. pythonagent/vendor/werkzeug/wrappers/request.py +49 -0
  178. pythonagent/vendor/werkzeug/wrappers/response.py +84 -0
  179. pythonagent/vendor/werkzeug/wrappers/user_agent.py +14 -0
  180. pythonagent/vendor/werkzeug/wsgi.py +1000 -0
@@ -0,0 +1,218 @@
1
+ import json
2
+ import logging
3
+ from enum import IntEnum
4
+
5
+ logger = logging.getLogger('pythonagent.agent')
6
+
7
+ class HavocType(IntEnum):
8
+ INBOUND_SERVICE_DELAY = 1
9
+ INBOUND_SERVICE_FAILURE = 2
10
+ OUTBOUND_SERVICE_DELAY = 3
11
+ OUTBOUND_SERVICE_FAILURE = 4
12
+ METHOD_CALL_DELAY = 5
13
+ METHOD_CALL_FAILURE = 6
14
+ CUSTOM_MEMORY_LEAK = 7
15
+ CUSTOM_THREAD_LEAK = 9
16
+ APPLICATION_KILL = 10
17
+
18
+ HAVOC_TYPE_NAMES = {
19
+ HavocType.INBOUND_SERVICE_DELAY: "InBoundService_Delay",
20
+ HavocType.INBOUND_SERVICE_FAILURE: "InBoundService_Failure",
21
+ HavocType.OUTBOUND_SERVICE_DELAY: "OutBoundService_Delay",
22
+ HavocType.OUTBOUND_SERVICE_FAILURE: "OutBoundService_Failure",
23
+ HavocType.METHOD_CALL_DELAY: "MethodCall_Delay",
24
+ HavocType.METHOD_CALL_FAILURE: "MethodCall_Failure",
25
+ HavocType.CUSTOM_MEMORY_LEAK: "Custom_Memory_Leak",
26
+ HavocType.CUSTOM_THREAD_LEAK: "Custom_Thread_Leak",
27
+ HavocType.APPLICATION_KILL: "Application_Kill"
28
+ }
29
+
30
+ HAVOC_TYPES = [
31
+ "InBoundService_Delay",
32
+ "InBoundService_Failure",
33
+ "OutBoundService_Delay",
34
+ "OutBoundService_Failure",
35
+ "MethodCall_Delay",
36
+ "MethodCall_Failure",
37
+ "Custom_Memory_Leak",
38
+ "Custom_Thread_Leak",
39
+ "Application_Kill"
40
+ ]
41
+
42
+ # EXPIRE_DURATION_MS = 300000 # 5 minutes
43
+ # EXPIRE_DURATION_MS = 3000 # 3 seconds
44
+ EXPIRE_DURATION_MS = 1000 # 1 seconds
45
+
46
+
47
+ SIZE_OF_OBJECTS_BYTES = 524288000 # 500 MB
48
+
49
+ # Inbound Service Delay
50
+ IB_SERV_DELAY_DICT = {
51
+ "enable": 0,
52
+ "havocType": 1,
53
+ "bTName": "",
54
+ "uRL": "/prod/path/to/resource",
55
+ "methodFQM": "",
56
+ "delayInSec": 10,
57
+ "totalDurationInSec": 20,
58
+ "threshOld": {"count": 0, "percentage": 0, "currentcount": 0},
59
+ "protocol": "",
60
+ "hostname": "",
61
+ "backendName": "",
62
+ "leaksINMB": "",
63
+ "memoryLeaksInSec": ""
64
+ }
65
+ IB_SERV_DELAY_JSON = json.dumps(IB_SERV_DELAY_DICT)
66
+
67
+ # Inbound Service Failure
68
+ IB_SERV_FAIL_DICT = {
69
+ "enable": 0,
70
+ "havocType": 2,
71
+ "bTName": "",
72
+ "uRL": "/prod/path/to/resource",
73
+ "methodFQM": "",
74
+ "delayInSec": 10,
75
+ "totalDurationInSec": 20,
76
+ "threshOld": {"count": 0, "percentage": 0, "currentcount": 0},
77
+ "protocol": "",
78
+ "hostname": "",
79
+ "backendName": "",
80
+ "leaksINMB": "",
81
+ "memoryLeaksInSec": ""
82
+ }
83
+ IB_SERV_FAIL_JSON = json.dumps(IB_SERV_FAIL_DICT)
84
+
85
+ # Outbound Service Delay
86
+ OB_SERV_DELAY_DICT = {
87
+ "enable": 0,
88
+ "havocType": 3,
89
+ "bTName": "",
90
+ "uRL": "",
91
+ "methodFQM": "",
92
+ "delayInSec": 10,
93
+ "totalDurationInSec": 20,
94
+ "threshOld": {"count": 0, "percentage": 0, "currentcount": 0},
95
+ "protocol": "",
96
+ "hostname": "sample_hostname",
97
+ "backendName": "",
98
+ "leaksINMB": "",
99
+ "memoryLeaksInSec": ""
100
+ }
101
+ OB_SERV_DELAY_JSON = json.dumps(OB_SERV_DELAY_DICT)
102
+
103
+ # Outbound Service Failure
104
+ OB_SERV_FAIL_DICT = {
105
+ "enable": 0,
106
+ "havocType": 4,
107
+ "bTName": "",
108
+ "uRL": "",
109
+ "methodFQM": "",
110
+ "delayInSec": 0,
111
+ "totalDurationInSec": 20,
112
+ "threshOld": {"count": 0, "percentage": 0, "currentcount": 0},
113
+ "protocol": "",
114
+ "hostname": "sample_hostname",
115
+ "backendName": "",
116
+ "leaksINMB": "",
117
+ "memoryLeaksInSec": ""
118
+ }
119
+ OB_SERV_FAIL_JSON = json.dumps(OB_SERV_FAIL_DICT)
120
+
121
+ # Method Call Delay
122
+ METH_CALL_DELAY_DICT = {
123
+ "enable": 0,
124
+ "havocType": 5,
125
+ "bTName": "",
126
+ "uRL": "",
127
+ "methodFQM": "/var/task.lambda_handler",
128
+ "delayInSec": 10,
129
+ "totalDurationInSec": 20,
130
+ "threshOld": {"count": 0, "percentage": 0, "currentcount": 0},
131
+ "protocol": "",
132
+ "hostname": "",
133
+ "backendName": "",
134
+ "leaksINMB": "",
135
+ "memoryLeaksInSec": ""
136
+ }
137
+ METH_CALL_DELAY_JSON = json.dumps(METH_CALL_DELAY_DICT)
138
+
139
+ # Method Invocation Failure
140
+ METH_INV_FAIL_DICT = {
141
+ "enable": 0,
142
+ "havocType": 6,
143
+ "bTName": "",
144
+ "uRL": "",
145
+ "methodFQM": "/var/task.lambda_handler",
146
+ "delayInSec": "",
147
+ "totalDurationInSec": 20,
148
+ "threshOld": {"count": 0, "percentage": 0, "currentcount": 0},
149
+ "protocol": "",
150
+ "hostname": "",
151
+ "backendName": "",
152
+ "leaksINMB": "",
153
+ "memoryLeaksInSec": ""
154
+ }
155
+ METH_INV_FAIL_JSON = json.dumps(METH_INV_FAIL_DICT)
156
+
157
+ # Custom Memory Leak
158
+ CUSTOM_MEMORY_LEAK_DICT = {
159
+ "enable": 0,
160
+ "havocType": 7,
161
+ "bTName": "",
162
+ "uRL": "",
163
+ "methodFQM": "/var/task.lambda_handler",
164
+ "delayInSec": "",
165
+ "totalDurationInSec": 20,
166
+ "threshOld": {"count": 0, "percentage": 0, "currentcount": 0},
167
+ "protocol": "",
168
+ "hostname": "",
169
+ "backendName": "",
170
+ "leaksINMB": 100,
171
+ "objectSize": 30,
172
+ "rampup": 0
173
+
174
+ }
175
+ CUSTOM_MEMORY_LEAK_JSON = json.dumps(CUSTOM_MEMORY_LEAK_DICT)
176
+
177
+ # Custom Thread Leak
178
+ CUSTOM_THREAD_LEAK_DICT = {
179
+ "enable": 0,
180
+ "havocType": 9,
181
+ "bTName": "",
182
+ "uRL": "",
183
+ "methodFQM": "",
184
+ "delayInSec": "",
185
+ "totalDurationInSec": 20,
186
+ "threshOld": {"count": 0, "percentage": 0, "currentcount": 0},
187
+ "protocol": "",
188
+ "hostname": "",
189
+ "backendName": "",
190
+ "numberOfThreads": 10,
191
+ "threadSleepTimeInMS": 5000
192
+ }
193
+ CUSTOM_THREAD_LEAK_JSON = json.dumps(CUSTOM_THREAD_LEAK_DICT)
194
+
195
+ # Application Kill
196
+ APPLICATION_KILL_DICT = {
197
+ "enable": 1,
198
+ "havocType": 10,
199
+ "methodMod": 1,
200
+ "methodFQM": "",
201
+ "customExitCode": 0,
202
+ "methodEntryOrExit": 0,
203
+ "killApplication": 1,
204
+ "latencyInSec": 0,
205
+ "totalDurationInSec": 0,
206
+ "threshOld": {"count": 0, "percentage": 100, "currentcount": 0}
207
+ }
208
+ APPLICATION_KILL_JSON = json.dumps(APPLICATION_KILL_DICT)
209
+
210
+
211
+ HAVOC_PROFILES_JSON = [IB_SERV_DELAY_JSON, IB_SERV_FAIL_JSON,
212
+ OB_SERV_DELAY_JSON, OB_SERV_FAIL_JSON,
213
+ METH_CALL_DELAY_JSON, METH_INV_FAIL_JSON,
214
+ CUSTOM_MEMORY_LEAK_JSON, CUSTOM_THREAD_LEAK_JSON,
215
+ APPLICATION_KILL_JSON]
216
+
217
+ logger.debug("HavocConstants: Havoc constants initialized")
218
+