subgraph / Vega

Subgraph Vega
http://subgraph.com
354 stars 94 forks source link

Build Vega on Linux fails #147

Open leisipeisi opened 6 years ago

leisipeisi commented 6 years ago

Hi everyone,

just tried to build Vega on my Kali Linux as described at the corresponding wiki site (Link). During the ant command, I receive the following errors:

     [java]     [javac] 1. WARNING in /root/Dokumente/subgraph/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/AlertExportWizard.java (at line 3)
     [java]     [javac]     import java.util.ArrayList;
     [java]     [javac]            ^^^^^^^^^^^^^^^^^^^
     [java]     [javac] The import java.util.ArrayList is never used
     [java]     [javac] ----------
     [java]     [javac] ----------
     [java]     [javac] 2. ERROR in /root/Dokumente/subgraph/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageOne.java (at line 71)
     [java]     [javac]     choice = htmlButton.getText();
     [java]     [javac]              ^^^^^^^^^^
     [java]     [javac] Cannot refer to a non-final variable htmlButton inside an inner class defined in a different method
     [java]     [javac] ----------
     [java]     [javac] ----------
     [java]     [javac] 3. ERROR in /root/Dokumente/subgraph/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageThree.java (at line 69)
     [java]     [javac]     doFileDialog(parent.getShell());
     [java]     [javac]                  ^^^^^^
     [java]     [javac] Cannot refer to a non-final variable parent inside an inner class defined in a different method
     [java]     [javac] ----------
     [java]     [javac] ----------
     [java]     [javac] 4. ERROR in /root/Dokumente/subgraph/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java (at line 85)
     [java]     [javac]     if (selectAllButton.getSelection() == true) {
     [java]     [javac]         ^^^^^^^^^^^^^^^
     [java]     [javac] Cannot refer to a non-final variable selectAllButton inside an inner class defined in a different method
     [java]     [javac] ----------
     [java]     [javac] 5. ERROR in /root/Dokumente/subgraph/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java (at line 168)
     [java]     [javac]     if (selectAllButton.getSelection() == true) {
     [java]     [javac]         ^^^^^^^^^^^^^^^
     [java]     [javac] Cannot refer to a non-final variable selectAllButton inside an inner class defined in a different method
     [java]     [javac] ----------
     [java]     [javac] 6. ERROR in /root/Dokumente/subgraph/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java (at line 169)
     [java]     [javac]     selectAllButton.setSelection(false);
     [java]     [javac]     ^^^^^^^^^^^^^^^
     [java]     [javac] Cannot refer to a non-final variable selectAllButton inside an inner class defined in a different method
     [java]     [javac] ----------
     [java]     [javac] 7. WARNING in /root/Dokumente/subgraph/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java (at line 220)
     [java]     [javac]     List<IScanAlert> scanInstanceAlerts = (List<IScanAlert>) t.getData();
     [java]     [javac]                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     [java]     [javac] Type safety: Unchecked cast from Object to List<IScanAlert>
     [java]     [javac] ----------
     [java]     [javac] 7 problems (5 errors, 2 warnings)
     [java]     [javac] Compilation failed. Compiler errors are available in /root/Dokumente/subgraph/Vega/build/stage/plugins/com.subgraph.vega.ui.util/@dot.log
     [java] 
     [java] BUILD FAILED

Anybody having a suggestion on how to fix this? Thanks in advance!


UPDATE:

I now did some "fixes", it compiles and works (kind of). Many others may already have done the same, feel free to add some information on how to make it more beautiful, I just wanted it to work.

Changes:

  1. ExportWizardPageOne.java Replace line 71 Before: choice = htmlButton.getText(); After: choice = "HTML"; (XML isn't working anyways)
  2. ExportWizardPageTwo.java Delete the if-clause in line 85 saying if (selectAllButton.getSelection() == true) { and the corresponding closing bracket. Delete lines 168 to 170 saying
    if (selectAllButton.getSelection() == true) {
    selectAllButton.setSelection(false);
    }
  3. ExportWizardPageThree.java Include final Composite parent1 = parent; somewhere before line 69 and change parent in this line to parent1

With this version, I can now do a right click on any scan report and choose Export Scan Results. A wizard pops up, I can click through and choose any location at the last step. The result will be saved in /tmp/test2.html no matter what. If you want, you can change the location in AlertExporter.java. I thought that with my modifications it would not be possible to export singe reports, but it is still possible (and it's also possible to export all reports at once).

I hope this helps somebody :)

Valraven commented 6 years ago

I keep trying these fixes, but everytime I edit the files and run ant again to build, they seem to be reverted back to their original state and I can't figure out how or where :/

I have a feeling I am editing the wrong files for some reason.

leisipeisi commented 6 years ago

To make persistant changes, you need to edit the files in the folder <vega_dir>/platform/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export. Did you use these files to apply the changes?

Valraven commented 6 years ago

Thanks for the answer @leisipeisi I have found the files (damn what a load of subdirs hahaha) and did the edits as said. However I get a new error now while building Vega


     [java]     [javac] ----------
     [java]     [javac] 1. WARNING in /opt/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/AlertExportWizard.java (at line 3)
     [java]     [javac]     import java.util.ArrayList;
     [java]     [javac]            ^^^^^^^^^^^^^^^^^^^
     [java]     [javac] The import java.util.ArrayList is never used
     [java]     [javac] ----------
     [java]     [javac] ----------
     [java]     [javac] 2. WARNING in /opt/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageOne.java (at line 15)
     [java]     [javac]     import org.eclipse.swt.widgets.Label;
     [java]     [javac]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     [java]     [javac] The import org.eclipse.swt.widgets.Label is never used
     [java]     [javac] ----------
     [java]     [javac] ----------
     [java]     [javac] 3. ERROR in /opt/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageThree.java (at line 68)
     [java]     [javac]     final Composite parent1 = parent;
     [java]     [javac]                               ^^^^^^
     [java]     [javac] Cannot refer to a non-final variable parent inside an inner class defined in a different method
     [java]     [javac] ----------
     [java]     [javac] ----------
     [java]     [javac] 4. WARNING in /opt/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java (at line 9)
     [java]     [javac]     import org.eclipse.jface.viewers.TreeSelection;
     [java]     [javac]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     [java]     [javac] The import org.eclipse.jface.viewers.TreeSelection is never used
     [java]     [javac] ----------
     [java]     [javac] 5. WARNING in /opt/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java (at line 18)
     [java]     [javac]     import org.eclipse.swt.graphics.Image;
     [java]     [javac]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     [java]     [javac] The import org.eclipse.swt.graphics.Image is never used
     [java]     [javac] ----------
     [java]     [javac] 6. WARNING in /opt/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java (at line 23)
     [java]     [javac]     import org.eclipse.swt.layout.RowLayout;
     [java]     [javac]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     [java]     [javac] The import org.eclipse.swt.layout.RowLayout is never used
     [java]     [javac] ----------
     [java]     [javac] 7. WARNING in /opt/Vega/build/stage/plugins/com.subgraph.vega.ui.util/src/com/subgraph/vega/ui/util/export/ExportWizardPageTwo.java (at line 220)
     [java]     [javac]     List<IScanAlert> scanInstanceAlerts = (List<IScanAlert>) t.getData();
     [java]     [javac]                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     [java]     [javac] Type safety: Unchecked cast from Object to List<IScanAlert>
     [java]     [javac] ----------
     [java]     [javac] 7 problems (1 error, 6 warnings)
     [java]     [javac] Compilation failed. Compiler errors are available in /opt/Vega/build/stage/plugins/com.subgraph.vega.ui.util/@dot.log
     [java] 
     [java] BUILD FAILED```

My question is where to put the `final Composite parent1 = parent;` in the code of ExportWizardPageThree.java

(I'm sorry, but Java is not my language :P )
leisipeisi commented 6 years ago

Glad you are making progress!

You need to change the method createControl to look as follows. Add the line final Composite parent1 = parent; at the position shown below and also change the value parent to parent1 as shown below.


@Override
public void createControl(Composite parent) {
[... clipped some code for readability, leave it as is ...]

GridData textFieldGridData = new GridData();
testFieldGridData.widthHint = 300;
textFiled.setLayoutData(textFieldGridData);

final Composite parent1 = parent;

button.addSelectionListener (new SelectionListener() {
     @Override
     public void widgetSelected(SelectionEvent e) {
          doFileDialog(parent1.getShell());
     }
     @Override
     public void widgetDefaultSelected(SelectionEvent e) {
          // TODO Auto-generated method stub
     }});

[... clipped some code for readability, leave it as is ...]
}
Valraven commented 6 years ago

@leisipeisi It worked, thank you so much. I placed the final Composite part after the button.addSelectionListener instead of before. This fixed it, and I have a successful build :)