-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ruby: Model Mime::Type #9918
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
Ruby: Model Mime::Type #9918
Conversation
Put routing modelling inside a Routing module.
This allows frameworks to add new instances where a node is interpreted as a regular expression. We introduce a class RegExpInterpretation::Range that represents these nodes. In the future we may want to make this a full Concept, but it's not necessary at the moment.
Add type summaries to recognise instances of Mime::Type, and recognise arguments to Mime::Type.match? and Mime::Type.=~ as regular expression interpretations.
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.
Looks good to me. Let's add a change note and fix the QLDoc warning.
ruby/ql/lib/codeql/ruby/Regexp.qll
Outdated
/** | ||
* Holds if `source` may be interpreted as a regular expression. | ||
* Nodes interpreted as regular expressions via various standard library methods. |
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.
Let's address The QLDoc for a class should start with 'A', 'An', or 'The'.
warning.
row = | ||
[ | ||
// Mime[type] : Mime::Type (omitted) | ||
// Method names with brackets like [] cannot be represented in MaD. |
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.
@asgerf Is there a way to escape [
and ]
symbols in a member name?
Mime::Type#match?
andMime::Type#=~
convert their argument to a regular expression, so they're relevant for queries like ReDoS. This PR adds modeling forMime::Type
so we recognise instances of it and consider arguments these two methods to be regular expressions.