Skip to content

Commit

Permalink
修复静态代码扫描问题
Browse files Browse the repository at this point in the history
  • Loading branch information
neilyhe committed Jan 20, 2025
1 parent e49b03f commit 6e8a596
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
5 changes: 3 additions & 2 deletions explorer/device-android-demo/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ char sg_cse_test_pic_path[256];

static void *thd_fn(void *arg) {
pthread_detach(pthread_self());
char *args[8] = {NULL, sg_dev_path, sg_flv_path, sg_cs_recv_talk_path, sg_cs_aac_path, sg_cs_video_path,sg_cse_srcipt_path,sg_cse_test_pic_path};
char *args[8] = {NULL, sg_dev_path, sg_flv_path, sg_cs_recv_talk_path, sg_cs_aac_path,
sg_cs_video_path, sg_cse_srcipt_path, sg_cse_test_pic_path};
iot_video_main(8, args);
}

extern "C" JNIEXPORT jstring JNICALL
Java_com_tencent_iot_explorer_device_video_push_1stream_PushStreamActivity_nativeDemo(
JNIEnv* env,
JNIEnv *env,
jobject /* this */,
jstring dir) {
const char *dir_path = env->GetStringUTFChars(dir, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class StringRequest private constructor() {
isSuccess = (process.waitFor() == 0)
} catch (e: Exception) {
isSuccess = false
e.printStackTrace()
TXLog.d(TAG, e.message)
process?.destroy()
} finally {
process?.destroy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.tencent.iot.explorer.device.android.http.retrofit.adapter

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import retrofit2.Call
import retrofit2.CallAdapter
import retrofit2.Retrofit
import java.lang.reflect.Type
import retrofit2.Call
import java.lang.Exception


class StringCallAdapterFactory private constructor() : CallAdapter.Factory() {

private val LOG: Logger = LoggerFactory.getLogger(StringCallAdapterFactory::class.java)

override fun get(
type: Type?,
array: Array<out Annotation>?,
Expand All @@ -23,7 +27,7 @@ class StringCallAdapterFactory private constructor() : CallAdapter.Factory() {
try {
return call.execute().body().toString()
} catch (e: Exception) {
e.printStackTrace()
LOG.error(e.message)
}
return ""
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.tencent.iot.explorer.device.central.message.payload

import com.alibaba.fastjson.JSON
import org.slf4j.Logger
import org.slf4j.LoggerFactory

class Payload {

private val LOG: Logger = LoggerFactory.getLogger(Payload::class.java)

//设备监听到下发的数据字符串
var json = ""

Expand All @@ -26,7 +30,7 @@ class Payload {
try {
return JSON.parseObject(data)?.keys
} catch (e: Exception) {
e.printStackTrace()
LOG.error(e.message)
}
return null
}
Expand All @@ -42,7 +46,7 @@ class Payload {
}
}
} catch (e: Exception) {
e.printStackTrace()
LOG.error(e.message)
}
return "0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import org.eclipse.paho.client.mqttv3.MqttClientPersistence;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttMessage;

import java.security.SecureRandom;
import java.util.HashMap;
import java.util.List;
import java.util.Random;

/**
* 影子连接类
Expand Down Expand Up @@ -139,7 +140,7 @@ public TXShadowConnection(Context context, String serverURI, String productID, S
OPERATION_TOPIC = "$shadow/operation/" + productID + "/" + mMqttConnection.mDeviceName;
OPERATION_RESULT_TOPIC = "$shadow/operation/result/" + productID + "/" + mMqttConnection.mDeviceName;

mPublishMessageId = new Random().nextInt(MAX_MESSAGE_ID);
mPublishMessageId = new SecureRandom().nextInt(MAX_MESSAGE_ID);

mTXShadowConn.setMqttConnection(mMqttConnection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.security.spec.KeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPrivateCrtKeySpec;
import java.util.Random;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
Expand All @@ -39,7 +38,7 @@ public class AsymcSslUtils {
*/
public static final String TAG = "iot.AsymcSslUtils";

private static String PASSWORD = String.valueOf(new Random(System.currentTimeMillis()).nextInt());
private static String PASSWORD = String.valueOf(new SecureRandom().nextInt());

/**
* 证书文件及 Key文件存放在 Android asset 目录下,通过 AssetManager 读取文件内容获取输入流,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;

/**
Expand Down Expand Up @@ -148,7 +148,7 @@ public TXShadowConnection(String serverURI, String productID, String deviceName,
OPERATION_TOPIC = "$shadow/operation/" + productID + "/" + mMqttConnection.mDeviceName;
OPERATION_RESULT_TOPIC = "$shadow/operation/result/" + productID + "/" + mMqttConnection.mDeviceName;

mPublishMessageId = new Random().nextInt(MAX_MESSAGE_ID);
mPublishMessageId = new SecureRandom().nextInt(MAX_MESSAGE_ID);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.SecureRandom;
import java.security.Security;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
Expand All @@ -27,7 +28,6 @@
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPrivateCrtKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Random;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -56,7 +56,7 @@ public class AsymcSslUtils {
private static final String TAG = AsymcSslUtils.class.getName();
private static final Logger logger = LoggerFactory.getLogger(AsymcSslUtils.class);
static { Loggor.setLogger(logger); }
private static String PASSWORD = String.valueOf(new Random(System.currentTimeMillis()).nextInt());
private static String PASSWORD = String.valueOf(new SecureRandom().nextInt());

/**
* 读取 resouce 文件证书文件及 Key 文件存放在 Android asset 目录
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.KeyStore;
import java.security.SecureRandom;
import java.security.Security;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Random;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
Expand All @@ -34,7 +34,7 @@ public class SymcSslUtils {
private static final Logger logger = LoggerFactory.getLogger(SymcSslUtils.class);
static { Loggor.setLogger(logger); }

private static String PASSWORD = String.valueOf(new Random(System.currentTimeMillis()).nextInt());
private static String PASSWORD = String.valueOf(new SecureRandom().nextInt());

/**
* 获取 socket SSL
Expand Down

0 comments on commit 6e8a596

Please sign in to comment.