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


Java BugInstance.addClassAndMethod方法代码示例

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


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

示例1: generateBugInstance

import edu.umd.cs.findbugs.BugInstance; //导入方法依赖的package包/类
/**
 * Uses immutable values, updated priority and added lines for reporting
 * 
 * @param taintedInsideMethod true if not influenced by method arguments
 * @return new bug instance filled with information
 */
public BugInstance generateBugInstance(boolean taintedInsideMethod) {
    BugInstance bug = new BugInstance(detector, bugType, originalPriority);
    bug.addClassAndMethod(classContext.getJavaClass(), method);
    bug.addSourceLine(SourceLineAnnotation.fromVisitedInstruction(classContext, method, instructionHandle));
    addMessage(bug, "Sink method", sinkMethod);

    for(TaintLocation source : unknownSources) {
        addMessage(bug, "Unknown source", source.getTaintSource());
        //md.getSlashedClassName() + "." + md.getName() + md.getSignature());
    }

    addMessage(bug, "Sink method", sinkMethod);
    if (sinkPriority != UNKNOWN_SINK_PRIORITY) {
        // higher priority is represented by lower integer
        if (sinkPriority < originalPriority) {
            bug.setPriority(sinkPriority);
            addMessage(bug, "Method usage", "with tainted arguments detected");
        } else if (sinkPriority > originalPriority) {
            bug.setPriority(Priorities.LOW_PRIORITY);
            addMessage(bug, "Method usage", "detected only with safe arguments");
        }
    } else if (!taintedInsideMethod) {
        addMessage(bug, "Method usage", "not detected");
    }
    Collections.sort(lines);
    SourceLineAnnotation annotation = null;
    for (Iterator<SourceLineAnnotation> it = lines.iterator(); it.hasNext();) {
        SourceLineAnnotation prev = annotation;
        annotation = it.next();
        if (prev != null && prev.getClassName().equals(annotation.getClassName())
                && prev.getStartLine() == annotation.getStartLine()) {
            // keep only one annotation per line
            it.remove();
        }
    }
    for (SourceLineAnnotation sourceLine : lines) {
        bug.addSourceLine(sourceLine);
    }
    return bug;
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:47,代码来源:InjectionSink.java


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