mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-06-29 13:37:49 +08:00
Compare commits
3 Commits
fcf998c10c
...
c0247cb762
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0247cb762 | ||
|
|
c73d6a1b27 | ||
|
|
c011389c3f |
@ -11,6 +11,7 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
|
|||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局异常处理
|
* 全局异常处理
|
||||||
@ -31,6 +32,17 @@ public class GlobalExceptionHandler {
|
|||||||
return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage());
|
return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认异常处理
|
||||||
|
* @param e 异常
|
||||||
|
* @return 统一返回结果
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(NoResourceFoundException.class)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
public WVPResult<String> exceptionHandler(NoResourceFoundException e) {
|
||||||
|
return WVPResult.fail(ErrorCode.ERROR404);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认异常处理
|
* 默认异常处理
|
||||||
* @param e 异常
|
* @param e 异常
|
||||||
|
|||||||
@ -205,6 +205,21 @@ public class SipUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Gb28181Sdp parseSDP(String sdpStr) throws SdpParseException {
|
public static Gb28181Sdp parseSDP(String sdpStr) throws SdpParseException {
|
||||||
|
|
||||||
|
// 校验:拦截空内容与注入攻击特征
|
||||||
|
if (sdpStr == null || sdpStr.trim().isEmpty()) {
|
||||||
|
throw new SdpParseException(0, 0, "SDP内容为空");
|
||||||
|
}
|
||||||
|
// 标准SDP每行格式固定为 "x=value",不存在SQL关键字;出现则视为注入攻击
|
||||||
|
String sdpUpper = sdpStr.toUpperCase();
|
||||||
|
if (sdpUpper.contains("' OR '") || sdpUpper.contains("' OR 1") || sdpUpper.contains(" OR 1=1")
|
||||||
|
|| sdpUpper.contains("--") || sdpUpper.contains("/*") || sdpUpper.contains("*/")
|
||||||
|
|| sdpUpper.contains("DROP ") || sdpUpper.contains("INSERT ") || sdpUpper.contains("UPDATE ")
|
||||||
|
|| sdpUpper.contains("DELETE ") || sdpUpper.contains("UNION ") || sdpUpper.contains("SELECT ")) {
|
||||||
|
log.error("[SDP注入攻击] 检测到非法SDP内容,已拒绝解析,内容长度: {}", sdpStr.length());
|
||||||
|
throw new SdpParseException(0, 0, "非法SDP内容");
|
||||||
|
}
|
||||||
|
//校验结束
|
||||||
|
|
||||||
// jainSip不支持y= f=字段, 移除以解析。
|
// jainSip不支持y= f=字段, 移除以解析。
|
||||||
int ssrcIndex = sdpStr.indexOf("y=");
|
int ssrcIndex = sdpStr.indexOf("y=");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user