Ruby: Simplify flow summaries for hash literals#9976
Merged
hvitved merged 2 commits intogithub:mainfrom Aug 10, 2022
Merged
Conversation
hmac
previously approved these changes
Aug 9, 2022
Contributor
hmac
left a comment
There was a problem hiding this comment.
Nice. As an optional addition, I thought it might be nice to add these two variants to the existing hash-flow.rb tests. I added them locally to confirm that things were working as expected.
diff --git a/ruby/ql/test/library-tests/dataflow/hash-flow/hash_flow.rb b/ruby/ql/test/library-tests/dataflow/hash-flow/hash_flow.rb
index f9de83dd47..06c57336a4 100644
--- a/ruby/ql/test/library-tests/dataflow/hash-flow/hash_flow.rb
+++ b/ruby/ql/test/library-tests/dataflow/hash-flow/hash_flow.rb
@@ -68,6 +68,14 @@ def m3()
hash4 = Hash[:a, taint(3.4), :b, 1]
sink(hash4[:a]) # $ hasValueFlow=3.4
sink(hash4[:b])
+
+ hash5 = Hash["a" => taint(3.4), "b" => 1]
+ sink(hash5["a"]) # $ hasValueFlow=3.4
+ sink(hash5["b"])
+
+ hash6 = Hash[{"a" => taint(3.4), "b" => 1}]
+ sink(hash6["a"]) # $ hasValueFlow=3.4
+ sink(hash6["b"])
end
m3()
@@ -746,4 +754,4 @@ def m45()
sink(hash[:h])
end
-m45()
\ No newline at end of file
+m45()But it doesn't need to block this PR
Contributor
Author
|
Thanks, I'll add the additional tests. |
hmac
approved these changes
Aug 9, 2022
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.
The existing summaries could be simplified using the models-as-data token
Argument[hash-splat], which refers to both keyword arguments wrapped in an implicit hash, as well as explicit hash splat arguments.