use of com.mebigfatguy.fbcontrib.utils.FQMethod in project fb-contrib by mebigfatguy.
the class MoreDumbMethods method getFQMethod.
private FQMethod getFQMethod() {
final String className = getClassConstantOperand();
final String methodName = getNameConstantOperand();
final String methodSig = getSigConstantOperand();
return new FQMethod(className, methodName, methodSig);
}
use of com.mebigfatguy.fbcontrib.utils.FQMethod in project fb-contrib by mebigfatguy.
the class MoreDumbMethods method visitClassContext.
@Override
public void visitClassContext(ClassContext classContext) {
if (classContext.getJavaClass().getMajor() <= MAJOR_1_5) {
dumbMethods.put(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, SignatureBuilder.SIG_VOID_TO_VOID), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY));
dumbMethods.put(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, byteArrayToVoid), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY));
dumbMethods.put(new FQMethod("java/security/SecureRandom", "getSeed", intToByteArray), new ReportInfo("MDM_SECURERANDOM", LOW_PRIORITY));
} else {
dumbMethods.remove(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, SignatureBuilder.SIG_VOID_TO_VOID));
dumbMethods.remove(new FQMethod("java/security/SecureRandom", Values.CONSTRUCTOR, byteArrayToVoid));
dumbMethods.remove(new FQMethod("java/security/SecureRandom", "getSeed", intToByteArray));
}
super.visitClassContext(classContext);
}
use of com.mebigfatguy.fbcontrib.utils.FQMethod in project fb-contrib by mebigfatguy.
the class NonCollectionMethodUse method sawOpcode.
/**
* implements the visitor to look for method calls that are one of the old pre-collections1.2 set of methods
*
* @param seen
* the currently parsed opcode
*/
@Override
public void sawOpcode(int seen) {
if (seen == INVOKEVIRTUAL) {
String className = getClassConstantOperand();
String methodName = getNameConstantOperand();
String methodSig = getSigConstantOperand();
FQMethod methodInfo = new FQMethod(className, methodName, methodSig);
if (oldMethods.contains(methodInfo)) {
bugReporter.reportBug(new BugInstance(this, BugType.NCMU_NON_COLLECTION_METHOD_USE.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
}
}
}
use of com.mebigfatguy.fbcontrib.utils.FQMethod in project fb-contrib by mebigfatguy.
the class Section508Compliance method processFaultyGuiStrings.
/**
* looks for calls to set a readable string that is generated from a static constant, as these strings are not translatable. also looks for setting readable
* strings that are appended together. This is likely not to be internationalizable.
*/
private void processFaultyGuiStrings() {
FQMethod methodInfo = new FQMethod(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand());
Integer parmIndex = displayTextMethods.get(methodInfo);
if ((parmIndex != null) && (stack.getStackDepth() > parmIndex.intValue())) {
OpcodeStack.Item item = stack.getStackItem(parmIndex.intValue());
if (item.getConstant() != null) {
bugReporter.reportBug(new BugInstance(this, BugType.S508C_NON_TRANSLATABLE_STRING.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
} else if (S508UserValue.APPENDED_STRING == item.getUserValue()) {
bugReporter.reportBug(new BugInstance(this, BugType.S508C_APPENDED_STRING.name(), NORMAL_PRIORITY).addClass(this).addMethod(this).addSourceLine(this));
}
}
}
use of com.mebigfatguy.fbcontrib.utils.FQMethod in project fb-contrib by mebigfatguy.
the class OverlyPermissiveMethod method isConstrainedByInterface.
/**
* looks to see if this method is an implementation of a method in an interface, including generic specified interface methods.
*
* @param fqMethod
* the method to check
* @return if this method is constrained by an interface method
*/
private boolean isConstrainedByInterface(FQMethod fqMethod) {
try {
JavaClass fqCls = Repository.lookupClass(fqMethod.getClassName());
if (fqCls.isInterface()) {
return true;
}
for (JavaClass inf : fqCls.getAllInterfaces()) {
for (Method infMethod : inf.getMethods()) {
if (infMethod.getName().equals(fqMethod.getMethodName())) {
String infMethodSig = infMethod.getSignature();
String fqMethodSig = fqMethod.getSignature();
if (infMethodSig.equals(fqMethodSig)) {
return true;
}
List<String> infTypes = SignatureUtils.getParameterSignatures(infMethodSig);
List<String> fqTypes = SignatureUtils.getParameterSignatures(fqMethodSig);
if (infTypes.size() == fqTypes.size()) {
boolean matches = true;
for (int i = 0; i < infTypes.size(); i++) {
String infParmType = infTypes.get(i);
String fqParmType = fqTypes.get(i);
if (infParmType.equals(fqParmType)) {
if ((infParmType.charAt(0) != 'L') || (fqParmType.charAt(0) != 'L')) {
matches = false;
break;
}
JavaClass infParmClass = Repository.lookupClass(SignatureUtils.stripSignature(infParmType));
JavaClass fqParmClass = Repository.lookupClass(SignatureUtils.stripSignature(fqParmType));
if (!fqParmClass.instanceOf(infParmClass)) {
matches = false;
break;
}
}
}
if (matches) {
return true;
}
}
}
}
}
return false;
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
return true;
}
}
Aggregations