Skip to content

Commit 889933c

Browse files
cleanup logging
1 parent bacb28b commit 889933c

2 files changed

Lines changed: 7 additions & 40 deletions

File tree

dojo/api_v2/serializers.py

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def __init__(self, **kwargs):
208208
self.pretty_print = pretty_print
209209

210210
def to_internal_value(self, data):
211-
logger.debug(f"to_internal_value called with data: {data}")
211+
# logger.debug(f"to_internal_value called with data: {data}")
212212
# logger.debug("Stacktrace:\n%s", "".join(traceback.format_stack()))
213213
if isinstance(data, list) and data == [""] and self.allow_empty:
214214
return []
@@ -239,15 +239,11 @@ def to_internal_value(self, data):
239239
tag_validator(sub, exception_class=RestFrameworkValidationError)
240240
data_safe.extend(substrings)
241241

242-
logger.debug(f"data_safe after processing: {data_safe}")
243-
# result = tagulous.utils.render_tags(data_safe)
244242
logger.debug(f"result after rendering tags: {data_safe}")
245243
return data_safe
246-
# logger.debug(f"result after rendering tags: {result}")
247-
# return result
248244

249245
def to_representation(self, value):
250-
logger.debug(f"to_representation called with value: {value}")
246+
# logger.debug(f"to_representation called with value: {value}")
251247
if not isinstance(value, list):
252248
# we can't use isinstance because TagRelatedManager is non-existing class
253249
# it cannot be imported or referenced, so we fallback to string
@@ -1741,12 +1737,7 @@ def process_risk_acceptance(self, data):
17411737

17421738
# Overriding this to push add Push to JIRA functionality
17431739
def update(self, instance, validated_data):
1744-
# remove tags from validated data and store them seperately
1745-
# to_be_tagged, validated_data = self._pop_tags(validated_data)
1746-
1747-
# pop push_to_jira so it won't get send to the model as a field
1748-
# TODO: JIRA can we remove this is_push_all_issues, already checked in
1749-
# apiv2 viewset?
1740+
# push_all_issues already checked in api views.py
17501741
push_to_jira = validated_data.pop("push_to_jira")
17511742

17521743
# Save vulnerability ids and pop them
@@ -1764,17 +1755,9 @@ def update(self, instance, validated_data):
17641755
instance, validated_data,
17651756
)
17661757

1767-
# If we need to push to JIRA, an extra save call is needed.
1768-
# Also if we need to update the mitigation date of the finding.
1769-
# TODO: try to combine create and save, but for now I'm just fixing a
1770-
# bug and don't want to change to much
17711758
if push_to_jira:
1772-
logger.debug(f"Pushing updated finding {instance.id} to JIRA")
17731759
jira_helper.push_to_jira(instance)
17741760

1775-
# not sure why we are returning a tag_object, but don't want to change
1776-
# too much now as we're just fixing a bug
1777-
# return self._save_tags(instance, to_be_tagged)
17781761
return instance
17791762

17801763
def validate(self, data):
@@ -1878,8 +1861,6 @@ class Meta:
18781861

18791862
# Overriding this to push add Push to JIRA functionality
18801863
def create(self, validated_data):
1881-
# Pop off of some fields that should not be sent to the model at this time
1882-
# to_be_tagged, validated_data = self._pop_tags(validated_data)
18831864
logger.debug(f"Creating finding with validated data: {validated_data}")
18841865
push_to_jira = validated_data.pop("push_to_jira", False)
18851866
notes = validated_data.pop("notes", None)
@@ -1894,8 +1875,6 @@ def create(self, validated_data):
18941875
new_finding = super().create(
18951876
validated_data)
18961877

1897-
# Create a findings in memory so that we have access to unsaved_vulnerability_ids
1898-
# new_finding = Finding(**validated_data)
18991878
new_finding.unsaved_vulnerability_ids = parsed_vulnerability_ids
19001879

19011880
# Deal with all of the many to many things
@@ -1908,13 +1887,9 @@ def create(self, validated_data):
19081887
if parsed_vulnerability_ids:
19091888
save_vulnerability_ids(new_finding, parsed_vulnerability_ids)
19101889

1911-
# If we need to push to JIRA, an extra save call is needed.
1912-
# TODO: try to combine create and save, but for now I'm just fixing a
1913-
# bug and don't want to change to much
19141890
if push_to_jira:
19151891
jira_helper.push_to_jira(new_finding)
1916-
# This final call will save the finding again and return it
1917-
# return self._save_tags(new_finding, to_be_tagged)
1892+
19181893
return new_finding
19191894

19201895
def validate(self, data):

dojo/api_v2/views.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -986,20 +986,15 @@ def tags(self, request, pk=None):
986986
new_tags = serializers.TagSerializer(data=request.data)
987987
if new_tags.is_valid():
988988
all_tags = finding.tags
989-
logger.debug("Current tags: %s", all_tags)
990989
all_tags = serializers.TagSerializer({"tags": all_tags}).data[
991990
"tags"
992991
]
993-
logger.debug("Current tags serialized: %s", all_tags)
994-
logger.debug("New tags raw: %s", new_tags.validated_data["tags"])
995992
for tag in new_tags.validated_data["tags"]:
996993
for sub_tag in tagulous.utils.parse_tags(tag):
997994
if sub_tag not in all_tags:
998-
logger.debug("Adding tag: %s", sub_tag)
999995
all_tags.append(sub_tag)
1000-
logger.debug("All tags: %s", all_tags)
996+
1001997
new_tags = tagulous.utils.render_tags(all_tags)
1002-
logger.debug("All tags rendered: %s", new_tags)
1003998

1004999
finding.tags = new_tags
10051000
finding.save()
@@ -1242,18 +1237,15 @@ def remove_tags(self, request, pk=None):
12421237
"tags"
12431238
]
12441239

1245-
logger.debug("Current tags serialized: %s", all_tags)
12461240
# serializer turns it into a string, but we need a list
12471241
del_tags = delete_tags.validated_data["tags"]
12481242
if len(del_tags) < 1:
12491243
return Response(
12501244
{"error": "Empty Tag List Not Allowed"},
12511245
status=status.HTTP_400_BAD_REQUEST,
12521246
)
1253-
logger.debug("Tags to delete: %s", del_tags)
1247+
12541248
for tag in del_tags:
1255-
# sub_tag = tagulous.utils.parse_tags(tag)
1256-
logger.debug("Sub tag: %s", tag)
12571249
if tag not in all_tags:
12581250
return Response(
12591251
{
@@ -2515,7 +2507,7 @@ def perform_create(self, serializer):
25152507
jira_driver = engagement or (product or None)
25162508
if jira_project := (jira_helper.get_jira_project(jira_driver) if jira_driver else None):
25172509
push_to_jira = push_to_jira or jira_project.push_all_issues
2518-
logger.debug(f"push_to_jira: {push_to_jira}")
2510+
# logger.debug(f"push_to_jira: {push_to_jira}")
25192511
serializer.save(push_to_jira=push_to_jira)
25202512

25212513
def get_queryset(self):

0 commit comments

Comments
 (0)