@@ -46,6 +46,7 @@ import org.eclipse.xtext.EcoreUtil2
4646import org.eclipse.xtext.nodemodel.util.NodeModelUtils
4747import org.eclipse.xtext.validation.Check
4848import org.eclipse.xtext.validation.EValidatorRegistrar
49+ import com.trivadis.oracle.plsql.plsql.ConstantDeclaration
4950
5051class 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