mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-06-29 13:37:49 +08:00
Compare commits
4 Commits
c0247cb762
...
300d380ca5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
300d380ca5 | ||
|
|
41fd16e5d3 | ||
|
|
2877bde26a | ||
|
|
c011389c3f |
@ -11,6 +11,7 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
|
||||
/**
|
||||
@ -32,13 +33,24 @@ public class GlobalExceptionHandler {
|
||||
return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认异常处理
|
||||
* @param e 异常
|
||||
* @return 统一返回结果
|
||||
*/
|
||||
@ExceptionHandler(MaxUploadSizeExceededException.class)
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public WVPResult<String> exceptionHandler(MaxUploadSizeExceededException e) {
|
||||
return WVPResult.fail(ErrorCode.ERROR403.getCode(), "文件过大");
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认异常处理
|
||||
* @param e 异常
|
||||
* @return 统一返回结果
|
||||
*/
|
||||
@ExceptionHandler(NoResourceFoundException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public WVPResult<String> exceptionHandler(NoResourceFoundException e) {
|
||||
return WVPResult.fail(ErrorCode.ERROR404);
|
||||
}
|
||||
|
||||
@ -205,6 +205,21 @@ public class SipUtils {
|
||||
}
|
||||
|
||||
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=字段, 移除以解析。
|
||||
int ssrcIndex = sdpStr.indexOf("y=");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user