mirror of
https://github.com/github/codeql.git
synced 2026-01-29 22:32:58 +01:00
Move existing OS (all caps name) module classes to stdlib.Os module (notice the camelcase name)
This commit is contained in:
@@ -395,87 +395,6 @@ module IoUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/** Provides models of commonly used functions in the `os` package. */
|
||||
module OS {
|
||||
/**
|
||||
* A call to a function in `os` that accesses the file system.
|
||||
*/
|
||||
private class OsFileSystemAccess extends FileSystemAccess::Range, DataFlow::CallNode {
|
||||
int pathidx;
|
||||
|
||||
OsFileSystemAccess() {
|
||||
exists(string fn | getTarget().hasQualifiedName("os", fn) |
|
||||
fn = "Chdir" and pathidx = 0
|
||||
or
|
||||
fn = "Chmod" and pathidx = 0
|
||||
or
|
||||
fn = "Chown" and pathidx = 0
|
||||
or
|
||||
fn = "Chtimes" and pathidx = 0
|
||||
or
|
||||
fn = "Create" and pathidx = 0
|
||||
or
|
||||
fn = "Lchown" and pathidx = 0
|
||||
or
|
||||
fn = "Link" and pathidx in [0 .. 1]
|
||||
or
|
||||
fn = "Lstat" and pathidx = 0
|
||||
or
|
||||
fn = "Mkdir" and pathidx = 0
|
||||
or
|
||||
fn = "MkdirAll" and pathidx = 0
|
||||
or
|
||||
fn = "NewFile" and pathidx = 1
|
||||
or
|
||||
fn = "Open" and pathidx = 0
|
||||
or
|
||||
fn = "OpenFile" and pathidx = 0
|
||||
or
|
||||
fn = "Readlink" and pathidx = 0
|
||||
or
|
||||
fn = "Remove" and pathidx = 0
|
||||
or
|
||||
fn = "RemoveAll" and pathidx = 0
|
||||
or
|
||||
fn = "Rename" and pathidx in [0 .. 1]
|
||||
or
|
||||
fn = "Stat" and pathidx = 0
|
||||
or
|
||||
fn = "Symlink" and pathidx in [0 .. 1]
|
||||
or
|
||||
fn = "Truncate" and pathidx = 0
|
||||
)
|
||||
}
|
||||
|
||||
override DataFlow::Node getAPathArgument() { result = getArgument(pathidx) }
|
||||
}
|
||||
|
||||
/** The `Expand` function. */
|
||||
class Expand extends TaintTracking::FunctionModel {
|
||||
Expand() { hasQualifiedName("os", "Expand") }
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
|
||||
inp.isParameter(0) and outp.isResult()
|
||||
}
|
||||
}
|
||||
|
||||
/** The `ExpandEnv` function. */
|
||||
class ExpandEnv extends TaintTracking::FunctionModel {
|
||||
ExpandEnv() { hasQualifiedName("os", "ExpandEnv") }
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
|
||||
inp.isParameter(0) and outp.isResult()
|
||||
}
|
||||
}
|
||||
|
||||
/** The `os.Exit` function, which ends the process. */
|
||||
private class Exit extends Function {
|
||||
Exit() { hasQualifiedName("os", "Exit") }
|
||||
|
||||
override predicate mayReturnNormally() { none() }
|
||||
}
|
||||
}
|
||||
|
||||
/** Provides a class for modeling functions which convert strings into integers. */
|
||||
module IntegerParser {
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,66 @@ import go
|
||||
|
||||
/** Provides models of commonly used functions in the `os` package. */
|
||||
module Os {
|
||||
/**
|
||||
* A call to a function in `os` that accesses the file system.
|
||||
*/
|
||||
private class OsFileSystemAccess extends FileSystemAccess::Range, DataFlow::CallNode {
|
||||
int pathidx;
|
||||
|
||||
OsFileSystemAccess() {
|
||||
exists(string fn | getTarget().hasQualifiedName("os", fn) |
|
||||
fn = "Chdir" and pathidx = 0
|
||||
or
|
||||
fn = "Chmod" and pathidx = 0
|
||||
or
|
||||
fn = "Chown" and pathidx = 0
|
||||
or
|
||||
fn = "Chtimes" and pathidx = 0
|
||||
or
|
||||
fn = "Create" and pathidx = 0
|
||||
or
|
||||
fn = "Lchown" and pathidx = 0
|
||||
or
|
||||
fn = "Link" and pathidx in [0 .. 1]
|
||||
or
|
||||
fn = "Lstat" and pathidx = 0
|
||||
or
|
||||
fn = "Mkdir" and pathidx = 0
|
||||
or
|
||||
fn = "MkdirAll" and pathidx = 0
|
||||
or
|
||||
fn = "NewFile" and pathidx = 1
|
||||
or
|
||||
fn = "Open" and pathidx = 0
|
||||
or
|
||||
fn = "OpenFile" and pathidx = 0
|
||||
or
|
||||
fn = "Readlink" and pathidx = 0
|
||||
or
|
||||
fn = "Remove" and pathidx = 0
|
||||
or
|
||||
fn = "RemoveAll" and pathidx = 0
|
||||
or
|
||||
fn = "Rename" and pathidx in [0 .. 1]
|
||||
or
|
||||
fn = "Stat" and pathidx = 0
|
||||
or
|
||||
fn = "Symlink" and pathidx in [0 .. 1]
|
||||
or
|
||||
fn = "Truncate" and pathidx = 0
|
||||
)
|
||||
}
|
||||
|
||||
override DataFlow::Node getAPathArgument() { result = getArgument(pathidx) }
|
||||
}
|
||||
|
||||
/** The `os.Exit` function, which ends the process. */
|
||||
private class Exit extends Function {
|
||||
Exit() { hasQualifiedName("os", "Exit") }
|
||||
|
||||
override predicate mayReturnNormally() { none() }
|
||||
}
|
||||
|
||||
private class FunctionModels extends TaintTracking::FunctionModel {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
Reference in New Issue
Block a user