-
Notifications
You must be signed in to change notification settings - Fork 82
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
Fix security issues of the argument parser #1133
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes. I have one open question otherwise looks good :)
@@ -88,27 +90,12 @@ class version_checker | |||
#endif | |||
std::smatch versionMatch; | |||
|
|||
// Ensure version string is not corrupt | |||
if (!version_.empty() && /*regex allows version prefix instead of exact match */ | |||
std::regex_search(version_, versionMatch, std::regex("^([[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+).*"))) | |||
{ | |||
version = versionMatch.str(1); // in case the git revision number is given take only version number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So version = "MALICIOUS CODE";
stays the same, because it does not match the regex and will therefore not be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(note the underscore difference)
if version_ == "some malicious code not matching the regex"
then the member version
will never be set inside the if clause and remains the default "0.0.0"
.
Is the "zusammenploebbeln" of the command more clear now with the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AH okay, I didn't catch the underscore.
Is the "zusammenploebbeln" of the command more clear now with the changes?
👍
Hmm jenkins and travis are failing.
|
{ | ||
const char * argv[] = {"./argument_parser_test"}; | ||
|
||
EXPECT_NO_THROW((argument_parser parser{"test_parser", 1, argv})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should do this:
EXPECT_NO_THROW((argument_parser parser{"test_parser", 1, argv})); | |
EXPECT_NO_THROW((argument_parser{"test_parser", 1, argv})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or
EXPECT_NO_THROW((argument_parser parser{"test_parser", 1, argv})); | |
EXPECT_NO_THROW(([]() | |
{ | |
argument_parser parser{"test_parser", 1, argv}; | |
}())); |
21d200b
to
7fd7ac1
Compare
Codecov Report
@@ Coverage Diff @@
## master #1133 +/- ##
==========================================
+ Coverage 96.42% 96.43% +<.01%
==========================================
Files 196 196
Lines 7757 7761 +4
==========================================
+ Hits 7480 7484 +4
Misses 277 277
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one minor docu comment. Otherwise looks good
7fd7ac1
to
f0c9154
Compare
@@ -166,6 +167,10 @@ class argument_parser | |||
* \param[in] argv The command line arguments to parse. | |||
* \param[in] version_check Notify users about app version updates (default true). | |||
* | |||
* \throws seqan3::parser_design_error if the application name contains illegal characters. | |||
* | |||
* The application name must only contain alpha-numeric characters or '_' and '-' (regex: \"^[a-zA-Z0-9_-]+$\"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The application name must only contain alpha-numeric characters or '_' and '-' (regex: \"^[a-zA-Z0-9_-]+$\"). | |
* The application name must only contain alpha-numeric characters, '_' or '-', i.e. the following regex must evaluate to true: `\"^[a-zA-Z0-9_-]+$\"`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little update of the comment 💅
ac0915a
to
3c37f5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor request.
…he first variable in PATH.
…ty leaks of the version call.
3c37f5a
to
ebfee17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Addresses several things of #1101
Best reviewd commit by commit.