summaryrefslogtreecommitdiffstats
path: root/src/toolsconfig/flawfinder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/toolsconfig/flawfinder.java')
-rw-r--r--src/toolsconfig/flawfinder.java115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/toolsconfig/flawfinder.java b/src/toolsconfig/flawfinder.java
new file mode 100644
index 0000000..4ed19c2
--- /dev/null
+++ b/src/toolsconfig/flawfinder.java
@@ -0,0 +1,115 @@
1package toolsconfig;
2
3import cppcheckplus.control.MyContorlUtil;
4import cppcheckplus.text.ViewPanel;
5import java.io.BufferedReader;
6import java.io.IOException;
7import java.io.InputStream;
8import java.io.InputStreamReader;
9
10public class flawfinder extends ToolsConfig{
11 public flawfinder() {
12 this.name = "flawfinder";
13 ToolsRegistry.registerTool(this.name, this);
14 }
15
16 @Override
17 public void execute(String src) {
18 // flawfinder
19// if (changedpathflaw) {
20// MyContorlUtil.loadToolsRoad(settingsXML, this);
21// changedpathflaw = false;
22// }
23
24 if (path == null) {
25 return;
26 }
27 Runtime runtime = Runtime.getRuntime();
28 Process p = null;
29 Runtime runtime2 = Runtime.getRuntime();
30 Process p2 = null;
31 try {
32
33 // 两个参数数组,一个是csv格式,一个是传入的参数
34 String[] arguments =
35 new String[] {"python", path, "--csv", src};
36 String[] arguments2 =
37 new String[] {"python", path, params, src};
38
39 p = runtime.exec(arguments);
40 p2 = runtime.exec(arguments2);
41 final InputStream is1 = p.getInputStream();
42 final InputStream is2 = p2.getInputStream();
43 System.out.println(arguments2[1]);
44
45 // csv结果添加到表格
46 new Thread() {
47 public void run() {
48 BufferedReader br1 =
49 new BufferedReader(new InputStreamReader(is1));
50 try {
51 String line1 = null;
52 while ((line1 = br1.readLine()) != null) {
53 uiFrame.ct.toRowsOfflawfinder(line1);
54 }
55 } catch (Exception e) {
56 e.printStackTrace();
57 } finally {
58 try {
59 is1.close();
60 } catch (IOException e) {
61 e.printStackTrace();
62 }
63 }
64 }
65 }.start();
66
67 // 普通结果显示在文本框
68 new Thread() {
69 public void run() {
70 //flawfinder result
71 BufferedReader br1 =
72 new BufferedReader(new InputStreamReader(is2));
73 StringBuilder l1 = new StringBuilder();
74 result.setText("");
75 try {
76 String line1 = null;
77 while ((line1 = br1.readLine()) != null) {
78 l1.append(line1 + ENTERWindows);
79 }
80 } catch (Exception e) {
81 e.printStackTrace();
82 } finally {
83 try {
84 result.setText(
85 l1.substring(0, l1.length()));
86 is2.close();
87 } catch (IOException e) {
88 e.printStackTrace();
89 }
90 }
91 }
92 }.start();
93
94 int exitCode = p.waitFor();
95 int exitCode2 = p2.waitFor();
96 if (exitCode == SUCCESS) {
97 System.out.println(SUCCESS_MESSAGE);
98 } else {
99 System.err.println(ERROR_MESSAGE + exitCode);
100 }
101 p.destroy();
102 p2.destroy();
103 } catch (Exception e) {
104 try {
105 p.getErrorStream().close();
106 p.getInputStream().close();
107 p.getOutputStream().close();
108 p2.getErrorStream().close();
109 p2.getInputStream().close();
110 p2.getOutputStream().close();
111 } catch (Exception ee) {
112 }
113 }
114 }
115}