Skip to content

Commit ad6d489

Browse files
committed
fixes exception cause
1 parent f51b5e2 commit ad6d489

File tree

18 files changed

+41
-31
lines changed

18 files changed

+41
-31
lines changed

dongtai-agent/src/main/java/io/dongtai/iast/agent/monitor/impl/PerformanceMonitor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public static Integer getDiskUsage() {
7272
return (int) rate;
7373
}
7474
} catch (Throwable e) {
75-
DongTaiLog.warn(ErrorCode.AGENT_MONITOR_GET_DISK_USAGE_FAILED, e.getMessage(), e.getCause().getMessage());
75+
DongTaiLog.warn(ErrorCode.AGENT_MONITOR_GET_DISK_USAGE_FAILED,
76+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
7677
}
7778
return 0;
7879
}

dongtai-common/src/main/java/io/dongtai/iast/common/utils/base64/CharacterEncoder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public String encode(byte[] var1) {
9494
return var4;
9595
} catch (Throwable e) {
9696
DongTaiLog.trace("CharacterEncoder.encode internal error: {}, {}",
97-
e.getMessage(), e.getCause().getMessage());
97+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
9898
return "";
9999
}
100100
}
@@ -168,7 +168,7 @@ public String encodeBuffer(byte[] var1) {
168168
this.encodeBuffer((InputStream) var3, var2);
169169
} catch (Throwable e) {
170170
DongTaiLog.trace("CharacterEncoder.encodeBuffer internal error: {}, {}",
171-
e.getMessage(), e.getCause().getMessage());
171+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
172172
}
173173

174174
return var2.toString();

dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/IastClassFileTransformer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ public void reTransform() {
322322
try {
323323
inst.retransformClasses(clazz);
324324
} catch (ClassCircularityError e) {
325-
DongTaiLog.error(ErrorCode.RETRANSFORM_CLASS_CIRCULARITY_ERROR,
326-
clazz.getCanonicalName(), e.getCause().getMessage());
325+
DongTaiLog.error(ErrorCode.RETRANSFORM_CLASS_CIRCULARITY_ERROR, clazz.getCanonicalName(),
326+
e.getCause() != null ? e.getCause().getMessage() : "");
327327
} catch (InternalError ignored) {
328328
} catch (Throwable e) {
329329
DongTaiLog.error(ErrorCode.RETRANSFORM_CLASS_FAILED, clazz.getCanonicalName(), e);

dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/sca/ScaReport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public static void sendReport(String report) {
2929
try {
3030
HttpClientUtils.sendPost(ApiPath.REPORT_UPLOAD, report);
3131
} catch (Throwable e) {
32-
DongTaiLog.warn(ErrorCode.SCA_REPORT_SEND_FAILED, e.getMessage(), e.getCause().getMessage());
32+
DongTaiLog.warn(ErrorCode.SCA_REPORT_SEND_FAILED,
33+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
3334
}
3435
}
3536

dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/sca/ScaScanner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ private void scanJarLib(String packagePath) {
181181
}
182182
}
183183
} catch (Throwable e) {
184-
DongTaiLog.warn(ErrorCode.SCA_SCAN_JAR_LIB_FAILED, e.getMessage(), e.getCause().getMessage());
184+
DongTaiLog.warn(ErrorCode.SCA_SCAN_JAR_LIB_FAILED,
185+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
185186
}
186187
}
187188

dongtai-core/src/main/java/io/dongtai/iast/core/bytecode/sca/SignatureAlgorithm.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public static String getSignature(InputStream is, String algorithm) {
2828
BigInteger bigInteger = new BigInteger(1, digest.digest());
2929
signature = String.format("%040x", bigInteger);
3030
} catch (Throwable e) {
31-
DongTaiLog.warn(ErrorCode.SCA_CALCULATE_JAR_SIGNATURE_FAILED, e.getMessage(), e.getCause().getMessage());
31+
DongTaiLog.warn(ErrorCode.SCA_CALCULATE_JAR_SIGNATURE_FAILED,
32+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
3233
}
3334
return signature;
3435
}
@@ -43,7 +44,8 @@ public static String getSignature(File file, String algorithm) {
4344
in = new FileInputStream(file);
4445
signature = getSignature(in, algorithm);
4546
} catch (Throwable e) {
46-
DongTaiLog.warn(ErrorCode.SCA_CALCULATE_JAR_SIGNATURE_FAILED, e.getMessage(), e.getCause().getMessage());
47+
DongTaiLog.warn(ErrorCode.SCA_CALCULATE_JAR_SIGNATURE_FAILED,
48+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
4749
} finally {
4850
try {
4951
if (in != null) {

dongtai-core/src/main/java/io/dongtai/iast/core/handler/hookpoint/service/ServiceHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public static void reportService(String category, String type, String host, Stri
2828
reportSingleService(category, type, srv.getHost(), srv.getPort());
2929
}
3030
} catch (Throwable e) {
31-
DongTaiLog.trace("report service failed: {}, {}", e.getMessage(), e.getCause().getMessage());
31+
DongTaiLog.trace("report service failed: {}, {}",
32+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
3233
}
3334
}
3435

dongtai-core/src/main/java/io/dongtai/iast/core/handler/hookpoint/service/trace/FeignService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public static void solveSyncInvoke(MethodEvent event, AtomicInteger invokeIdSequ
5252
} catch (NoSuchFieldException ignore) {
5353
} catch (NoSuchMethodException ignore) {
5454
} catch (Throwable e) {
55-
DongTaiLog.debug("solve feign invoke failed: {}, {}", e.getMessage(), e.getCause().getMessage());
55+
DongTaiLog.debug("solve feign invoke failed: {}, {}",
56+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
5657
}
5758
}
5859

dongtai-core/src/main/java/io/dongtai/iast/core/handler/hookpoint/service/trace/HttpService.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private String addTraceToJavaNetURL(MethodEvent event) {
5757
} catch (IllegalStateException ignore) {
5858
} catch (Throwable e) {
5959
DongTaiLog.debug("add traceId header to java.net.URLConnection failed: {}, {}",
60-
e.getMessage(), e.getCause().getMessage());
60+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
6161
}
6262
return null;
6363
}
@@ -87,7 +87,7 @@ private String addTraceToApacheHttpClient(MethodEvent event) {
8787
return traceId;
8888
} catch (Throwable e) {
8989
DongTaiLog.debug("add traceId header to apache http client failed: {}, {}",
90-
e.getMessage(), e.getCause().getMessage());
90+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
9191
}
9292
return null;
9393
}
@@ -108,7 +108,7 @@ private String addTraceToApacheHttpClientLegacy(MethodEvent event) {
108108
return traceId;
109109
} catch (Throwable e) {
110110
DongTaiLog.debug("add traceId header to apache legacy http client failed: {}, {}",
111-
e.getMessage(), e.getCause().getMessage());
111+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
112112
}
113113
return null;
114114
}
@@ -141,7 +141,7 @@ private String addTraceToOkhttp(MethodEvent event) {
141141
return traceId;
142142
} catch (Throwable e) {
143143
DongTaiLog.debug("add traceId header to okhttp client failed: {}, {}",
144-
e.getMessage(), e.getCause().getMessage());
144+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
145145
}
146146
return null;
147147
}
@@ -191,7 +191,7 @@ public static boolean validateURLConnection(MethodEvent event) {
191191
}
192192
} catch (Throwable e) {
193193
DongTaiLog.debug("validate URLConnection failed: {}, {}",
194-
e.getMessage(), e.getCause().getMessage());
194+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
195195
}
196196
return false;
197197
}
@@ -220,7 +220,7 @@ public static boolean validateApacheHttpClient(MethodEvent event) {
220220
}
221221
} catch (Throwable e) {
222222
DongTaiLog.debug("validate apache http client failed: {}, {}",
223-
e.getMessage(), e.getCause().getMessage());
223+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
224224
}
225225
return false;
226226
}
@@ -245,7 +245,8 @@ public static boolean validateOkhttp(MethodEvent event) {
245245
return true;
246246
}
247247
} catch (Throwable e) {
248-
DongTaiLog.debug("validate okhttp failed: {}, {}", e.getMessage(), e.getCause().getMessage());
248+
DongTaiLog.debug("validate okhttp failed: {}, {}",
249+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
249250
}
250251
return false;
251252
}

dongtai-core/src/main/java/io/dongtai/iast/core/handler/hookpoint/vulscan/dynamic/FastjsonCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public boolean isSafe(MethodEvent event, SinkNode sinkNode) {
5757
return isSafeMode != null && (Boolean) isSafeMode;
5858
} catch (Throwable e) {
5959
DongTaiLog.debug("fastjson version and safe mode check failed: {}, {}",
60-
e.getMessage(), e.getCause().getMessage());
60+
e.getMessage(), e.getCause() != null ? e.getCause().getMessage() : "");
6161
return true;
6262
}
6363
}

0 commit comments

Comments
 (0)