mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Ruby: Recognise File.atomic_write as a file writer
This method is an ActiveSupport extension, but there's no harm in recognising it universally as any identically-named method is likely to also be a file writer.
This commit is contained in:
@@ -137,7 +137,7 @@ class IOOrFileWriteMethodCall extends IOOrFileMethodCall {
|
||||
receiverKind = "class" and
|
||||
api = ["IO", "File"] and
|
||||
this = API::getTopLevelMember(api).getAMethodCall(methodName) and
|
||||
methodName = ["binwrite", "write"] and
|
||||
methodName = ["binwrite", "write", "atomic_write"] and
|
||||
dataNode = this.getArgument(1)
|
||||
or
|
||||
// e.g. `{IO,File}.new("foo.txt", "a+).puts("hello")`
|
||||
|
||||
@@ -76,6 +76,8 @@ fileSystemAccesses
|
||||
| Files.rb:41:1:41:26 | call to open |
|
||||
| Files.rb:41:1:41:43 | call to write |
|
||||
| Files.rb:48:1:48:40 | call to printf |
|
||||
| Files.rb:49:1:49:30 | call to write |
|
||||
| Files.rb:50:1:50:37 | call to atomic_write |
|
||||
fileNameSources
|
||||
| Files.rb:10:6:10:18 | call to path |
|
||||
| Files.rb:11:6:11:21 | call to to_path |
|
||||
@@ -86,7 +88,11 @@ fileWriters
|
||||
| Files.rb:40:1:40:22 | call to puts |
|
||||
| Files.rb:41:1:41:43 | call to write |
|
||||
| Files.rb:48:1:48:40 | call to printf |
|
||||
| Files.rb:49:1:49:30 | call to write |
|
||||
| Files.rb:50:1:50:37 | call to atomic_write |
|
||||
fileSystemWriteAccesses
|
||||
| Files.rb:40:1:40:22 | call to puts |
|
||||
| Files.rb:41:1:41:43 | call to write |
|
||||
| Files.rb:48:1:48:40 | call to printf |
|
||||
| Files.rb:49:1:49:30 | call to write |
|
||||
| Files.rb:50:1:50:37 | call to atomic_write |
|
||||
|
||||
@@ -46,3 +46,5 @@ str_1 = "hello"
|
||||
int_1 = 123
|
||||
# File/IO write
|
||||
io_file.printf("%s: %d\n", str_1, int_1)
|
||||
File.write("foo.txt", "hello")
|
||||
File.atomic_write("foo.txt", "hello")
|
||||
|
||||
Reference in New Issue
Block a user