Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLAT-8748] Truncate strings longer than maxStringValueLength #1449

Merged
merged 5 commits into from
Aug 8, 2022

Conversation

nickdowell
Copy link
Contributor

Goal

Truncate app-provided strings that may lead to oversized payloads - metadata strings and breadcrumb messages.

Changeset

Adds maxStringValueLength to BugsnagConfiguration.

Implements string truncation functions in BSGSerialization.m.

Implements -[BugsnagEvent truncateStrings:] to truncate breadcrumbs and metadata, called by BSGEventUploadOperation immediately prior to upload.

Updates BugsnagMetadata and BSGSerialization.m to avoid duplication of sanitization logic.

Testing

Adds unit tests to verify truncation of strings, including checks that composed character sequences are not sliced.

Amends barebones test to very truncation.

@github-actions
Copy link

Bugsnag.framework binary size decreased by 88 bytes from 774,680 to 774,592 🎉

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.2%    +616  +0.2%    +616    __TEXT,__text
  +0.5%    +132  +0.5%    +132    __TEXT,__objc_methname
  +0.5%     +96  +0.5%     +96    __DATA,__cfstring
  [ = ]       0  +0.7%     +88    [__LINKEDIT]
  +0.1%     +72  +0.1%     +72    __DATA,__objc_const
  +0.4%     +65  +0.4%     +65    __TEXT,__cstring
  +1.7%     +56  +1.7%     +56    __TEXT,__gcc_except_tab
  +0.4%     +24  +0.4%     +24    __DATA,__objc_selrefs
  +0.4%      +4  +0.4%      +4    __DATA,__objc_ivar
  -0.3%      -8  -0.3%      -8    Binding Info
  -0.2%      -8  -0.2%      -8    __TEXT,__unwind_info
  -0.0%     -16  -0.0%     -16    String Table
  [ = ]       0  -0.2%     -16    __DATA,__bss
  -1.0%     -32  -1.0%     -32    __DATA,__const
  -0.0%     -64  -0.0%     -64    Symbol Table
  -1.5%    -164 -11.3%    -148    [__DATA]
  -6.0%    -861  -6.0%    -861    [__TEXT]
  -0.0%     -88  [ = ]       0    TOTAL

Generated by 🚫 Danger

@nickdowell nickdowell requested a review from kattrali July 28, 2022 14:58
@nickdowell nickdowell merged commit 2942a09 into next Aug 8, 2022
@nickdowell nickdowell deleted the nickdowell/string-truncation branch August 8, 2022 07:18
@nickdowell nickdowell mentioned this pull request Aug 10, 2022
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