Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
kim.hanjie.common:common-xss
Advanced tools
req通过getParameter、getParameterValues获取值,json形式body,转成对象时,xss过滤
req通过getParameter、getParameterValues获取值,json形式body,转成对象时,xss过滤
使用StringEscapeUtils中的escapeHtml4来转换html的特殊字符,防止xss攻击
<dependency>
<groupId>kim.hanjie.common</groupId>
<artifactId>common-xss</artifactId>
<version>1.0.0</version>
</dependency>
@Configuration
public class FilterConfiguration {
@Bean
public FilterRegistrationBean<XssFilter> xssFilterFilterRegistration() {
FilterRegistrationBean<XssFilter> registration = new FilterRegistrationBean<>();
registration.setFilter(new XssFilter());
registration.addUrlPatterns("/*");
registration.setName("xssFilter");
return registration;
}
}
@Configuration
public class JacksonConvertersConfiguration {
@Bean
@Primary
ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
Jackson2ObjectMapperBuilder xmlMapper = builder.createXmlMapper(false);
xmlMapper.serializationInclusion(JsonInclude.Include.NON_NULL);
// 设置 String的deserializer Type为XssStringJsonDeserializer
builder.deserializerByType(String.class, new XssStringJsonDeserializer());
return xmlMapper.build();
}
}
对于一些不需要xss处理的文本,如果富文本内容,则可以使用StringEscapeUtils.unescapeHtml4转回来
对于向富文本这种,可以通过Jsoup.clean()方法来获取安全的富文本内容
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
FAQs
req通过getParameter、getParameterValues获取值,json形式body,转成对象时,xss过滤
We found that kim.hanjie.common:common-xss demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.