Files
codeql/cpp/ql/lib/semmle/code/cpp/security/SecurityOptions.qll
Andrew Eisenberg 2c5dd2dfa3 Packaging: Refactor the cpp libraries
This PR separates the core cpp packs into `codeql/cpp-queries` and
`codeql/cpp-all`.

There are very few lines of code changed. Almost all changes are moving
files around.
2021-08-17 11:22:36 -07:00

50 lines
1.8 KiB
Plaintext

/**
* Security pack options.
*
* see https://semmle.com/wiki/display/SD/_Configuring+SecurityOptions+for+your+code+base
*
* Please note that functions for MySql and SQLite are included by default and do not
* require any customization here.
*/
import semmle.code.cpp.security.Security
/**
* This class overrides `SecurityOptions` and can be used to add project
* specific customization.
*/
class CustomSecurityOptions extends SecurityOptions {
override predicate sqlArgument(string function, int arg) {
SecurityOptions.super.sqlArgument(function, arg)
or
// --- custom functions that access SQL code via one of their arguments:
// 'arg' is the 0-based index of the argument that contains an SQL string
// for example: (function = "MySpecialSqlFunction" and arg = 0)
none() // rules to match custom functions replace this line
}
override predicate userInputArgument(FunctionCall functionCall, int arg) {
SecurityOptions.super.userInputArgument(functionCall, arg)
or
exists(string fname |
functionCall.getTarget().hasGlobalName(fname) and
exists(functionCall.getArgument(arg)) and
// --- custom functions that return user input via one of their arguments:
// 'arg' is the 0-based index of the argument that is used to return user input
// for example: (fname = "readXmlInto" and arg = 1)
none() // rules to match custom functions replace this line
)
}
override predicate userInputReturned(FunctionCall functionCall) {
SecurityOptions.super.userInputReturned(functionCall)
or
exists(string fname |
functionCall.getTarget().hasGlobalName(fname) and
// --- custom functions that return user input via their return value:
// for example: fname = "xmlReadAttribute"
none() // rules to match custom functions replace this line
)
}
}