质量分配:添加@JsonProperty批注后,活页夹配置不安全(强化错误)

时间:2018-11-13 13:13:12

标签: spring-mvc fortify

我在强化分析中得到了质量分配:不安全的粘合剂配置

这是AuthorisationController.class

@Controller
public class AuthorisationController {

    @RequestMapping(value = "/authorisation_request", method = RequestMethod.POST,
                produces = MediaType.APPLICATION_JSON_VALUE)
        @ResponseBody
        public ResponseEntity<AuthorisationRequest> createAuthorisation(HttpServletRequest request,
                @RequestBody AuthorisationRequestInfo createAuthorisation) {
        //processing code
    }
}

这是AuthorisationRequestInfo.class,将在其上映射http请求参数。

import com.fasterxml.jackson.annotation.JsonProperty;

public class OrderAuthorisationRequestInfo {


private String hashValue;
private String expiryDateTime;
private Integer initiatingRolePlayerId;

@JsonProperty("feedbackURI")
private String feedbackUri;

/**
 * Gets the hash value.
 *
 * @return the hash value
 */
public String getHashValue() {
    return hashValue;
}

/**
 * Sets the hash value.
 *
 * @param hashValue the new hash value
 */
public void setHashValue(String hashValue) {
    this.hashValue = hashValue;
}

/**
 * Gets the expiry date time.
 *
 * @return the expiry date time
 */
public String getExpiryDateTime() {
    return expiryDateTime;
}

/**
 * Sets the expiry date time.
 *
 * @param expiryDateTime the new expiry date time
 */
public void setExpiryDateTime(String expiryDateTime) {
    this.expiryDateTime = expiryDateTime;
}

/**
 * Gets the initiating role player id.
 *
 * @return the initiating role player id
 */
public Integer getInitiatingRolePlayerId() {
    return initiatingRolePlayerId;
}

/**
 * Sets the initiating role player id.
 *
 * @param initiatingRolePlayerId the new initiating role player id
 */
public void setInitiatingRolePlayerId(Integer initiatingRolePlayerId) {
    this.initiatingRolePlayerId = initiatingRolePlayerId;
}

/**
 * Gets the feedback URI.
 *
 * @return the feedback URI
 */
public String getFeedbackUri() {
    return feedbackUri;
}

/**
 * Sets the feedback URI.
 *
 * @param feedbackUri the new feedback URI
 */
public void setFeedbackUri(String feedbackUri) {
    this.feedbackUri = feedbackUri;
}
}

有趣的是,我只是在feedbackUri列上添加@JsonProperty(“ feedbackURI”)批注后才开始出现此错误。

@InitBinder以前没有使用过,没有强化错误,请求中的所有参数都是必需的。

所有其他API都很好,并且不报告任何强化问题。只有此api和添加了@JsonProperty的另一个api开始显示此错误。

Fortify Issue Image

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

在您的情况下,您可以使用@JsonIgnoreProperties:

@JsonIgnoreProperties(ignoreUnknown = true)
public class OrderAuthorisationRequestInfo {