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

Regexes: Sanitize user input #1624

Merged
merged 4 commits into from
Jun 11, 2024
Merged

Conversation

franzpoeschel
Copy link
Contributor

For detecting files of file-based encoding, we use Regexes and emplace user input into them. This might lead to Regex injection when the file name contains a special character, e.g. openpmd-ls simData_+10_1_%T.bp5. Fix that.

src/Series.cpp Outdated Show resolved Hide resolved
src/Series.cpp Outdated
Comment on lines 3054 to 3058
auto sanitize_regex(std::string const &input) -> std::string
{
std::regex specialChars{R"([-[\]{}()*+?.,\^$|#\s])"};
return std::regex_replace(input, specialChars, R"(\$&)");
}
Copy link
Member

@ax3l ax3l Jun 11, 2024

Choose a reason for hiding this comment

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

src/Series.cpp Outdated Show resolved Hide resolved
@ax3l ax3l added this to the 0.16.0 milestone Jun 11, 2024
@ax3l ax3l merged commit a207118 into openPMD:dev Jun 11, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants