Skip to content

Comments

feat(csv-stringify): Add escape_formulas to defend against injection attacks#380

Merged
wdavidw merged 2 commits intoadaltas:masterfrom
atlanteh:feature/escape_formulas
Mar 3, 2023
Merged

feat(csv-stringify): Add escape_formulas to defend against injection attacks#380
wdavidw merged 2 commits intoadaltas:masterfrom
atlanteh:feature/escape_formulas

Conversation

@atlanteh
Copy link
Contributor

@atlanteh atlanteh commented Feb 28, 2023

This PR allows setting simple parameter to defend against CSV injection attacks by adding escape_formulas parameter that escapes values that start with =, +, -, @, \t, or \r with a '

@atlanteh
Copy link
Contributor Author

atlanteh commented Mar 1, 2023

@wdavidw Can you please review?

}
});
quotedMatch = quotedMatch && quotedMatch.length > 0;
if (escape_formulas && ['=', '+', '-', '@', '\t', '\r'].includes(value[0])) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this happen in the __onField function ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think __onField is only in csv-parse. not csv-stringify

@atlanteh
Copy link
Contributor Author

atlanteh commented Mar 2, 2023

@wdavidw PR updated according to your review

@wdavidw
Copy link
Member

wdavidw commented Mar 3, 2023

Thank you for your contribution, I'll take it from there.

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