use of org.apache.bcel.generic.Type in project fb-contrib by mebigfatguy.
the class JAXRSIssues method processJAXRSMethod.
private void processJAXRSMethod(Method m, String path, boolean hasConsumes) {
Type[] parmTypes = m.getArgumentTypes();
int numParms = parmTypes.length;
if (numParms > 0) {
boolean sawBareParm = false;
ParameterAnnotationEntry[] pes = m.getParameterAnnotationEntries();
int parmIndex = 0;
for (ParameterAnnotationEntry pe : pes) {
boolean foundParamAnnotation = false;
for (AnnotationEntry a : pe.getAnnotationEntries()) {
String annotationType = a.getAnnotationType();
if (PARAM_ANNOTATIONS.contains(annotationType)) {
foundParamAnnotation = true;
if ((path != null) && "Ljavax/ws/rs/PathParam;".equals(annotationType)) {
String parmPath = getDefaultAnnotationValue(a);
if ((parmPath != null) && (!path.matches(".*\\{" + parmPath + "\\b.*"))) {
bugReporter.reportBug(new BugInstance(this, BugType.JXI_PARM_PARAM_NOT_FOUND_IN_PATH.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addString("Path param: " + parmPath));
}
} else if ("Ljavax/ws/rs/core/Context;".equals(annotationType)) {
String parmSig = parmTypes[parmIndex].getSignature();
if (!VALID_CONTEXT_TYPES.contains(parmSig)) {
bugReporter.reportBug(new BugInstance(this, BugType.JXI_INVALID_CONTEXT_PARAMETER_TYPE.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addString("Parameter signature: " + parmSig));
}
}
}
}
if (!foundParamAnnotation) {
if ((!sawBareParm) && (hasConsumes || NATIVE_JAXRS_TYPES.contains(parmTypes[parmIndex].getSignature()))) {
sawBareParm = true;
} else {
bugReporter.reportBug(new BugInstance(this, BugType.JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addString("Parameter " + (parmIndex + 1)));
break;
}
}
parmIndex++;
}
}
}
use of org.apache.bcel.generic.Type in project fb-contrib by mebigfatguy.
the class ArrayIndexOutOfBounds method visitCode.
/**
* overrides the visitor to collect parameter registers
*
* @param obj
* the code block of the currently parsed method
*/
@Override
public void visitCode(Code obj) {
Method m = getMethod();
stack.resetForMethodEntry(this);
initializedRegs.clear();
modifyRegs.clear();
Type[] argTypes = m.getArgumentTypes();
int arg = m.isStatic() ? 0 : 1;
for (Type argType : argTypes) {
String argSig = argType.getSignature();
initializedRegs.set(arg);
arg += SignatureUtils.getSignatureSize(argSig);
}
nullStoreToLocation.clear();
super.visitCode(obj);
for (Integer pc : nullStoreToLocation.values()) {
bugReporter.reportBug(new BugInstance(this, BugType.AIOB_ARRAY_STORE_TO_NULL_REFERENCE.name(), HIGH_PRIORITY).addClass(this).addMethod(this).addSourceLine(this, pc.intValue()));
}
}
Aggregations