From 1803a2d65ff27bf52b1a9cafa65cc1964bfc9c63 Mon Sep 17 00:00:00 2001 From: AnonymousAnalyst Date: Thu, 26 Dec 2019 15:19:36 +0100 Subject: [PATCH] add description text area and remove some attributes --- .../gui/taintdoc/TaintAnalysisFinding.java | 18 ++++++++++--- .../gui/taintdoc/TaintAnalysisReport.java | 19 +++++++------ .../main/java/jadx/gui/ui/ReportDialog.java | 27 +++++++++++++++++++ 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisFinding.java b/jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisFinding.java index f0a3e34a..0692b610 100644 --- a/jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisFinding.java +++ b/jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisFinding.java @@ -13,13 +13,13 @@ public class TaintAnalysisFinding { private MarkedLocation source; private MarkedLocation sink; private ArrayList intermediateFlows; + private String description; + private Map attributes; - private final String creationDate; public TaintAnalysisFinding(){ intermediateFlows = new ArrayList(); attributes = new TreeMap<>(); - creationDate = new SimpleDateFormat(" (HH:mm:ss)").format(new Date()); } public void removeSource(){ @@ -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); @@ -102,8 +107,8 @@ public void showAllHighlights(){ @Override public String toString(){ if(source == null) - return "" + creationDate; - return source.toString() + creationDate; + return ""; + return source.toString(); } public void setAttribute(String key, boolean value){ @@ -113,4 +118,9 @@ public void setAttribute(String key, boolean value){ public Map getAttributes(){ return attributes; } + + public String getDescription() + { + return this.description; + } } diff --git a/jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisReport.java b/jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisReport.java index 834a117c..66890958 100644 --- a/jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisReport.java +++ b/jadx-gui/src/main/java/jadx/gui/taintdoc/TaintAnalysisReport.java @@ -26,7 +26,6 @@ public class TaintAnalysisReport { private static transient TaintAnalysisReport instance; private String fileName; - private String day; private ArrayList findings; private transient TaintAnalysisFinding currentFinding; private transient int currentFindingIndex; @@ -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); } @@ -60,22 +58,14 @@ private static HashMap createFindingAttributesJsonKeyToDisplayNa HashMap 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; @@ -167,6 +157,7 @@ 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); @@ -174,6 +165,7 @@ public void selectCurrentFinding(int index, boolean updateReportDialog){ reportDialog.updateMarkedIntermediates(null); reportDialog.updateMarkedSink(null); reportDialog.updateAttributes(null); + reportDialog.updateDescription(null); } } @@ -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); @@ -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); @@ -303,4 +301,5 @@ public void setAttributeOfCurrent(String key, boolean value){ if(currentFinding != null) currentFinding.setAttribute(key, value); } + } diff --git a/jadx-gui/src/main/java/jadx/gui/ui/ReportDialog.java b/jadx-gui/src/main/java/jadx/gui/ui/ReportDialog.java index d495f6e3..0b3cdb03 100644 --- a/jadx-gui/src/main/java/jadx/gui/ui/ReportDialog.java +++ b/jadx-gui/src/main/java/jadx/gui/ui/ReportDialog.java @@ -18,6 +18,7 @@ public class ReportDialog extends JDialog { private final DefaultListModel intermediatesListModel; private Map findingAttributesCheckboxMap; private Map findingCheckboxAttributesMap; + private final JTextArea description; public ReportDialog(){ findingComboBox = new JComboBox<>(); @@ -27,6 +28,7 @@ public ReportDialog(){ intermediatesListModel = new DefaultListModel<>(); findingAttributesCheckboxMap = new TreeMap<>(); findingCheckboxAttributesMap = new HashMap<>(); + description = new JTextArea(); initCheckboxMap(); initUI(); } @@ -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)); @@ -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; @@ -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; @@ -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); } @@ -201,4 +223,9 @@ public void updateAttributes(Map attributes){ findingAttributesCheckboxMap.get(key).setSelected(false); } } + + public String getDescription() + { + return this.description.getText(); + } }