Skip to content

bug-2032278: escape user-provided field values for /signature graphs tab#7188

Merged
biancadanforth merged 1 commit intomainfrom
bug-2032278
Apr 27, 2026
Merged

bug-2032278: escape user-provided field values for /signature graphs tab#7188
biancadanforth merged 1 commit intomainfrom
bug-2032278

Conversation

@biancadanforth
Copy link
Copy Markdown
Contributor

@biancadanforth biancadanforth commented Apr 24, 2026

Because:

  • We don't escape crash report field values in this tab (though I've confirmed that we do everywhere else).

This PR:

  • Ensures we convert the value to text content before rendering it.
  • I actually found a second place in this same tab where we weren't escaping (this one wasn't part of the bug report), and I fixed that as well.

How to test:

  1. Load the crash from the bug report into a local running instance of Socorro
    a. This was a little annoying, since the crash report is only in stage, and our bin/process_crashes.sh script defaults to prod. You can pass a --host flag, but then those args also get passed to the pubsub-cli command which doesn't have that option and throws an error. This means the crash report was fetched and uploaded to the GCS emulator, but a message wasn't published to the local pubsub emulator. You can explicitly run the pubsub-cli command separately afterward as a workaround (pubsub-cli publish test local-standard-topic {$crash_id}).
  2. Otherwise follow the STR in the bug report starting from step 4.

I have tested the fix locally.

Since we have no JS unit tests (see CRINGE-3), I didn't add any here.

Analogous Jira ticket: CRINGE-249

@biancadanforth biancadanforth requested a review from a team as a code owner April 24, 2026 19:09
$.each(lineDataObject, function (fieldValue, lineData) {
lineDataArray.push(lineData);
legend.push(key);
legend.push(escapeHTML(fieldValue));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one for the issue reported in the bug.

show_secondary_x_label: false,
mouseover: function (d) {
$('.mg-active-datapoint', contentElement).html(d.term + ': ' + d.count + (d.count === 1 ? ' crash' : ' crashes'));
$('.mg-active-datapoint', contentElement).text(d.term + ': ' + d.count + (d.count === 1 ? ' crash' : ' crashes'));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another area I discovered while fixing the reported issue after I audited other places where we render field values outside of Django/Jinja (which autoescapes).

Copy link
Copy Markdown
Contributor

@smarnach smarnach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. This is the right short-term solution for the problem.

I think the cause of this mistake is actually in the metrics-graphics package (specifically in the mg_add_legend_element() function, see the source code). This library apparently was originally developed at Mozilla, but the latest stable version is eight years old. We have a ticket to migrate to a different library somewhere. For our simple needs the D3 and metrics-graphics stacks seems total overkill anyway, so a migration to something simpler would be the right long-term solution.

@biancadanforth
Copy link
Copy Markdown
Contributor Author

Thank you! Yes that's one of the tickets under CRINGE-3 -- CRINGE-38. I referenced this PR there as a comment.

@biancadanforth biancadanforth added this pull request to the merge queue Apr 27, 2026
Merged via the queue into main with commit febfb0b Apr 27, 2026
1 check passed
@biancadanforth biancadanforth deleted the bug-2032278 branch April 27, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants