mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
C++: Replace hasQualifiedName by hasGlobalName in docs examples
This commit is contained in:
@@ -2,7 +2,7 @@ import cpp
|
||||
import semmle.code.cpp.dataflow.new.DataFlow
|
||||
|
||||
class GetenvSource extends DataFlow::Node {
|
||||
GetenvSource() { this.asIndirectExpr(1).(FunctionCall).getTarget().hasQualifiedName("getenv") }
|
||||
GetenvSource() { this.asIndirectExpr(1).(FunctionCall).getTarget().hasGlobalName("getenv") }
|
||||
}
|
||||
|
||||
class GetenvToGethostbynameConfiguration extends DataFlow::Configuration {
|
||||
|
||||
@@ -3,7 +3,7 @@ import semmle.code.cpp.dataflow.new.DataFlow
|
||||
|
||||
from Function fopen, FunctionCall fc, Expr src, DataFlow::Node source, DataFlow::Node sink
|
||||
where
|
||||
fopen.hasQualifiedName("fopen") and
|
||||
fopen.hasGlobalName("fopen") and
|
||||
fc.getTarget() = fopen and
|
||||
source.asIndirectExpr(1) = src and
|
||||
sink.asIndirectExpr(1) = fc.getArgument(0) and
|
||||
|
||||
@@ -7,14 +7,14 @@ class EnvironmentToFileConfiguration extends DataFlow::Configuration {
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Function getenv |
|
||||
source.asIndirectExpr(1).(FunctionCall).getTarget() = getenv and
|
||||
getenv.hasQualifiedName("getenv")
|
||||
getenv.hasGlobalName("getenv")
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(FunctionCall fc |
|
||||
sink.asIndirectExpr(1) = fc.getArgument(0) and
|
||||
fc.getTarget().hasQualifiedName("fopen")
|
||||
fc.getTarget().hasGlobalName("fopen")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import semmle.code.cpp.dataflow.new.DataFlow
|
||||
|
||||
from Function fopen, FunctionCall fc, Parameter p, DataFlow::Node source, DataFlow::Node sink
|
||||
where
|
||||
fopen.hasQualifiedName("fopen") and
|
||||
fopen.hasGlobalName("fopen") and
|
||||
fc.getTarget() = fopen and
|
||||
source.asParameter(1) = p and
|
||||
sink.asIndirectExpr(1) = fc.getArgument(0) and
|
||||
|
||||
@@ -2,6 +2,6 @@ import cpp
|
||||
|
||||
from Function fopen, FunctionCall fc
|
||||
where
|
||||
fopen.hasQualifiedName("fopen") and
|
||||
fopen.hasGlobalName("fopen") and
|
||||
fc.getTarget() = fopen
|
||||
select fc.getArgument(0)
|
||||
|
||||
@@ -97,7 +97,7 @@ The following query finds the filename passed to ``fopen``.
|
||||
|
||||
from Function fopen, FunctionCall fc
|
||||
where
|
||||
fopen.hasQualifiedName("fopen") and
|
||||
fopen.hasGlobalName("fopen") and
|
||||
fc.getTarget() = fopen
|
||||
select fc.getArgument(0)
|
||||
|
||||
@@ -110,7 +110,7 @@ Unfortunately, this will only give the expression in the argument, not the value
|
||||
|
||||
from Function fopen, FunctionCall fc, Expr src, DataFlow::Node source, DataFlow::Node sink
|
||||
where
|
||||
fopen.hasQualifiedName("fopen") and
|
||||
fopen.hasGlobalName("fopen") and
|
||||
fc.getTarget() = fopen and
|
||||
source.asIndirectExpr(1) = src and
|
||||
sink.asIndirectExpr(1) = fc.getArgument(0) and
|
||||
@@ -126,7 +126,7 @@ Then we can vary the source and, for example, use the parameter of a function. T
|
||||
|
||||
from Function fopen, FunctionCall fc, Parameter p, DataFlow::Node source, DataFlow::Node sink
|
||||
where
|
||||
fopen.hasQualifiedName("fopen") and
|
||||
fopen.hasGlobalName("fopen") and
|
||||
fc.getTarget() = fopen and
|
||||
source.asParameter(1) = p and
|
||||
sink.asIndirectExpr(1) = fc.getArgument(0) and
|
||||
@@ -253,14 +253,14 @@ The following data flow configuration tracks data flow from environment variable
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Function getenv |
|
||||
source.asIndirectExpr(1).(FunctionCall).getTarget() = getenv and
|
||||
getenv.hasQualifiedName("getenv")
|
||||
getenv.hasGlobalName("getenv")
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(FunctionCall fc |
|
||||
sink.asIndirectExpr(1) = fc.getArgument(0) and
|
||||
fc.getTarget().hasQualifiedName("fopen")
|
||||
fc.getTarget().hasGlobalName("fopen")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -386,7 +386,7 @@ Exercise 3
|
||||
import semmle.code.cpp.dataflow.new.DataFlow
|
||||
|
||||
class GetenvSource extends DataFlow::Node {
|
||||
GetenvSource() { this.asIndirectExpr(1).(FunctionCall).getTarget().hasQualifiedName("getenv") }
|
||||
GetenvSource() { this.asIndirectExpr(1).(FunctionCall).getTarget().hasGlobalName("getenv") }
|
||||
}
|
||||
|
||||
Exercise 4
|
||||
@@ -398,7 +398,7 @@ Exercise 4
|
||||
import semmle.code.cpp.dataflow.new.DataFlow
|
||||
|
||||
class GetenvSource extends DataFlow::Node {
|
||||
GetenvSource() { this.asIndirectExpr(1).(FunctionCall).getTarget().hasQualifiedName("getenv") }
|
||||
GetenvSource() { this.asIndirectExpr(1).(FunctionCall).getTarget().hasGlobalName("getenv") }
|
||||
}
|
||||
|
||||
class GetenvToGethostbynameConfiguration extends DataFlow::Configuration {
|
||||
|
||||
@@ -88,7 +88,7 @@ The following query finds the filename passed to ``fopen``.
|
||||
import cpp
|
||||
|
||||
from Function fopen, FunctionCall fc
|
||||
where fopen.hasQualifiedName("fopen")
|
||||
where fopen.hasGlobalName("fopen")
|
||||
and fc.getTarget() = fopen
|
||||
select fc.getArgument(0)
|
||||
|
||||
@@ -100,7 +100,7 @@ Unfortunately, this will only give the expression in the argument, not the value
|
||||
import semmle.code.cpp.dataflow.DataFlow
|
||||
|
||||
from Function fopen, FunctionCall fc, Expr src
|
||||
where fopen.hasQualifiedName("fopen")
|
||||
where fopen.hasGlobalName("fopen")
|
||||
and fc.getTarget() = fopen
|
||||
and DataFlow::localFlow(DataFlow::exprNode(src), DataFlow::exprNode(fc.getArgument(0)))
|
||||
select src
|
||||
@@ -113,7 +113,7 @@ Then we can vary the source and, for example, use the parameter of a function. T
|
||||
import semmle.code.cpp.dataflow.DataFlow
|
||||
|
||||
from Function fopen, FunctionCall fc, Parameter p
|
||||
where fopen.hasQualifiedName("fopen")
|
||||
where fopen.hasGlobalName("fopen")
|
||||
and fc.getTarget() = fopen
|
||||
and DataFlow::localFlow(DataFlow::parameterNode(p), DataFlow::exprNode(fc.getArgument(0)))
|
||||
select p
|
||||
@@ -236,14 +236,14 @@ The following data flow configuration tracks data flow from environment variable
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists (Function getenv |
|
||||
source.asExpr().(FunctionCall).getTarget() = getenv and
|
||||
getenv.hasQualifiedName("getenv")
|
||||
getenv.hasGlobalName("getenv")
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists (FunctionCall fc |
|
||||
sink.asExpr() = fc.getArgument(0) and
|
||||
fc.getTarget().hasQualifiedName("fopen")
|
||||
fc.getTarget().hasGlobalName("fopen")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ Exercise 3
|
||||
|
||||
class GetenvSource extends FunctionCall {
|
||||
GetenvSource() {
|
||||
this.getTarget().hasQualifiedName("getenv")
|
||||
this.getTarget().hasGlobalName("getenv")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ Exercise 4
|
||||
|
||||
class GetenvSource extends DataFlow::Node {
|
||||
GetenvSource() {
|
||||
this.asExpr().(FunctionCall).getTarget().hasQualifiedName("getenv")
|
||||
this.asExpr().(FunctionCall).getTarget().hasGlobalName("getenv")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user