Skip to content

Commit 7120b53

Browse files
committed
update imports for tracer.Pin privatization
1 parent b8f7990 commit 7120b53

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

utils/build/docker/python/django/app/urls.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ def track_custom_event(self, *args, **kwargs):
5353
track_user_sdk = TUS()
5454

5555
try:
56-
from ddtrace.trace import Pin, tracer
56+
from ddtrace._trace.pin import Pin
57+
from ddtrace.trace import tracer
5758
except ImportError:
58-
from ddtrace import tracer, Pin
59+
try:
60+
from ddtrace.trace import Pin, tracer
61+
except ImportError:
62+
from ddtrace import tracer, Pin
5963

6064

6165
ddtrace.patch_all(urllib3=True)
@@ -545,7 +549,8 @@ def view_iast_xss_secure(request):
545549

546550
@csrf_exempt
547551
def view_iast_stacktraceleak_insecure(request):
548-
return HttpResponse("""
552+
return HttpResponse(
553+
"""
549554
Traceback (most recent call last):
550555
File "/usr/local/lib/python3.9/site-packages/some_module.py", line 42, in process_data
551556
result = complex_calculation(data)
@@ -568,7 +573,8 @@ def view_iast_stacktraceleak_insecure(request):
568573
ValueError: Constraint violation at step 9
569574
570575
Lorem Ipsum Foobar
571-
""")
576+
"""
577+
)
572578

573579

574580
@csrf_exempt

utils/build/docker/python/fastapi/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@
3838
from ddtrace.appsec import trace_utils as appsec_trace_utils
3939

4040
try:
41-
from ddtrace.trace import Pin
41+
from ddtrace._trace.pin import Pin
4242
from ddtrace.trace import tracer
4343
except ImportError:
44-
from ddtrace import Pin
45-
from ddtrace import tracer
44+
try:
45+
from ddtrace.trace import Pin
46+
from ddtrace.trace import tracer
47+
except ImportError:
48+
from ddtrace import Pin
49+
from ddtrace import tracer
4650

4751
ddtrace.patch_all(urllib3=True)
4852

utils/build/docker/python/flask/app.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,15 @@
104104
from exception_replay_controller import exception_replay_blueprint
105105

106106
try:
107-
from ddtrace.trace import Pin
107+
from ddtrace._trace.pin import Pin
108108
from ddtrace.trace import tracer
109109
except ImportError:
110-
from ddtrace import Pin
111-
from ddtrace import tracer
110+
try:
111+
from ddtrace.trace import Pin
112+
from ddtrace.trace import tracer
113+
except ImportError:
114+
from ddtrace import Pin
115+
from ddtrace import tracer
112116

113117
# Patch kombu and urllib3 since they are not patched automatically
114118
ddtrace.patch_all(kombu=True, urllib3=True)
@@ -250,23 +254,27 @@ def check_and_create_users_table():
250254
cur = postgres_db.cursor()
251255

252256
# Check if 'users' exists
253-
cur.execute("""
257+
cur.execute(
258+
"""
254259
SELECT EXISTS (
255260
SELECT FROM information_schema.tables
256261
WHERE table_name = 'users'
257262
);
258-
""")
263+
"""
264+
)
259265
table_exists = cur.fetchone()[0]
260266

261267
if not table_exists:
262-
cur.execute("""
268+
cur.execute(
269+
"""
263270
CREATE TABLE users (
264271
id VARCHAR(255) PRIMARY KEY,
265272
username VARCHAR(255),
266273
email VARCHAR(255),
267274
password VARCHAR(255)
268275
);
269-
""")
276+
"""
277+
)
270278
postgres_db.commit()
271279

272280
users_data = [

0 commit comments

Comments
 (0)