Skip to content

Commit

Permalink
add some java rule verified
Browse files Browse the repository at this point in the history
  • Loading branch information
v1ll4n committed Aug 20, 2024
1 parent b9ab9ba commit 6cadbc7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions java-verified-rules/java-spring-resource-handler-location.sf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
desc(
title: "Checking [Resource Handler Location] in Spring",
type: audit,
level: low,
)

addResourceHandlers(*?{<typeName>?{have: ResourceHandlerRegistry,springframework}} as $params);
check $params;

$params.addResourceHandler(*<slice(start=1)> as $results);
$results ?{have: 'swagger'} as $swaggerVariable;
alert $swaggerVariable for "Swagger Resource Handler Location";
alert $params;

desc(
lang: java,

'file://a.java': <<<TEXT
package com.ruoyi.common.swagger.config;

import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* swagger 资源映射路径
*/
public class SwaggerWebConfiguration implements WebMvcConfigurer
{
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
/** swagger-ui 地址 */
registry.addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
}
}
TEXT
)
1 change: 1 addition & 0 deletions java-verified-rules/java-springfox-awared.sf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ check $config
alert $config;

desc(
lang: java,
'file://config.java': <<<TEXT
package com.ruoyi.common.swagger.config;

Expand Down

0 comments on commit 6cadbc7

Please sign in to comment.