Skip to content

Commit 2e129a2

Browse files
consider constant declarations
1 parent 90b82eb commit 2e129a2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main/java/com/trivadis/tvdcc/validators/SQLInjection.xtend

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import org.eclipse.xtext.EcoreUtil2
4646
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
4747
import org.eclipse.xtext.validation.Check
4848
import org.eclipse.xtext.validation.EValidatorRegistrar
49+
import com.trivadis.oracle.plsql.plsql.ConstantDeclaration
4950

5051
class SQLInjection extends PLSQLValidator implements PLSQLCopValidator {
5152
HashMap<Integer, PLSQLCopGuideline> guidelines
@@ -315,13 +316,22 @@ class SQLInjection extends PLSQLValidator implements PLSQLCopValidator {
315316
}
316317
val declareSection = body.declareSection
317318
if (declareSection !== null) {
318-
val variable = EcoreUtil2.getAllContentsOfType(declareSection, VariableDeclaration).findFirst [
319+
var EObject varOrConst = EcoreUtil2.getAllContentsOfType(declareSection, VariableDeclaration).findFirst [
319320
it.variable.value.equalsIgnoreCase(n.value) && it.getDefault() !== null
320321
]
321-
if (variable !== null) {
322-
for (name : getRelevantSimplExpressionNameValues(variable.getDefault())) {
322+
if (varOrConst !== null) {
323+
for (name : getRelevantSimplExpressionNameValues((varOrConst as VariableDeclaration).getDefault())) {
323324
expressions.put(name.value.toLowerCase, name)
324325
}
326+
} else {
327+
varOrConst = EcoreUtil2.getAllContentsOfType(declareSection, ConstantDeclaration).findFirst [
328+
it.constant.value.equalsIgnoreCase(n.value) && it.getDefault() !== null
329+
]
330+
if (varOrConst !== null) {
331+
for (name : getRelevantSimplExpressionNameValues((varOrConst as ConstantDeclaration).getDefault())) {
332+
expressions.put(name.value.toLowerCase, name)
333+
}
334+
}
325335
}
326336
}
327337
return expressions;

0 commit comments

Comments
 (0)