Skip to content

Commit

Permalink
add description text area and remove some attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousAnalyst committed Dec 26, 2019
1 parent 70fad25 commit 1803a2d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
18 changes: 14 additions & 4 deletions jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisFinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public class TaintAnalysisFinding {
private MarkedLocation source;
private MarkedLocation sink;
private ArrayList<MarkedLocation> intermediateFlows;
private String description;

private Map<String, Boolean> attributes;
private final String creationDate;

public TaintAnalysisFinding(){
intermediateFlows = new ArrayList<MarkedLocation>();
attributes = new TreeMap<>();
creationDate = new SimpleDateFormat(" (HH:mm:ss)").format(new Date());
}

public void removeSource(){
Expand Down Expand Up @@ -65,6 +65,11 @@ public void setSink(MarkedLocation sink){
this.sink = sink;
}

public void setDescription(String description)
{
assert (this.description==null);
this.description=description;
}
public void addIntermediateFlow(MarkedLocation intermediate){
assert(!intermediateFlows.contains(intermediate));
intermediateFlows.add(intermediate);
Expand Down Expand Up @@ -102,8 +107,8 @@ public void showAllHighlights(){
@Override
public String toString(){
if(source == null)
return "<no source>" + creationDate;
return source.toString() + creationDate;
return "<no source>";
return source.toString();
}

public void setAttribute(String key, boolean value){
Expand All @@ -113,4 +118,9 @@ public void setAttribute(String key, boolean value){
public Map<String, Boolean> getAttributes(){
return attributes;
}

public String getDescription()
{
return this.description;
}
}
19 changes: 9 additions & 10 deletions jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
public class TaintAnalysisReport {
private static transient TaintAnalysisReport instance;
private String fileName;
private String day;
private ArrayList<TaintAnalysisFinding> findings;
private transient TaintAnalysisFinding currentFinding;
private transient int currentFindingIndex;
Expand All @@ -44,7 +43,6 @@ private TaintAnalysisReport(){
sinkColor = new Color(0x1b, 0x89, 0x7f);
intermediateColor = new Color(0xe4, 0xd9, 0x73);
currentFindingIndex = -1;
day = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
reportDialog = new ReportDialog();
reportDialog.setVisible(true);
}
Expand All @@ -60,22 +58,14 @@ private static HashMap<String, String> createFindingAttributesJsonKeyToDisplayNa
HashMap<String, String> result = new HashMap<>();
result.put("intraProcedural", "Intra-procedural");
result.put("interProcedural", "Inter-procedural");
result.put("fieldSensitive", "Field-sensitive");
result.put("flowSensitive", "Flow-sensitive");
result.put("contextSensitive", "Context-sensitive");
result.put("objectSensitive", "Object-sensitive");
result.put("pathSensitive", "Path-sensitive");
result.put("staticField", "Static Field");
result.put("array", "Array");
result.put("reflection", "Reflection");
result.put("exception", "Exception");
result.put("implicitflows", "Implicit Flows");
result.put("threading", "Threading");
result.put("lifecycle", "Lifecycle");
result.put("callbacks", "Callbacks");
result.put("interComponentCommunication", "Inter-Component Communication");
result.put("interAppCommunication", "Inter-App Communication");
result.put("emulatorDetection", "Emulator Detection");
result.put("collections", "Collections");
result.put("partialFlow", "Partial Flow");
return result;
Expand Down Expand Up @@ -167,13 +157,15 @@ public void selectCurrentFinding(int index, boolean updateReportDialog){
reportDialog.updateMarkedIntermediates(currentFinding.getIntermediateFlows());
reportDialog.updateMarkedSink(currentFinding.getSink());
reportDialog.updateAttributes(currentFinding.getAttributes());
reportDialog.updateDescription(currentFinding.getDescription());
}
else{
reportDialog.updateFindings(findings);
reportDialog.updateMarkedSource(null);
reportDialog.updateMarkedIntermediates(null);
reportDialog.updateMarkedSink(null);
reportDialog.updateAttributes(null);
reportDialog.updateDescription(null);
}
}

Expand All @@ -186,6 +178,9 @@ public void previousFinding(boolean updateReportDialog){
}

public void createAndSwitchToNewFinding(){
String description= this.reportDialog.getDescription();
if(currentFinding!=null)
currentFinding.setDescription(description);
TaintAnalysisFinding finding = new TaintAnalysisFinding();
currentFindingIndex = findings.size();
findings.add(findings.size(), finding);
Expand Down Expand Up @@ -216,6 +211,9 @@ public void setFileName(String filename){
}

public void serializeToJson(){
String description= this.reportDialog.getDescription();
if(currentFinding!=null)
currentFinding.setDescription(description);
String json = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create().toJson(this);
JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(false);
Expand Down Expand Up @@ -303,4 +301,5 @@ public void setAttributeOfCurrent(String key, boolean value){
if(currentFinding != null)
currentFinding.setAttribute(key, value);
}

}
27 changes: 27 additions & 0 deletions jadx-gui/src/main/java/jadx/gui/ui/ReportDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ReportDialog extends JDialog {
private final DefaultListModel<String> intermediatesListModel;
private Map<String, JCheckBox> findingAttributesCheckboxMap;
private Map<JCheckBox, String> findingCheckboxAttributesMap;
private final JTextArea description;

public ReportDialog(){
findingComboBox = new JComboBox<>();
Expand All @@ -27,6 +28,7 @@ public ReportDialog(){
intermediatesListModel = new DefaultListModel<>();
findingAttributesCheckboxMap = new TreeMap<>();
findingCheckboxAttributesMap = new HashMap<>();
description = new JTextArea();
initCheckboxMap();
initUI();
}
Expand Down Expand Up @@ -107,6 +109,13 @@ public void mouseClicked(MouseEvent e) {
markedSinkText.setPreferredSize(new Dimension(480, 20));
markedSinkText.setEditable(false);
markedSinkText.setFocusable(false);
description.setEditable(true);
description.setLineWrap(true);
description.setWrapStyleWord(true);
JScrollPane areaScrollPane = new JScrollPane(description);
areaScrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
areaScrollPane.setPreferredSize(new Dimension(480, 80));

JScrollPane listScroller = new JScrollPane(markedIntermediatesList);
listScroller.setPreferredSize(new Dimension(480, 420));
Expand All @@ -124,6 +133,8 @@ public void mouseClicked(MouseEvent e) {
centerPanel.add(new JLabel("Intermediates: "), constraints);
constraints.gridy = 3;
centerPanel.add(new JLabel("Sink: "), constraints);
constraints.gridy = 4;
centerPanel.add(new JLabel("Description: "),constraints);

constraints.gridx = 1;
constraints.gridy = 0;
Expand All @@ -134,6 +145,8 @@ public void mouseClicked(MouseEvent e) {
centerPanel.add(listScroller, constraints);
constraints.gridy = 3;
centerPanel.add(markedSinkText, constraints);
constraints.gridy=4;
centerPanel.add(areaScrollPane,constraints);

constraints.gridy = 0;
constraints.gridx = 2;
Expand Down Expand Up @@ -185,6 +198,15 @@ public void updateMarkedSink(MarkedLocation sink){
markedSinkText.setCaretPosition(0);
}

public void updateDescription(String des)
{
if(description!=null)
description.setText(des);
else
description.setText("");
description.setCaretPosition(0);
}

public void selectCurrentFinding(int index){
findingComboBox.setSelectedIndex(index);
}
Expand All @@ -201,4 +223,9 @@ public void updateAttributes(Map<String, Boolean> attributes){
findingAttributesCheckboxMap.get(key).setSelected(false);
}
}

public String getDescription()
{
return this.description.getText();
}
}

0 comments on commit 1803a2d

Please sign in to comment.