我使用restTemplate
在微服务架构中进行同步服务间通信。
当我们完成Veracode
扫描时,我们得到的是getForEntity
方法中的Server-Side Request Forgery (SSRF) (CWE ID 918)
。
restTemplate.getForEntity(URL, Entity.class);
不确定我为什么会收到这个SSRF
问题
对此可能的解决方案是什么?
我已经解决了这个问题,在restTemplate中使用UriComponents之前,先构建URL。
UriComponents uriComponents = UriComponentsBuilder.newInstance()
.scheme("http").host("www.yourdomain.com").path("/yourPath").build();
请参阅此链接以使用UriComponentshttps://www.baeldung.com/spring-uricomponentsbuilder