Add IntentModel for starting the analysis at an Intent
This commit is contained in:
parent
00d711dd64
commit
7aed4b5095
|
@ -376,7 +376,7 @@ public class AndroidModel /* makes SummarizedMethod */
|
|||
application = tmpApp;
|
||||
} else {
|
||||
// Generate a real one?
|
||||
logger.warn("I didn't get an application");
|
||||
logger.warn("I didn't get an application. Generating a new object.");
|
||||
application = paramManager.getUnmanaged(AndroidTypes.Application, "app");
|
||||
this.body.addConstant(application.getNumber(), new ConstantValue(null));
|
||||
application.setAssigned();
|
||||
|
|
|
@ -128,7 +128,7 @@ public final /* singleton */ class AndroidModelClass extends SyntheticClass {
|
|||
@Override
|
||||
public IMethod getMethod(Selector selector) {
|
||||
assert (macroModel != null) : "Macro Model was not set yet!";
|
||||
|
||||
|
||||
if (macroModel.getSelector().equals(selector)) {
|
||||
return macroModel;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* Copyright (c) 2013,
|
||||
* Tobias Blaschke <code@tobiasblaschke.de>
|
||||
* All rights reserved.
|
||||
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. The names of the contributors may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package com.ibm.wala.dalvik.ipa.callgraph.androidModel;
|
||||
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
import com.ibm.wala.types.Descriptor;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.types.TypeName;
|
||||
import com.ibm.wala.types.Selector;
|
||||
import com.ibm.wala.ipa.callgraph.impl.FakeRootClass;
|
||||
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentStarters.StartInfo;
|
||||
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentStarters.StarterFlags;
|
||||
import com.ibm.wala.dalvik.util.AndroidTypes;
|
||||
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
|
||||
import com.ibm.wala.ipa.summaries.SummarizedMethod;
|
||||
import com.ibm.wala.ipa.summaries.MethodSummary;
|
||||
import com.ibm.wala.classLoader.JavaLanguage.JavaInstructionFactory;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
|
||||
import com.ibm.wala.classLoader.CallSiteReference;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.ssa.SSANewInstruction;
|
||||
import com.ibm.wala.ssa.SSAPhiInstruction;
|
||||
import com.ibm.wala.ssa.ConstantValue;
|
||||
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
||||
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
|
||||
import com.ibm.wala.ipa.callgraph.MethodTargetSelector;
|
||||
import com.ibm.wala.ipa.summaries.BypassMethodTargetSelector;
|
||||
import com.ibm.wala.ipa.summaries.BypassSyntheticClassLoader;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ipa.callgraph.Context;
|
||||
import com.ibm.wala.ssa.SSAOptions;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.ibm.wala.util.CancelException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.helpers.NOPLogger;
|
||||
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.ipa.callgraph.Context;
|
||||
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
|
||||
import com.ibm.wala.ipa.summaries.VolatileMethodSummary;
|
||||
/**
|
||||
* Like MicroModel but includes CallBacks.
|
||||
*
|
||||
* @author Tobias Blaschke <code@tobiasblaschke.de>
|
||||
* @since 2014-02-12
|
||||
*/
|
||||
public class IntentModel extends AndroidModel {
|
||||
private static Logger logger = LoggerFactory.getLogger(IntentModel.class);
|
||||
|
||||
public final Atom name;
|
||||
public final Atom target;
|
||||
private SummarizedMethod activityModel;
|
||||
/**
|
||||
* Restrict the model to Activities.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected boolean selectEntryPoint(AndroidEntryPoint ep) {
|
||||
return ep.isMemberOf(this.target);
|
||||
}
|
||||
|
||||
public IntentModel(final IClassHierarchy cha, final AnalysisOptions options, final AnalysisCache cache, Atom target) {
|
||||
super(cha, options, cache);
|
||||
|
||||
this.target = target;
|
||||
this.name = Atom.concat(Atom.findOrCreateAsciiAtom("intent"), target.right(target.rIndex((byte)'/') - 1));
|
||||
|
||||
logger.info("Model for {}", target);
|
||||
logger.debug("Will be known as {}/{}.", AndroidModelClass.ANDROID_MODEL_CLASS.getName(), this.name);
|
||||
}
|
||||
|
||||
private void register(SummarizedMethod model) {
|
||||
AndroidModelClass mClass = AndroidModelClass.getInstance(cha);
|
||||
if (!(mClass.containsMethod(model.getSelector()))) {
|
||||
mClass.addMethod(model);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Atom getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SummarizedMethod getMethod() throws CancelException {
|
||||
/*AndroidModelClass mClass = AndroidModelClass.getInstance(cha);
|
||||
if (mClass.containsMethod(null)) {
|
||||
Selector sel = new Selector(this.name
|
||||
return mClass.getMethod();
|
||||
}*/
|
||||
if (!built) {
|
||||
super.build(this.name);
|
||||
this.register(super.model);
|
||||
}
|
||||
return super.model;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,12 +125,14 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
|
|||
throw new IllegalArgumentException("node is null");
|
||||
}
|
||||
assert understands(node); // Should already have been checked before
|
||||
logger.info("IntentContextInterpreter - Retreiving IR of " + node.getMethod().getSignature());
|
||||
{
|
||||
// TODO: CACHE!
|
||||
final Context ctx = node.getContext();
|
||||
|
||||
|
||||
if (ctx.get(Intent.INTENT_KEY) != null) {
|
||||
logger.debug("Got an Intent-Context");
|
||||
try { // Translate CancelException to IllegalStateException
|
||||
final Intent inIntent = (Intent) ctx.get(Intent.INTENT_KEY); // Intent without overrides
|
||||
final Intent intent = AndroidEntryPointManager.MANAGER.getIntent(inIntent); // Apply overrides
|
||||
|
|
Loading…
Reference in New Issue