mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
Merge pull request #6994 from erik-krogh/redundant-cast
Approved by RasmusWL, aschackmull, esbena, geoffw0, hvitved, nickrolfe
This commit is contained in:
@@ -126,10 +126,7 @@ DataFlow::Node getASubexpressionWithinQuery(DataFlow::Node query) {
|
||||
exists(DataFlow::SourceNode receiver |
|
||||
receiver.flowsTo(getASubexpressionWithinQuery*(query.getALocalSource())) and
|
||||
result =
|
||||
[
|
||||
receiver.(DataFlow::SourceNode).getAPropertyWrite().getRhs(),
|
||||
receiver.(DataFlow::ArrayCreationNode).getAnElement()
|
||||
]
|
||||
[receiver.getAPropertyWrite().getRhs(), receiver.(DataFlow::ArrayCreationNode).getAnElement()]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -658,7 +658,7 @@ abstract class ReExportDeclaration extends ExportDeclaration {
|
||||
cached
|
||||
Module getReExportedModule() {
|
||||
Stages::Imports::ref() and
|
||||
result.getFile() = getEnclosingModule().resolve(getImportedPath().(PathExpr))
|
||||
result.getFile() = getEnclosingModule().resolve(getImportedPath())
|
||||
or
|
||||
result = resolveFromTypeRoot()
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ module PrintHTML {
|
||||
childIndex = -1 and result.(HTMLAttributesNodes).getElement() = element
|
||||
or
|
||||
exists(HTML::Element child | result.(HTMLElementNode).getElement() = child |
|
||||
child = element.(HTML::Element).getChild(childIndex)
|
||||
child = element.getChild(childIndex)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ pragma[nomagic]
|
||||
predicate isAnalyzedParameter(Parameter p) {
|
||||
exists(FunctionWithAnalyzedParameters f, int parmIdx | p = f.getParameter(parmIdx) |
|
||||
// we cannot track flow into rest parameters
|
||||
not p.(Parameter).isRestParameter()
|
||||
not p.isRestParameter()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ private class AnalyzedNewExpr extends DataFlow::AnalyzedValueNode {
|
||||
*/
|
||||
private predicate isIndefinite() {
|
||||
exists(DataFlow::AnalyzedNode callee, AbstractValue calleeVal |
|
||||
callee = astNode.(NewExpr).getCallee().analyze() and
|
||||
callee = astNode.getCallee().analyze() and
|
||||
calleeVal = callee.getALocalValue()
|
||||
|
|
||||
calleeVal.isIndefinite(_) or
|
||||
@@ -217,7 +217,7 @@ private class NewInstance extends DataFlow::AnalyzedValueNode {
|
||||
|
||||
override AbstractValue getALocalValue() {
|
||||
exists(DataFlow::AnalyzedNode callee |
|
||||
callee = astNode.(NewExpr).getCallee().analyze() and
|
||||
callee = astNode.getCallee().analyze() and
|
||||
result = TAbstractInstance(callee.getALocalValue())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ private class JQueryDomElementDefinition extends DOM::ElementDefinition, @call_e
|
||||
JQueryDomElementDefinition() {
|
||||
this = call and
|
||||
call = jquery().getACall().asExpr() and
|
||||
exists(string s | s = call.getArgument(0).(Expr).getStringValue() |
|
||||
exists(string s | s = call.getArgument(0).getStringValue() |
|
||||
// match an opening angle bracket followed by a tag name, followed by arbitrary
|
||||
// text and a closing angle bracket, potentially with whitespace in between
|
||||
tagName = s.regexpCapture("\\s*<\\s*(\\w+)\\b[^>]*>\\s*", 1).toLowerCase()
|
||||
|
||||
@@ -317,7 +317,7 @@ module PrettyPrintCatCall {
|
||||
*/
|
||||
string createFileThatIsReadFromCommandList(CommandCall call) {
|
||||
exists(DataFlow::ArrayCreationNode array, DataFlow::Node element |
|
||||
array = call.getArgumentList().(DataFlow::ArrayCreationNode) and
|
||||
array = call.getArgumentList() and
|
||||
array.getSize() = 1 and
|
||||
element = array.getElement(0)
|
||||
|
|
||||
|
||||
@@ -526,9 +526,7 @@ module ReflectedXss {
|
||||
* ```
|
||||
*/
|
||||
predicate isLocalHeaderDefinition(HTTP::HeaderDefinition header) {
|
||||
exists(ReachableBasicBlock headerBlock |
|
||||
headerBlock = header.getBasicBlock().(ReachableBasicBlock)
|
||||
|
|
||||
exists(ReachableBasicBlock headerBlock | headerBlock = header.getBasicBlock() |
|
||||
1 =
|
||||
strictcount(HTTP::ResponseSendArgument sender |
|
||||
sender.getRouteHandler() = header.getRouteHandler() and
|
||||
|
||||
@@ -4,5 +4,5 @@ from ClassDefinition class_, FieldDefinition field
|
||||
where
|
||||
class_.getAField() = field and
|
||||
field.isStatic() and
|
||||
field.getInit().getFirstControlFlowNode().getAPredecessor*() = class_.(ControlFlowNode)
|
||||
field.getInit().getFirstControlFlowNode().getAPredecessor*() = class_
|
||||
select field, "Field initializer occurs after its class is created"
|
||||
|
||||
@@ -4,4 +4,4 @@ from FunctionWithAnalyzedParameters f, SimpleParameter p, AnalyzedVarDef var
|
||||
where
|
||||
f.argumentPassing(p, _) and
|
||||
var.getAVariable() = p.getVariable()
|
||||
select p, var.(AnalyzedVarDef).getAnAssignedValue()
|
||||
select p, var.getAnAssignedValue()
|
||||
|
||||
Reference in New Issue
Block a user