public FindUnsatisfiedObligation(BugReporter bugReporter) { this.bugReporter = bugReporter; IAnalysisCache analysisCache = Global.getAnalysisCache(); database = analysisCache.getDatabase(ObligationPolicyDatabase.class); }
/** * @return Returns the database. */ static MethodInfoDatabase getDatabase() { return Global.getAnalysisCache().getDatabase(MethodInfoDatabase.class); } static IdentityHashMap<MethodInfo, Void> getUnconditionalthrowers() {
/** * Get the Subtypes2 inheritance hierarchy database. */ public Subtypes2 getSubtypes2() { return Global.getAnalysisCache().getDatabase(Subtypes2.class); }
public FindDoubleCheck(BugReporter bugReporter) { this.bugReporter = bugReporter; this.nse = Global.getAnalysisCache().getDatabase(NoSideEffectMethodsDatabase.class); }
public FindUselessObjects(BugReporter reporter) { this.reporter = reporter; this.noSideEffectMethods = Global.getAnalysisCache().getDatabase(NoSideEffectMethodsDatabase.class); }
public DirectlyRelevantTypeQualifiersDatabase getDirectlyRelevantTypeQualifiersDatabase() { return Global.getAnalysisCache().getDatabase(DirectlyRelevantTypeQualifiersDatabase.class); }
protected <E> E getDatabase(Class<E> cls) { return Global.getAnalysisCache().getDatabase(cls); }
/** * Determine if one reference type is a subtype of another. * * @param t * a reference type * @param possibleSupertype * the possible supertype * @return true if t is a subtype of possibleSupertype, false if not */ public static boolean isSubtype(ReferenceType t, ReferenceType possibleSupertype) throws ClassNotFoundException { return Global.getAnalysisCache().getDatabase(Subtypes2.class).isSubtype(t, possibleSupertype); }
public RepeatedConditionals(BugReporter bugReporter) { this.bugReporter = bugReporter; this.noSideEffectMethods = Global.getAnalysisCache().getDatabase(NoSideEffectMethodsDatabase.class); reset(); }
public MethodReturnCheck(BugReporter bugReporter) { this.bugAccumulator = new BugAccumulator(bugReporter); this.noSideEffectMethods = Global.getAnalysisCache().getDatabase(NoSideEffectMethodsDatabase.class); }
public FindSqlInjection(BugReporter bugReporter) { this.bugReporter = bugReporter; this.bugAccumulator = new BugAccumulator(bugReporter); Set<MethodParameter> baseExecuteMethods = new HashSet<>(); for(MethodDescriptor executeMethod : EXECUTE_METHODS) { baseExecuteMethods.add(new MethodParameter(executeMethod, 0)); } executeMethods = Global.getAnalysisCache().getDatabase(StringPassthruDatabase.class).findLinkedMethods(baseExecuteMethods); Set<MethodParameter> basePrepareMethods = new HashSet<>(); for(String signature : PREPARE_STATEMENT_SIGNATURES) { basePrepareMethods.add(new MethodParameter(new MethodDescriptor("java/sql/Connection", "prepareStatement", signature), 0)); } preparedStatementMethods = Global.getAnalysisCache().getDatabase(StringPassthruDatabase.class).findLinkedMethods(basePrepareMethods); allMethods.addAll(executeMethods.keySet()); allMethods.addAll(preparedStatementMethods.keySet()); }
public CrossSiteScripting(BugReporter bugReporter) { this.bugReporter = bugReporter; this.accumulator = new BugAccumulator(bugReporter); StringPassthruDatabase database = Global.getAnalysisCache().getDatabase(StringPassthruDatabase.class); allFileNameStringMethods = database.getFileNameStringMethods(); }
private static Subtypes2 getSubtypes2() { return Global.getAnalysisCache().getDatabase(Subtypes2.class); }
private void initialize() { initialized = true; IAnalysisCache analysisCache = Global.getAnalysisCache(); Class<? extends Dataflow<Fact,AnalysisType>> cls = null; // First, try loading the dataflow class from the general findBugs code. try { Class<?> c = getClass().getClassLoader().loadClass(dataflowClassName); cls = asDataflowClass(c); } catch (ClassNotFoundException e) { assert true; } if (cls == null) { // Find the dataflow class from the plugin in which it was loaded DetectorFactoryCollection detectorFactoryCollection = analysisCache.getDatabase(DetectorFactoryCollection.class); for (Iterator<Plugin> i = detectorFactoryCollection.pluginIterator(); i.hasNext();) { Plugin plugin = i.next(); try { cls = asDataflowClass(plugin.getClassLoader().loadClass(dataflowClassName)); break; } catch (ClassNotFoundException e) { assert true; } } } if (cls == null) { analysisCache.getErrorLogger().logError("TestDataflowAnalysis: could not load class " + dataflowClassName); return; } dataflowClass = cls; }
@Override public boolean matches(Type t) { if (!(t instanceof ReferenceType)) { return false; } IAnalysisCache analysisCache = Global.getAnalysisCache(); Subtypes2 subtypes2 = analysisCache.getDatabase(Subtypes2.class); try { return subtypes2.isSubtype((ReferenceType) t, supertype); } catch (ClassNotFoundException e) { analysisCache.getErrorLogger().reportMissingClass(e); return false; } }
private void scanForResourceTypes() { Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class); Collection<XClass> knownClasses = subtypes2.getXClassCollection(); for (XClass xclass : knownClasses) { // Is this class a resource type? if (xclass.getAnnotation(cleanupObligation) != null) { // Add it as an obligation type database.getFactory().addObligation(xclass.getClassDescriptor().toDottedClassName()); } } if (DEBUG_ANNOTATIONS) { System.out.println("After scanning for resource types:"); for (Iterator<Obligation> i = database.getFactory().obligationIterator(); i.hasNext();) { Obligation obligation = i.next(); System.out.println(" " + obligation); } } } }
public DumbMethodInvocations(BugReporter bugReporter) { this.bugReporter = bugReporter; this.bugAccumulator = new BugAccumulator(bugReporter); StringPassthruDatabase database = Global.getAnalysisCache().getDatabase(StringPassthruDatabase.class); allFileNameStringMethods = database.getFileNameStringMethods(); allDatabasePasswordMethods = database.findLinkedMethods(Collections.singleton(new MethodParameter(new MethodDescriptor( "java/sql/DriverManager", "getConnection", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection;", true), 2))); }
/** * Determine if the given ObjectType refers to an unchecked exception * (RuntimeException or Error). */ public static boolean isUncheckedException(ObjectType type) throws ClassNotFoundException { if (type.equals(Type.THROWABLE) || type.equals(RUNTIME_EXCEPTION_TYPE) || type.equals(ERROR_TYPE)) { return true; } ClassDescriptor c = DescriptorFactory.getClassDescriptor(type); Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class); return subtypes2.isSubtype(c, RUNTIME_EXCEPTION, ERROR); }
/** * Determine whether one class (or reference type) is a subtype of another. * * @param clsName * the name of the class or reference type * @param possibleSupertypeClassName * the name of the possible superclass * @return true if clsName is a subtype of possibleSupertypeClassName, false * if not */ public static boolean isSubtype(@DottedClassName String clsName, @DottedClassName String possibleSupertypeClassName) throws ClassNotFoundException { Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class); return subtypes2.isSubtype(DescriptorFactory.createClassDescriptorFromDottedClassName(clsName), DescriptorFactory.createClassDescriptorFromDottedClassName(possibleSupertypeClassName)); }
ConstantPoolGen cpg = analysisCache.getClassAnalysis(ConstantPoolGen.class, methodDescriptor.getClassDescriptor()); ObligationPolicyDatabase database = analysisCache.getDatabase(ObligationPolicyDatabase.class);