code-node-graph 0.1.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.
Files changed (178) hide show
  1. code_node/__init__.py +40 -0
  2. code_node/__main__.py +7 -0
  3. code_node/analysis/__init__.py +3 -0
  4. code_node/analysis/aws_model.py +197 -0
  5. code_node/analysis/findings.py +462 -0
  6. code_node/analysis/graph.py +780 -0
  7. code_node/analysis/mapping.py +114 -0
  8. code_node/analysis/model.py +289 -0
  9. code_node/analysis/reader.py +1926 -0
  10. code_node/analysis/syntax.py +220 -0
  11. code_node/analysis/terms.py +505 -0
  12. code_node/cli.py +316 -0
  13. code_node/deploys/__init__.py +321 -0
  14. code_node/deploys/sam.py +371 -0
  15. code_node/deploys/serverless.py +117 -0
  16. code_node/kit/__init__.py +4 -0
  17. code_node/kit/blocks.py +184 -0
  18. code_node/kit/fmt.py +389 -0
  19. code_node/kit/highlight.py +131 -0
  20. code_node/kit/render.py +1066 -0
  21. code_node/kit/text.py +81 -0
  22. code_node/libraries/__init__.py +333 -0
  23. code_node/libraries/llm.py +124 -0
  24. code_node/libraries/mongo.py +169 -0
  25. code_node/libraries/redis.py +253 -0
  26. code_node/libraries/sql.py +232 -0
  27. code_node/pages.py +92 -0
  28. code_node/platforms/__init__.py +203 -0
  29. code_node/platforms/aws_lambda.py +290 -0
  30. code_node/platforms/web.py +301 -0
  31. code_node/project.py +402 -0
  32. code_node/report/__init__.py +3 -0
  33. code_node/report/brands.py +244 -0
  34. code_node/report/build.py +119 -0
  35. code_node/report/editor.py +40 -0
  36. code_node/report/graph.py +1411 -0
  37. code_node/report/logos/README.md +8 -0
  38. code_node/report/logos/anthropic-icon.svg +1 -0
  39. code_node/report/logos/aws-amplify.svg +1 -0
  40. code_node/report/logos/aws-api-gateway.svg +1 -0
  41. code_node/report/logos/aws-appflow.svg +1 -0
  42. code_node/report/logos/aws-appsync.svg +1 -0
  43. code_node/report/logos/aws-athena.svg +1 -0
  44. code_node/report/logos/aws-backup.svg +1 -0
  45. code_node/report/logos/aws-batch.svg +1 -0
  46. code_node/report/logos/aws-certificate-manager.svg +1 -0
  47. code_node/report/logos/aws-cloudformation.svg +1 -0
  48. code_node/report/logos/aws-cloudfront.svg +1 -0
  49. code_node/report/logos/aws-cloudtrail.svg +1 -0
  50. code_node/report/logos/aws-cloudwatch.svg +1 -0
  51. code_node/report/logos/aws-codebuild.svg +1 -0
  52. code_node/report/logos/aws-codecommit.svg +1 -0
  53. code_node/report/logos/aws-codedeploy.svg +1 -0
  54. code_node/report/logos/aws-codepipeline.svg +1 -0
  55. code_node/report/logos/aws-cognito.svg +1 -0
  56. code_node/report/logos/aws-config.svg +1 -0
  57. code_node/report/logos/aws-documentdb.svg +1 -0
  58. code_node/report/logos/aws-dynamodb.svg +1 -0
  59. code_node/report/logos/aws-ec2.svg +1 -0
  60. code_node/report/logos/aws-ecs.svg +1 -0
  61. code_node/report/logos/aws-eks.svg +1 -0
  62. code_node/report/logos/aws-elasticache.svg +1 -0
  63. code_node/report/logos/aws-elb.svg +1 -0
  64. code_node/report/logos/aws-eventbridge.svg +1 -0
  65. code_node/report/logos/aws-glacier.svg +1 -0
  66. code_node/report/logos/aws-glue.svg +1 -0
  67. code_node/report/logos/aws-iam.svg +1 -0
  68. code_node/report/logos/aws-keyspaces.svg +1 -0
  69. code_node/report/logos/aws-kinesis.svg +1 -0
  70. code_node/report/logos/aws-kms.svg +1 -0
  71. code_node/report/logos/aws-lake-formation.svg +1 -0
  72. code_node/report/logos/aws-lambda.svg +1 -0
  73. code_node/report/logos/aws-lightsail.svg +1 -0
  74. code_node/report/logos/aws-mq.svg +1 -0
  75. code_node/report/logos/aws-msk.svg +1 -0
  76. code_node/report/logos/aws-neptune.svg +1 -0
  77. code_node/report/logos/aws-open-search.svg +1 -0
  78. code_node/report/logos/aws-quicksight.svg +1 -0
  79. code_node/report/logos/aws-rds.svg +1 -0
  80. code_node/report/logos/aws-redshift.svg +1 -0
  81. code_node/report/logos/aws-route53.svg +1 -0
  82. code_node/report/logos/aws-s3.svg +1 -0
  83. code_node/report/logos/aws-secrets-manager.svg +1 -0
  84. code_node/report/logos/aws-ses.svg +1 -0
  85. code_node/report/logos/aws-shield.svg +1 -0
  86. code_node/report/logos/aws-sns.svg +1 -0
  87. code_node/report/logos/aws-sqs.svg +1 -0
  88. code_node/report/logos/aws-step-functions.svg +1 -0
  89. code_node/report/logos/aws-systems-manager.svg +1 -0
  90. code_node/report/logos/aws-timestream.svg +1 -0
  91. code_node/report/logos/aws-waf.svg +1 -0
  92. code_node/report/logos/aws-xray.svg +1 -0
  93. code_node/report/logos/aws.svg +1 -0
  94. code_node/report/logos/azure-icon.svg +1 -0
  95. code_node/report/logos/django-icon.svg +1 -0
  96. code_node/report/logos/elasticsearch.svg +1 -0
  97. code_node/report/logos/fastapi-icon.svg +1 -0
  98. code_node/report/logos/firebase-icon.svg +1 -0
  99. code_node/report/logos/flask.svg +1 -0
  100. code_node/report/logos/google-cloud.svg +1 -0
  101. code_node/report/logos/kafka-icon.svg +1 -0
  102. code_node/report/logos/mariadb-icon.svg +1 -0
  103. code_node/report/logos/mongodb-icon.svg +1 -0
  104. code_node/report/logos/mysql-icon.svg +1 -0
  105. code_node/report/logos/openai-icon.svg +1 -0
  106. code_node/report/logos/postgresql.svg +1 -0
  107. code_node/report/logos/python.svg +1 -0
  108. code_node/report/logos/rabbitmq-icon.svg +1 -0
  109. code_node/report/logos/redis.svg +1 -0
  110. code_node/report/logos/serverless.svg +1 -0
  111. code_node/report/logos/slack-icon.svg +1 -0
  112. code_node/report/logos/small/aws-api-gateway.svg +1 -0
  113. code_node/report/logos/small/aws-appflow.svg +1 -0
  114. code_node/report/logos/small/aws-appsync.svg +1 -0
  115. code_node/report/logos/small/aws-athena.svg +1 -0
  116. code_node/report/logos/small/aws-backup.svg +1 -0
  117. code_node/report/logos/small/aws-batch.svg +1 -0
  118. code_node/report/logos/small/aws-certificate-manager.svg +1 -0
  119. code_node/report/logos/small/aws-cloudformation.svg +1 -0
  120. code_node/report/logos/small/aws-cloudfront.svg +1 -0
  121. code_node/report/logos/small/aws-cloudtrail.svg +1 -0
  122. code_node/report/logos/small/aws-cloudwatch.svg +1 -0
  123. code_node/report/logos/small/aws-codebuild.svg +1 -0
  124. code_node/report/logos/small/aws-codecommit.svg +1 -0
  125. code_node/report/logos/small/aws-codedeploy.svg +1 -0
  126. code_node/report/logos/small/aws-codepipeline.svg +1 -0
  127. code_node/report/logos/small/aws-cognito.svg +1 -0
  128. code_node/report/logos/small/aws-config.svg +1 -0
  129. code_node/report/logos/small/aws-documentdb.svg +1 -0
  130. code_node/report/logos/small/aws-dynamodb.svg +1 -0
  131. code_node/report/logos/small/aws-ec2.svg +1 -0
  132. code_node/report/logos/small/aws-ecs.svg +1 -0
  133. code_node/report/logos/small/aws-eks.svg +1 -0
  134. code_node/report/logos/small/aws-elasticache.svg +1 -0
  135. code_node/report/logos/small/aws-elb.svg +1 -0
  136. code_node/report/logos/small/aws-eventbridge.svg +1 -0
  137. code_node/report/logos/small/aws-glacier.svg +1 -0
  138. code_node/report/logos/small/aws-glue.svg +1 -0
  139. code_node/report/logos/small/aws-iam.svg +1 -0
  140. code_node/report/logos/small/aws-keyspaces.svg +1 -0
  141. code_node/report/logos/small/aws-kinesis.svg +1 -0
  142. code_node/report/logos/small/aws-kms.svg +1 -0
  143. code_node/report/logos/small/aws-lake-formation.svg +1 -0
  144. code_node/report/logos/small/aws-lambda.svg +1 -0
  145. code_node/report/logos/small/aws-mq.svg +1 -0
  146. code_node/report/logos/small/aws-msk.svg +1 -0
  147. code_node/report/logos/small/aws-neptune.svg +1 -0
  148. code_node/report/logos/small/aws-open-search.svg +1 -0
  149. code_node/report/logos/small/aws-quicksight.svg +1 -0
  150. code_node/report/logos/small/aws-rds.svg +1 -0
  151. code_node/report/logos/small/aws-redshift.svg +1 -0
  152. code_node/report/logos/small/aws-route53.svg +1 -0
  153. code_node/report/logos/small/aws-s3.svg +1 -0
  154. code_node/report/logos/small/aws-secrets-manager.svg +1 -0
  155. code_node/report/logos/small/aws-ses.svg +1 -0
  156. code_node/report/logos/small/aws-shield.svg +1 -0
  157. code_node/report/logos/small/aws-sns.svg +1 -0
  158. code_node/report/logos/small/aws-sqs.svg +1 -0
  159. code_node/report/logos/small/aws-step-functions.svg +1 -0
  160. code_node/report/logos/small/aws-systems-manager.svg +1 -0
  161. code_node/report/logos/small/aws-timestream.svg +1 -0
  162. code_node/report/logos/small/aws-waf.svg +1 -0
  163. code_node/report/logos/small/aws-xray.svg +1 -0
  164. code_node/report/logos/snowflake-icon.svg +1 -0
  165. code_node/report/logos/sqlite.svg +1 -0
  166. code_node/report/logos/stripe.svg +1 -0
  167. code_node/report/logos/supabase-icon.svg +1 -0
  168. code_node/report/logos/twilio-icon.svg +1 -0
  169. code_node/report/outline.py +219 -0
  170. code_node/report/style.py +358 -0
  171. code_node/report/tabs.py +73 -0
  172. code_node/report/walk.py +624 -0
  173. code_node/serve.py +277 -0
  174. code_node_graph-0.1.0.dist-info/METADATA +165 -0
  175. code_node_graph-0.1.0.dist-info/RECORD +178 -0
  176. code_node_graph-0.1.0.dist-info/WHEEL +4 -0
  177. code_node_graph-0.1.0.dist-info/entry_points.txt +2 -0
  178. code_node_graph-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,505 @@
1
+ """
2
+ What the code reader knows: how deep it reads, which modules are libraries, what
3
+ each AWS call and common call does, and what looks like a secret.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import re
9
+
10
+ MB = 1024 * 1024
11
+
12
+
13
+ _MAP_DEPTH = 8 # calls followed from the handler; a function deeper than this is named, not opened
14
+
15
+ _MAP_STEPS = 2_500 # outline lines, at most: past that, the functions it calls are named, not opened
16
+
17
+ _MAP_RUNS = 3_000 # function bodies read (one function is read again for other arguments), at most
18
+
19
+ _MAP_FILES = 400 # its own Python files map_package() reads, at most...
20
+
21
+ _MAP_BYTES = 8 * MB # ...and their size, together
22
+
23
+ # What the Python runtime gives every function, so the package needn't carry it.
24
+ _RUNTIME_MODULES = frozenset(
25
+ {
26
+ "boto3",
27
+ "botocore",
28
+ "s3transfer",
29
+ "jmespath",
30
+ "dateutil",
31
+ "urllib3",
32
+ "six",
33
+ "awslambdaric",
34
+ "bootstrap",
35
+ }
36
+ )
37
+
38
+ # Libraries often packed without their .dist-info folder (which is how the others are told from the code's own
39
+ # files): their files aren't read as its own code.
40
+ _LIBRARIES = frozenset(
41
+ {
42
+ "requests",
43
+ "certifi",
44
+ "idna",
45
+ "charset_normalizer",
46
+ "chardet",
47
+ "pytz",
48
+ "yaml",
49
+ "attr",
50
+ "attrs",
51
+ "pydantic",
52
+ "pydantic_core",
53
+ "typing_extensions",
54
+ "numpy",
55
+ "pandas",
56
+ "aws_lambda_powertools",
57
+ "aws_xray_sdk",
58
+ "wrapt",
59
+ "psycopg2",
60
+ "pymysql",
61
+ "sqlalchemy",
62
+ "jwt",
63
+ "cryptography",
64
+ "cffi",
65
+ "_cffi_backend",
66
+ "simplejson",
67
+ "redis",
68
+ "opensearchpy",
69
+ "elasticsearch",
70
+ "requests_aws4auth",
71
+ "markupsafe",
72
+ "jinja2",
73
+ "httpx",
74
+ "httpcore",
75
+ "anyio",
76
+ "sniffio",
77
+ "h11",
78
+ "openai",
79
+ "anthropic",
80
+ "google",
81
+ "PIL",
82
+ "pyarrow",
83
+ "sklearn",
84
+ "scipy",
85
+ "joblib",
86
+ "fastapi",
87
+ "starlette",
88
+ "mangum",
89
+ "flask",
90
+ "werkzeug",
91
+ "click",
92
+ "itsdangerous",
93
+ "dotenv",
94
+ "orjson",
95
+ "ujson",
96
+ "pymongo",
97
+ "bson",
98
+ "dns",
99
+ "nacl",
100
+ "OpenSSL",
101
+ "rsa",
102
+ "pyasn1",
103
+ "jose",
104
+ "tenacity",
105
+ "backoff",
106
+ "structlog",
107
+ "loguru",
108
+ "multidict",
109
+ "yarl",
110
+ "aiohttp",
111
+ "aiosignal",
112
+ "frozenlist",
113
+ "async_timeout",
114
+ "awswrangler",
115
+ "langchain",
116
+ "langchain_core",
117
+ "langchain_aws",
118
+ "tiktoken",
119
+ "regex",
120
+ "tqdm",
121
+ "smart_open",
122
+ "s3fs",
123
+ "fsspec",
124
+ "aiobotocore",
125
+ "chalice",
126
+ "zappa",
127
+ "dateparser",
128
+ "tzdata",
129
+ "tzlocal",
130
+ "packaging",
131
+ "pkg_resources",
132
+ "setuptools",
133
+ "_distutils_hack",
134
+ "pip",
135
+ "wheel",
136
+ "annotated_types",
137
+ "jsonschema",
138
+ "fastjsonschema",
139
+ "pyrsistent",
140
+ "referencing",
141
+ "rpds",
142
+ }
143
+ )
144
+
145
+ # Standard-library modules a newer Python removed: (the first Python without it). Code that imports one fails with
146
+ # Runtime.ImportModuleError on that runtime, a trap when moving to a newer one.
147
+ _REMOVED_MODULES = {
148
+ "distutils": (3, 12),
149
+ "imp": (3, 12),
150
+ "asynchat": (3, 12),
151
+ "asyncore": (3, 12),
152
+ "smtpd": (3, 12),
153
+ "cgi": (3, 13),
154
+ "cgitb": (3, 13),
155
+ "pipes": (3, 13),
156
+ "crypt": (3, 13),
157
+ "telnetlib": (3, 13),
158
+ "nntplib": (3, 13),
159
+ "imghdr": (3, 13),
160
+ "sndhdr": (3, 13),
161
+ "mailcap": (3, 13),
162
+ "uu": (3, 13),
163
+ "xdrlib": (3, 13),
164
+ "aifc": (3, 13),
165
+ "audioop": (3, 13),
166
+ "chunk": (3, 13),
167
+ "msilib": (3, 13),
168
+ "nis": (3, 13),
169
+ "ossaudiodev": (3, 13),
170
+ "spwd": (3, 13),
171
+ "sunau": (3, 13),
172
+ "lib2to3": (3, 13),
173
+ }
174
+
175
+ _ADDED_MODULES = {"tomllib": (3, 11)} # standard-library modules a newer Python added: (the first Python with it)
176
+
177
+ _SERVICE_NAMES = { # boto3's name -> what people call it, where botocore's serviceId reads oddly
178
+ "stepfunctions": "Step Functions",
179
+ "apigatewaymanagementapi": "API Gateway (WebSocket)",
180
+ "es": "OpenSearch",
181
+ "opensearchserverless": "OpenSearch Serverless",
182
+ "iot-data": "IoT",
183
+ "sesv2": "SES",
184
+ "cloudwatch": "CloudWatch",
185
+ "logs": "CloudWatch Logs",
186
+ "appconfigdata": "AppConfig",
187
+ "ApiGatewayManagementApi": "API Gateway (WebSocket)",
188
+ }
189
+
190
+ _IAM_PREFIXES = {
191
+ "cloudwatch": "cloudwatch",
192
+ "iot-data": "iot",
193
+ "sesv2": "ses",
194
+ "appconfigdata": "appconfig",
195
+ }
196
+
197
+ _IAM_ACTIONS = { # (service, operation) -> the IAM action, where it isn't <prefix>:<operation>
198
+ ("s3", "ListObjectsV2"): "s3:ListBucket",
199
+ ("s3", "ListObjects"): "s3:ListBucket",
200
+ ("s3", "HeadBucket"): "s3:ListBucket",
201
+ ("s3", "HeadObject"): "s3:GetObject",
202
+ ("s3", "SelectObjectContent"): "s3:GetObject",
203
+ ("s3", "CopyObject"): "s3:PutObject",
204
+ ("s3", "DeleteObjects"): "s3:DeleteObject",
205
+ ("s3", "CreateMultipartUpload"): "s3:PutObject",
206
+ ("s3", "UploadPart"): "s3:PutObject",
207
+ ("s3", "CompleteMultipartUpload"): "s3:PutObject",
208
+ ("s3", "ListObjectVersions"): "s3:ListBucketVersions",
209
+ ("s3", "ListBuckets"): "s3:ListAllMyBuckets",
210
+ ("bedrock-runtime", "Converse"): "bedrock:InvokeModel",
211
+ ("bedrock-runtime", "ConverseStream"): "bedrock:InvokeModelWithResponseStream",
212
+ ("apigatewaymanagementapi", "PostToConnection"): "execute-api:ManageConnections",
213
+ ("apigatewaymanagementapi", "GetConnection"): "execute-api:ManageConnections",
214
+ ("apigatewaymanagementapi", "DeleteConnection"): "execute-api:ManageConnections",
215
+ ("sqs", "SendMessageBatch"): "sqs:SendMessage",
216
+ ("sqs", "DeleteMessageBatch"): "sqs:DeleteMessage",
217
+ ("sqs", "ChangeMessageVisibilityBatch"): "sqs:ChangeMessageVisibility",
218
+ ("sns", "PublishBatch"): "sns:Publish",
219
+ ("dynamodb", "ExecuteStatement"): "dynamodb:PartiQL*",
220
+ ("sts", "GetCallerIdentity"): "",
221
+ }
222
+
223
+ _RUNS_PREFIXES = (
224
+ "Invoke",
225
+ "Converse",
226
+ "RetrieveAndGenerate",
227
+ "Start",
228
+ "Detect",
229
+ "Analyze",
230
+ "Translate",
231
+ "Synthesize",
232
+ "Classify",
233
+ "Recognize",
234
+ "Compare",
235
+ "Decrypt",
236
+ "Encrypt",
237
+ "GenerateDataKey",
238
+ "Sign",
239
+ "Verify",
240
+ "AssumeRole",
241
+ "Rerank",
242
+ "Execute",
243
+ "Run",
244
+ )
245
+
246
+ _SENDS_PREFIXES = (
247
+ "Send",
248
+ "Publish",
249
+ "PostToConnection",
250
+ "PutEvents",
251
+ ) # a message or an event, sent on
252
+
253
+ _READS_PREFIXES = (
254
+ "Get",
255
+ "List",
256
+ "Describe",
257
+ "Head",
258
+ "Query",
259
+ "Scan",
260
+ "Select",
261
+ "BatchGet",
262
+ "Search",
263
+ "Lookup",
264
+ "Retrieve",
265
+ "Filter",
266
+ "Check",
267
+ "Estimate",
268
+ "Preview",
269
+ "Receive",
270
+ "Download",
271
+ )
272
+
273
+ _BATCHES = { # a call that sends one item, made in a loop -> (the call that sends many, how many at a time)
274
+ ("dynamodb", "PutItem"): ("table.batch_writer() (BatchWriteItem)", 25),
275
+ ("dynamodb", "DeleteItem"): ("table.batch_writer() (BatchWriteItem)", 25),
276
+ ("dynamodb", "GetItem"): ("batch_get_item", 100),
277
+ ("sqs", "SendMessage"): ("send_message_batch", 10),
278
+ ("sqs", "DeleteMessage"): ("delete_message_batch", 10),
279
+ ("sns", "Publish"): ("publish_batch", 10),
280
+ ("s3", "DeleteObject"): ("delete_objects", 1000),
281
+ ("kinesis", "PutRecord"): ("put_records", 500),
282
+ ("firehose", "PutRecord"): ("put_record_batch", 500),
283
+ ("ssm", "GetParameter"): ("get_parameters", 10),
284
+ ("secretsmanager", "GetSecretValue"): ("batch_get_secret_value", 20),
285
+ }
286
+
287
+ _RESOURCE_ACTIONS = { # a boto3 resource object's methods that aren't the client's -> the operation they call
288
+ ("s3", "Object"): {
289
+ "get": "GetObject",
290
+ "put": "PutObject",
291
+ "delete": "DeleteObject",
292
+ "load": "HeadObject",
293
+ "reload": "HeadObject",
294
+ "copy_from": "CopyObject",
295
+ "upload_file": "PutObject",
296
+ "upload_fileobj": "PutObject",
297
+ "download_file": "GetObject",
298
+ "download_fileobj": "GetObject",
299
+ },
300
+ ("s3", "ObjectSummary"): {
301
+ "get": "GetObject",
302
+ "put": "PutObject",
303
+ "delete": "DeleteObject",
304
+ "load": "HeadObject",
305
+ },
306
+ ("s3", "Bucket"): {
307
+ "upload_file": "PutObject",
308
+ "upload_fileobj": "PutObject",
309
+ "download_file": "GetObject",
310
+ "download_fileobj": "GetObject",
311
+ },
312
+ ("dynamodb", "Table"): {"load": "DescribeTable", "reload": "DescribeTable"},
313
+ ("sqs", "Queue"): {
314
+ "send_messages": "SendMessageBatch",
315
+ "receive_messages": "ReceiveMessage",
316
+ "delete_messages": "DeleteMessageBatch",
317
+ "load": "GetQueueAttributes",
318
+ },
319
+ ("sqs", "Message"): {"delete": "DeleteMessage"},
320
+ ("sns", "Topic"): {"load": "GetTopicAttributes"},
321
+ }
322
+
323
+ _COLLECTIONS = {
324
+ ("s3", "objects"): "ListObjects",
325
+ ("s3", "object_versions"): "ListObjectVersions",
326
+ ("s3", "buckets"): "ListBuckets",
327
+ ("dynamodb", "tables"): "ListTables",
328
+ ("sqs", "queues"): "ListQueues",
329
+ ("sns", "topics"): "ListTopics",
330
+ } # a resource's collection -> the list call iterating it makes
331
+
332
+ _TRANSFERS = {
333
+ "upload_file": "PutObject",
334
+ "upload_fileobj": "PutObject",
335
+ "download_file": "GetObject",
336
+ "download_fileobj": "GetObject",
337
+ "copy": "CopyObject",
338
+ } # an S3 client's transfer methods
339
+
340
+ _GUESSES = { # a method name only one AWS service has, for a client it couldn't follow
341
+ "put_item": ("dynamodb", "PutItem"),
342
+ "get_item": ("dynamodb", "GetItem"),
343
+ "update_item": ("dynamodb", "UpdateItem"),
344
+ "delete_item": ("dynamodb", "DeleteItem"),
345
+ "batch_write_item": ("dynamodb", "BatchWriteItem"),
346
+ "batch_get_item": ("dynamodb", "BatchGetItem"),
347
+ "transact_write_items": ("dynamodb", "TransactWriteItems"),
348
+ "get_object": ("s3", "GetObject"),
349
+ "put_object": ("s3", "PutObject"),
350
+ "head_object": ("s3", "HeadObject"),
351
+ "delete_object": ("s3", "DeleteObject"),
352
+ "list_objects_v2": ("s3", "ListObjectsV2"),
353
+ "copy_object": ("s3", "CopyObject"),
354
+ "send_message": ("sqs", "SendMessage"),
355
+ "send_message_batch": ("sqs", "SendMessageBatch"),
356
+ "receive_message": ("sqs", "ReceiveMessage"),
357
+ "get_secret_value": ("secretsmanager", "GetSecretValue"),
358
+ "get_parameter": ("ssm", "GetParameter"),
359
+ "get_parameters_by_path": ("ssm", "GetParametersByPath"),
360
+ "start_execution": ("stepfunctions", "StartExecution"),
361
+ "invoke_model": ("bedrock-runtime", "InvokeModel"),
362
+ "put_events": ("events", "PutEvents"),
363
+ "start_query_execution": ("athena", "StartQueryExecution"),
364
+ }
365
+
366
+ _HTTP_METHODS = ("get", "post", "put", "patch", "delete", "head", "options", "request")
367
+
368
+ _HTTP_SESSIONS = {
369
+ "requests.Session": "requests",
370
+ "requests.session": "requests",
371
+ "httpx.Client": "httpx",
372
+ "httpx.AsyncClient": "httpx",
373
+ "urllib3.PoolManager": "urllib3",
374
+ "aiohttp.ClientSession": "aiohttp",
375
+ "http.client.HTTPSConnection": "http.client",
376
+ "http.client.HTTPConnection": "http.client",
377
+ }
378
+
379
+ _DEFAULT_TIMEOUTS = {
380
+ "httpx",
381
+ "aiohttp",
382
+ } # HTTP libraries that stop waiting by themselves (5 s and 5 minutes)
383
+
384
+ _LOG_LEVELS = {
385
+ "debug": "logs",
386
+ "info": "logs",
387
+ "warning": "logs a warning",
388
+ "warn": "logs a warning",
389
+ "error": "logs an error",
390
+ "exception": "logs an error",
391
+ "critical": "logs an error",
392
+ "log": "logs",
393
+ }
394
+
395
+ _JSON_LOADS = {
396
+ "json.loads",
397
+ "json.load",
398
+ "simplejson.loads",
399
+ "orjson.loads",
400
+ "ujson.loads",
401
+ }
402
+
403
+ _B64_DECODES = {
404
+ "base64.b64decode",
405
+ "base64.standard_b64decode",
406
+ "base64.urlsafe_b64decode",
407
+ }
408
+
409
+ _COMMANDS = {
410
+ "subprocess.run",
411
+ "subprocess.call",
412
+ "subprocess.check_call",
413
+ "subprocess.check_output",
414
+ "subprocess.Popen",
415
+ "os.system",
416
+ "os.popen",
417
+ }
418
+
419
+ _FILE_WRITERS = {
420
+ "to_csv",
421
+ "to_parquet",
422
+ "to_json",
423
+ "to_excel",
424
+ "to_pickle",
425
+ "to_feather",
426
+ "savefig",
427
+ }
428
+
429
+ _ROUTE_METHODS = {
430
+ "get",
431
+ "post",
432
+ "put",
433
+ "patch",
434
+ "delete",
435
+ "head",
436
+ "options",
437
+ "route",
438
+ "api_route",
439
+ }
440
+
441
+ _URL_PATHS = {
442
+ "django.urls.path",
443
+ "django.urls.re_path",
444
+ "django.conf.urls.url",
445
+ } # a URL conf's routes: path('x/', view)
446
+
447
+ _URL_INCLUDES = {"django.urls.include", "django.conf.urls.include"} # path('api/', include('shop.urls'))
448
+
449
+ _VIEW_VERBS = {"require_GET": "GET", "require_POST": "POST", "require_safe": "GET, HEAD"} # a Django view's decorators
450
+
451
+ _VIEW_METHODS = ("get", "post", "put", "patch", "delete") # a class-based view's methods, each a route
452
+
453
+ _VIEWSET_ACTIONS = { # a Django REST framework ViewSet's methods: what a router answers with each, and on which path
454
+ "list": ("GET", False),
455
+ "create": ("POST", False),
456
+ "retrieve": ("GET", True),
457
+ "update": ("PUT", True),
458
+ "partial_update": ("PATCH", True),
459
+ "destroy": ("DELETE", True),
460
+ }
461
+
462
+ _DICT_METHODS = {
463
+ "get",
464
+ "items",
465
+ "keys",
466
+ "values",
467
+ "copy",
468
+ "pop",
469
+ "setdefault",
470
+ "update",
471
+ }
472
+
473
+ _CACHES = {"lru_cache", "cache", "cached", "cached_property"}
474
+
475
+ _SECRET_NAME_RE = re.compile(
476
+ r"passw(?:or)?d|secret|token|api_?key|apikey|private_?key|access_?key|credential",
477
+ re.I,
478
+ )
479
+
480
+ _NOT_SECRET_NAME_RE = re.compile(
481
+ r"(?:name|id|arn|path|env|var|url|uri|header|field|param|parameter|file|type|len|length|key_name|prefix|ttl|"
482
+ r"expiry|expires|timeout)$",
483
+ re.I,
484
+ )
485
+
486
+ _PLACEHOLDERS = {
487
+ "password",
488
+ "secret",
489
+ "token",
490
+ "changeme",
491
+ "change-me",
492
+ "test",
493
+ "dummy",
494
+ "example",
495
+ "none",
496
+ "null",
497
+ "redacted",
498
+ "todo",
499
+ }
500
+
501
+ _AWS_KEY_RE = re.compile(r"\b(?:AKIA|ASIA)[0-9A-Z]{16}\b")
502
+
503
+ LATEST_RUNTIMES = {"python": "python3.14"} # the newest Python findings suggest moving to
504
+
505
+ _JUNK_RE = re.compile(r"(^|/)(__pycache__|\.git|\.pytest_cache|tests?|\.venv|venv|\.idea|\.vscode|node_modules)/")