mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
Files library tests
This commit is contained in:
58
ql/test/library-tests/frameworks/Files.expected
Normal file
58
ql/test/library-tests/frameworks/Files.expected
Normal file
@@ -0,0 +1,58 @@
|
||||
fileInstances
|
||||
| Files.rb:2:1:2:30 | ... = ... |
|
||||
| Files.rb:2:1:2:30 | ... = ... |
|
||||
| Files.rb:2:12:2:30 | call to new |
|
||||
| Files.rb:3:1:3:21 | ... = ... |
|
||||
| Files.rb:3:1:3:21 | ... = ... |
|
||||
| Files.rb:3:14:3:21 | foo_file |
|
||||
| Files.rb:4:1:4:8 | foo_file |
|
||||
| Files.rb:7:13:7:22 | foo_file_2 |
|
||||
| Files.rb:10:6:10:13 | foo_file |
|
||||
| Files.rb:11:6:11:13 | foo_file |
|
||||
| Files.rb:23:1:23:33 | ... = ... |
|
||||
| Files.rb:23:19:23:33 | call to open |
|
||||
| Files.rb:24:1:24:40 | ... = ... |
|
||||
| Files.rb:24:19:24:40 | call to open |
|
||||
ioInstances
|
||||
| Files.rb:2:1:2:30 | ... = ... |
|
||||
| Files.rb:2:1:2:30 | ... = ... |
|
||||
| Files.rb:2:12:2:30 | call to new |
|
||||
| Files.rb:3:1:3:21 | ... = ... |
|
||||
| Files.rb:3:1:3:21 | ... = ... |
|
||||
| Files.rb:3:14:3:21 | foo_file |
|
||||
| Files.rb:4:1:4:8 | foo_file |
|
||||
| Files.rb:7:13:7:22 | foo_file_2 |
|
||||
| Files.rb:10:6:10:13 | foo_file |
|
||||
| Files.rb:11:6:11:13 | foo_file |
|
||||
| Files.rb:17:1:17:50 | ... = ... |
|
||||
| Files.rb:17:1:17:50 | ... = ... |
|
||||
| Files.rb:17:8:17:50 | call to new |
|
||||
| Files.rb:18:1:18:13 | ... = ... |
|
||||
| Files.rb:18:10:18:13 | rand |
|
||||
| Files.rb:20:13:20:16 | rand |
|
||||
| Files.rb:23:1:23:33 | ... = ... |
|
||||
| Files.rb:23:19:23:33 | call to open |
|
||||
| Files.rb:24:1:24:40 | ... = ... |
|
||||
| Files.rb:24:19:24:40 | call to open |
|
||||
fileReaders
|
||||
| Files.rb:7:13:7:32 | call to readlines |
|
||||
ioReaders
|
||||
| Files.rb:7:13:7:32 | call to readlines | File |
|
||||
| Files.rb:20:13:20:25 | call to read | IO |
|
||||
| Files.rb:29:12:29:29 | call to read | IO |
|
||||
| Files.rb:32:8:32:23 | call to read | IO |
|
||||
ioFileReaders
|
||||
| Files.rb:7:13:7:32 | call to readlines | File |
|
||||
| Files.rb:29:12:29:29 | call to read | IO |
|
||||
fileModuleFilenameSources
|
||||
| Files.rb:10:6:10:18 | call to path |
|
||||
| Files.rb:11:6:11:21 | call to to_path |
|
||||
fileUtilsFilenameSources
|
||||
| Files.rb:14:8:14:43 | call to makedirs |
|
||||
fileSystemReadAccesses
|
||||
| Files.rb:7:13:7:32 | call to readlines |
|
||||
| Files.rb:29:12:29:29 | call to read |
|
||||
fileNameSources
|
||||
| Files.rb:10:6:10:18 | call to path |
|
||||
| Files.rb:11:6:11:21 | call to to_path |
|
||||
| Files.rb:14:8:14:43 | call to makedirs |
|
||||
21
ql/test/library-tests/frameworks/Files.ql
Normal file
21
ql/test/library-tests/frameworks/Files.ql
Normal file
@@ -0,0 +1,21 @@
|
||||
private import ruby
|
||||
private import codeql.ruby.frameworks.Files
|
||||
private import codeql.ruby.Concepts
|
||||
|
||||
query predicate fileInstances(File::FileInstance i) { any() }
|
||||
|
||||
query predicate ioInstances(IO::IOInstance i) { any() }
|
||||
|
||||
query predicate fileReaders(File::FileModuleReader r) { any() }
|
||||
|
||||
query predicate ioReaders(IO::IOReader r, string api) { api = r.getAPI() }
|
||||
|
||||
query predicate ioFileReaders(IO::IOFileReader r, string api) { api = r.getAPI() }
|
||||
|
||||
query predicate fileModuleFilenameSources(File::FileModuleFilenameSource s) { any() }
|
||||
|
||||
query predicate fileUtilsFilenameSources(FileUtils::FileUtilsFilenameSource s) { any() }
|
||||
|
||||
query predicate fileSystemReadAccesses(FileSystemReadAccess a) { any() }
|
||||
|
||||
query predicate fileNameSources(FileNameSource s) { any() }
|
||||
32
ql/test/library-tests/frameworks/Files.rb
Normal file
32
ql/test/library-tests/frameworks/Files.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
# `foo_file` is a `File` instance
|
||||
foo_file = File.new("foo.txt")
|
||||
foo_file_2 = foo_file
|
||||
foo_file
|
||||
|
||||
# File read access
|
||||
foo_lines = foo_file_2.readlines
|
||||
|
||||
# `fp` is a file path
|
||||
fp = foo_file.path
|
||||
fp = foo_file.to_path
|
||||
|
||||
# `FileUtils.makedirs` returns an array of file names
|
||||
dirs = FileUtils.makedirs(["dir1", "dir2"])
|
||||
|
||||
# `rand` is an `IO` instance
|
||||
rand = IO.new(IO.sysopen("/dev/random", "r"), "r")
|
||||
rand_2 = rand
|
||||
|
||||
rand_data = rand.read(32)
|
||||
|
||||
# `foo_file_kernel` is a `File` instance
|
||||
foo_file_kernel = open("foo.txt")
|
||||
foo_file_kernel = Kernel.open("foo.txt")
|
||||
|
||||
foo_command_kernel = open("|ls")
|
||||
|
||||
# `IO.read("foo.txt")` reads from a file
|
||||
foo_text = IO.read("foo.txt")
|
||||
|
||||
# `IO.read("|date")` does not read from a file
|
||||
date = IO.read("|date")
|
||||
Reference in New Issue
Block a user