Browse Source

1, 为新增的最后拍照日期设计加入防御性代码,避免恶意修改和攻击, 导致一直无法拍照的情况出现; 2, 变更打包脚本版本为v2.0.0.5

niujiuru 2 months ago
parent
commit
4050291f5b
2 changed files with 8 additions and 1 deletions
  1. 1 1
      package/armv7hf.sh
  2. 7 0
      reporter/takephoto.go

+ 1 - 1
package/armv7hf.sh

@@ -4,7 +4,7 @@
 set -e
 set -e
 set -o pipefail
 set -o pipefail
 
 
-ver_num="2.0.0.4"
+ver_num="2.0.0.5"
 cur_dir="$(pwd)"
 cur_dir="$(pwd)"
 pre_dir="$(dirname "$cur_dir")"
 pre_dir="$(dirname "$cur_dir")"
 RTU_LINUX_MODULES_PATH="${pre_dir}/../rtu_linux_modules"
 RTU_LINUX_MODULES_PATH="${pre_dir}/../rtu_linux_modules"

+ 7 - 0
reporter/takephoto.go

@@ -53,6 +53,13 @@ func canTakePhoto() bool {
 
 
 	now := time.Now()
 	now := time.Now()
 	today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
 	today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
+
+	if lastDate.After(today) {
+		baseapp.Logger.Warnf("[%s] 最后拍照日期异常: %s, 晚于当前日期, 忽略该日期并执行拍照",
+			MODULE_NAME, lastDate.Format("2006-01-02"))
+		return true
+	}
+
 	days := int(today.Sub(lastDate).Hours() / 24)
 	days := int(today.Sub(lastDate).Hours() / 24)
 	if days < mcu.CfgParams.TakePhotoIntervalDays {
 	if days < mcu.CfgParams.TakePhotoIntervalDays {
 		baseapp.Logger.Infof("[%s] 未达到拍照间隔天数要求, 上次拍照日期: %s, 已间隔: %d天, 间隔要求: %d天, 忽略本次拍照请求",
 		baseapp.Logger.Infof("[%s] 未达到拍照间隔天数要求, 上次拍照日期: %s, 已间隔: %d天, 间隔要求: %d天, 忽略本次拍照请求",