├── README.md
├── icons
├── owasp.gif
├── view.gif
├── c
│ ├── synced.gif
│ ├── refresh.gif
│ ├── setfocus.gif
│ ├── collapseall.gif
│ └── expandall.gif
├── d
│ ├── Thumbs.db
│ ├── synced.gif
│ ├── refresh.gif
│ ├── setfocus.gif
│ ├── collapseall.gif
│ └── expandall.gif
├── e
│ ├── synced.gif
│ ├── refresh.gif
│ ├── setfocus.gif
│ ├── collapseall.gif
│ └── expandall.gif
├── sample.gif
└── e_search_menu.gif
├── safes.xml
├── derived.xml
├── META-INF
└── MANIFEST.MF
├── fuentes
└── lapsePlus
│ ├── views
│ ├── ColorDecoratingLabelProvider.java
│ ├── MethodFinder.java
│ ├── LapseLayoutActionGroup.java
│ ├── LapseImages.java
│ ├── SinkStatsDialog.java
│ ├── SuperListener.java
│ ├── HistoryDropDownAction.java
│ ├── DLTreeLabelProvider.java
│ ├── DeclarationInfoManager.java
│ ├── LapseMultiActionGroup.java
│ ├── LapseConfigurationDialog.java
│ └── ProvenanceContentProvider.java
│ ├── DefinitionLocation.java
│ ├── PerspectiveFactory.java
│ ├── Utils.java
│ ├── NodeFinder.java
│ ├── NestedDefinitionLocation.java
│ ├── HistoryDefinitionLocation.java
│ ├── LapsePlugin.java
│ ├── MethodSearchRequestor.java
│ ├── Binding2JavaModel.java
│ ├── CallerFinder.java
│ └── XMLConfig.java
├── .gitignore
├── plugin.xml
├── sources.xml
├── sinks.xml
└── LICENSE
/README.md:
--------------------------------------------------------------------------------
1 | ## Lapse+
--------------------------------------------------------------------------------
/icons/owasp.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/owasp.gif
--------------------------------------------------------------------------------
/icons/view.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/view.gif
--------------------------------------------------------------------------------
/icons/c/synced.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/c/synced.gif
--------------------------------------------------------------------------------
/icons/d/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/d/Thumbs.db
--------------------------------------------------------------------------------
/icons/d/synced.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/d/synced.gif
--------------------------------------------------------------------------------
/icons/e/synced.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/e/synced.gif
--------------------------------------------------------------------------------
/icons/sample.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/sample.gif
--------------------------------------------------------------------------------
/icons/c/refresh.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/c/refresh.gif
--------------------------------------------------------------------------------
/icons/c/setfocus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/c/setfocus.gif
--------------------------------------------------------------------------------
/icons/d/refresh.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/d/refresh.gif
--------------------------------------------------------------------------------
/icons/d/setfocus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/d/setfocus.gif
--------------------------------------------------------------------------------
/icons/e/refresh.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/e/refresh.gif
--------------------------------------------------------------------------------
/icons/e/setfocus.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/e/setfocus.gif
--------------------------------------------------------------------------------
/icons/c/collapseall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/c/collapseall.gif
--------------------------------------------------------------------------------
/icons/c/expandall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/c/expandall.gif
--------------------------------------------------------------------------------
/icons/d/collapseall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/d/collapseall.gif
--------------------------------------------------------------------------------
/icons/d/expandall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/d/expandall.gif
--------------------------------------------------------------------------------
/icons/e/collapseall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/e/collapseall.gif
--------------------------------------------------------------------------------
/icons/e/expandall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/e/expandall.gif
--------------------------------------------------------------------------------
/icons/e_search_menu.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OWASP/lapse-plus/HEAD/icons/e_search_menu.gif
--------------------------------------------------------------------------------
/safes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | javax.servlet.http.HttpServletRequest
5 | getContextPath
6 | 0
7 | SQL
8 |
9 |
10 |
11 | java.lang.System.getProperty
12 | getProperty
13 | 1
14 | SQL
15 |
16 |
17 |
18 | java.util.Properties
19 | getProperty
20 | 1
21 | SQL
22 |
23 |
--------------------------------------------------------------------------------
/derived.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | java.lang.String
5 | String
6 |
7 |
8 | java.lang.StringBuffer
9 | StringBuffer
10 |
11 |
12 | java.lang.Object
13 | toString
14 |
15 |
16 | java.lang.String
17 | substring
18 |
19 |
20 | java.lang.String
21 | substring
22 |
23 |
24 |
--------------------------------------------------------------------------------
/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: LAPSE+ finds security vulnerabilities in Java EE Applications
4 | Bundle-SymbolicName: LapsePlus;singleton:=true
5 | Bundle-Version: 2.8.1
6 | Bundle-ClassPath: lapse.jar
7 | Bundle-Activator: lapsePlus.LapsePlugin
8 | Bundle-Vendor: Pablo Martin Perez - EVALUES - IT Security Evaluation
9 | Export-Package: .,
10 | lapsePlus,
11 | lapsePlus.views
12 | Require-Bundle: org.eclipse.core.runtime,
13 | org.eclipse.jface.text,
14 | org.eclipse.ui.workbench.texteditor,
15 | org.eclipse.ui.editors,
16 | org.eclipse.core.resources,
17 | org.eclipse.jdt.core,
18 | org.eclipse.jdt.ui,
19 | org.eclipse.swt,
20 | org.eclipse.jface,
21 | org.eclipse.ui,
22 | org.eclipse.ui.ide
23 | Bundle-ActivationPolicy: lazy
24 | Bundle-RequiredExecutionEnvironment: JavaSE-1.6
25 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/ColorDecoratingLabelProvider.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * ColorDecoratingLabelProvider.java,version 2.8, 2010
5 | */
6 |
7 |
8 | import org.eclipse.jface.viewers.DecoratingLabelProvider;
9 | import org.eclipse.jface.viewers.IColorProvider;
10 | import org.eclipse.jface.viewers.ILabelDecorator;
11 | import org.eclipse.jface.viewers.ILabelProvider;
12 | import org.eclipse.swt.graphics.Color;
13 |
14 | public class ColorDecoratingLabelProvider extends DecoratingLabelProvider
15 | implements IColorProvider
16 | {
17 | public ColorDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator)
18 | {
19 | super(provider, decorator);
20 | }
21 |
22 | @Override
23 | public Color getForeground(Object element) {
24 | ILabelProvider labelProvider = getLabelProvider();
25 | if ((labelProvider instanceof IColorProvider))
26 | return ((IColorProvider)labelProvider).getForeground(element);
27 | return null;
28 | }
29 |
30 | @Override
31 | public Color getBackground(Object element) {
32 | ILabelProvider labelProvider = getLabelProvider();
33 | if ((labelProvider instanceof IColorProvider))
34 | return ((IColorProvider)labelProvider).getBackground(element);
35 | return null;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/DefinitionLocation.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * DefinitionLocation.java, version 2.8, 2010
5 | */
6 |
7 | import org.eclipse.core.resources.IResource;
8 | import org.eclipse.jdt.core.dom.ASTNode;
9 |
10 | public class DefinitionLocation {
11 | public static final int INVALID_SOURCE_LINE = -1;
12 |
13 | String name;
14 | int lineNumber;
15 | ASTNode ast;
16 | IResource resource;
17 |
18 | DefinitionLocation(String name, IResource resource, int lineNumber, ASTNode ast){
19 | this.name = name;
20 | if (this.name.endsWith("\n")) this.name = this.name.substring(0, this.name.length() - 1);
21 | if (this.name.endsWith(";")) this.name = this.name.substring(0, this.name.length() - 1);
22 | this.lineNumber = lineNumber;
23 | this.ast = ast;
24 | this.resource = resource;
25 | }
26 | public int getLineNumber() {
27 | return lineNumber;
28 | }
29 | public String getName() {
30 | return name;
31 | }
32 | public IResource getResource() {
33 | return resource;
34 | }
35 | public String toString() {
36 | return /*ast.toString() +*/
37 | name +
38 | (lineNumber == INVALID_SOURCE_LINE ?
39 | "" :
40 | resource != null ?
41 | (" (" + resource.getName() + ":" + lineNumber + ")") :
42 | "");
43 | }
44 | public ASTNode getASTNode() {
45 | return ast;
46 | }
47 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/PerspectiveFactory.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * PerspectiveFactory.java, version 2.8, 2010
5 | */
6 |
7 | import org.eclipse.ui.IFolderLayout;
8 | import org.eclipse.ui.IPageLayout;
9 | import org.eclipse.ui.IPerspectiveFactory;
10 |
11 | public class PerspectiveFactory implements IPerspectiveFactory {
12 | private static final String PROVENANCE_TRACKER_VIEW_ID = "lapsePlus.views.LapseView";
13 | private static final String SOURCE_VIEW_ID = "lapsePlus.views.SourceView";
14 | private static final String SINK_VIEW_ID = "lapsePlus.views.SinkView";
15 |
16 | /* (non-Javadoc)
17 | * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
18 | */
19 | public void createInitialLayout(IPageLayout layout) {
20 | // Get the editor area.
21 | String editorArea = layout.getEditorArea();
22 |
23 | IFolderLayout bottom = layout.createFolder("bottom", IPageLayout.BOTTOM, 0.75f, editorArea);
24 | bottom.addView(PROVENANCE_TRACKER_VIEW_ID);
25 | bottom.addView(SOURCE_VIEW_ID);
26 | bottom.addView(SINK_VIEW_ID);
27 | //bottom.addView(MARKER_VIEW_ID);
28 | bottom.addView(IPageLayout.ID_TASK_LIST);
29 | bottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
30 |
31 | // Add the favorites action set
32 | //layout.addActionSet(FAVORITES_ACTION_ID);
33 |
34 | layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, 0.85f, editorArea);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/java,eclipse
3 |
4 | ### Eclipse ###
5 |
6 | .metadata
7 | bin/
8 | tmp/
9 | *.tmp
10 | *.bak
11 | *.swp
12 | *~.nib
13 | local.properties
14 | .settings/
15 | .loadpath
16 | .recommenders
17 |
18 | # External tool builders
19 | .externalToolBuilders/
20 |
21 | # Locally stored "Eclipse launch configurations"
22 | *.launch
23 |
24 | # PyDev specific (Python IDE for Eclipse)
25 | *.pydevproject
26 |
27 | # CDT-specific (C/C++ Development Tooling)
28 | .cproject
29 |
30 | # Java annotation processor (APT)
31 | .factorypath
32 |
33 | # PDT-specific (PHP Development Tools)
34 | .buildpath
35 |
36 | # sbteclipse plugin
37 | .target
38 |
39 | # Tern plugin
40 | .tern-project
41 |
42 | # TeXlipse plugin
43 | .texlipse
44 |
45 | # STS (Spring Tool Suite)
46 | .springBeans
47 |
48 | # Code Recommenders
49 | .recommenders/
50 |
51 | # Scala IDE specific (Scala & Java development for Eclipse)
52 | .cache-main
53 | .scala_dependencies
54 | .worksheet
55 |
56 | ### Eclipse Patch ###
57 | # Eclipse Core
58 | .project
59 |
60 | # JDT-specific (Eclipse Java Development Tools)
61 | .classpath
62 |
63 | ### Java ###
64 | # Compiled class file
65 | *.class
66 |
67 | # Log file
68 | *.log
69 |
70 | # BlueJ files
71 | *.ctxt
72 |
73 | # Mobile Tools for Java (J2ME)
74 | .mtj.tmp/
75 |
76 | # Package Files #
77 | *.jar
78 | *.war
79 | *.ear
80 | *.zip
81 | *.tar.gz
82 | *.rar
83 |
84 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
85 | hs_err_pid*
86 |
87 |
88 | # End of https://www.gitignore.io/api/java,eclipse
89 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/MethodFinder.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * MethodFinder.java, version 2.8, 2010
5 | */
6 |
7 | import org.eclipse.core.resources.IFile;
8 | import org.eclipse.jdt.core.ICompilationUnit;
9 | import org.eclipse.jdt.core.IJavaElement;
10 | import org.eclipse.jdt.core.IMethod;
11 | import org.eclipse.jdt.core.JavaCore;
12 | import org.eclipse.jdt.core.JavaModelException;
13 | import org.eclipse.jdt.core.dom.MethodDeclaration;
14 | import org.eclipse.jdt.core.dom.SimpleName;
15 |
16 | public class MethodFinder {
17 | IFile resource;
18 | //MethodFinderVisitor visitor = new MethodFinderVisitor();
19 |
20 | public MethodFinder(IFile resource){
21 | this.resource = resource;
22 | }
23 | public IMethod convertMethodDecl2IMethod(MethodDeclaration methodDecl){
24 | SimpleName methodName = methodDecl.getName();
25 | //cu.accept(visitor);
26 |
27 | try {
28 | ICompilationUnit iCompilationUnit = JavaCore.createCompilationUnitFrom((IFile) resource);
29 |
30 | int startPos = methodDecl.getStartPosition();
31 | IJavaElement element = iCompilationUnit.getElementAt(startPos);
32 | if(element instanceof IMethod) {
33 | return (IMethod) element;
34 | }
35 | return null;
36 | } catch (JavaModelException e) {
37 | e.printStackTrace();
38 | }
39 | return null;
40 | }
41 | /*
42 | class MethodFinderVisitor extends ASTVisitor {
43 | public boolean visit(ITypeBinding node) {
44 | System.out.println(">>> Visiting " + node);
45 | return true;
46 | }
47 | public boolean visit(MethodDeclaration node) {
48 | System.out.println(">>> Visiting " + node);
49 | return true;
50 | }
51 | }
52 | */
53 | }
54 |
--------------------------------------------------------------------------------
/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
10 |
11 |
12 |
19 |
20 |
27 |
34 |
35 |
37 |
39 |
44 |
45 |
46 |
47 |
49 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/LapseLayoutActionGroup.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * LapseLayoutActionGroup.java, version 2.8, 2010
5 | */
6 |
7 | import org.eclipse.jdt.internal.ui.JavaPluginImages;
8 | import org.eclipse.jface.action.Action;
9 | import org.eclipse.jface.action.IAction;
10 | import org.eclipse.ui.IActionBars;
11 |
12 | class LapseLayoutActionGroup extends LapseRadioActionGroup {
13 |
14 | public LapseLayoutActionGroup(LapseView packageExplorer) {
15 | super(
16 | //creates hierarchical and leaves only options in Provenance Tracker View
17 | createActions(packageExplorer),
18 | packageExplorer.isFlatLayout() ? 1 : 0,
19 | false
20 | );
21 | }
22 |
23 | private static LayoutAction hierarchicalLayoutAction;
24 | private static LayoutAction flatLayoutAction;
25 |
26 | static int getSelectedState(LapseView packageExplorer) {
27 | if (packageExplorer.isFlatLayout())
28 | return 1;
29 | else
30 | return 0;
31 | }
32 |
33 | public void fillActionBars(IActionBars actionBars){
34 | addActions(actionBars.getMenuManager());
35 | setEnabled(false);
36 | }
37 |
38 | /**Provenance Tracker - Hierarchichal Layout, Leaves Only Layout*/
39 |
40 | static IAction[] createActions(LapseView packageExplorer) {
41 | hierarchicalLayoutAction = new LayoutAction(packageExplorer, false);
42 | hierarchicalLayoutAction.setText("Hierarchical layout");
43 | JavaPluginImages.setLocalImageDescriptors(hierarchicalLayoutAction, "hierarchicalLayout.gif");
44 |
45 | flatLayoutAction = new LayoutAction(packageExplorer, true);
46 | flatLayoutAction.setText("Leaves only");
47 | JavaPluginImages.setLocalImageDescriptors(flatLayoutAction, "flatLayout.gif");
48 |
49 | return new IAction[]{hierarchicalLayoutAction, flatLayoutAction};
50 | }
51 | }
52 |
53 |
54 | class LayoutAction extends Action implements IAction {
55 | private boolean fIsFlatLayout;
56 | private LapseView fViewer;
57 |
58 | public LayoutAction(LapseView viewer, boolean flat) {
59 | super("", AS_PUSH_BUTTON);
60 |
61 | fIsFlatLayout = flat;
62 | fViewer = viewer;
63 | }
64 |
65 | public void run() {
66 | if (fViewer.isFlatLayout() != fIsFlatLayout) {
67 | fViewer.toggleViewer();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/LapseImages.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * LapseImages.java, version 2.8, 2010
5 | */
6 |
7 | import java.net.MalformedURLException;
8 | import java.net.URL;
9 | import org.eclipse.jdt.internal.ui.JavaPlugin;
10 | import org.eclipse.jface.action.IAction;
11 | import org.eclipse.jface.resource.ImageDescriptor;
12 |
13 | public class LapseImages {
14 | private static URL fgIconBaseURL = null;
15 |
16 | static {
17 | fgIconBaseURL= JavaPlugin.getDefault().getBundle().getEntry("/icons/"); //$NON-NLS-1$
18 | System.err.println("URL: " + fgIconBaseURL);
19 | }
20 |
21 | public static final String COLLAPSE= "collapseall.gif"; //$NON-NLS-1$
22 | public static final String EXPAND= "expandall.gif"; //$NON-NLS-1$
23 | public static final String LINK_WITH_EDITOR= "synced.gif"; //$NON-NLS-1$
24 |
25 | public static final String SETFOCUS= "setfocus.gif"; //$NON-NLS-1$
26 | public static final String REFRESH= "refresh.gif"; //$NON-NLS-1$
27 |
28 | public static final String STATISTICS= "statistics.gif"; //$NON-NLS-1$
29 |
30 | //---- Helper methods to access icons on the file system --------------------------------------
31 | public static void setImageDescriptors(IAction action, String type) {
32 | try {
33 | ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL("d", type)); //$NON-NLS-1$
34 | if (id != null)
35 | action.setDisabledImageDescriptor(id);
36 | } catch (MalformedURLException e) {
37 | e.printStackTrace();
38 | }
39 |
40 | try {
41 | ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL("c", type)); //$NON-NLS-1$
42 | if (id != null)
43 | action.setHoverImageDescriptor(id);
44 | } catch (MalformedURLException e) {
45 | e.printStackTrace();
46 | }
47 |
48 | action.setImageDescriptor(create("e", type)); //$NON-NLS-1$
49 | }
50 |
51 |
52 | private static ImageDescriptor create(String path, String name) {
53 | try {
54 | return ImageDescriptor.createFromURL(makeIconFileURL(path, name));
55 | } catch (MalformedURLException e) {
56 | return ImageDescriptor.getMissingImageDescriptor();
57 | }
58 | }
59 |
60 | private static URL makeIconFileURL(String path, String name) throws MalformedURLException {
61 | if (fgIconBaseURL == null) {
62 | throw new MalformedURLException();
63 | }
64 |
65 | StringBuffer buffer= new StringBuffer(path);
66 | buffer.append('/');
67 | buffer.append(name);
68 | return new URL(fgIconBaseURL, buffer.toString());
69 | }
70 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/SinkStatsDialog.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * SinkStatsDialog.java, version 2.8, 2010
5 | */
6 | import org.eclipse.jface.dialogs.IDialogConstants;
7 | import org.eclipse.jface.dialogs.StatusDialog;
8 | import org.eclipse.swt.SWT;
9 | import org.eclipse.swt.layout.GridData;
10 | import org.eclipse.swt.layout.GridLayout;
11 | import org.eclipse.swt.widgets.Composite;
12 | import org.eclipse.swt.widgets.Control;
13 | import org.eclipse.swt.widgets.Display;
14 | import org.eclipse.swt.widgets.Shell;
15 | import org.eclipse.swt.widgets.Text;
16 |
17 | class SinkStatsDialog extends StatusDialog {
18 | // private Text fMaxCallDepth;
19 | // private Text fMaxCallers;
20 | // // checkboxes
21 | // private Button fInitialUse;
22 | // private Button fFilterOnNames;
23 | // private Button fFormalParameters;
24 | // private Button fLocalDeclarations;
25 | // private Button fFollowCalls;
26 | // private Button fLimitPropDepth;
27 | private SinkView view;
28 |
29 | protected SinkStatsDialog(Shell parentShell, SinkView view) {
30 | super(parentShell);
31 | this.view = view;
32 | }
33 |
34 | protected void configureShell(Shell newShell) {
35 | super.configureShell(newShell);
36 | newShell.setText("Sink statistics properties");
37 | }
38 |
39 | protected Control createDialogArea(Composite parent) {
40 | Composite superComposite = (Composite) super.createDialogArea(parent);
41 | Composite composite = new Composite(superComposite, SWT.NONE);
42 | composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
43 | GridLayout layout = new GridLayout();
44 | layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
45 | layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
46 | layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
47 | layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
48 | composite.setLayout(layout);
49 | Text outputArea = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL);
50 | outputArea.setSize(500, 300);
51 | outputArea.setText(view.getStatisticsManager().getStatistics());
52 | outputArea.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
53 | return composite;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/Utils.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * Utils.java, version 2.8, 2010
5 | */
6 |
7 | import org.eclipse.core.resources.IResource;
8 | import org.eclipse.jdt.core.IMember;
9 | import org.eclipse.jdt.core.dom.CompilationUnit;
10 | import org.eclipse.jdt.core.dom.Expression;
11 | import org.eclipse.jdt.core.dom.MethodDeclaration;
12 |
13 | /**
14 | * Some strongly typed pairs...
15 | * */
16 | public class Utils {
17 | public static class ExprUnitResource {
18 | Expression expr;
19 | CompilationUnit cu;
20 | IResource resource;
21 |
22 | public ExprUnitResource(Expression expr, CompilationUnit cu, IResource resource) {
23 | this.expr = expr;
24 | this.cu = cu;
25 | this.resource = resource;
26 | }
27 | public CompilationUnit getCompilationUnit() {
28 | return cu;
29 | }
30 |
31 | /**
32 | * This is either a MethodInvocation or a ClassInstanceCreation.
33 | * */
34 | public Expression getExpression() {
35 | return expr;
36 | }
37 | public IResource getResource() {
38 | return resource;
39 | }
40 | }
41 | public static class ExprUnitResourceMember extends ExprUnitResource {
42 | private IMember member;
43 |
44 | public ExprUnitResourceMember(Expression expr, CompilationUnit cu, IResource resource, IMember member) {
45 | super(expr, cu, resource);
46 | this.member = member;
47 | }
48 |
49 | public IMember getMember() {
50 | return member;
51 | }
52 | }
53 |
54 | public static class MethodDeclarationUnitPair {
55 | MethodDeclaration method;
56 | CompilationUnit cu;
57 | IResource resource;
58 | IMember member;
59 |
60 | public MethodDeclarationUnitPair(MethodDeclaration method, CompilationUnit cu, IResource resource, IMember member) {
61 | this.method = method;
62 | this.cu = cu;
63 | this.resource = resource;
64 | this.member = member;
65 | }
66 | public CompilationUnit getCompilationUnit() {
67 | return cu;
68 | }
69 | public MethodDeclaration getMethod() {
70 | return method;
71 | }
72 | public IResource getResource() {
73 | return resource;
74 | }
75 | public IMember getMember() {
76 | return member;
77 | }
78 | }
79 |
80 | public static class ExpressionUnitPair {
81 | Expression expr;
82 | CompilationUnit cu;
83 | IResource resource;
84 |
85 | public ExpressionUnitPair(Expression expr, CompilationUnit cu, IResource resource) {
86 | this.expr = expr;
87 | this.cu = cu;
88 | this.resource = resource;
89 | }
90 | public CompilationUnit getCompilationUnit() {
91 | return cu;
92 | }
93 | public Expression getExpression() {
94 | return expr;
95 | }
96 | public IResource getResource() {
97 | return resource;
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/SuperListener.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * SuperListener.java,version 2.8, 2010
5 | */
6 |
7 | import org.eclipse.core.filebuffers.IFileBuffer;
8 | import org.eclipse.core.filebuffers.IFileBufferListener;
9 | import org.eclipse.core.filebuffers.ITextFileBuffer;
10 | import org.eclipse.core.runtime.CoreException;
11 | import org.eclipse.core.runtime.IPath;
12 |
13 | import org.eclipse.jdt.internal.ui.JavaPlugin;
14 |
15 | import org.eclipse.jface.text.DocumentEvent;
16 | import org.eclipse.jface.text.IDocumentListener;
17 | import org.eclipse.jface.viewers.ISelection;
18 |
19 | import org.eclipse.ui.ISelectionListener;
20 | import org.eclipse.ui.IWorkbenchPart;
21 | import org.eclipse.ui.texteditor.ITextEditor;
22 |
23 |
24 | class SuperListener implements ISelectionListener, IFileBufferListener, IDocumentListener
25 | {
26 | private final LapseView view;
27 |
28 | /**
29 | * @param LapseView
30 | */
31 | SuperListener(LapseView view) {
32 | this.view = view;
33 | }
34 |
35 | //Listener to see the changes in the selection of the text editor view
36 | public void selectionChanged(IWorkbenchPart part, ISelection selection) {
37 |
38 | if (part != this.view.fEditor && part instanceof ITextEditor && (LapseView.getJavaInput((ITextEditor) part) != null))
39 | {
40 | try {
41 | if(LapseView.TRACE) {
42 | System.out.println("In selectionChanged: setting the input");
43 | }
44 |
45 | this.view.setInput((ITextEditor) part);
46 |
47 | if(this.view.fEditor == null) {
48 | throw new RuntimeException("Couldn't set the editor properly");
49 | }
50 |
51 | } catch (CoreException e) {
52 | JavaPlugin.logErrorMessage("Caught exception: " + e.toString());
53 | return;
54 | }
55 | }
56 |
57 | }
58 |
59 | public void bufferCreated(IFileBuffer buffer) {
60 | //System.out.println("Buffer created for " + buffer.getLocation());
61 | }
62 |
63 | public void bufferDisposed(IFileBuffer buffer) {
64 | if (buffer instanceof ITextFileBuffer) {
65 | this.view.uninstallModificationListener();
66 | }
67 | }
68 |
69 | public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {}
70 | public void bufferContentReplaced(IFileBuffer buffer) {}
71 | public void stateChanging(IFileBuffer buffer) {}
72 | public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) {}
73 | public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {}
74 | public void underlyingFileMoved(IFileBuffer buffer, IPath path) {}
75 | public void underlyingFileDeleted(IFileBuffer buffer) {}
76 | public void stateChangeFailed(IFileBuffer buffer) {}
77 |
78 |
79 | public void documentChanged(DocumentEvent event) {
80 | try {
81 | this.view.setInput(this.view.fEditor);
82 | } catch (CoreException e) {
83 | JavaPlugin.log(e);
84 | }
85 | }
86 | public void documentAboutToBeChanged(DocumentEvent event) {}
87 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/NodeFinder.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * NodeFinder.java, version 2.8, 2010
5 | */
6 |
7 | import org.eclipse.jdt.core.dom.ASTNode;
8 | import org.eclipse.jdt.internal.corext.dom.GenericVisitor;
9 |
10 | /**
11 | * For a give range finds the node covered and the node covering.
12 | */
13 | public class NodeFinder extends GenericVisitor {
14 |
15 | /**
16 | * A visitor that maps a selection to a given ASTNode. The result node is
17 | * determined as follows:
18 | *
19 | * - first the visitor tries to find a node with the exact start and length
20 | * - if no such node exists than the node that encloses the range defined by
21 | * start and end is returned.
22 | * - if the length is zero than also nodes are considered where the node's
23 | * start or end position matches
start.
24 | * - otherwise
null is returned.
25 | *
26 | */
27 | public static ASTNode perform(ASTNode root, int start, int length) {
28 | NodeFinder finder= new NodeFinder(start, length);
29 | root.accept(finder);
30 | ASTNode result= finder.getCoveredNode();
31 | if (result == null || result.getStartPosition() != start || result.getLength() != length) {
32 | return finder.getCoveringNode();
33 | }
34 | return result;
35 | }
36 |
37 | private int fStart;
38 | private int fEnd;
39 |
40 | private ASTNode fCoveringNode;
41 | private ASTNode fCoveredNode;
42 |
43 | public NodeFinder(int offset, int length) {
44 | super(/*true*/); // include Javadoc tags
45 | fStart= offset;
46 | fEnd= offset + length;
47 | }
48 |
49 | public NodeFinder() {}
50 |
51 | protected boolean visitNode(ASTNode node) {
52 | int nodeStart= node.getStartPosition();
53 | int nodeEnd= nodeStart + node.getLength();
54 | if (nodeEnd < fStart || fEnd < nodeStart) {
55 | return false;
56 | }
57 | if (nodeStart <= fStart && fEnd <= nodeEnd) {
58 | fCoveringNode= node;
59 | }
60 | if (fStart <= nodeStart && nodeEnd <= fEnd) {
61 | if (fCoveringNode == node) { // nodeStart == fStart && nodeEnd == fEnd
62 | fCoveredNode= node;
63 | return true; // look further for node with same length as parent
64 | } else if (fCoveredNode == null) { // no better found
65 | fCoveredNode= node;
66 | }
67 | return false;
68 | }
69 | return true;
70 | }
71 |
72 | /**
73 | * Returns the covered node. If more than one nodes are covered by the selection, the
74 | * returned node is first covered node found in a top-down traversal of the AST
75 | * @return ASTNode
76 | */
77 | public ASTNode getCoveredNode() {
78 | return fCoveredNode;
79 | }
80 |
81 | /**
82 | * Returns the covering node. If more than one nodes are covering the selection, the
83 | * returned node is last covering node found in a top-down traversal of the AST
84 | * @return ASTNode
85 | */
86 | public ASTNode getCoveringNode() {
87 | return fCoveringNode;
88 | }
89 | public void setOffset(int offset) {
90 | fStart = offset;
91 | }
92 | public void setLength(int length) {
93 | fEnd= fStart + length;
94 | }
95 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/NestedDefinitionLocation.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * NestedDefinitionLocation.java, version 2.8, 2010
5 | */
6 |
7 | import java.util.ArrayList;
8 | import java.util.Collection;
9 |
10 | import org.eclipse.core.resources.IResource;
11 | import org.eclipse.jdt.core.dom.ASTNode;
12 |
13 | public class NestedDefinitionLocation extends DefinitionLocation {
14 | NestedDefinitionLocation parent;
15 | private Collection children;
16 | boolean recursive = false;
17 |
18 | public NestedDefinitionLocation(String name, IResource resource, int lineNumber, ASTNode ast, NestedDefinitionLocation parent){
19 | super(name, resource, lineNumber, ast);
20 |
21 | this.parent = parent;
22 |
23 | if(parent != null) {
24 | // register children
25 | parent.addChild(this);
26 | }
27 | }
28 |
29 | public NestedDefinitionLocation(String name, IResource resource, int lineNumber, ASTNode ast){
30 | this(name, resource, lineNumber, ast, null);
31 | }
32 |
33 | private void addChild(DefinitionLocation location) {
34 | if(children == null) {
35 | children = new ArrayList();
36 | }
37 | children.add(location);
38 | }
39 |
40 | public NestedDefinitionLocation getParent() {
41 | return parent;
42 | }
43 |
44 | /**
45 | * @return Returns the children.
46 | */
47 | public Collection getChildren() {
48 | return children;
49 | }
50 |
51 | public boolean hasChildren() {
52 | return children != null && children.size() > 0;
53 | }
54 |
55 | public boolean containsAncestor(ASTNode name) {
56 | // System.out.println(
57 | // "Checking " + getASTNode() + ", " + getASTNode().hashCode() + " vs " +
58 | // name + ", " + name.hashCode());
59 | if(parent == null) {
60 | return false;
61 | }
62 |
63 | if(same(parent.getASTNode(), name)) {
64 | logError(
65 | getParent().getASTNode() + " at " + parent.getASTNode().getStartPosition() + " and " +
66 | name + " at " + name.getStartPosition() +
67 | " matched."
68 | );
69 | return true;
70 | } else {
71 | return getParent().containsAncestor(name);
72 | }
73 | }
74 |
75 | /**
76 | * Fast and, hopefully, correct comparator of AST nodes.
77 | * */
78 | private boolean same(ASTNode node1, ASTNode node2) {
79 | if(!node1.toString().equals(node2.toString())) return false;
80 | if(node1.getStartPosition() != node2.getStartPosition()) return false;
81 | if(node1.getLength() != node2.getLength()) return false;
82 |
83 | return true;
84 | }
85 |
86 | public int getDepth() {
87 | if(getParent() == null) return 1;
88 | return getParent().getDepth() + 1;
89 | }
90 |
91 | public boolean isRecursive() {
92 | return recursive;
93 | }
94 | public void setRecursive(boolean recursive) {
95 | this.recursive = recursive;
96 | }
97 |
98 | private static void log(String message, Throwable e) {
99 | LapsePlugin.trace(LapsePlugin.RECURSION, "NestedDefinitionLocation: " + message, e);
100 | }
101 |
102 | @SuppressWarnings("unused")
103 | private static void log(String message) {
104 | log(message, null);
105 | }
106 |
107 | private static void logError(String message) {
108 | log(message, new Throwable());
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/HistoryDropDownAction.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * HistoryDropDownAction.java, version 2.8, 2010
5 | */
6 |
7 | import lapsePlus.HistoryDefinitionLocation;
8 |
9 | import org.eclipse.jdt.internal.ui.JavaPluginImages;
10 | import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
11 | import org.eclipse.jface.action.Action;
12 | import org.eclipse.jface.action.ActionContributionItem;
13 | import org.eclipse.jface.action.IMenuCreator;
14 | import org.eclipse.jface.resource.ImageDescriptor;
15 | import org.eclipse.swt.SWT;
16 | import org.eclipse.swt.widgets.Control;
17 | import org.eclipse.swt.widgets.Menu;
18 | import org.eclipse.swt.widgets.MenuItem;
19 |
20 |
21 | /**
22 | * This file provides support for a pull-down history menu.
23 | * */
24 | public class HistoryDropDownAction extends Action implements IMenuCreator {
25 | public static final int RESULTS_IN_DROP_DOWN = 10;
26 |
27 | private LapseView fView;
28 | private Menu fMenu;
29 |
30 | public HistoryDropDownAction(LapseView view) {
31 | fView = view;
32 | fMenu= null;
33 | //setToolTipText(TypeHierarchyMessages.getString("HistoryDropDownAction.tooltip")); //$NON-NLS-1$
34 | JavaPluginImages.setLocalImageDescriptors(this, "history_list.gif"); //$NON-NLS-1$
35 | setMenuCreator(this);
36 | }
37 |
38 | public void dispose() {
39 | // action is reused, can be called several times.
40 | if (fMenu != null) {
41 | fMenu.dispose();
42 | fMenu= null;
43 | }
44 | }
45 |
46 | public Menu getMenu(Menu parent) {
47 | return null;
48 | }
49 |
50 | public Menu getMenu(Control parent) {
51 | if (fMenu != null) {
52 | fMenu.dispose();
53 | }
54 | fMenu= new Menu(parent);
55 | HistoryDefinitionLocation[] elements= fView.getHistoryEntries();
56 | boolean checked = addEntries(fMenu, elements);
57 | if (elements.length > RESULTS_IN_DROP_DOWN) {
58 | new MenuItem(fMenu, SWT.SEPARATOR);
59 | // Action others= new HistoryListAction(fView);
60 | // others.setChecked(checked);
61 | // addActionToMenu(fMenu, others);
62 | }
63 | return fMenu;
64 | }
65 |
66 | private boolean addEntries(Menu menu, HistoryDefinitionLocation[] elements) {
67 | boolean checked = false;
68 |
69 | int min = Math.min(elements.length, RESULTS_IN_DROP_DOWN);
70 | for (int i= 0; i < min; i++) {
71 | HistoryAction action = new HistoryAction(fView, elements[i]);
72 | action.setChecked(elements[i].equals(fView.getCurrentInput()));
73 | checked= checked || action.isChecked();
74 | addActionToMenu(menu, action);
75 | }
76 | return checked;
77 | }
78 |
79 |
80 | protected void addActionToMenu(Menu parent, Action action) {
81 | ActionContributionItem item= new ActionContributionItem(action);
82 | item.fill(parent, -1);
83 | }
84 | }
85 |
86 | class HistoryAction extends Action {
87 | private LapseView fViewPart;
88 | private HistoryDefinitionLocation fElement;
89 |
90 | public HistoryAction(LapseView viewPart, HistoryDefinitionLocation element) {
91 | super();
92 | fViewPart= viewPart;
93 | fElement= element;
94 |
95 | setText(element.getName() + " at " + element.getResource().getName() + ":" + element.getLineNumber());
96 | setImageDescriptor(getImageDescriptor(element));
97 |
98 | setDescription(element.getName() + " at " + element.getResource().getName() + ":" + element.getLineNumber());
99 | setToolTipText(element.toString());
100 | }
101 |
102 | private ImageDescriptor getImageDescriptor(HistoryDefinitionLocation elem) {
103 | JavaElementImageProvider imageProvider= new JavaElementImageProvider();
104 | ImageDescriptor desc = JavaPluginImages.DESC_FIELD_DEFAULT;
105 | imageProvider.dispose();
106 | return desc;
107 | }
108 |
109 | /*
110 | * @see Action#run()
111 | */
112 | public void run() {
113 | fViewPart.gotoHistoryEntry(fElement);
114 | }
115 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/HistoryDefinitionLocation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created on Jun 3, 2004
3 | *
4 | * To change the template for this generated file go to
5 | * Window>Preferences>Java>Code Generation>Code and Comments
6 | */
7 | package lapsePlus;
8 |
9 | /*
10 | * HistoryDefinitionLocation.java, version 2.8, 2010
11 | */
12 |
13 | import java.util.Iterator;
14 |
15 | import org.eclipse.core.resources.IResource;
16 | import org.eclipse.jdt.core.dom.ASTNode;
17 |
18 | public class HistoryDefinitionLocation extends NestedDefinitionLocation {
19 | /**
20 | * Type contants. Make sure to update the string descriptions below if you change
21 | * any of these constants.
22 | * */
23 | public final static int NO_TYPE = 0; // default type
24 | public final static int CALL_ARG = 1; // actual parameter of a call
25 | public final static int CALL = 2; // call expression
26 | public final static int FORMAL_PARAMETER = 3; // formal parameter of a method
27 | public final static int RETURN = 4; // formal parameter of a method
28 | public final static int DECLARATION = 5; // local declaration
29 | public final static int FIELD = 6; // field declaration
30 | public final static int STRING_CONSTANT = 7; // string constant or a result of their concatenations
31 | public final static int STRING_CONCAT = 8; // string constant or a result of their concatenations
32 | public final static int UNDEFINED = 9; // no definition found for some reason
33 | public final static int INITIAL = 10; // initial query
34 | public final static int RECURSION = 11; // recursive invocation
35 | public final static int COPY = 12; // assignment
36 | public final static int ARRAYACCESS = 13; // array access
37 | public final static int NULL = 14; // array access
38 | public final static int DERIVATION = 15; // array access
39 | public final static int CLASS_INSTANCE_CREATION = 16; // array access
40 |
41 | /*final static String[] TYPE_NAMES = {
42 | "",
43 | "CALL ARGUMENT",
44 | "CALL EXPRESSION",
45 | "FORMAL PARAMETER",
46 | "RETURN",
47 | "LOCAL DECLARATION",
48 | "FIELD DECLARATION",
49 | "STRING CONSTANT",
50 | "STRING CONCATENATION",
51 | "UNDEFINED",
52 | "INITIAL",
53 | "RECURSION",
54 | "COPY"
55 | };*/
56 |
57 | final static String[] TYPE_NAMES = {
58 | "",
59 | "argument of a call",
60 | "call expression",
61 | "formal argument",
62 | "return value",
63 | "local variable declaration",
64 | "field declaration",
65 | "string constant",
66 | "string concatenation operation",
67 | "undefined value or constant",
68 | "initial",
69 | "recursion",
70 | "assignment operation",
71 | "array access",
72 | "null literal",
73 | "derivation method",
74 | "class instance creation"
75 | };
76 |
77 | private int type = NO_TYPE;
78 | boolean maxLevel = false;
79 |
80 | public HistoryDefinitionLocation(String name, IResource resource, int lineNumber, ASTNode ast, NestedDefinitionLocation parent, int type) {
81 | super(name, resource, lineNumber, ast, parent);
82 |
83 | this.type = type;
84 | }
85 |
86 | public HistoryDefinitionLocation(String name, IResource resource, int lineNumber, ASTNode ast, NestedDefinitionLocation parent) {
87 | this(name, resource, lineNumber, ast, parent, NO_TYPE);
88 | }
89 |
90 | public int getType() {return type;}
91 |
92 | String getTypeName() {return TYPE_NAMES[type];}
93 |
94 | public boolean isMaxLevel() {
95 | return maxLevel;
96 | }
97 | public void setMaxLevel(boolean maxLevel) {
98 | this.maxLevel = maxLevel;
99 | }
100 |
101 | public boolean isConstant() {
102 | if(!hasChildren()) {
103 | return type == STRING_CONSTANT;
104 | } else {
105 | for(Iterator iter = getChildren().iterator(); iter.hasNext();) {
106 | HistoryDefinitionLocation child = (HistoryDefinitionLocation) iter.next();
107 |
108 | if(!child.isConstant()) {
109 | return false;
110 | }
111 | }
112 | return true;
113 | }
114 | }
115 |
116 | public String toString() {
117 | return super.toString() + " [" + getTypeName() + "] " +
118 | (isMaxLevel() ? " exceeding the maximum depth" : "") +
119 | (isRecursive() ? " terminated because of recursion" : "");
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/sources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Parameter Tampering
7 |
8 |
9 |
10 | Parameter Tampering
11 |
12 |
13 |
14 | Parameter Tampering
15 |
16 |
17 |
18 | Parameter Tampering
19 |
20 |
21 |
22 | Parameter Tampering
23 |
24 |
25 |
26 | Parameter Tampering
27 |
28 |
29 |
30 | Parameter Tampering
31 |
32 |
33 |
34 | Parameter Tampering
35 |
36 |
37 |
38 |
39 | Header Manipulation
40 |
41 |
42 |
43 | Header Manipulation
44 |
45 |
46 |
47 | Header Manipulation
48 |
49 |
50 |
51 | Header Manipulation
52 |
53 |
54 |
55 | Header Manipulation
56 |
57 |
58 |
59 | Header Manipulation
60 |
61 |
62 |
63 | Header Manipulation
64 |
65 |
66 |
67 | Header Manipulation
68 |
69 |
70 |
71 | Header Manipulation
72 |
73 |
74 |
75 | Header Manipulation
76 |
77 |
78 |
79 | Header Manipulation
80 |
81 |
82 |
83 | Header Manipulation
84 |
85 |
86 |
87 | Header Manipulation
88 |
89 |
90 |
91 | Header Manipulation
92 |
93 |
94 |
95 | Header Manipulation
96 |
97 |
98 |
99 | Header Manipulation
100 |
101 |
102 |
103 | Header Manipulation
104 |
105 |
106 |
107 | Header Manipulation
108 |
109 |
110 |
113 |
114 |
117 |
118 |
119 |
120 | URL Tampering
121 |
122 |
123 |
124 | URL Tampering
125 |
126 |
127 |
128 |
129 | Cookie Poisoning
130 |
131 |
132 |
133 | Cookie Poisoning
134 |
135 |
136 |
139 |
140 |
141 | Cookie Poisoning
142 |
143 |
144 |
145 | Cookie Poisoning
146 |
147 |
148 |
149 |
150 |
151 | Information Leakage
152 |
153 |
154 |
155 | Information Leakage
156 |
157 |
158 |
159 | Information Leakage
160 |
161 |
162 |
163 | Information Leakage
164 |
165 |
166 |
167 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/DLTreeLabelProvider.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * DLTreeLabelProvider.java, version 2.8, 2010
5 | */
6 |
7 | import lapsePlus.HistoryDefinitionLocation;
8 |
9 | import org.eclipse.jdt.core.dom.ClassInstanceCreation;
10 | import org.eclipse.jdt.core.dom.Expression;
11 | import org.eclipse.jdt.core.dom.MethodInvocation;
12 | import org.eclipse.jdt.internal.ui.JavaPlugin;
13 | import org.eclipse.jdt.internal.ui.JavaPluginImages;
14 | import org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyImageDescriptor;
15 | import org.eclipse.jdt.internal.ui.viewsupport.ImageImageDescriptor;
16 | import org.eclipse.jface.resource.ImageDescriptor;
17 | import org.eclipse.jface.viewers.ILabelProviderListener;
18 | import org.eclipse.swt.SWT;
19 | import org.eclipse.swt.graphics.Color;
20 | import org.eclipse.swt.graphics.Image;
21 | import org.eclipse.swt.graphics.Point;
22 | import org.eclipse.swt.graphics.Rectangle;
23 | import org.eclipse.swt.widgets.Display;
24 | import org.eclipse.ui.internal.dialogs.ViewLabelProvider;
25 |
26 | public class DLTreeLabelProvider /*implements ILabelProvider*/ extends ColorDecoratingLabelProvider {
27 | public DLTreeLabelProvider() {
28 | super(new ViewLabelProvider(null, null), null);
29 | }
30 |
31 | public Color getForeground(Object element) {
32 | Display display = Display.getCurrent();
33 | HistoryDefinitionLocation loc = (HistoryDefinitionLocation) element;
34 |
35 | if(loc.isConstant()) {
36 | return display.getSystemColor(SWT.COLOR_DARK_BLUE);
37 | } else {
38 | String fullCalleeName = null;
39 | if(loc.getASTNode() instanceof MethodInvocation) {
40 | MethodInvocation mi = (MethodInvocation) loc.getASTNode();
41 | Expression s=mi.getExpression();
42 | fullCalleeName = mi.getName().getFullyQualifiedName();
43 | }else
44 | if(loc.getASTNode() instanceof ClassInstanceCreation) {
45 | ClassInstanceCreation mi = (ClassInstanceCreation) loc.getASTNode();
46 | fullCalleeName = mi.getType().toString();
47 | }
48 |
49 | if(fullCalleeName != null) {
50 | if(SourceView.isSourceName(fullCalleeName)) {
51 | return display.getSystemColor(SWT.COLOR_DARK_RED);
52 | } else
53 | if(SourceView.isSafeName(fullCalleeName)) {
54 | return display.getSystemColor(SWT.COLOR_DARK_GREEN);
55 | }
56 | }
57 | }
58 |
59 | return display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
60 | }
61 |
62 | public Image getImage(Object element) {
63 | if(!(element instanceof HistoryDefinitionLocation)) return null;
64 | HistoryDefinitionLocation hdl = (HistoryDefinitionLocation)element;
65 | Image result = null;
66 | switch(hdl.getType()) {
67 | case HistoryDefinitionLocation.CALL_ARG :
68 | result = JavaPluginImages.get(JavaPluginImages.IMG_MISC_PRIVATE); // actual parameter of a call
69 | break;
70 | case HistoryDefinitionLocation.FORMAL_PARAMETER :
71 | result = JavaPluginImages.get(JavaPluginImages.IMG_MISC_PROTECTED); // formal parameter of a method
72 | break;
73 | case HistoryDefinitionLocation.RETURN :
74 | result = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_INTERFACE_DEFAULT); // return result of a method
75 | break;
76 | case HistoryDefinitionLocation.DECLARATION :
77 | result = JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC); // local declaration
78 | break;
79 | case HistoryDefinitionLocation.UNDEFINED :
80 | result = JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE); // no definition found for some reason
81 | break;
82 | case HistoryDefinitionLocation.INITIAL :
83 | result = JavaPluginImages.get(JavaPluginImages.IMG_MISC_DEFAULT); // initial query
84 | break;
85 | default:
86 | result = JavaPluginImages.get(JavaPluginImages.IMG_MISC_PROTECTED);
87 | }
88 | int flags = 0;
89 | if (hdl.isRecursive()) {
90 | flags |= CallHierarchyImageDescriptor.RECURSIVE;
91 | }
92 | if (hdl.isMaxLevel()) {
93 | flags |= CallHierarchyImageDescriptor.MAX_LEVEL;
94 | }
95 | // adorn the image with a small arrow
96 | ImageDescriptor baseImage= new ImageImageDescriptor(result);
97 | Rectangle bounds= result.getBounds();
98 | return JavaPlugin.getImageDescriptorRegistry().get(
99 | new CallHierarchyImageDescriptor(
100 | baseImage,
101 | flags,
102 | new Point(bounds.width, bounds.height)));
103 | }
104 |
105 | /* (non-Javadoc)
106 | * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
107 | */
108 | public String getText(Object element) {
109 | HistoryDefinitionLocation curElem = (HistoryDefinitionLocation) element;
110 | if (curElem == null) {
111 | return "(error)";
112 | }
113 | return curElem.toString();
114 | }
115 |
116 | /* (non-Javadoc)
117 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
118 | */
119 | public void addListener(ILabelProviderListener listener) {
120 | }
121 |
122 | /* (non-Javadoc)
123 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
124 | */
125 | public void dispose() {
126 | }
127 |
128 | /* (non-Javadoc)
129 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
130 | */
131 | public boolean isLabelProperty(Object element, String property) {
132 | return false;
133 | }
134 |
135 | /* (non-Javadoc)
136 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
137 | */
138 | public void removeListener(ILabelProviderListener listener) {
139 | }
140 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/LapsePlugin.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * LapsePlugin.java, version 2.8, 2010
5 | */
6 | import java.util.MissingResourceException;
7 | import java.util.ResourceBundle;
8 |
9 | import lapsePlus.views.LapseView;
10 |
11 | import org.eclipse.core.runtime.Assert;
12 | import org.eclipse.core.runtime.IStatus;
13 | import org.eclipse.core.runtime.Platform;
14 | import org.eclipse.core.runtime.Plugin;
15 | import org.eclipse.core.runtime.Status;
16 | import org.osgi.framework.BundleContext;
17 |
18 | /**
19 | * The main plugin class to be used in the desktop.
20 | */
21 | public class LapsePlugin extends /* AbstractUI */Plugin {
22 | // The shared instance.
23 | private static LapsePlugin plugin;
24 |
25 | // Resource bundle.
26 | private ResourceBundle resourceBundle;
27 | LapseView lapseView = null;
28 |
29 | /** Setting that determine the logic of the slicer */
30 | private static int maxCallDepth = 10;
31 | public static int maxCallers = 10;
32 | public static boolean FOLLOW_INTO_FUNCTIONS = true;
33 | public static boolean LIMIT_PROP_DEPTH = true;
34 |
35 | public LapsePlugin() {
36 | super();
37 | plugin = this;
38 | try {
39 | resourceBundle = ResourceBundle.getBundle("lapse.LapsePluginResources");
40 | } catch (MissingResourceException x) {
41 | resourceBundle = null;
42 | }
43 | }
44 |
45 | /**
46 | * This method is called upon plug-in activation
47 | */
48 | public void start(BundleContext context) throws Exception {
49 | super.start(context);
50 | }
51 |
52 | /**
53 | * This method is called when the plug-in is stopped
54 | */
55 | public void stop(BundleContext context) throws Exception {
56 | super.stop(context);
57 | }
58 |
59 | /**
60 | * Returns the shared instance.
61 | */
62 | public static LapsePlugin getDefault() {
63 | return plugin;
64 | }
65 |
66 | /**
67 | * Returns the string from the plugin's resource bundle, or 'key' if not
68 | * found.
69 | */
70 | public static String getResourceString(String key) {
71 | ResourceBundle bundle = LapsePlugin.getDefault().getResourceBundle();
72 | try {
73 | return (bundle != null) ? bundle.getString(key) : key;
74 | } catch (MissingResourceException e) {
75 | return key;
76 | }
77 | }
78 |
79 | /**
80 | * Returns the plugin's resource bundle,
81 | */
82 | public ResourceBundle getResourceBundle() {
83 | return resourceBundle;
84 | }
85 |
86 | public static void setMaxCallDepth(int theMaxCallDepth) {
87 | maxCallDepth = theMaxCallDepth;
88 | }
89 |
90 | public static int getMaxCallDepth() {
91 | return maxCallDepth;
92 | }
93 |
94 | public static void setMaxCallers(int theMaxCallers) {
95 | maxCallers = theMaxCallers;
96 | }
97 |
98 | public static int getMaxCallers() {
99 | return maxCallers;
100 | }
101 |
102 | public void setLapseView(LapseView view) {
103 | this.lapseView = view;
104 | }
105 |
106 | public LapseView getLapseView() {
107 | return lapseView;
108 | }
109 |
110 | /**
111 | * Performs the Platform.getDebugOption true check on the provided trace
112 | *
113 | * @param trace
114 | * constant, defined in the Trace class
115 | * @return true if -debug is on for this plugin
116 | */
117 | public static boolean isDebugging(final String trace) {
118 | return
119 | getDefault().isDebugging()
120 | && "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$
121 | }
122 |
123 | /**
124 | * Outputs a message or an Exception if the current plug-in is debugging.
125 | *
126 | * @param message
127 | * if not null, message will be sent to standard out
128 | * @param e
129 | * if not null, e.printStackTrace() will be called.
130 | */
131 | public static void trace(String trace_mode, String message, Throwable e) {
132 | if (isDebugging(trace_mode)) {
133 | Assert.isNotNull(message);
134 | if (e == null) {
135 | logInfo(message);
136 | } else {
137 | logError(message, e);
138 | }
139 | }
140 | }
141 |
142 | /**
143 | * Logging APIs.
144 | * */
145 |
146 | public static final String SOURCE_DEBUG = "lapse/source-debug";
147 | public static final String SINK_DEBUG = "lapse/sink-debug";
148 | public static final String PROVENANCE_DEBUG = "lapse/provenance-debug";
149 | public static final String AST_PARSING = "lapse/ast-parsing";
150 | public static final String SEARCH = "lapse/search";
151 | public static final String RECURSION = "lapse/recursion";
152 | public static final String ALL_DEBUG = "lapse/debug";
153 |
154 | public static void logInfo(String message) {
155 | log(IStatus.INFO, IStatus.OK, message, null);
156 | }
157 |
158 | public static void logError(Throwable exception) {
159 | logError("Unexpected Exception", exception);
160 | }
161 |
162 | public static void logError(String message, Throwable exception) {
163 | log(IStatus.ERROR, IStatus.OK, message, exception);
164 | }
165 |
166 | public static void log(int severity, int code, String message, Throwable exception) {
167 | log(createStatus(severity, code, message, exception));
168 | }
169 |
170 | public static IStatus createStatus(int severity, int code, String message, Throwable exception) {
171 | return new Status(severity, LapsePlugin.getDefault().getBundle().getSymbolicName(), code,
172 | message, exception);
173 | }
174 |
175 | private static void log(IStatus status) {
176 | LapsePlugin.getDefault().getLog().log(status);
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/DeclarationInfoManager.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * DeclarationInfoManager.java,version 2.8, 2010
5 | */
6 |
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | import lapsePlus.LapsePlugin;
11 |
12 | import org.eclipse.jdt.core.dom.ASTNode;
13 | import org.eclipse.jdt.core.dom.ASTVisitor;
14 | import org.eclipse.jdt.core.dom.CompilationUnit;
15 | import org.eclipse.jdt.core.dom.MethodDeclaration;
16 | import org.eclipse.jdt.core.dom.Modifier;
17 | import org.eclipse.jdt.core.dom.SimpleName;
18 | import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
19 | import org.eclipse.jdt.core.dom.VariableDeclaration;
20 | import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
21 |
22 | public class DeclarationInfoManager {
23 |
24 | static Map unit2info = new HashMap();
25 | //static Map unit2info;
26 |
27 | public static DeclarationInfo retrieveDeclarationInfo(CompilationUnit unit) {
28 | DeclarationInfo info = (DeclarationInfo) unit2info.get(unit);
29 | if(info == null) {
30 | DeclarationFinderVisitor visitor = new DeclarationFinderVisitor();
31 | unit.accept(visitor);
32 | info = visitor.getInfo();
33 | // save for future use
34 | unit2info.put(unit, info);
35 | visitor = null;
36 | }
37 |
38 | return info;
39 | }
40 |
41 | /*public static void initializeDeclarationMap(){
42 |
43 | unit2info = new HashMap();
44 |
45 | }*/
46 |
47 | public static class DeclarationInfo {
48 |
49 | Map name2node = new HashMap();
50 | private HashMap finalMap = new HashMap();
51 |
52 | public void setVariableDeclaration(String name, VariableDeclaration node) {
53 | log("Entering " + name + " -> " + node);
54 | name2node.put(name, node);
55 | }
56 |
57 | public VariableDeclaration getVariableDeclaration(String name) {
58 | log("Requesting " + name);
59 | return (VariableDeclaration) name2node.get(name);
60 | }
61 |
62 | public void setFinal(SimpleName name) {
63 | log("Making " + name + " final");
64 | finalMap.put(name, null);
65 | }
66 |
67 | public boolean isFinal(SimpleName name) {
68 | log("Requesting final status for " + name);
69 | return finalMap.get(name) != null;
70 | }
71 |
72 | public VariableDeclaration getVariableDeclaration(SimpleName name) {
73 | ASTNode node = name;
74 | do {
75 | node = node.getParent();
76 | } while ( node != null && !(node instanceof MethodDeclaration) );
77 |
78 | String key = null;
79 |
80 | if(node != null) {
81 | key = node.toString() + "/" + name.getFullyQualifiedName();
82 | }else {
83 | key = "GLOBAL" + name.getFullyQualifiedName();
84 | }
85 |
86 | logError("Trying " + key);
87 | VariableDeclaration var = getVariableDeclaration(key);
88 | if(var == null && node != null) {
89 | key = "GLOBAL" + name.getFullyQualifiedName();
90 | log("Trying " + key);
91 | var = getVariableDeclaration(key);
92 | }
93 |
94 | return var;
95 | }
96 |
97 | public String toString() {
98 | return "[VariableDeclaration for " + name2node.size() + "] name(s)";
99 | }
100 | }
101 |
102 | public static class DeclarationFinderVisitor extends ASTVisitor {
103 |
104 | DeclarationInfo info = new DeclarationInfo();
105 | MethodDeclaration fCurrentMethod = null;
106 |
107 | //////////////////////////////// VISITORS START ////////////////////////////////
108 | public boolean visit(MethodDeclaration node) {
109 | fCurrentMethod = node;
110 | return true;
111 | }
112 |
113 | public boolean visit(SingleVariableDeclaration node) {
114 | SimpleName name = node.getName();
115 | boolean isFinal = Modifier.isFinal(node.getModifiers());
116 | if(isFinal) {
117 | info.setFinal(name);
118 | }
119 |
120 | info.setVariableDeclaration(getKey(name), node);
121 | log("1. Encountered " + node);
122 |
123 | return true;
124 | }
125 |
126 | /*public boolean visit(VariableDeclarationExpression node) {
127 | for (Iterator iter = node.fragments().iterator(); iter.hasNext();) {
128 | VariableDeclarationFragment fragment = (VariableDeclarationFragment) iter.next();
129 | visit(fragment);
130 | }
131 | if(TRACE) System.out.println("2. Encountered " + node);
132 | return true;
133 | }*/
134 |
135 | // public boolean visit(FieldDeclaration node) {
136 | // for (Iterator iter = node.fragments().iterator(); iter.hasNext();) {
137 | // VariableDeclarationFragment fragment = (VariableDeclarationFragment) iter.next();
138 | // visit(fragment);
139 | // }
140 | // if(TRACE) System.out.println("3. Encountered " + node);
141 | // return true;
142 | // }
143 | //
144 | public boolean visit(VariableDeclarationFragment node) {
145 | info.setVariableDeclaration(getKey(node.getName()), node);
146 | log("4. Encountered " + node.getName());
147 | return true;
148 | }
149 |
150 | public void endVisit(MethodDeclaration node) {
151 | fCurrentMethod = null;
152 | }
153 | //////////////////////////////// END OF VISITORS ////////////////////////////////
154 |
155 | private String getKey(SimpleName name) {
156 | String result = null;
157 | if(fCurrentMethod != null) {
158 | result = fCurrentMethod.toString() + "/" + name.getFullyQualifiedName();
159 | }else {
160 | result = "GLOBAL" + name.getFullyQualifiedName();
161 | }
162 | log("Creating key " + result);
163 |
164 | return result;
165 | }
166 |
167 | // public boolean visit(VariableDeclarationStatement node) {
168 | // if(TRACE) System.err.println("5. Encountered " + node);
169 | // return true;
170 | // }
171 |
172 | public DeclarationInfo getInfo() {
173 | return info;
174 | }
175 | }
176 |
177 | private static void log(String message, Throwable e) {
178 | LapsePlugin.trace(LapsePlugin.AST_PARSING, message, e);
179 | }
180 |
181 | private static void log(String message) {
182 | log("Source view: " + message, null);
183 | }
184 |
185 | private static void logError(String message) {
186 | log(message, new Throwable());
187 | }
188 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/LapseMultiActionGroup.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * LapseMultiActionGroup.java, version 2.8, 2010
5 | */
6 |
7 | import org.eclipse.jdt.internal.ui.JavaPlugin;
8 | import org.eclipse.jface.action.ContributionItem;
9 | import org.eclipse.jface.action.IAction;
10 | import org.eclipse.jface.action.IMenuManager;
11 | import org.eclipse.jface.action.Separator;
12 | import org.eclipse.jface.resource.ImageDescriptor;
13 | import org.eclipse.swt.SWT;
14 | import org.eclipse.swt.events.SelectionAdapter;
15 | import org.eclipse.swt.events.SelectionEvent;
16 | import org.eclipse.swt.widgets.Menu;
17 | import org.eclipse.swt.widgets.MenuItem;
18 | import org.eclipse.ui.actions.ActionGroup;
19 |
20 | abstract public class LapseMultiActionGroup extends ActionGroup {
21 |
22 | IAction[] fActions;
23 | MenuItem[] fItems;
24 | boolean[] fStatus;
25 |
26 | /**
27 | * Creates a new action group with a given set of actions.
28 | *
29 | * @param actions
30 | * the actions for this multi group
31 | * @param currentSelection
32 | * decides which action is selected in the menu on start up.
33 | * Denotes the location in the actions array of the current
34 | * selected state. It cannot be null.
35 | */
36 | public LapseMultiActionGroup(IAction[] actions) {
37 | super();
38 |
39 | fActions = actions;
40 | }
41 |
42 | /**
43 | * Add the actions to the given menu manager.
44 | */
45 | abstract protected void addActions(IMenuManager viewMenu);
46 | }
47 |
48 | class LapseRadioActionGroup extends LapseMultiActionGroup {
49 | private int fCurrentSelection;
50 |
51 | public LapseRadioActionGroup(IAction[] actions, int currentSelection, boolean toggle) {
52 | super(actions);
53 |
54 | fCurrentSelection = currentSelection;
55 | fActions = actions;
56 | }
57 |
58 | public void setEnabled(boolean enabled) {
59 | for (int i = 0; i < fItems.length; i++) {
60 | MenuItem e = fItems[i];
61 | if (e != null) {
62 | e.setEnabled(enabled);
63 | }
64 | }
65 | }
66 |
67 | /**
68 | * Add the actions to the given menu manager.
69 | */
70 | protected void addActions(IMenuManager viewMenu) {
71 |
72 | viewMenu.add(new Separator());//we begin adding a Separator
73 |
74 | fItems = new MenuItem[fActions.length];
75 | fStatus = new boolean[fActions.length];
76 |
77 | //We go all over the actions
78 | for (int i = 0; i < fActions.length; i++) {
79 |
80 | final int j = i;
81 |
82 | //We create the menu
83 | viewMenu.add(new ContributionItem() {//Contribution item in a menu is a button or a separator. A contribution item in a menu bar is a menu
84 |
85 | public void fill(Menu menu, int index) {
86 | // System.err.println("Filling the menu");
87 | int style = SWT.CHECK;
88 |
89 | if ((fActions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0)
90 | style = SWT.RADIO;
91 |
92 | //Initializing the menu and the images
93 | //The MenuItem receives a menu, the style of check or radio button
94 | MenuItem mi = new MenuItem(menu, style, index);
95 | ImageDescriptor d = fActions[j].getImageDescriptor();
96 | mi.setImage(JavaPlugin.getImageDescriptorRegistry().get(d));
97 | fItems[j] = mi;
98 |
99 | mi.setEnabled(true);
100 | mi.setText(fActions[j].getText());
101 | mi.setSelection(fCurrentSelection == j);
102 | fStatus[j] = (fCurrentSelection == j);
103 |
104 | //To know if the menu is selected
105 | mi.addSelectionListener(new SelectionAdapter() {
106 | public void widgetSelected(SelectionEvent e) {
107 | if (fCurrentSelection == j) {
108 | // already selected
109 | fItems[fCurrentSelection].setSelection(true);
110 | fStatus[fCurrentSelection] = true;
111 | return;
112 | }
113 |
114 | fActions[j].run();
115 |
116 | // Update checked state
117 | fItems[fCurrentSelection].setSelection(false);
118 | fStatus[fCurrentSelection] = false;
119 | fCurrentSelection = j;
120 | fItems[fCurrentSelection].setSelection(true);
121 | fStatus[fCurrentSelection] = true;
122 | }
123 | });
124 | }
125 | });
126 | }
127 | }
128 | }
129 |
130 | class LapseCheckboxActionGroup extends LapseMultiActionGroup {
131 | boolean fInitial[]; // initial values
132 |
133 | public LapseCheckboxActionGroup(IAction[] actions, boolean[] initial) {
134 | super(actions);
135 |
136 | fActions = actions;
137 | this.fInitial = initial;
138 | }
139 |
140 | public void setEnabled(boolean enabled) {
141 | for (int i = 0; i < fItems.length; i++) {
142 | MenuItem e = fItems[i];
143 | if (e != null) {
144 | e.setEnabled(enabled);
145 | }
146 | }
147 | }
148 |
149 | /**
150 | * Add the actions to the given menu manager.
151 | */
152 | protected void addActions(IMenuManager viewMenu) {
153 | viewMenu.add(new Separator());
154 | fItems = new MenuItem[fActions.length];
155 | fStatus = new boolean[fActions.length];
156 |
157 | for (int i = 0; i < fActions.length; i++) {
158 | final int j = i;
159 |
160 | if ((fInitial != null) && fInitial[j]) {
161 | fActions[j].run();
162 | }
163 |
164 | viewMenu.add(new ContributionItem() {
165 | public void fill(Menu menu, int index) {
166 | // System.err.println("Filling the menu");
167 | int style = SWT.CHECK;
168 |
169 | MenuItem mi = new MenuItem(menu, style, index);
170 | ImageDescriptor d = fActions[j].getImageDescriptor();
171 | mi.setImage(JavaPlugin.getImageDescriptorRegistry().get(d));
172 | fItems[j] = mi;
173 |
174 | mi.setEnabled(true);
175 | mi.setText(fActions[j].getText());
176 |
177 | mi.setSelection((fInitial != null) && fInitial[j]);
178 | fStatus[j] = (fInitial != null) && fInitial[j];
179 |
180 | mi.addSelectionListener(new SelectionAdapter() {
181 | public void widgetSelected(SelectionEvent e) {
182 | MenuItem item = fItems[j];
183 | // System.err.println("Old value: " +
184 | // item.getSelection());
185 | item.setSelection(!fStatus[j]);
186 | fStatus[j] = !fStatus[j];
187 | // System.err.println("New value: " +
188 | // item.getSelection());
189 |
190 | fActions[j].run();
191 |
192 | }
193 | });
194 | }
195 | });
196 | }
197 | }
198 | }
199 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/MethodSearchRequestor.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * MethodSearchRequestor.java, version 2.8, 2010
5 | */
6 |
7 | import java.util.ArrayList;
8 | import java.util.Collection;
9 | import java.util.HashMap;
10 | import java.util.Map;
11 |
12 | import org.eclipse.core.resources.IResource;
13 | import org.eclipse.jdt.core.ICompilationUnit;
14 | import org.eclipse.jdt.core.IMember;
15 | import org.eclipse.jdt.core.JavaModelException;
16 | import org.eclipse.jdt.core.dom.AST;
17 | import org.eclipse.jdt.core.dom.ASTNode;
18 | import org.eclipse.jdt.core.dom.ASTParser;
19 | import org.eclipse.jdt.core.dom.ClassInstanceCreation;
20 | import org.eclipse.jdt.core.dom.CompilationUnit;
21 | import org.eclipse.jdt.core.dom.Expression;
22 | import org.eclipse.jdt.core.dom.MethodDeclaration;
23 | import org.eclipse.jdt.core.dom.MethodInvocation;
24 | import org.eclipse.jdt.core.search.SearchMatch;
25 | import org.eclipse.jdt.core.search.SearchRequestor;
26 | import org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil;
27 |
28 | public class MethodSearchRequestor{
29 |
30 | //static Map parserMap = new HashMap();
31 |
32 | static Map parserMap;
33 |
34 | // Settings
35 | final static boolean SKIP_NOT_SOURCE = false;
36 | final static boolean SKIP_BINARY = false;
37 |
38 | static CompilationUnit retrieveCompilationUnit(ICompilationUnit unit) {
39 | CompilationUnit cu = (CompilationUnit) parserMap.get(unit);
40 | if (cu == null) {
41 | ASTParser parser = ASTParser.newParser(AST.JLS3);
42 | parser.setSource(unit);
43 | cu = (CompilationUnit) parser.createAST(null);
44 |
45 | parserMap.put(unit, cu);
46 | }
47 |
48 | return cu;
49 | }
50 |
51 | static void initializeParserMap(){
52 |
53 | parserMap = new HashMap();
54 |
55 | }
56 |
57 | public static class MethodReferencesSearchRequestor extends SearchRequestor {
58 |
59 | public class MethodCallResultCollector {
60 | ArrayList _methodUnitPairs;
61 |
62 | MethodCallResultCollector() {
63 | _methodUnitPairs = new ArrayList();
64 | }
65 |
66 | public void addCaller(Expression expr, CompilationUnit cu,
67 | IResource resource, IMember member) {
68 | _methodUnitPairs.add(new Utils.ExprUnitResourceMember(expr, cu,
69 | resource, member));
70 | }
71 |
72 | public Collection/* */getMethodUnitPairs() {
73 | return _methodUnitPairs;
74 | }
75 | }
76 |
77 | private MethodCallResultCollector fSearchResults;
78 | private boolean fRequireExactMatch = true;
79 |
80 | MethodReferencesSearchRequestor() {
81 | fSearchResults = new MethodCallResultCollector();
82 | }
83 |
84 | public void acceptSearchMatch(SearchMatch match) {
85 | log("Got match: " + match);
86 | if (fRequireExactMatch
87 | && (match.getAccuracy() != SearchMatch.A_ACCURATE)) {
88 | logError("Skipping unaccurate match " + match);
89 | return;
90 | }
91 |
92 | if (match.isInsideDocComment()) {
93 | log("Is inside doc " + match);
94 | return;
95 | }
96 |
97 | if (match.getElement() != null
98 | && match.getElement() instanceof IMember) {
99 | IMember member = (IMember) match.getElement();
100 | if (SKIP_BINARY && member.isBinary()) {
101 | log("Skipping binary member " + member);
102 | return;
103 | }
104 | // match.get
105 | if (member.getCompilationUnit() == null) {
106 | logError("No compilation unit for " + member);
107 | if (!SKIP_NOT_SOURCE) {
108 | fSearchResults.addCaller(null, null,
109 | match.getResource(), member);
110 | }
111 | return;
112 | }
113 | CompilationUnit cuNode = retrieveCompilationUnit(member.getCompilationUnit());
114 | ASTNode node = ASTNodeSearchUtil.getAstNode(match, cuNode);
115 | Expression expr = null;
116 |
117 | if (node != null) {
118 |
119 | if (node instanceof MethodInvocation) {
120 | expr = (MethodInvocation) node;
121 | } else if (node.getParent() instanceof MethodInvocation) {
122 | expr = (MethodInvocation) node.getParent();
123 | } else if (node instanceof ClassInstanceCreation) {
124 | expr = (ClassInstanceCreation) node;
125 | } else if (node.getParent() instanceof ClassInstanceCreation) {
126 | expr = (ClassInstanceCreation) node.getParent();
127 | } else {
128 | System.err.println("Unknown match type: " + node
129 | + " of type " + node.getClass());
130 | try {
131 | System.err
132 | .println("MethodReferencesSearchRequestor: Skipping node that appears in the search: "
133 | + node
134 | + " of type "
135 | + node.getClass()
136 | + " at line "
137 | + member.getCorrespondingResource()
138 | + ":"
139 | + cuNode.getLineNumber(node
140 | .getStartPosition()));
141 | } catch (JavaModelException e) {
142 | log(e.getMessage(), e);
143 | return;
144 | }
145 | return;
146 | }
147 | }
148 |
149 | IResource resource = match.getResource();
150 | if (resource == null) {
151 | System.err.println("No resource for " + match);
152 | return;
153 | }
154 |
155 | if (expr == null)
156 | System.err.println("expr is null");
157 |
158 | fSearchResults.addCaller(expr, cuNode, resource, member);
159 | // System.err.println("Matched " + mi + " of type " +
160 | // mi.getClass());
161 | } else {
162 | System.err.println("Skipping match: " + match);
163 | }
164 | }
165 |
166 | public Collection/* */getMethodUnitPairs() {
167 | return fSearchResults.getMethodUnitPairs();
168 | }
169 | }
170 |
171 | public static class MethodDeclarationsSearchRequestor extends
172 | SearchRequestor {
173 | public class MethodDeclarationlResultCollector {
174 | ArrayList _methodDeclarationUnitPairs;
175 |
176 | MethodDeclarationlResultCollector() {
177 | _methodDeclarationUnitPairs = new ArrayList();
178 | }
179 |
180 | public void addCaller(MethodDeclaration mi, CompilationUnit cu,
181 | IResource resource, IMember member) {
182 | _methodDeclarationUnitPairs
183 | .add(new Utils.MethodDeclarationUnitPair(mi, cu,
184 | resource, member));
185 | }
186 |
187 | public Collection/* */getMethodDeclarationUnitPairs() {
188 | return _methodDeclarationUnitPairs;
189 | }
190 | }
191 |
192 | private MethodDeclarationlResultCollector fSearchResults;
193 | private boolean fRequireExactMatch = true;
194 |
195 | public MethodDeclarationsSearchRequestor() {
196 | fSearchResults = new MethodDeclarationlResultCollector();
197 | }
198 |
199 | /*
200 | * (non-Javadoc)
201 | *
202 | * @see
203 | * org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org
204 | * .eclipse.jdt.core.search.SearchMatch)
205 | */
206 | public void acceptSearchMatch(SearchMatch match) {
207 | if (fRequireExactMatch
208 | && (match.getAccuracy() != SearchMatch.A_ACCURATE)) {
209 | return;
210 | }
211 |
212 | if (match.isInsideDocComment()) {
213 | return;
214 | }
215 |
216 | if (match.getElement() != null
217 | && match.getElement() instanceof IMember) {
218 | IMember member = (IMember) match.getElement();
219 | if (SKIP_BINARY && member.isBinary()) {
220 | log("Skipping binary member " + member);
221 | return;
222 | }
223 |
224 | if (member.getCompilationUnit() == null) {
225 | logError("No compilation unit for " + member);
226 | if (!SKIP_NOT_SOURCE) {
227 | fSearchResults.addCaller(null, null,
228 | match.getResource(), member);
229 | }
230 | return;
231 | }
232 |
233 | CompilationUnit cu = retrieveCompilationUnit(member
234 | .getCompilationUnit());
235 | ASTNode node = ASTNodeSearchUtil.getAstNode(match, cu);
236 |
237 | MethodDeclaration md = null;
238 |
239 | if (node != null) {
240 | if (node instanceof MethodDeclaration) {
241 | md = (MethodDeclaration) node;
242 | } else if (node.getParent() instanceof MethodDeclaration) {
243 | md = (MethodDeclaration) node.getParent();
244 | } else {
245 | try {
246 | System.err
247 | .println("MethodDeclarationsSearchRequestor: Skipping node that appears in the search: "
248 | + node
249 | + " of type "
250 | + node.getClass()
251 | + " at line "
252 | + member.getCorrespondingResource()
253 | + ":"
254 | + cu.getLineNumber(node
255 | .getStartPosition()));
256 | } catch (JavaModelException e) {
257 | log(e.getMessage(), e);
258 | return;
259 | }
260 | return;
261 | }
262 | }
263 |
264 | IResource resource = match.getResource();
265 | if (resource == null) {
266 | System.err.println("No resource for " + match);
267 | return;
268 | }
269 | fSearchResults.addCaller(md, cu, resource, member);
270 | log("Matched " + md + " in " + resource);
271 | }
272 | }
273 |
274 | public Collection/* */getMethodUnitPairs() {
275 | return fSearchResults.getMethodDeclarationUnitPairs();
276 | }
277 | }
278 |
279 | private static void log(String message, Throwable e) {
280 | LapsePlugin.trace(LapsePlugin.SEARCH, "Method search: " + message, e);
281 | }
282 |
283 | private static void log(String message) {
284 | log(message, null);
285 | }
286 |
287 | private static void logError(String message) {
288 | log(message, new Throwable());
289 | }
290 | }
--------------------------------------------------------------------------------
/sinks.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 1
7 | 0
8 | SQL Injection
9 |
10 |
11 | 2
12 | 0
13 | SQL Injection
14 |
15 |
16 | 2
17 | 0
18 | SQL Injection
19 |
20 |
21 | 2
22 | 0
23 | SQL Injection
24 |
25 |
26 | 1
27 | 0
28 | SQL Injection
29 |
30 |
31 | 1
32 | 0
33 | SQL Injection
34 |
35 |
36 | 2
37 | 0
38 | SQL Injection
39 |
40 |
41 | 2
42 | 0
43 | SQL Injection
44 |
45 |
46 | 2
47 | 0
48 | SQL Injection
49 |
50 |
51 | 1
52 | 0
53 | SQL Injection
54 |
55 |
56 | 1
57 | 0
58 | SQL Injection
59 |
60 |
61 | 2
62 | 0
63 | SQL Injection
64 |
65 |
66 | 2
67 | 0
68 | SQL Injection
69 |
70 |
71 | 3
72 | 0
73 | SQL Injection
74 |
75 |
76 | 4
77 | 0
78 | SQL Injection
79 |
80 |
81 | 2
82 | 0
83 | SQL Injection
84 |
85 |
86 | 1
87 | 0
88 | SQL Injection
89 |
90 |
91 | 3
92 | 0
93 | SQL Injection
94 |
95 |
96 | 4
97 | 0
98 | SQL Injection
99 |
100 |
101 |
102 |
103 | 1
104 | 0
105 | HTTP Response Splitting
106 |
107 |
108 |
109 |
110 | 1
111 | 0
112 | Cross-site Scripting
113 |
114 |
115 | 1
116 | 0
117 | Cross-site Scripting
118 |
119 |
120 | 1
121 | 0
122 | Cross-site Scripting
123 |
124 |
125 | 1
126 | 0
127 | Cross-site Scripting
128 |
129 |
130 | 1
131 | 0
132 | Cross-site Scripting
133 |
134 |
135 | 1
136 | 0
137 | Cross-site Scripting
138 |
139 |
140 |
141 | 1
142 | 0
143 | Path Traversal
144 |
145 |
146 | 2
147 | 0
148 | Path Traversal
149 |
150 |
151 | 1
152 | 0
153 | Path Traversal
154 |
155 |
156 | 1
157 | 0
158 | Path Traversal
159 |
160 |
161 | 1
162 | 0
163 | Path Traversal
164 |
165 |
166 | 1
167 | 0
168 | Path Traversal
169 |
170 |
171 |
172 |
173 | 1
174 | 0
175 | Command Injection
176 |
177 |
178 | 1
179 | 0
180 | Command Injection
181 |
182 |
183 | 2
184 | 0
185 | Command Injection
186 |
187 |
188 | 2
189 | 0
190 | Command Injection
191 |
192 |
193 | 3
194 | 0
195 | Command Injection
196 |
197 |
198 |
199 | 1
200 | 0
201 | Information Leakage
202 |
203 |
204 | 2
205 | 1
206 | Information Leakage
207 |
208 |
209 | 1
210 | 0
211 | XPath Injection
212 |
213 |
214 | 2
215 | 0
216 | XPath Injection
217 |
218 |
219 | 3
220 | 0
221 | XPath Injection
222 |
223 |
224 | 2
225 | 0
226 | XPath Injection
227 |
228 |
229 | 3
230 | 0
231 | XPath Injection
232 |
233 |
234 | 4
235 | 0
236 | XPath Injection
237 |
238 |
239 | 5
240 | 0
241 | XPath Injection
242 |
243 |
244 | 6
245 | 0
246 | XPath Injection
247 |
248 |
249 | 1
250 | 0
251 | XPath Injection
252 |
253 |
254 | 1
255 | 0
256 | XPath Injection
257 |
258 |
259 | 2
260 | 1
261 | XPath Injection
262 |
263 |
264 | 1
265 | 0
266 | XPath Injection
267 |
268 |
269 |
270 |
271 | 2
272 | 0
273 | LDAP Injection
274 |
275 |
276 | 5
277 | 0
278 | LDAP Injection
279 |
280 |
281 | 6
282 | 0
283 | LDAP Injection
284 |
285 |
286 |
287 | 6
288 | 2
289 | LDAP Injection
290 |
291 |
292 |
293 |
294 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/LapseConfigurationDialog.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * LapseConfigurationDialog.java,version 2.8, 2010
5 | */
6 |
7 | import lapsePlus.LapsePlugin;
8 |
9 | import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
10 | import org.eclipse.jface.dialogs.IDialogConstants;
11 | import org.eclipse.jface.dialogs.StatusDialog;
12 | import org.eclipse.swt.SWT;
13 | import org.eclipse.swt.events.ModifyEvent;
14 | import org.eclipse.swt.events.ModifyListener;
15 | import org.eclipse.swt.events.SelectionEvent;
16 | import org.eclipse.swt.events.SelectionListener;
17 | import org.eclipse.swt.layout.GridData;
18 | import org.eclipse.swt.layout.GridLayout;
19 | import org.eclipse.swt.widgets.Button;
20 | import org.eclipse.swt.widgets.Composite;
21 | import org.eclipse.swt.widgets.Control;
22 | import org.eclipse.swt.widgets.Group;
23 | import org.eclipse.swt.widgets.Label;
24 | import org.eclipse.swt.widgets.Shell;
25 | import org.eclipse.swt.widgets.Text;
26 |
27 | class LapseConfigurationDialog extends StatusDialog {
28 | private Text fMaxCallDepth;
29 | private Text fMaxCallers;
30 | // checkboxes
31 |
32 | /*private Button fInitialUse;
33 | private Button fFilterOnNames;
34 | private Button fFormalParameters;
35 | private Button fLocalDeclarations;*/
36 | private Button fFollowCalls;
37 | private Button fLimitPropDepth;
38 |
39 | protected LapseConfigurationDialog(Shell parentShell) {
40 | super(parentShell);
41 | }
42 |
43 | /*
44 | * (non-Javadoc) Method declared on Window.
45 | */
46 | protected void configureShell(Shell newShell) {
47 | super.configureShell(newShell);
48 | newShell.setText("Provenance tracker properties");
49 | }
50 |
51 | protected Control createDialogArea(Composite parent) {
52 | Composite superComposite = (Composite) super.createDialogArea(parent);
53 | Composite composite = new Composite(superComposite, SWT.NONE);
54 | composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
55 | GridLayout layout = new GridLayout();
56 | layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
57 | layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
58 | layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
59 | layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
60 | composite.setLayout(layout);
61 | //createFiltersArea(composite);
62 | //new Label(composite, SWT.NONE); // Filler
63 | createMaxCallDepthArea(composite);
64 | new Label(composite, SWT.NONE); // Filler
65 | applyDialogFont(parent);
66 | updateUIFromFilter();
67 | return composite;
68 | }
69 |
70 | private void createMaxCallDepthArea(Composite parent) {
71 | GridLayout l = new GridLayout();
72 | l.numColumns = 2;
73 | {
74 | Group group = new Group(parent, SWT.SHADOW_ETCHED_IN | SWT.FILL);
75 | group.setText("Slicer settings");
76 | group.setLayout(l);
77 | group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
78 | fLimitPropDepth = createCheckbox(group, "&Limit propagation depth", true);
79 | fLimitPropDepth.addSelectionListener(new SelectionListener() {
80 | public void widgetSelected(SelectionEvent e) {
81 | fMaxCallDepth.setEnabled(fLimitPropDepth.getSelection());
82 | }
83 |
84 | public void widgetDefaultSelected(SelectionEvent e) {
85 | // TODO Auto-generated method stub
86 | }
87 | });
88 | fLimitPropDepth.setSelection(true);
89 | new Label(group, SWT.NONE);
90 | new Label(group, SWT.NONE).setText("&Maximum call depth");
91 | fMaxCallDepth = new Text(group, SWT.SINGLE | SWT.BORDER);
92 | fMaxCallDepth.setTextLimit(4);
93 | fMaxCallDepth.addModifyListener(new ModifyListener() {
94 | public void modifyText(ModifyEvent e) {
95 | validateInput();
96 | }
97 | });
98 | }
99 | {
100 | Group group = new Group(parent, SWT.SHADOW_ETCHED_IN | SWT.FILL);
101 | group.setText("Traversal through return results");
102 | group.setLayout(l);
103 | group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
104 | fFollowCalls = createCheckbox(group, "Follow t&hrough calls backwards", true);
105 | fFollowCalls.addSelectionListener(new SelectionListener() {
106 | public void widgetSelected(SelectionEvent e) {
107 | fMaxCallers.setEnabled(fFollowCalls.getSelection());
108 | }
109 |
110 | public void widgetDefaultSelected(SelectionEvent e) {
111 | // TODO Auto-generated method stub
112 | }
113 | });
114 | fFollowCalls.setSelection(true);
115 | new Label(group, SWT.NONE);
116 | new Label(group, SWT.NONE).setText("Maximum callers to &process");
117 | fMaxCallers = new Text(group, SWT.SINGLE | SWT.BORDER);
118 | fMaxCallers.setTextLimit(4);
119 | fMaxCallers.addModifyListener(new ModifyListener() {
120 | public void modifyText(ModifyEvent e) {
121 | validateInput();
122 | }
123 | });
124 | {
125 | GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.END);
126 | gridData.widthHint = convertWidthInCharsToPixels(2);
127 | fMaxCallDepth.setLayoutData(gridData);
128 | }
129 | }
130 | {
131 | GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.END);
132 | gridData.widthHint = convertWidthInCharsToPixels(2);
133 | fMaxCallers.setLayoutData(gridData);
134 | }
135 | }
136 |
137 | /*private void createFiltersArea(Composite parent) {
138 | Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
139 | group.setText("Filter settings");
140 | GridLayout layout = new GridLayout();
141 | layout.numColumns = 2;
142 | group.setLayout(layout);
143 | fInitialUse = createCheckbox(group, "Include &inital use", true);
144 | fInitialUse.setSelection(true);
145 | fFilterOnNames = createCheckbox(group, "Include &call arguments", true);
146 | fFilterOnNames.setSelection(true);
147 | fFormalParameters = createCheckbox(group, "Include &formal parameters", true);
148 | fFormalParameters.setSelection(true);
149 | fLocalDeclarations = createCheckbox(group, "Include &local declarations", true);
150 | fLocalDeclarations.setSelection(true);
151 | // GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
152 | // GridData.GRAB_HORIZONTAL);
153 | // gridData.widthHint = convertWidthInCharsToPixels(60);
154 | }*/
155 |
156 | /**
157 | * Creates a check box button with the given parent and text.
158 | *
159 | * @param parent
160 | * the parent composite
161 | * @param text
162 | * the text for the check box
163 | * @param grabRow
164 | * trueto grab the remaining horizontal space,
165 | * false otherwise
166 | *
167 | * @return the check box button
168 | */
169 | private Button createCheckbox(Composite parent, String text, boolean grabRow) {
170 | Button button = new Button(parent, SWT.CHECK);
171 | if (grabRow) {
172 | GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
173 | button.setLayoutData(gridData);
174 | }
175 | button.setText(text);
176 | return button;
177 | }
178 |
179 | private void updateFilterFromUI() {
180 | int maxCallDepth = Integer.parseInt(this.fMaxCallDepth.getText());
181 | int maxCallers = Integer.parseInt(this.fMaxCallers.getText());
182 | LapsePlugin.setMaxCallDepth(maxCallDepth);
183 | LapsePlugin.setMaxCallers(maxCallers);
184 | LapsePlugin.FOLLOW_INTO_FUNCTIONS = fFollowCalls.getSelection();
185 | LapsePlugin.LIMIT_PROP_DEPTH = fLimitPropDepth.getSelection();
186 | // LapsePlugin.getDefault().getPreferenceStore().setValue("includeInitial",
187 | // fInitialUse.getEnabled());
188 | }
189 |
190 | /**
191 | * Updates the UI state from the given filter.
192 | *
193 | * @param filter
194 | * the filter to use
195 | */
196 | private void updateUIFromFilter() {
197 | fMaxCallDepth.setText(String.valueOf(LapsePlugin.getMaxCallDepth()));
198 | fMaxCallers.setText(String.valueOf(LapsePlugin.getMaxCallers()));
199 | fFollowCalls.setSelection(LapsePlugin.FOLLOW_INTO_FUNCTIONS);
200 | fLimitPropDepth.setSelection(LapsePlugin.LIMIT_PROP_DEPTH);
201 | }
202 |
203 | /**
204 | * Updates the filter from the UI state. Must be done here rather than by
205 | * extending open() because after super.open() is called, the widgetry is
206 | * disposed.
207 | *
208 | * @see org.eclipse.jface.dialogs.Dialog#okPressed()
209 | */
210 | protected void okPressed() {
211 | if (!isIntValid(fMaxCallDepth.getText())) {
212 | if (fMaxCallDepth.forceFocus()) {
213 | fMaxCallDepth.setSelection(0, fMaxCallDepth.getCharCount());
214 | fMaxCallDepth.showSelection();
215 | }
216 | }
217 | if (!isIntValid(fMaxCallers.getText())) {
218 | if (fMaxCallers.forceFocus()) {
219 | fMaxCallers.setSelection(0, fMaxCallers.getCharCount());
220 | fMaxCallers.showSelection();
221 | }
222 | }
223 | updateFilterFromUI();
224 | super.okPressed();
225 | }
226 |
227 | private boolean isIntValid(String text) {
228 | if (text.length() == 0) return false;
229 | try {
230 | int num = Integer.parseInt(text);
231 | return (num >= 1 && num <= 99);
232 | } catch (NumberFormatException e) {
233 | return false;
234 | }
235 | }
236 |
237 | private void validateInput() {
238 | StatusInfo status = new StatusInfo();
239 | if (!isIntValid(fMaxCallDepth.getText())) {
240 | status.setError("Invalid input: expecting a number between 1 and 99");
241 | }
242 | if (!isIntValid(fMaxCallers.getText())) {
243 | status.setError("Invalid input: expecting a number between 1 and 99");
244 | }
245 | updateStatus(status);
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/views/ProvenanceContentProvider.java:
--------------------------------------------------------------------------------
1 | package lapsePlus.views;
2 |
3 | /*
4 | * ProvenanceContentProvider.java, version 2.8, 2010
5 | */
6 |
7 | import java.util.ArrayList;
8 | import java.util.Collection;
9 | import java.util.HashSet;
10 | import java.util.Iterator;
11 | import java.util.Vector;
12 |
13 | import lapsePlus.HistoryDefinitionLocation;
14 |
15 | import org.eclipse.core.resources.IResource;
16 | import org.eclipse.jdt.internal.ui.JavaPlugin;
17 | import org.eclipse.jface.viewers.ISelection;
18 | import org.eclipse.jface.viewers.ITreeContentProvider;
19 | import org.eclipse.jface.viewers.StructuredSelection;
20 | import org.eclipse.jface.viewers.Viewer;
21 |
22 |
23 | public interface ProvenanceContentProvider extends ITreeContentProvider {
24 | public abstract void addElement(HistoryDefinitionLocation defLoc);
25 | public abstract void setCurrentInput(HistoryDefinitionLocation input);
26 | public abstract HistoryDefinitionLocation getCurrentInput();
27 | public abstract Object[] getAllElements();
28 | public abstract void clearElements();
29 | public abstract ProvenanceContentProvider switchType();
30 | public abstract ISelection getFirstElement();
31 | public abstract int getDepth();
32 |
33 | //---------------------------------- Methods for providing statistics ----------------------------------
34 | public abstract int getTotalElementCount();
35 | public abstract int getLeafElementCount();
36 | public abstract int getFileCount();
37 | public abstract int getTruncatedElementCount();
38 |
39 | public class HierarchicalViewContentProvider implements ProvenanceContentProvider {
40 | HistoryDefinitionLocation element = null;
41 | public HierarchicalViewContentProvider() {}
42 | public void inputChanged(Viewer v, Object oldInput, Object newInput) {
43 | }
44 | public void dispose() {
45 | }
46 | public Object[] getElements(Object parent) {
47 | return element != null ?
48 | new Object[] { element } :
49 | new Object[] {};
50 | }
51 | public void setElement(HistoryDefinitionLocation defLoc) {
52 | element = defLoc;
53 | }
54 | public void clearElements() {
55 | element = null;
56 | }
57 | public ProvenanceContentProvider switchType() {
58 | FlatViewContentProvider result = new FlatViewContentProvider();
59 | if(this.element != null) {
60 | result.addElement(this.element);
61 | }
62 |
63 | return result;
64 | }
65 |
66 | ////////////////////////////////////////////////////////////////////////
67 | // Tree support
68 | ////////////////////////////////////////////////////////////////////////
69 | public Object[] getChildren(Object parentElement) {
70 | if (parentElement instanceof HistoryDefinitionLocation) {
71 | HistoryDefinitionLocation loc = (HistoryDefinitionLocation) parentElement;
72 | if(loc.getChildren() != null) {
73 | return loc.getChildren().toArray();
74 | }
75 | }
76 | return null;
77 | }
78 | public Object[] getAllElements() {
79 | ArrayList result = new ArrayList();
80 | if(getCurrentInput() != null) {
81 | addElementsUnder(getCurrentInput(), result);
82 | }
83 | return result.toArray();
84 | }
85 |
86 | private void addElementsUnder(HistoryDefinitionLocation currentInput, ArrayList result) {
87 | if(currentInput == null) {
88 | JavaPlugin.logErrorMessage("Called addElementsUnder with currentInput==null");
89 | return;
90 | } else {
91 | result.add(currentInput); // the only place where elements are added
92 | if ( currentInput.hasChildren() ) {
93 | for (Iterator iter = currentInput.getChildren().iterator(); iter.hasNext();) {
94 | HistoryDefinitionLocation element = (HistoryDefinitionLocation) iter.next();
95 | addElementsUnder(element, result);
96 | }
97 | }
98 | }
99 | }
100 | /* (non-Javadoc)
101 | * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
102 | */
103 | public Object getParent(Object element) {
104 | if (element instanceof HistoryDefinitionLocation) {
105 | return ((HistoryDefinitionLocation) element).getParent();
106 | }
107 |
108 | return null;
109 | }
110 |
111 | /* (non-Javadoc)
112 | * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
113 | */
114 | public boolean hasChildren(Object element) {
115 | if (element instanceof HistoryDefinitionLocation) {
116 | if(element == null) return false;
117 |
118 | Collection children = ((HistoryDefinitionLocation) element).getChildren();
119 | return children != null && !children.isEmpty();
120 | }
121 | return false;
122 | }
123 |
124 | /////////////////////////////////////// Methods for providing statistics ///////////////////////////////////////
125 | public int getTotalElementCount() {
126 | return getElementCount(element);
127 | }
128 | private int getElementCount(HistoryDefinitionLocation element) {
129 | if(element == null) return 0;
130 | if(element.getChildren() == null || element.getChildren().isEmpty()) return 1;
131 | int result = 1;
132 | for(Iterator iter = element.getChildren().iterator(); iter.hasNext();) {
133 | HistoryDefinitionLocation child = (HistoryDefinitionLocation) iter.next();
134 | result += getElementCount(child);
135 | }
136 |
137 | return result;
138 | }
139 | public int getLeafElementCount() {
140 | return getLeafElementCount(element);
141 | }
142 | private int getLeafElementCount(HistoryDefinitionLocation element) {
143 | if(element == null) return 0;
144 | if(element.getChildren() == null || element.getChildren().isEmpty()) return 1;
145 | int result = 0;
146 | for(Iterator iter = element.getChildren().iterator(); iter.hasNext();) {
147 | HistoryDefinitionLocation child = (HistoryDefinitionLocation) iter.next();
148 | result += getLeafElementCount(child);
149 | }
150 |
151 | return result;
152 | }
153 |
154 | public int getFileCount() {
155 | HashSet files = new HashSet();
156 | getFiles(element, files);
157 | return files.size();
158 | }
159 | private void getFiles(HistoryDefinitionLocation element, HashSet files) {
160 | if(element == null) return;
161 |
162 | files.add(element.getResource());
163 |
164 | if(element.getChildren() == null || element.getChildren().isEmpty()) return;
165 | for(Iterator iter = element.getChildren().iterator(); iter.hasNext();) {
166 | HistoryDefinitionLocation child = (HistoryDefinitionLocation) iter.next();
167 | getFiles(child, files);
168 | }
169 | }
170 |
171 | public int getTruncatedElementCount() {
172 | return getTruncatedElementCount(element);
173 | }
174 | private int getTruncatedElementCount(HistoryDefinitionLocation element) {
175 | if(element == null) return 0;
176 | int result = element.isMaxLevel() ? 1 : 0;
177 |
178 | if(element.getChildren() == null || element.getChildren().isEmpty()) return result;
179 |
180 | for(Iterator iter = element.getChildren().iterator(); iter.hasNext();) {
181 | HistoryDefinitionLocation child = (HistoryDefinitionLocation) iter.next();
182 | result += getTruncatedElementCount(child);
183 | }
184 |
185 | return result;
186 | }
187 | /* (non-Javadoc)
188 | * @see lapse.views.ProvenanceResultsContentProvider#addElement(lapse.HistoryDefinitionLocation)
189 | */
190 | public void addElement(HistoryDefinitionLocation defLoc) {
191 | if(element == null) {
192 | setElement(defLoc);
193 | } else
194 | if(defLoc != element){
195 | JavaPlugin.logErrorMessage("Error in addElement(...): calling addElement with " + defLoc +
196 | " old value: " + element);
197 | } else {
198 | // just setting it twice, it's benign, I guess
199 | }
200 | }
201 | public void setCurrentInput(HistoryDefinitionLocation input) {
202 | setElement(input);
203 | }
204 | public HistoryDefinitionLocation getCurrentInput() {
205 | return this.element;
206 | }
207 | /* (non-Javadoc)
208 | * @see lapse.views.ProvenanceContentProvider#getFirstElement()
209 | */
210 | public ISelection getFirstElement() {
211 | if(element == null) return null;
212 | return new StructuredSelection(new Object[] {element});
213 | }
214 | /* (non-Javadoc)
215 | * @see lapse.views.ProvenanceContentProvider#getDepth()
216 | */
217 | public int getDepth() {
218 | return getDepth(element);
219 | }
220 |
221 | private int getDepth(HistoryDefinitionLocation element) {
222 | if(element == null) return 0;
223 | if(!element.hasChildren()) {
224 | return 1;
225 | }
226 | int maxLevel = 0;
227 | for (Iterator iter = element.getChildren().iterator(); iter.hasNext();) {
228 | HistoryDefinitionLocation e = (HistoryDefinitionLocation) iter.next();
229 | int level = getDepth(e);
230 | if(maxLevel < level) {
231 | maxLevel = level;
232 | }
233 | }
234 | return maxLevel + 1;
235 | }
236 | }
237 |
238 | public class FlatViewContentProvider implements ProvenanceContentProvider {
239 | private Vector elements = new Vector();
240 | private static final Object[] EMPTY_ARRAY = new Object[] {};
241 | public void inputChanged(Viewer v, Object oldInput, Object newInput) {
242 | }
243 | public void dispose() {
244 | }
245 | public Object[] getElements(Object parent) {
246 | return elements.toArray();
247 | }
248 | public Object[] getAllElements() {
249 | return elements.toArray();
250 | }
251 | public void addElement(HistoryDefinitionLocation defLoc) {
252 | if(!defLoc.hasChildren()) {
253 | // terminal node
254 | elements.add(defLoc);
255 | }else {
256 | for (Iterator iter = defLoc.getChildren().iterator(); iter.hasNext(); ) {
257 | HistoryDefinitionLocation element = (HistoryDefinitionLocation) iter.next();
258 | addElement(element);
259 | }
260 | }
261 | }
262 | public void clearElements() {
263 | elements.clear();
264 | }
265 |
266 | //
267 | // Tree support
268 | //
269 | public Object[] getChildren(Object parentElement) {
270 | return EMPTY_ARRAY;
271 | }
272 |
273 | /* (non-Javadoc)
274 | * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
275 | */
276 | public Object getParent(Object element) {
277 | return null;
278 | }
279 |
280 | /* (non-Javadoc)
281 | * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
282 | */
283 | public boolean hasChildren(Object element) {
284 | return false;
285 | }
286 |
287 | /////////////////////////////////////// Methods for providing statistics ///////////////////////////////////////
288 | public int getTotalElementCount() {
289 | return elements.size();
290 | }
291 | public int getLeafElementCount() {
292 | return getTotalElementCount();
293 | }
294 | public int getFileCount() {
295 | HashSet files = new HashSet();
296 | for (Iterator iter = elements.iterator(); iter.hasNext();) {
297 | HistoryDefinitionLocation element = (HistoryDefinitionLocation) iter.next();
298 | files.add(element.getResource());
299 | }
300 | return files.size();
301 | }
302 | public int getTruncatedElementCount() {
303 | int result = 0;
304 | for (Iterator iter = elements.iterator(); iter.hasNext();) {
305 | HistoryDefinitionLocation element = (HistoryDefinitionLocation) iter.next();
306 | if(element.isMaxLevel()) {
307 | result++;
308 | }
309 | }
310 | return result;
311 | }
312 | public ProvenanceContentProvider switchType() {
313 | HierarchicalViewContentProvider result = new HierarchicalViewContentProvider();
314 | // need to find the topmost element
315 | if(this.getTotalElementCount() == 0) {
316 | result.element = null;
317 | } else {
318 | HistoryDefinitionLocation dl = (HistoryDefinitionLocation) this.getAllElements()[0];
319 | do {
320 | if(dl.getParent() != null) {
321 | dl = (HistoryDefinitionLocation)dl.getParent();
322 | } else {
323 | break;
324 | }
325 | } while(true);
326 | // topmost element
327 | result.element = dl;
328 | }
329 |
330 | return result;
331 | }
332 | /* (non-Javadoc)
333 | * @see lapsePlus.views.ProvenanceContentProvider#getFirstElement()
334 | */
335 | public ISelection getFirstElement() {
336 | if(elements == null || elements.size() == 0) return null;
337 | return new StructuredSelection(new Object[] {elements.firstElement()});
338 | }
339 | /* (non-Javadoc)
340 | * @see lapsePlus.views.ProvenanceContentProvider#getDepth()
341 | */
342 | public int getDepth() {
343 | return 1;
344 | }
345 | /* (non-Javadoc)
346 | * @see lapsePlus.views.ProvenanceContentProvider#setCurrentInput(lapse.HistoryDefinitionLocation)
347 | */
348 | public void setCurrentInput(HistoryDefinitionLocation input) {
349 | // TODO: fix this
350 | }
351 | public HistoryDefinitionLocation getCurrentInput() {
352 | // TODO: fix this
353 | return null;
354 | }
355 | }
356 | }
--------------------------------------------------------------------------------
/fuentes/lapsePlus/Binding2JavaModel.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * Binding2JavaModel.java, version 2.8, 2010
5 | */
6 |
7 | import java.util.ArrayList;
8 | import java.util.Arrays;
9 | import java.util.HashSet;
10 | import java.util.Iterator;
11 | import java.util.List;
12 | import java.util.Set;
13 |
14 | import org.eclipse.core.runtime.IPath;
15 | import org.eclipse.core.runtime.IProgressMonitor;
16 | import org.eclipse.core.runtime.Path;
17 | import org.eclipse.core.runtime.SubProgressMonitor;
18 | import org.eclipse.jdt.core.IClassFile;
19 | import org.eclipse.jdt.core.ICompilationUnit;
20 | import org.eclipse.jdt.core.IField;
21 | import org.eclipse.jdt.core.IJavaElement;
22 | import org.eclipse.jdt.core.IJavaProject;
23 | import org.eclipse.jdt.core.IMethod;
24 | import org.eclipse.jdt.core.IPackageFragment;
25 | import org.eclipse.jdt.core.IPackageFragmentRoot;
26 | import org.eclipse.jdt.core.IType;
27 | import org.eclipse.jdt.core.ITypeHierarchy;
28 | import org.eclipse.jdt.core.JavaModelException;
29 | import org.eclipse.jdt.core.Signature;
30 | import org.eclipse.jdt.core.dom.IMethodBinding;
31 | import org.eclipse.jdt.core.dom.IPackageBinding;
32 | import org.eclipse.jdt.core.dom.ITypeBinding;
33 | import org.eclipse.jdt.core.dom.IVariableBinding;
34 |
35 | /**
36 | * A helper class to convert compiler bindings into corresponding
37 | * Java elements.
38 | */
39 | public class Binding2JavaModel {
40 |
41 | private Binding2JavaModel(){}
42 |
43 |
44 | public static ICompilationUnit findCompilationUnit(ITypeBinding typeBinding, IJavaProject project) throws JavaModelException {
45 | if (!typeBinding.isFromSource()) {
46 | return null;
47 | }
48 | while (typeBinding != null && !typeBinding.isTopLevel()) {
49 | typeBinding= typeBinding.getDeclaringClass();
50 | }
51 | if (typeBinding != null) {
52 | IPackageBinding pack= typeBinding.getPackage();
53 | String packageName= pack.isUnnamed() ? "" : pack.getName(); //$NON-NLS-1$
54 | IType type= project.findType(packageName, typeBinding.getName());
55 | if (type != null) {
56 | return type.getCompilationUnit();
57 | }
58 | }
59 | return null;
60 | }
61 |
62 |
63 | /**
64 | * Converts the given IVariableBinding into a IField
65 | * using the classpath defined by the given Java project. Returns null
66 | * if the conversion isn't possible.
67 | */
68 | public static IField find(IVariableBinding field, IJavaProject in) throws JavaModelException {
69 | IType declaringClass = find(field.getDeclaringClass(), in);
70 | if (declaringClass == null)
71 | return null;
72 | IField foundField= declaringClass.getField(field.getName());
73 | if (! foundField.exists())
74 | return null;
75 | return foundField;
76 | }
77 |
78 | /**
79 | * Converts the given ITypeBinding into a IType
80 | * using the classpath defined by the given Java project. Returns null
81 | * if the conversion isn't possible.
82 | */
83 | public static IType find(ITypeBinding type, IJavaProject scope) throws JavaModelException {
84 | if (type.isPrimitive())
85 | return null;
86 | String[] typeElements= getNameComponents(type);
87 | IJavaElement element= scope.findElement(getPathToCompilationUnit(type.getPackage(), typeElements[0]));
88 | IType candidate= null;
89 | if (element instanceof ICompilationUnit) {
90 | candidate= ((ICompilationUnit)element).getType(typeElements[0]);
91 | } else if (element instanceof IClassFile) {
92 | candidate= ((IClassFile)element).getType();
93 | } else if (element == null){
94 | if (type.isMember())
95 | candidate= findType(scope, getFullyQualifiedImportName(type.getDeclaringClass()));
96 | else
97 | candidate= findType(scope, getFullyQualifiedImportName(type));
98 | }
99 |
100 | if (candidate == null || typeElements.length == 1)
101 | return candidate;
102 |
103 | return findTypeInType(typeElements, candidate);
104 | }
105 |
106 | /**
107 | * Finds a type by its qualified type name (dot separated).
108 | * @param jproject The java project to search in
109 | * @param str The fully qualified name (type name with enclosing type names and package (all separated by dots))
110 | * @return The type found, or null if not existing
111 | */
112 | public static IType findType(IJavaProject jproject, String fullyQualifiedName) throws JavaModelException {
113 | //workaround for bug 22883
114 | IType type= jproject.findType(fullyQualifiedName);
115 | if (type != null)
116 | return type;
117 | IPackageFragmentRoot[] roots= jproject.getPackageFragmentRoots();
118 | for (int i= 0; i < roots.length; i++) {
119 | IPackageFragmentRoot root= roots[i];
120 | type= findType(root, fullyQualifiedName);
121 | if (type != null && type.exists())
122 | return type;
123 | }
124 | return null;
125 | }
126 |
127 | private static IType findType(IPackageFragmentRoot root, String fullyQualifiedName) throws JavaModelException{
128 | IJavaElement[] children= root.getChildren();
129 | for (int i= 0; i < children.length; i++) {
130 | IJavaElement element= children[i];
131 | if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT){
132 | IPackageFragment pack= (IPackageFragment)element;
133 | if (! fullyQualifiedName.startsWith(pack.getElementName()))
134 | continue;
135 | IType type= findType(pack, fullyQualifiedName);
136 | if (type != null && type.exists())
137 | return type;
138 | }
139 | }
140 | return null;
141 | }
142 |
143 | private static IType findType(IPackageFragment pack, String fullyQualifiedName) throws JavaModelException{
144 | ICompilationUnit[] cus= pack.getCompilationUnits();
145 | for (int i= 0; i < cus.length; i++) {
146 | ICompilationUnit unit= cus[i];
147 | IType type= findType(unit, fullyQualifiedName);
148 | if (type != null && type.exists())
149 | return type;
150 | }
151 | return null;
152 | }
153 |
154 | private static IType findType(ICompilationUnit cu, String fullyQualifiedName) throws JavaModelException{
155 | IType[] types= cu.getAllTypes();
156 | for (int i= 0; i < types.length; i++) {
157 | IType type= types[i];
158 | if (getFullyQualifiedName(type).equals(fullyQualifiedName))
159 | return type;
160 | }
161 | return null;
162 | }
163 |
164 | /**
165 | * Returns the fully qualified name of the given type using '.' as separators.
166 | * This is a replace for IType.getFullyQualifiedTypeName
167 | * which uses '$' as separators. As '$' is also a valid character in an id
168 | * this is ambiguous. JavaCore PR: 1GCFUNT
169 | */
170 | public static String getFullyQualifiedName(IType type) {
171 | return type.getFullyQualifiedName('.');
172 | }
173 |
174 |
175 | /**
176 | * Finds the given IMethodBinding in the given IType. Returns
177 | * null if the type doesn't contain a corresponding method.
178 | */
179 | public static IMethod find(IMethodBinding method, IType type) throws JavaModelException {
180 | IMethod[] candidates= type.getMethods();
181 | for (int i= 0; i < candidates.length; i++) {
182 | IMethod candidate= candidates[i];
183 | if (candidate.getElementName().equals(method.getName()) && sameParameters(method, candidate)) {
184 | return candidate;
185 | }
186 | }
187 | return null;
188 | }
189 |
190 | public static IMethod findIncludingSupertypes(IMethodBinding method, IType type, IProgressMonitor pm) throws JavaModelException {
191 | IMethod inThisType= find(method, type);
192 | if (inThisType != null)
193 | return inThisType;
194 | IType[] superTypes= getAllSuperTypes(type, pm);
195 | for (int i= 0; i < superTypes.length; i++) {
196 | IMethod m= find(method, superTypes[i]);
197 | if (m != null)
198 | return m;
199 | }
200 | return null;
201 | }
202 |
203 | public static IMethod find(IMethodBinding method, IJavaProject scope) throws JavaModelException {
204 | IType type= find(method.getDeclaringClass(), scope);
205 | if (type == null)
206 | return null;
207 | return find(method, type);
208 | }
209 |
210 | //---- Helper methods to convert a type --------------------------------------------
211 |
212 | private static IPath getPathToCompilationUnit(IPackageBinding packageBinding, String topLevelTypeName) {
213 | IPath result= new Path(""); //$NON-NLS-1$
214 | String[] packageNames= packageBinding.getNameComponents();
215 | for (int i= 0; i < packageNames.length; i++) {
216 | result= result.append(packageNames[i]);
217 | }
218 | return result.append(topLevelTypeName + ".java"); //$NON-NLS-1$
219 | }
220 |
221 | private static IType findTypeInType(String[] typeElements, IType jmType) {
222 | IType result= jmType;
223 | for (int i= 1; i < typeElements.length; i++) {
224 | result= result.getType(typeElements[i]);
225 | if (!result.exists())
226 | return null;
227 | }
228 | return result == jmType ? null : result;
229 | }
230 |
231 | //---- Helper methods to convert a method ---------------------------------------------
232 |
233 | private static boolean sameParameters(IMethodBinding method, IMethod candidate) throws JavaModelException {
234 | ITypeBinding[] methodParamters= method.getParameterTypes();
235 | String[] candidateParameters= candidate.getParameterTypes();
236 | if (methodParamters.length != candidateParameters.length)
237 | return false;
238 | IType scope= candidate.getDeclaringType();
239 | for (int i= 0; i < methodParamters.length; i++) {
240 | ITypeBinding methodParameter= methodParamters[i];
241 | String candidateParameter= candidateParameters[i];
242 | if (!sameParameter(methodParameter, candidateParameter, scope))
243 | return false;
244 | }
245 | return true;
246 | }
247 |
248 | private static boolean sameParameter(ITypeBinding type, String candidate, IType scope) throws JavaModelException {
249 | if (type.getDimensions() != Signature.getArrayCount(candidate))
250 | return false;
251 |
252 | // Normalizes types
253 | if (type.isArray())
254 | type= type.getElementType();
255 | candidate= Signature.getElementType(candidate);
256 |
257 | if (isPrimitiveType(candidate) || type.isPrimitive()) {
258 | return type.getName().equals(Signature.toString(candidate));
259 | } else {
260 | if (isResolvedType(candidate)) {
261 | return Signature.toString(candidate).equals(getFullyQualifiedName(type));
262 | } else {
263 | String[][] qualifiedCandidates= scope.resolveType(Signature.toString(candidate));
264 | if (qualifiedCandidates == null || qualifiedCandidates.length == 0)
265 | return false;
266 | String packageName= type.getPackage().isUnnamed() ? "" : type.getPackage().getName(); //$NON-NLS-1$
267 | String typeName= getTypeQualifiedName(type);
268 | for (int i= 0; i < qualifiedCandidates.length; i++) {
269 | String[] qualifiedCandidate= qualifiedCandidates[i];
270 | if (qualifiedCandidate[0].equals(packageName) &&
271 | qualifiedCandidate[1].equals(typeName)) {
272 | return true;
273 | }
274 | }
275 | }
276 | }
277 | return false;
278 | }
279 |
280 | public static String getTypeQualifiedName(ITypeBinding type) {
281 | StringBuffer buffer= new StringBuffer();
282 | createName(type, false, buffer);
283 | return buffer.toString();
284 | }
285 |
286 | private static boolean isPrimitiveType(String s) {
287 | char c= s.charAt(0);
288 | return c != Signature.C_RESOLVED && c != Signature.C_UNRESOLVED;
289 | }
290 |
291 | private static boolean isResolvedType(String s) {
292 | int arrayCount= Signature.getArrayCount(s);
293 | return s.charAt(arrayCount) == Signature.C_RESOLVED;
294 | }
295 |
296 | public static String[] getNameComponents(ITypeBinding type) {
297 | List result= new ArrayList(5);
298 | createName(type, false, result);
299 | return (String[]) result.toArray(new String[result.size()]);
300 | }
301 |
302 | private static void createName(ITypeBinding type, boolean includePackage, StringBuffer buffer) {
303 | ITypeBinding baseType= type;
304 | if (type.isArray()) {
305 | baseType= type.getElementType();
306 | }
307 | if (!baseType.isPrimitive() && !baseType.isNullType()) {
308 | ITypeBinding declaringType= baseType.getDeclaringClass();
309 | if (declaringType != null) {
310 | createName(declaringType, includePackage, buffer);
311 | buffer.append('.');
312 | } else if (includePackage && !baseType.getPackage().isUnnamed()) {
313 | buffer.append(baseType.getPackage().getName());
314 | buffer.append('.');
315 | }
316 | }
317 | if (!baseType.isAnonymous()) {
318 | buffer.append(type.getName());
319 | } else {
320 | buffer.append("$local$"); //$NON-NLS-1$
321 | }
322 | }
323 |
324 | private static void createName(ITypeBinding type, boolean includePackage, List list) {
325 | ITypeBinding baseType= type;
326 | if (type.isArray()) {
327 | baseType= type.getElementType();
328 | }
329 | if (!baseType.isPrimitive() && !baseType.isNullType()) {
330 | ITypeBinding declaringType= baseType.getDeclaringClass();
331 | if (declaringType != null) {
332 | createName(declaringType, includePackage, list);
333 | } else if (includePackage && !baseType.getPackage().isUnnamed()) {
334 | String[] components= baseType.getPackage().getNameComponents();
335 | for (int i= 0; i < components.length; i++) {
336 | list.add(components[i]);
337 | }
338 | }
339 | }
340 | if (!baseType.isAnonymous()) {
341 | list.add(type.getName());
342 | } else {
343 | list.add("$local$"); //$NON-NLS-1$
344 | }
345 | }
346 |
347 |
348 | public static String getFullyQualifiedImportName(ITypeBinding type) {
349 | if (type.isArray()) {
350 | return getFullyQualifiedName(type.getElementType());
351 | } else if (type.isAnonymous()) {
352 | return getFullyQualifiedImportName(type.getSuperclass());
353 | } else {
354 | return getFullyQualifiedName(type);
355 | }
356 | }
357 |
358 | public static String getFullyQualifiedName(ITypeBinding type) {
359 | StringBuffer buffer= new StringBuffer();
360 | createName(type, true, buffer);
361 | return buffer.toString();
362 | }
363 |
364 | public static IType[] getAllSuperTypes(IType type, IProgressMonitor pm) throws JavaModelException {
365 | //workaround for bugs 23644 and 23656
366 | try{
367 | pm.beginTask("", 3); //$NON-NLS-1$
368 | ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new SubProgressMonitor(pm, 1));
369 |
370 | IProgressMonitor subPm= new SubProgressMonitor(pm, 2);
371 | List typeList= Arrays.asList(hierarchy.getAllSupertypes(type));
372 | subPm.beginTask("", typeList.size()); //$NON-NLS-1$
373 | Set types= new HashSet(typeList);
374 | for (Iterator iter= typeList.iterator(); iter.hasNext();) {
375 | IType superType= (IType)iter.next();
376 | IType[] superTypes= getAllSuperTypes(superType, new SubProgressMonitor(subPm, 1));
377 | types.addAll(Arrays.asList(superTypes));
378 | }
379 | types.add(type.getJavaProject().findType("java.lang.Object"));//$NON-NLS-1$
380 | subPm.done();
381 | return (IType[]) types.toArray(new IType[types.size()]);
382 | } finally {
383 | pm.done();
384 | }
385 | }
386 |
387 |
388 | }
389 |
390 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/CallerFinder.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * CallerFinder.java, version 2.8, 2010
5 | */
6 |
7 | import java.lang.reflect.InvocationTargetException;
8 | import java.util.ArrayList;
9 | import java.util.Collection;
10 | import java.util.HashSet;
11 | import java.util.Iterator;
12 | import java.util.LinkedList;
13 | import java.util.List;
14 | import org.eclipse.core.runtime.CoreException;
15 | import org.eclipse.core.runtime.IProgressMonitor;
16 | import org.eclipse.core.runtime.SubProgressMonitor;
17 | import org.eclipse.jdt.core.IJavaProject;
18 | import org.eclipse.jdt.core.IMethod;
19 | import org.eclipse.jdt.core.JavaModelException;
20 | import org.eclipse.jdt.core.dom.ASTVisitor;
21 | import org.eclipse.jdt.core.dom.ClassInstanceCreation;
22 | import org.eclipse.jdt.core.dom.Expression;
23 | import org.eclipse.jdt.core.dom.MethodDeclaration;
24 | import org.eclipse.jdt.core.dom.MethodInvocation;
25 | import org.eclipse.jdt.core.dom.Name;
26 | import org.eclipse.jdt.core.dom.ReturnStatement;
27 | import org.eclipse.jdt.core.dom.SimpleName;
28 | import org.eclipse.jdt.core.search.IJavaSearchConstants;
29 | import org.eclipse.jdt.core.search.IJavaSearchScope;
30 | import org.eclipse.jdt.core.search.SearchEngine;
31 | import org.eclipse.jdt.core.search.SearchParticipant;
32 | import org.eclipse.jdt.core.search.SearchPattern;
33 | import org.eclipse.jdt.core.search.SearchRequestor;
34 | import org.eclipse.jdt.internal.core.JavaProject;
35 | import org.eclipse.jdt.internal.core.search.JavaSearchScope;
36 | import org.eclipse.jdt.internal.ui.JavaPlugin;
37 | import org.eclipse.jface.operation.IRunnableWithProgress;
38 | import org.eclipse.ui.PlatformUI;
39 |
40 | public class CallerFinder {
41 |
42 | private static IJavaSearchScope fSearchScope;
43 |
44 | public static Collection/**/ findCallers(final String methodName, final JavaProject project, final boolean isConstructor) {
45 | class FindingOp implements IRunnableWithProgress {
46 | Collection c = null;
47 | public void run(IProgressMonitor monitor) {
48 | c = findCallers(monitor, methodName, project, isConstructor);
49 | if(c == null) {
50 | JavaPlugin.logErrorMessage("Collection is null");
51 | }
52 | // notify();
53 | }
54 | public Collection/**/ getCollection() {return c;}
55 | }
56 |
57 | try {
58 | FindingOp operation = new FindingOp();
59 | PlatformUI.getWorkbench().getProgressService().run(false, true, operation);
60 | // operation.wait();
61 | Collection c = operation.getCollection();
62 | if(c == null) {
63 | JavaPlugin.logErrorMessage("No collection is computed");
64 | }
65 | return c;
66 | } catch (InvocationTargetException e) {
67 | JavaPlugin.log(e);
68 | } catch (InterruptedException e) {
69 | // canceled
70 | }
71 | return null;
72 | }
73 |
74 | public static Collection/**/ findCallers(final IMethod method, final IJavaProject project) {
75 | // TODO Auto-generated method stub
76 | return null;
77 | }
78 |
79 | public static Collection/**/ findMethods(final SimpleName methodName, final JavaProject project, final boolean isConstructor) {
80 | class FindingOp implements IRunnableWithProgress {
81 | Collection c = null;
82 | public void run(IProgressMonitor monitor) {
83 | c = findCallees(monitor, methodName.toString(), project, isConstructor);
84 | if(c == null) {
85 | JavaPlugin.logErrorMessage("Collection is null");
86 | }
87 | // notify();
88 | }
89 | public Collection/**/ getCollection() {return c;}
90 | }
91 | try {
92 | FindingOp operation = new FindingOp();
93 | PlatformUI.getWorkbench().getProgressService().run(false, true, operation);
94 | // operation.wait();
95 | Collection c = operation.getCollection();
96 | if(c == null) {
97 | JavaPlugin.logErrorMessage("No collection is computed");
98 | }
99 | return c;
100 | } catch (InvocationTargetException e) {
101 | JavaPlugin.log(e);
102 | } catch (InterruptedException e) {
103 | // canceled
104 | }
105 | return null;
106 | }
107 |
108 | public static Collection/**/
109 | findCallees(IProgressMonitor progressMonitor, String methodName, IJavaProject project, boolean isConstructor)
110 | {
111 | try {
112 | MethodSearchRequestor.MethodDeclarationsSearchRequestor searchRequestor =
113 | new MethodSearchRequestor.MethodDeclarationsSearchRequestor();
114 | SearchEngine searchEngine = new SearchEngine();
115 |
116 | IProgressMonitor monitor = new SubProgressMonitor(
117 | progressMonitor, 5, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
118 | monitor.beginTask("Searching for declaration of " + methodName +
119 | (project != null ? " in " + project.getProject().getName() : ""), 100);
120 | IJavaSearchScope searchScope = getSearchScope(project);
121 | int matchType = !isConstructor ? IJavaSearchConstants.METHOD : IJavaSearchConstants.CONSTRUCTOR;
122 | SearchPattern pattern = SearchPattern.createPattern(
123 | methodName,
124 | matchType,
125 | IJavaSearchConstants.DECLARATIONS,
126 | SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE );
127 |
128 | searchEngine.search(
129 | pattern,
130 | new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
131 | searchScope,
132 | searchRequestor,
133 | monitor
134 | );
135 | monitor.done();
136 |
137 | return searchRequestor.getMethodUnitPairs();
138 | } catch (CoreException e) {
139 | JavaPlugin.log(e);
140 |
141 | return new LinkedList();
142 | }
143 | }
144 |
145 | /**
146 | * Returns a collection of return statements withing @param methodDeclaration.
147 | * */
148 | public static Collection findReturns(IProgressMonitor progressMonitor, MethodDeclaration methodDeclaration, JavaProject project) {
149 | progressMonitor.setTaskName("Looking for returns in " + methodDeclaration.getName());
150 | final Collection returns = new ArrayList();
151 | ASTVisitor finder = new ASTVisitor() {
152 | public boolean visit(ReturnStatement node) {
153 | return returns.add(node);
154 | }
155 | };
156 |
157 | methodDeclaration.accept(finder);
158 | return returns;
159 | }
160 |
161 | public static String callersToString(IMethod method) {
162 | Collection/**/ callers = findCallers(method, null);
163 | String result = "[ ";
164 | for (Iterator iter = callers.iterator(); iter.hasNext();) {
165 | Object element = (Object) iter.next();
166 | result += element + " ";
167 | }
168 | return result + "]";
169 | }
170 |
171 | public static Collection getActualsForFormal(IMethod method, Name name, Expression onlyCall, IProgressMonitor monitor, IJavaProject project) {
172 | Collection result = new ArrayList();
173 | Collection/**/ c = findCallers(monitor, method, project);
174 | if (c.isEmpty()) {
175 | log("No callers for " + method);
176 | } else {
177 | monitor.beginTask("Getting actuals for " + name + " in " + method.getElementName(), c.size());
178 | int i = 0;
179 | for (Iterator iter = c.iterator(); iter.hasNext();) {
180 | Utils.ExprUnitResource mi = (Utils.ExprUnitResource) iter.next();
181 | int pos = SlicingUtils.getFormalArgumentPos(method, name);
182 | if (pos == SlicingUtils.NO_FORMAL_ARGUMENT) {
183 | log("No parameter " + name + " found in " + method);
184 | continue;
185 | }
186 | if (mi.getExpression() == null) {
187 | logError("unexpected error: mi.getExpression() == null when looking at " + name + " and " + method);
188 | continue;
189 | }
190 | String s1 = mi.getExpression().toString();
191 | //String s2 = onlyCall.toString();
192 | if ( (onlyCall != null) && (!s1.equals(onlyCall.toString())) ) {
193 | log("Skipping " + mi.getExpression() + "while looking for " + onlyCall + " instead");
194 | continue;
195 | }
196 | Expression expr = SlicingUtils.mapFormal2Actual(mi.getExpression(), pos);
197 | if(expr != null) {
198 | result.add(new Utils.ExpressionUnitPair(expr, mi.getCompilationUnit(), mi.getResource()));
199 | }
200 | monitor.worked(++i);
201 | }
202 | monitor.done();
203 | }
204 |
205 | return result;
206 | }
207 |
208 | public static Collection/**/ getActualsForFormal(final IMethod method, final Name name, final Expression onlyCall, final JavaProject project) {
209 | class FindingOp implements IRunnableWithProgress {
210 | Collection c = null;
211 | public void run(IProgressMonitor monitor) {
212 | c = getActualsForFormal(method, name, onlyCall, monitor, project);
213 | }
214 | public Collection getCollection() {return c;}
215 | }
216 | try {
217 | FindingOp operation = new FindingOp();
218 | PlatformUI.getWorkbench().getProgressService().run(false, true, operation);
219 |
220 | return operation.getCollection();
221 | } catch (InvocationTargetException e) {
222 | JavaPlugin.log(e);
223 | } catch (InterruptedException e) {
224 | // canceled
225 | }
226 | return null;
227 | }
228 |
229 | public static Collection/**/ findCallers(IProgressMonitor progressMonitor, IMethod member, IJavaProject project) {
230 | boolean isConstructor = false;
231 | try {
232 | isConstructor = member.isConstructor(); // interrogate the member itself
233 | } catch (JavaModelException e) {
234 | JavaPlugin.log(e);
235 | }
236 | String methodName = isConstructor ?
237 | member.getDeclaringType().getElementName() :
238 | member.getDeclaringType().getElementName() + "." + member.getElementName();
239 | return findCallers(progressMonitor, methodName, project, isConstructor);
240 | }
241 |
242 | public static Collection/**/ findCallers(IProgressMonitor progressMonitor, String methodName, IJavaProject project, boolean isConstructor) {
243 |
244 | try {
245 |
246 | MethodSearchRequestor.initializeParserMap();
247 |
248 | SearchRequestor searchRequestor = (SearchRequestor)new MethodSearchRequestor.MethodReferencesSearchRequestor();
249 |
250 | SearchEngine searchEngine = new SearchEngine();
251 |
252 | IProgressMonitor monitor = new SubProgressMonitor(progressMonitor, 5, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
253 |
254 | monitor.beginTask("Searching for calls to " + methodName + (project != null ? " in " + project.getProject().getName() : ""), 100);
255 |
256 | IJavaSearchScope searchScope = getSearchScope(project);
257 |
258 | // This is kind of hacky: we need to make up a string name for the search to work right
259 |
260 | log("Looking for calls to " + methodName);
261 |
262 | int matchType = !isConstructor ? IJavaSearchConstants.METHOD : IJavaSearchConstants.CONSTRUCTOR;
263 |
264 | SearchPattern pattern = SearchPattern.createPattern(
265 | methodName,
266 | matchType,
267 | IJavaSearchConstants.REFERENCES,
268 | SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
269 |
270 | searchEngine.search(
271 | pattern,
272 | new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
273 | searchScope,
274 | searchRequestor,
275 | monitor
276 | );
277 |
278 | if(searchRequestor instanceof MethodSearchRequestor.MethodDeclarationsSearchRequestor){
279 | return ((MethodSearchRequestor.MethodDeclarationsSearchRequestor)searchRequestor).getMethodUnitPairs();
280 | }else{
281 | return ((MethodSearchRequestor.MethodReferencesSearchRequestor)searchRequestor).getMethodUnitPairs();
282 | }
283 |
284 | } catch (CoreException e) {
285 | JavaPlugin.log(e);
286 |
287 | return new LinkedList();
288 | }
289 | }
290 |
291 | public static Collection/**/ findDeclarations(IProgressMonitor progressMonitor, String methodName, IJavaProject project, boolean isConstructor) {
292 | try {
293 | SearchRequestor searchRequestor = new MethodSearchRequestor.MethodDeclarationsSearchRequestor();
294 | SearchEngine searchEngine = new SearchEngine();
295 |
296 | IProgressMonitor monitor = new SubProgressMonitor(
297 | progressMonitor, 5, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
298 | monitor.beginTask("Searching for calls to " +
299 | methodName + (project != null ? " in " + project.getProject().getName() : ""), 100);
300 | IJavaSearchScope searchScope = getSearchScope(project);
301 | // This is kind of hacky: we need to make up a string name for the search to work right
302 | log("Looking for " + methodName);
303 | int matchType = !isConstructor ? IJavaSearchConstants.METHOD : IJavaSearchConstants.CONSTRUCTOR;
304 | SearchPattern pattern = SearchPattern.createPattern(
305 | methodName,
306 | matchType,
307 | IJavaSearchConstants.DECLARATIONS,
308 | SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE );
309 |
310 | searchEngine.search(
311 | pattern,
312 | new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
313 | searchScope,
314 | searchRequestor,
315 | monitor
316 | );
317 |
318 | if(searchRequestor instanceof MethodSearchRequestor.MethodDeclarationsSearchRequestor){
319 | return ((MethodSearchRequestor.MethodDeclarationsSearchRequestor)searchRequestor).getMethodUnitPairs();
320 | }else{
321 | return ((MethodSearchRequestor.MethodReferencesSearchRequestor)searchRequestor).getMethodUnitPairs();
322 | }
323 | } catch (CoreException e) {
324 | JavaPlugin.log(e);
325 |
326 | return new LinkedList();
327 | }
328 | }
329 |
330 | public static IJavaSearchScope getSearchScope(IJavaProject project) {
331 | if (fSearchScope == null) {
332 | fSearchScope = SearchEngine.createWorkspaceScope();
333 | //fSearchScope = SearchEngine.createJavaSearchScope(new IResource[] {method.getResource()});
334 | }
335 | // return fSearchScope;
336 |
337 | if(project == null) {
338 | return fSearchScope;
339 | } else {
340 | JavaSearchScope js = new JavaSearchScope();
341 | try {
342 | int includeMask =
343 | JavaSearchScope.SOURCES |
344 | JavaSearchScope.APPLICATION_LIBRARIES |
345 | JavaSearchScope.SYSTEM_LIBRARIES ;
346 | js.add((JavaProject) project, includeMask, new HashSet());
347 | } catch (JavaModelException e) {
348 | log(e.getMessage(), e);
349 | return fSearchScope;
350 | }
351 | return js;
352 | }
353 | }
354 |
355 | public static class SlicingUtils {
356 | public static final int NO_FORMAL_ARGUMENT = -1;
357 |
358 | public static Expression mapFormal2Actual(Expression mi, int pos){
359 | //if(mi == null) return null;
360 | List args = null;
361 | if (mi instanceof ClassInstanceCreation) {
362 | args = ((ClassInstanceCreation)mi).arguments();
363 | } else if(mi instanceof MethodInvocation) {
364 | args = ((MethodInvocation)mi).arguments();
365 | } else {
366 | JavaPlugin.logErrorMessage("Unexpected type in mapFormal2Actual for " + mi);
367 | return null;
368 | }
369 |
370 | return (Expression) args.get(pos);
371 | }
372 |
373 | public static SimpleName getVariable(Expression expr){
374 | if (expr instanceof SimpleName) {
375 | return (SimpleName) expr;
376 | } else {
377 | return null;
378 | }
379 | }
380 |
381 | /**
382 | * @return NO_FORMAL_ARGUMENT signals that there's no matching position in the method declaration.
383 | * */
384 |
385 | public static int getFormalArgumentPos(IMethod method, Name arg){
386 | String[] names;
387 | try {
388 | names = method.getParameterNames();
389 | } catch (JavaModelException e) {
390 | return NO_FORMAL_ARGUMENT;
391 | }
392 | for (int i = 0; i < names.length; i++) {
393 | if(names[i].equals(arg.toString())) {
394 | return i;
395 | }
396 | }
397 | return NO_FORMAL_ARGUMENT;
398 | }
399 | }
400 |
401 | private static void log(String message, Throwable e) {
402 | LapsePlugin.trace(LapsePlugin.SEARCH, "Call finder: " + message, e);
403 | }
404 |
405 | private static void logError(String message) {
406 | log(message, new Throwable());
407 | }
408 |
409 | private static void log(String message) {
410 | log(message, null);
411 | }
412 | }
413 |
414 |
--------------------------------------------------------------------------------
/fuentes/lapsePlus/XMLConfig.java:
--------------------------------------------------------------------------------
1 | package lapsePlus;
2 |
3 | /*
4 | * XMLConfig.java, version 2.8, 2010
5 | */
6 |
7 | import java.io.File;
8 | import java.io.IOException;
9 | import java.net.URL;
10 | import java.util.Collection;
11 | import java.util.HashMap;
12 | import java.util.LinkedList;
13 | import java.util.Map;
14 | import javax.xml.parsers.DocumentBuilder;
15 | import javax.xml.parsers.DocumentBuilderFactory;
16 | import javax.xml.parsers.ParserConfigurationException;
17 | import org.eclipse.core.runtime.FileLocator;
18 | import org.eclipse.jdt.core.IMethod;
19 | import org.eclipse.jface.util.Assert;
20 | import org.w3c.dom.Document;
21 | import org.w3c.dom.Element;
22 | import org.w3c.dom.Node;
23 | import org.w3c.dom.NodeList;
24 | import org.xml.sax.SAXException;
25 | import org.xml.sax.SAXParseException;
26 |
27 | public class XMLConfig {
28 | private static boolean TRACE = false;
29 | static Map method2desc = new HashMap();
30 |
31 | public static class SinkDescription {
32 | public int getVulnerableParameter() {
33 | return vulnerableParameter;
34 | }
35 | String id, typeName, methodName, categoryName;
36 | private int vulnerableParameter;
37 |
38 | protected SinkDescription(String id, String typeName, String methodName, String categoryName,
39 | int parameterCount, int vulnerableParameter)
40 | {
41 | this.id = id;
42 | this.typeName = typeName;
43 | this.methodName = methodName;
44 | this.categoryName = categoryName;
45 | this.vulnerableParameter = vulnerableParameter;
46 | }
47 |
48 | public SinkDescription(String id, String categoryName, int vulnerableParameter){
49 | this.id = id;
50 |
51 | int right_bracker_idx = id.lastIndexOf(')');
52 | int left_bracker_idx = id.lastIndexOf('(');
53 | String param = id.substring(left_bracker_idx+1, right_bracker_idx);
54 | int comma_count = 0;
55 | for(int i=0; i < param.length(); i++) {
56 | char c = param.charAt(i);
57 | if(c == ',') {
58 | comma_count++;
59 | }
60 | }
61 | int dot_index = id.lastIndexOf('.');
62 |
63 | this.typeName = id.substring(0, dot_index);
64 | this.methodName = id.substring(0, left_bracker_idx);
65 | this.categoryName = categoryName;
66 | this.vulnerableParameter = vulnerableParameter;
67 | }
68 |
69 | public String toString(){
70 | return "Sink: " + (typeName + ", " + methodName + ", " + categoryName);
71 | }
72 | public String getCategoryName() {
73 | return categoryName;
74 | }
75 | public String getMethodName() {
76 | return methodName;
77 | }
78 | public String getTypeName() {
79 | return typeName;
80 | }
81 | public String getID() {
82 | return id;
83 | }
84 | }
85 |
86 | public static class SourceDescription {
87 | String typeName, methodName, categoryName, id;
88 |
89 | public String getCategoryName() {
90 | return categoryName;
91 | }
92 | public String getMethodName() {
93 | return methodName;
94 | }
95 | public String getTypeName() {
96 | return typeName;
97 | }
98 | protected SourceDescription(String id, String typeName, String methodName, String categoryName) {
99 | this.id = id;
100 | this.typeName = typeName;
101 | this.methodName = methodName;
102 | this.categoryName = categoryName;
103 | }
104 |
105 | public SourceDescription(String id, String categoryName){
106 | this.id = id;
107 |
108 | //int right_bracker_idx = id.lastIndexOf(')');
109 | int left_bracker_idx = id.lastIndexOf('(');
110 | //String param = id.substring(left_bracker_idx+1, right_bracker_idx);
111 | int dot_index = id.lastIndexOf('.');
112 |
113 | this.typeName = id.substring(0, dot_index);
114 | this.methodName = id.substring(0, left_bracker_idx);
115 | this.categoryName = categoryName;
116 | }
117 |
118 | public String toString(){
119 | return "Source: " + (typeName + ", " + methodName + ", " + categoryName);
120 | }
121 | public String getID() {
122 | return this.id;
123 | }
124 | }
125 |
126 | public static class SafeDescription {
127 | String typeName, methodName, id;
128 |
129 | public String getMethodName() {
130 | return methodName;
131 | }
132 | public String getTypeName() {
133 | return typeName;
134 | }
135 | public SafeDescription(String id, String typeName, String methodName) {
136 | this.id = id;
137 | this.typeName = typeName;
138 | this.methodName = methodName;
139 | }
140 |
141 | public String toString(){
142 | return "Safe: " + (typeName + ", " + methodName);
143 | }
144 | public String getID() {
145 | return this.id;
146 | }
147 | }
148 | public static class DerivationDescription {
149 | String typeName, methodName, id;
150 |
151 |
152 | public String getMethodName() {
153 | return methodName;
154 | }
155 | public String getTypeName() {
156 | return typeName;
157 | }
158 | public DerivationDescription(String id, String typeName, String methodName){
159 | this.id = id;
160 | this.typeName = typeName;
161 | this.methodName = methodName;
162 | }
163 |
164 | public String toString(){
165 | return "Derivator: " + (typeName + ", " + methodName);
166 | }
167 | public String getID() {
168 | return this.id;
169 | }
170 | }
171 | public static class ReflectorDescription {
172 | String typeName, methodName, categoryName, id;
173 |
174 | public String getCategoryName() {
175 | return categoryName;
176 | }
177 | public String getMethodName() {
178 | return methodName;
179 | }
180 | public String getTypeName() {
181 | return typeName;
182 | }
183 | public ReflectorDescription(String id, String typeName, String methodName, String categoryName) {
184 | this.id = id;
185 | this.typeName = typeName;
186 | this.methodName = methodName;
187 | this.categoryName = categoryName;
188 | }
189 |
190 | public String toString(){
191 | return "Reflector: " + (typeName + ", " + methodName + ", " + categoryName);
192 | }
193 | public String getID() {
194 | return this.id;
195 | }
196 | }
197 |
198 | public static void main(String argv []){
199 | TRACE = true;
200 | Collection sources = readSources("sources.xml", "");
201 | Collection sinks = readSinks("sinks.xml", "");
202 | Collection derived = readDerivators("derived.xml", "");
203 |
204 | if(TRACE) {
205 | System.out.println(sources);
206 | System.out.println(sinks);
207 | System.out.println(derived);
208 | }
209 | }
210 |
211 | public static Collection readSinks(String fileName, String base) {
212 | LinkedList result = new LinkedList();
213 |
214 | try {
215 | DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
216 | DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
217 | Document doc = docBuilder.parse(new File(base + fileName));
218 |
219 | // normalize text representation
220 | doc.getDocumentElement ().normalize ();
221 | if(TRACE) System.out.println ("Root element of the doc is " + doc.getDocumentElement().getNodeName());
222 |
223 | NodeList sinks = doc.getElementsByTagName("sink");
224 | if(TRACE) System.out.println("Total no of sinks: " + sinks.getLength());
225 |
226 | for(int s=0; s < sinks.getLength() ; s++){
227 | if(sinks.item(s).getNodeType() == Node.ELEMENT_NODE){
228 | Element sinkNode = (Element) sinks.item(s);
229 | Assert.isNotNull(sinkNode);
230 | String id = sinkNode.getAttribute("id");
231 | Assert.isNotNull(id);
232 |
233 | //String typeName = sinkNode.getElementsByTagName("type").item(0).getChildNodes().item(0).getNodeValue().trim();
234 | //String methodName = sinkNode.getElementsByTagName("method").item(0).getChildNodes().item(0).getNodeValue().trim();
235 | String categoryName = sinkNode.getElementsByTagName("category").item(0).getChildNodes().item(0).getNodeValue().trim();
236 | int parameterCount = new Integer(sinkNode.getElementsByTagName("paramCount").item(0).getChildNodes().item(0).getNodeValue().trim()).intValue();
237 | int vulnerableParameter = new Integer(sinkNode.getElementsByTagName("vulnParam").item(0).getChildNodes().item(0).getNodeValue().trim()).intValue();
238 |
239 | SinkDescription desc = new SinkDescription(id, categoryName, vulnerableParameter);
240 | result.add(desc);
241 | if(TRACE) System.out.println(desc);
242 | }//end of if clause
243 | }//end of for loop with s var
244 | } catch (SAXParseException err) {
245 | System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
246 | System.out.println(" " + err.getMessage ());
247 | return null;
248 | }catch (SAXException e) {
249 | Exception x = e.getException ();
250 | ((x == null) ? e : x).printStackTrace ();
251 | return null;
252 | }catch (Throwable t) {
253 | t.printStackTrace ();
254 | return null;
255 | }
256 |
257 | return result;
258 | }
259 |
260 | public static Collection readSinks(String fileName) {
261 | return readSinks("sinks.xml", getPlugingBasePath());
262 | }
263 |
264 | public static Collection readSources(String fileName, String base) {
265 | LinkedList result = new LinkedList();
266 | try {
267 | DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
268 | DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
269 | Document doc = docBuilder.parse(new File(base + fileName));
270 |
271 | // normalize text representation
272 | doc.getDocumentElement ().normalize ();
273 | if(TRACE) System.out.println ("Root element of the doc is " + doc.getDocumentElement().getNodeName());
274 |
275 | NodeList sources = doc.getElementsByTagName("source");
276 | if(TRACE) System.out.println("Total no of sources: " + sources.getLength());
277 |
278 | for (int s = 0; s < sources.getLength(); s++) {
279 | if(sources.item(s).getNodeType() == Node.ELEMENT_NODE){
280 | Element sourceNode = (Element) sources.item(s);
281 | Assert.isNotNull(sourceNode);
282 |
283 | String id = sourceNode.getAttribute("id");
284 | //String typeName = sourceNode.getElementsByTagName("type").item(0).getChildNodes().item(0).getNodeValue().trim();
285 | //String methodName = sourceNode.getElementsByTagName("method").item(0).getChildNodes().item(0).getNodeValue().trim();
286 | String categoryName = sourceNode.getElementsByTagName("category").item(0).getChildNodes().item(0).getNodeValue().trim();
287 |
288 | SourceDescription desc = new SourceDescription(id, categoryName);
289 | result.add(desc);
290 | if(TRACE) System.out.println(desc);
291 | }//end of if clause
292 | }//end of for loop with s var
293 | } catch (SAXParseException err) {
294 | System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
295 | System.out.println(" " + err.getMessage ());
296 | return null;
297 | }catch (SAXException e) {
298 | Exception x = e.getException ();
299 | ((x == null) ? e : x).printStackTrace ();
300 | return null;
301 | }catch (Throwable t) {
302 | t.printStackTrace ();
303 | return null;
304 | }
305 |
306 | return result;
307 | }
308 |
309 | public static Collection readSafes(String fileName, String base) {
310 | LinkedList result = new LinkedList();
311 | try {
312 | DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
313 | DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
314 | Document doc = docBuilder.parse(new File(base + fileName));
315 |
316 | // normalize text representation
317 | doc.getDocumentElement ().normalize ();
318 | if(TRACE) System.out.println ("Root element of the doc is " + doc.getDocumentElement().getNodeName());
319 |
320 | NodeList sources = doc.getElementsByTagName("safe");
321 | if(TRACE) System.out.println("Total no of safes: " + sources.getLength());
322 |
323 | for(int s=0; s readDerivators(String fileName) {
353 | return readDerivators(fileName, getPlugingBasePath());
354 | }
355 |
356 | public static Collection readDerivators(String fileName, String base) {
357 | LinkedList result = new LinkedList();
358 |
359 | DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
360 | Document doc = null;
361 | try {
362 | DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
363 | doc = docBuilder.parse(new File(base + fileName));
364 | }catch (SAXParseException err) {
365 | System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
366 | System.out.println(" " + err.getMessage ());
367 | return null;
368 | }catch (SAXException e) {
369 | Exception x = e.getException ();
370 | ((x == null) ? e : x).printStackTrace ();
371 | return null;
372 | } catch (IOException e) {
373 | e.printStackTrace();
374 | return null;
375 | } catch (ParserConfigurationException e) {
376 | e.printStackTrace();
377 | return null;
378 | }
379 |
380 | // normalize text representation
381 | doc.getDocumentElement ().normalize ();
382 | if(TRACE) System.out.println ("Root element of the doc is " + doc.getDocumentElement().getNodeName());
383 |
384 | NodeList derivators = doc.getElementsByTagName("derivation");
385 | if(TRACE) System.out.println("Total no of reflectors: " + derivators.getLength());
386 |
387 | for(int s=0; s readReflectors(String fileName, String base) {
411 | LinkedList result = new LinkedList();
412 |
413 | DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
414 | Document doc = null;
415 | try {
416 | DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
417 | doc = docBuilder.parse(new File(base + fileName));
418 | }catch (SAXParseException err) {
419 | System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
420 | System.out.println(" " + err.getMessage ());
421 | return null;
422 | }catch (SAXException e) {
423 | Exception x = e.getException ();
424 | ((x == null) ? e : x).printStackTrace ();
425 | return null;
426 | } catch (IOException e) {
427 | e.printStackTrace();
428 | return null;
429 | } catch (ParserConfigurationException e) {
430 | e.printStackTrace();
431 | return null;
432 | }
433 |
434 | // normalize text representation
435 | doc.getDocumentElement ().normalize ();
436 | if(TRACE) System.out.println ("Root element of the doc is " + doc.getDocumentElement().getNodeName());
437 |
438 | NodeList sources = doc.getElementsByTagName("reflector");
439 | if(TRACE) System.out.println("Total no of reflectors: " + sources.getLength());
440 |
441 | for(int s=0; s readSources(String fileName) {
466 | return readSources(fileName, getPlugingBasePath());
467 | }
468 |
469 | public static Collection readSafes(String fileName) {
470 | return readSafes(fileName, getPlugingBasePath());
471 | }
472 |
473 | public static Collection readReflectors(String fileName) {
474 | return readReflectors(fileName, getPlugingBasePath());
475 | }
476 |
477 | public static String getPlugingBasePath(){
478 | LapsePlugin plugin = LapsePlugin.getDefault();
479 | URL base = plugin.getDescriptor().getInstallURL();
480 |
481 | try {
482 | return FileLocator.toFileURL(base).getFile() + "/";
483 | } catch (IOException e) {
484 | e.printStackTrace();
485 | return "";
486 | }
487 | }
488 |
489 | // private static void saveDescription(IMethod method, SinkDescription desc) {
490 | // method2desc.put(method, desc);
491 | // }
492 |
493 | public static SinkDescription getDescription(IMethod method) {
494 | return method2desc.get(method);
495 | }
496 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------