当前位置: 首页>>代码示例>>Java>>正文


Java ClassContext.getJavaClass方法代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.ba.ClassContext.getJavaClass方法的典型用法代码示例。如果您正苦于以下问题:Java ClassContext.getJavaClass方法的具体用法?Java ClassContext.getJavaClass怎么用?Java ClassContext.getJavaClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.umd.cs.findbugs.ba.ClassContext的用法示例。


在下文中一共展示了ClassContext.getJavaClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reportMatch

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
public void reportMatch(ClassContext classContext, Method method, ByteCodePatternMatch match) {
	MethodGen methodGen = classContext.getMethodGen(method);
	JavaClass javaClass = classContext.getJavaClass();

	BindingSet bindingSet = match.getBindingSet();

	// Note that the lookup of "h" cannot fail, and
	// it is guaranteed to be bound to a FieldVariable.
	Binding binding = bindingSet.lookup("h");
	FieldVariable field = (FieldVariable) binding.getVariable();

	// Ignore fields generated for accesses to Foo.class
	if (field.getFieldName().startsWith("class$"))
		return;

	// Find start and end instructions (for reporting source lines)
	InstructionHandle start = match.getLabeledInstruction("startDC");
	InstructionHandle end = match.getLabeledInstruction("endDC");

	String sourceFile = javaClass.getSourceFileName();
	bugReporter.reportBug(new BugInstance(this, "BCPDC_DOUBLECHECK", NORMAL_PRIORITY)
	        .addClassAndMethod(methodGen, sourceFile)
	        .addField(field).describe("FIELD_ON")
	        .addSourceLine(methodGen, sourceFile, start, end));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:BCPDoubleCheck.java

示例2: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    
    //The class extends WebChromeClient
    boolean isWebChromeClient = InterfaceUtils.isSubtype(javaClass, "android.webkit.WebChromeClient");
    
    //Not the target of this detector
    if (!isWebChromeClient) {
        return;
    }
    Method[] methodList = javaClass.getMethods();
    for (Method m : methodList) {
        if (DEBUG) {
            System.out.println(">>> Method: " + m.getName());
        }
        //The presence of onGeolocationPermissionsShowPrompt is not enforce for the moment
        if (!m.getName().equals("onGeolocationPermissionsShowPrompt")) {
            continue;
        }
        //Since the logic implemented need to be analyze by a human, all implementation will be flagged.
        bugReporter.reportBug(new BugInstance(this, ANDROID_GEOLOCATION_TYPE, Priorities.NORMAL_PRIORITY) //
                .addClassAndMethod(javaClass, m));
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:26,代码来源:GeolocationDetector.java

示例3: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    if (OBJECT_MAPPER_CLASSES.contains(javaClass.getClassName())) {
        return;
    }
    for (Field field : javaClass.getFields()) {
        analyzeField(field, javaClass);
    }
    for (Method m : javaClass.getMethods()) {
        try {
            analyzeMethod(m, classContext);
        }
        catch (CFGBuilderException | DataflowAnalysisException e) {
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:18,代码来源:UnsafeJacksonDeserializationDetector.java

示例4: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();

    //The class extends HttpServletRequestWrapper
    boolean isRequestWrapper = InterfaceUtils.isSubtype(javaClass, "javax.servlet.http.HttpServletRequestWrapper");

    //Not the target of this detector
    if (!isRequestWrapper) return;

    Method[] methodList = javaClass.getMethods();

    for (Method m : methodList) {
        if (m.getName().equals("stripXSS")) {
            bugReporter.reportBug(new BugInstance(this, XSS_REQUEST_WRAPPER_TYPE, Priorities.NORMAL_PRIORITY) //
                    .addClassAndMethod(javaClass, m));
            return;
        }
    }

}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:22,代码来源:XSSRequestWrapperDetector.java

示例5: analyzeMethod

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
private void analyzeMethod(Method m, ClassContext classContext) throws CFGBuilderException, DataflowAnalysisException {

        ConstantPoolGen cpg = classContext.getConstantPoolGen();
        CFG cfg = classContext.getCFG(m);
        
        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) {
            Location location = i.next();

            Instruction inst = location.getHandle().getInstruction();
            
            if (inst instanceof LDC) {
                LDC ldc = (LDC) inst;
                if (ldc != null) {
                    if("java.naming.security.authentication".equals(ldc.getValue(cpg)) &&
                       "none".equals(ByteCode.getConstantLDC(location.getHandle().getNext(), cpg, String.class))){
                        JavaClass clz = classContext.getJavaClass();
                        bugReporter.reportBug(new BugInstance(this, LDAP_ANONYMOUS, Priorities.LOW_PRIORITY) //
                        .addClass(clz)
                        .addMethod(clz, m)
                        .addSourceLine(classContext, m, location));
                        break;
                    }
                }
            }            
        }
    }
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:27,代码来源:AnonymousLdapDetector.java

示例6: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
public void visitClassContext(ClassContext cc) {
	JavaClass jc = cc.getJavaClass();
	
	Method[] methods = jc.getMethods();
	
	for (Method m : methods) {
		MethodGen mg = cc.getMethodGen(m);
		
		if (mg == null) {
			continue;
		}
		
		try {
			analyzeMethod(cc, m);
		} catch (Exception e) {
			// There was a problem,
			// report it. Probably
			// isn't going to
			// be a big deal.
			e.printStackTrace();
		}
	}
}
 
开发者ID:jkusner,项目名称:FindMoreBugs,代码行数:24,代码来源:CommandInjectionVulnerabilityDetector.java

示例7: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    try {
        JavaClass cls = classContext.getJavaClass();
        superclassName = cls.getSuperclassName();
        JavaClass[] interfaces = null;
        if (cls.isClass() && ((cls.getAccessFlags() & Constants.ACC_ABSTRACT) != 0)) {
            interfaces = cls.getAllInterfaces();
            interfaceMethods = new HashSet<String>();
            for (JavaClass aInterface : interfaces) {
                Method[] infMethods = aInterface.getMethods();
                for (Method meth : infMethods) {
                    interfaceMethods.add(meth.getName() + meth.getSignature());
                }
            }
        }
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    }
    super.visitClassContext(classContext);
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:22,代码来源:UselessSubclassMethod.java

示例8: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    if (!enabled())
        return;

    JavaClass jClass = classContext.getJavaClass();
    XClass xClass = classContext.getXClass();

    try {

        if (!isJunit3TestCase(xClass))
            return;
        if ((jClass.getAccessFlags() & ACC_ABSTRACT) == 0) {
            if (!hasTestMethods(jClass)) {
                bugReporter.reportBug(new BugInstance(this, "IJU_NO_TESTS", LOW_PRIORITY).addClass(jClass));
            }
        }
        directChildOfTestCase = "junit.framework.TestCase".equals(jClass.getSuperclassName());
        jClass.accept(this);
    } catch (ClassNotFoundException cnfe) {
        bugReporter.reportMissingClass(cnfe);
    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:InvalidJUnitTest.java

示例9: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass jclass = classContext.getJavaClass();

    // We can ignore classes that were compiled for anything
    // less than JDK 1.5. This should avoid lots of unnecessary work
    // when analyzing code for older VM targets.
    if (BCELUtil.preTiger(jclass))
        return;

    boolean sawUtilConcurrentLocks = false;
    for (Constant c : jclass.getConstantPool().getConstantPool())
        if (c instanceof ConstantMethodref) {
            ConstantMethodref m = (ConstantMethodref) c;
            ConstantClass cl = (ConstantClass) jclass.getConstantPool().getConstant(m.getClassIndex());
            ConstantUtf8 name = (ConstantUtf8) jclass.getConstantPool().getConstant(cl.getNameIndex());
            String nameAsString = name.getBytes();
            if (nameAsString.startsWith("java/util/concurrent/locks"))
                sawUtilConcurrentLocks = true;

        }
    if (sawUtilConcurrentLocks)
        super.visitClassContext(classContext);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:FindUnreleasedLock.java

示例10: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();

    for (Method method : javaClass.getMethods()) {
        if (isVulnerable(method)) {
            bugReporter.reportBug(new BugInstance(this, SPRING_CSRF_UNRESTRICTED_REQUEST_MAPPING_TYPE, Priorities.HIGH_PRIORITY) //
                    .addClassAndMethod(javaClass, method));
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:12,代码来源:SpringCsrfUnrestrictedRequestMappingDetector.java

示例11: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
public void visitClassContext(ClassContext classContext) {
	if (appletClass == null)
		return;
		
	JavaClass cls = classContext.getJavaClass();
	try {
		if (cls.instanceOf(appletClass))
			cls.accept(this);
	} catch (ClassNotFoundException cnfe) {
		bugReporter.reportMissingClass(cnfe);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:13,代码来源:BadAppletConstructor.java

示例12: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass clazz = classContext.getJavaClass();

    if (hasRequestMapping(clazz)) {
        Method[] methods = clazz.getMethods();
        for (Method m: methods) {

            try {
                analyzeMethod(m, classContext);
            } catch (CFGBuilderException e){
            }
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:16,代码来源:SpringUnvalidatedRedirectDetector.java

示例13: analyzeMethod

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
private void analyzeMethod(Method m, ClassContext classContext) throws CFGBuilderException{
    JavaClass clazz = classContext.getJavaClass();
    ConstantPoolGen cpg = classContext.getConstantPoolGen();
    CFG cfg = classContext.getCFG(m);

    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) {
        Location loc = i.next();
        Instruction inst = loc.getHandle().getInstruction();

        if (inst instanceof INVOKEVIRTUAL) {
            INVOKEVIRTUAL invoke = (INVOKEVIRTUAL)inst;
            if( "java.lang.StringBuilder".equals(invoke.getClassName(cpg)) && "append".equals(invoke.getMethodName(cpg))) {
                Instruction prev = loc.getHandle().getPrev().getInstruction();

                if (prev instanceof LDC) {
                    LDC ldc = (LDC)prev;
                    Object value = ldc.getValue(cpg);

                    if (value instanceof String) {
                        String v = (String)value;

                        if ("redirect:".equals(v)) {
                            BugInstance bug = new BugInstance(this, SPRING_UNVALIDATED_REDIRECT_TYPE, Priorities.NORMAL_PRIORITY);
                            bug.addClass(clazz).addMethod(clazz,m).addSourceLine(classContext,m,loc);
                            reporter.reportBug(bug);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:33,代码来源:SpringUnvalidatedRedirectDetector.java

示例14: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();

    boolean isActionForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.action.ActionForm");
    boolean isValidatorForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.validator.ValidatorForm");
    boolean isDynaValidatorForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.validator.DynaValidatorForm");

    if (isActionForm && !(isValidatorForm || isDynaValidatorForm)) {
        bugReporter.reportBug(new BugInstance(this, STRUTS_FORM_VALIDATION_TYPE, Priorities.NORMAL_PRIORITY) //
                .addClass(javaClass) //
                .addString("ActionForm"));
        return;
    }

    if (!isValidatorForm && !isDynaValidatorForm) return; //Not form implementation

    final String expectedSig = "(Lorg/apache/struts/action/ActionMapping;Ljavax/servlet/http/HttpServletRequest;)Lorg/apache/struts/action/ActionErrors;";
    boolean validateMethodFound = false;
    for (Method m : javaClass.getMethods()) {

        if ("validate".equals(m.getName()) && expectedSig.equals(m.getSignature())) {
            validateMethodFound = true;
        }
    }

    //ValidatorForm without a validate method is just like a regular ActionForm
    if (!validateMethodFound) {
        bugReporter.reportBug(new BugInstance(this, STRUTS_FORM_VALIDATION_TYPE, Priorities.LOW_PRIORITY) //
                .addClass(javaClass) //
                .addString("ValidatorForm"));
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:34,代码来源:StrutsValidatorFormDetector.java

示例15: visitClassContext

import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();

    Method[] methodList = javaClass.getMethods();

    for (Method m : methodList) {
        try {
            analyzeMethod(m,classContext);
        } catch (CFGBuilderException e) {
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:14,代码来源:CookieFlagsDetector.java


注:本文中的edu.umd.cs.findbugs.ba.ClassContext.getJavaClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。