JS: Modeling of underscore.string package#19049
Merged
Napalys merged 24 commits intogithub:mainfrom Mar 20, 2025
Merged
Conversation
… sources points.
…e it return simple string.
b299373 to
3a069f9
Compare
Co-authored-by: Asgerf <asgerf@github.com>
3a069f9 to
922a07d
Compare
asgerf
reviewed
Mar 20, 2025
| extensible: summaryModel | ||
| data: | ||
| - ["'underscore.string'", "Member[slugify,capitalize,decapitalize,clean,cleanDiacritics,swapCase,escapeHTML,unescapeHTML,wrap,dedent,reverse,pred,succ,titleize,camelize,classify,underscored,dasherize,humanize,trim,ltrim,rtrim,truncate,sprintf,strRight,strRightBack,strLeft,strLeftBack,stripTags,unquote,map]", "Argument[0]", "ReturnValue", "taint"] | ||
| - ["'underscore.string'", "Member[chop,chars,words,lines]", "Argument[0]", "ReturnValue", "taint"] |
Contributor
There was a problem hiding this comment.
Suggested change
| - ["'underscore.string'", "Member[chop,chars,words,lines]", "Argument[0]", "ReturnValue", "taint"] | |
| - ["'underscore.string'", "Member[chop,chars,words,lines]", "Argument[0]", "ReturnValue.ArrayElement", "taint"] |
This is a bit more precise.
If the whole return value is tainted, the analysis thinks all its properties are tainted too, including .length. You could try adding the test:
sink(s.chop(source("s1"), 3).length);
Contributor
Author
There was a problem hiding this comment.
It looks like there is still something off with ArrayElement f4ca2dc?
Contributor
There was a problem hiding this comment.
Some of the tests have a typo, they should access the [0] on the returned array, not on the source string:
sink(s.chars(source("s2")[0])) -> sink(s.chars(source("s2"))[0])I know why the last test is failing but it's complicated. Would you mind leaving it as MISSING: for now?
javascript/ql/lib/semmle/javascript/frameworks/UnderscoreDotString.qll
Outdated
Show resolved
Hide resolved
javascript/ql/lib/semmle/javascript/frameworks/UnderscoreDotString.qll
Dismissed
Show dismissed
Hide dismissed
asgerf
approved these changes
Mar 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds package modeling for
underscore.string.