Skip to content

Commit

Permalink
bug 1709658: show mac_crash_info in Details and make searchable
Browse files Browse the repository at this point in the history
This adds mac_crash_info to the Details tab in the crash report.

This also makes it searchable. This JSON encodes the structure into a
string and then indexes that. That should be good enough to work with
"has terms", "contains", and "exists" filters.
  • Loading branch information
willkg committed May 10, 2021
1 parent a2afe54 commit 749511d
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
18 changes: 18 additions & 0 deletions socorro/external/es/super_search_fields.py
Expand Up @@ -2216,6 +2216,24 @@ def has_key_val(key, val, data):
"query_type": "number",
"storage_mapping": {"type": "long"},
},
"mac_crash_info": {
"data_validation_type": "str",
"description": "macOS __crash_info data.",
"form_field_choices": [],
"has_full_version": True,
"in_database_name": "mac_crash_info",
"is_exposed": True,
"is_returned": True,
"name": "mac_crash_info",
"namespace": "processed_crash",
"permissions_needed": [],
"query_type": "string",
"storage_mapping": {
"fields": {"full": {"index": "not_analyzed", "type": "string"}},
"index": "analyzed",
"type": "string",
},
},
"major_version": {
"data_validation_type": "int",
"description": "Major part of the version",
Expand Down
2 changes: 2 additions & 0 deletions socorro/processor/processor_pipeline.py
Expand Up @@ -46,6 +46,7 @@
MajorVersionRule,
ModulesInStackRule,
ModuleURLRewriteRule,
MacCrashInfoRule,
MozCrashReasonRule,
OSPrettyVersionRule,
OutOfMemoryBinaryRule,
Expand Down Expand Up @@ -218,6 +219,7 @@ def get_rulesets(self, config):
PHCRule(),
BreadcrumbsRule(),
JavaProcessRule(),
MacCrashInfoRule(),
MozCrashReasonRule(),
# post processing of the processed crash
CrashingThreadRule(),
Expand Down
18 changes: 18 additions & 0 deletions socorro/processor/rules/mozilla.py
Expand Up @@ -397,6 +397,24 @@ def action(self, raw_crash, dumps, processed_crash, processor_meta):
processor_meta["processor_notes"].append(f"Breadcrumbs: malformed: {exc}")


class MacCrashInfoRule(Rule):
"""Extracts mac_crash_info from json_dump
If there's a mac_crash_info in the json_dump, this extracts it and keeps
it around as a JSON-encoded string.
"""

def predicate(self, raw_crash, dumps, processed_crash, proc_meta):
return "mac_crash_info" in processed_crash.get("json_dump", {})

def action(self, raw_crash, dumps, processed_crash, processor_meta):
mac_crash_info = glom(processed_crash, "json_dump.mac_crash_info", default="")
processed_crash["mac_crash_info"] = json.dumps(
mac_crash_info, indent=2, sort_keys=True
)


class MozCrashReasonRule(Rule):
"""This rule sanitizes the MozCrashReason value
Expand Down
38 changes: 38 additions & 0 deletions socorro/unittest/processor/rules/test_mozilla.py
Expand Up @@ -24,6 +24,7 @@
FenixVersionRewriteRule,
FlashVersionRule,
JavaProcessRule,
MacCrashInfoRule,
MajorVersionRule,
MalformedBreadcrumbs,
ModulesInStackRule,
Expand Down Expand Up @@ -652,6 +653,43 @@ def test_bad_seconds_since_last_crash(self):
]


class TestMacCrashInfoRule:
@pytest.mark.parametrize(
"processed, expected",
[
({}, False),
({"json_dump": {}}, False),
({"json_dump": {"mac_crash_info": {}}}, True),
],
)
def test_mac_crash_info_predicate(self, processed, expected):
raw_crash = {}
dumps = {}
processor_meta = get_basic_processor_meta()
rule = MacCrashInfoRule()

assert rule.predicate(raw_crash, dumps, processed, processor_meta) == expected

def test_mac_crash_info_action(self):
raw_crash = {}
dumps = {}
processed_crash = {"json_dump": {"mac_crash_info": {"key": "val"}}}
processor_meta = get_basic_processor_meta()

rule = MacCrashInfoRule()
rule.act(raw_crash, dumps, processed_crash, processor_meta)

assert processed_crash == {
"json_dump": {
"mac_crash_info": {
"key": "val",
}
},
# The mac_crash_info is a json encoded string
"mac_crash_info": '{\n "key": "val"\n}',
}


class TestMajorVersionRule:
@pytest.mark.parametrize(
"version, expected",
Expand Down
Expand Up @@ -356,6 +356,12 @@ <h2>{{ report.product }} {{ report.version }} Crash Report [@ {{ report.signatur
<td>{{ parsed_dump.threads[crashing_thread].last_error_value }}</td>
</tr>
{% endif %}
{% if report.mac_crash_info %}
<tr title="Mac crash info">
<th scope="row">Mac Crash info</th>
<td><pre>{{ report.mac_crash_info }}</pre></td>
</tr>
{% endif %}
{% if request.user.has_perm('crashstats.view_pii') or your_crash %}
{% if report.java_stack_trace_raw %}
<tr title="{{ fields_desc['processed_crash.java_stack_trace_raw'] }}">
Expand Down

0 comments on commit 749511d

Please sign in to comment.