parent
acb892fc5d
commit
70a77aabd7
@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.pc.crawl</groupId>
|
||||
<artifactId>vul_repo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>vul_repo</name>
|
||||
<description>vul_repo</description>
|
||||
<properties>
|
||||
<java.version>8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!--mysql驱动包-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.28</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<!--druid依赖添加-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- easyexcel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>2.1.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<verbose>false</verbose>
|
||||
<fork>true</fork>
|
||||
<compilerVersion>1.8</compilerVersion>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<optimize>false</optimize>
|
||||
<encoding>UTF8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!--跳过测试 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,15 @@
|
||||
package com.pc.crawl.vul_repo;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@MapperScan("com.pc.crawl.vul_repo.mapper")
|
||||
@SpringBootApplication
|
||||
public class VulRepoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(VulRepoApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.pc.crawl.vul_repo.controller;
|
||||
|
||||
|
||||
import com.pc.crawl.vul_repo.service.VulnerabilityRepoService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* 漏洞库文件 前端控制器
|
||||
*
|
||||
* @author jshixiong
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/vulnerability/repo")
|
||||
public class VulnerabilityRepoController {
|
||||
|
||||
@Autowired
|
||||
private VulnerabilityRepoService vulnerabilityRepoService;
|
||||
|
||||
@GetMapping("/update")
|
||||
public void updateRepo(){
|
||||
new Thread(() -> {
|
||||
vulnerabilityRepoService.updateRepoFile();
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 漏洞库文件
|
||||
*
|
||||
*/
|
||||
@GetMapping("/file")
|
||||
public void vulnerabilityRepoFile(HttpServletResponse response){
|
||||
String content = vulnerabilityRepoService.getRepoFile();
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition","attachment;filename=repoFile.json");
|
||||
|
||||
int len;
|
||||
byte[] buffer = new byte[1024];
|
||||
try (InputStream in = new ByteArrayInputStream(content.getBytes());
|
||||
BufferedInputStream bis = new BufferedInputStream(in);
|
||||
OutputStream out = response.getOutputStream()) {
|
||||
while ((len = bis.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
out.flush();
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
package com.pc.crawl.vul_repo.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author jshixiong
|
||||
*/
|
||||
@Data
|
||||
public class VulnerabilityRepoDTO {
|
||||
|
||||
/**
|
||||
* 自定义id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 组件厂商
|
||||
*/
|
||||
private String vendor;
|
||||
|
||||
/**
|
||||
*组件名
|
||||
*/
|
||||
private String product;
|
||||
|
||||
/**
|
||||
*漏洞影响版本
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
*组件语言
|
||||
*/
|
||||
private String language;
|
||||
/**
|
||||
*漏洞名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
*cve编号
|
||||
*/
|
||||
private String cve_id;
|
||||
/**
|
||||
*cnnvd编号
|
||||
*/
|
||||
private String cnnvd_id;
|
||||
/**
|
||||
*cnvd编号
|
||||
*/
|
||||
private String cnvd_id;
|
||||
/**
|
||||
*cwe编号
|
||||
*/
|
||||
private String cwe_id;
|
||||
/**
|
||||
*漏洞描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
*漏洞英文描述
|
||||
*/
|
||||
private String description_en;
|
||||
/**
|
||||
*漏洞修复建议
|
||||
*/
|
||||
private String suggestion;
|
||||
/**
|
||||
*攻击方式
|
||||
*/
|
||||
private String attack_type;
|
||||
/**
|
||||
*漏洞发布日期
|
||||
*/
|
||||
private String release_date;
|
||||
/**
|
||||
*漏洞风险评级(1~4 风险程度递减)
|
||||
*/
|
||||
private Integer security_level_id;
|
||||
/**
|
||||
*漏洞利用评级(0:不可利用,1:可利用)
|
||||
*/
|
||||
private Integer exploit_level_id;
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.pc.crawl.vul_repo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 漏洞库文件
|
||||
* </p>
|
||||
*
|
||||
* @author jshixiong
|
||||
* @since 2023-03-21
|
||||
*/
|
||||
@Data
|
||||
@TableName("vulnerability_repo")
|
||||
public class VulnerabilityRepo {
|
||||
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 自定义id
|
||||
*/
|
||||
private String xmirrorId;
|
||||
/**
|
||||
* 组件厂商
|
||||
*/
|
||||
private String vendor;
|
||||
|
||||
/**
|
||||
*组件名
|
||||
*/
|
||||
private String product;
|
||||
|
||||
/**
|
||||
*漏洞影响版本
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
*组件语言
|
||||
*/
|
||||
private String language;
|
||||
/**
|
||||
*漏洞名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
*cve编号
|
||||
*/
|
||||
private String cveId;
|
||||
/**
|
||||
*cnnvd编号
|
||||
*/
|
||||
private String cnnvdId;
|
||||
/**
|
||||
*cnvd编号
|
||||
*/
|
||||
private String cnvdId;
|
||||
/**
|
||||
*cwe编号
|
||||
*/
|
||||
private String cweId;
|
||||
/**
|
||||
*漏洞描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
*漏洞英文描述
|
||||
*/
|
||||
private String descriptionEn;
|
||||
/**
|
||||
*漏洞修复建议
|
||||
*/
|
||||
private String suggestion;
|
||||
/**
|
||||
*攻击方式
|
||||
*/
|
||||
private String attackType;
|
||||
/**
|
||||
*漏洞发布日期
|
||||
*/
|
||||
private String releaseDate;
|
||||
/**
|
||||
*漏洞风险评级(1~4 风险程度递减)
|
||||
*/
|
||||
private Integer securityLevelId;
|
||||
/**
|
||||
*漏洞利用评级(0:不可利用,1:可利用)
|
||||
*/
|
||||
private Integer exploitLevelId;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.pc.crawl.vul_repo.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.pc.crawl.vul_repo.dto.VulnerabilityRepoDTO;
|
||||
import com.pc.crawl.vul_repo.entity.VulnerabilityRepo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 漏洞库文件 Mapper 接口
|
||||
*
|
||||
* @author jshixiong
|
||||
*/
|
||||
@Mapper
|
||||
public interface VulnerabilityRepoMapper extends BaseMapper<VulnerabilityRepo> {
|
||||
|
||||
List<VulnerabilityRepoDTO> getAll();
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.pc.crawl.vul_repo.utils.bean;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* shell执行结果
|
||||
*
|
||||
* @author 威少
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ShellResult {
|
||||
/**
|
||||
* 退出码
|
||||
*/
|
||||
private Integer exitStatus;
|
||||
/**
|
||||
* 实际输出
|
||||
*/
|
||||
private String out;
|
||||
|
||||
public enum ExitStatus {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS(0),
|
||||
/**
|
||||
* 超时
|
||||
*/
|
||||
TIMEOUT(124),
|
||||
/**
|
||||
* 默认失败
|
||||
*/
|
||||
FAIL(-1);
|
||||
|
||||
private int code;
|
||||
ExitStatus(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.pc.crawl.vul_repo.mapper.VulnerabilityRepoMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.pc.crawl.vul_repo.entity.VulnerabilityRepo">
|
||||
<id column="id" property="id"/>
|
||||
<result column="xmirror_id" property="xmirrorId" />
|
||||
<result column="vendor" property="vendor" />
|
||||
<result column="product" property="product" />
|
||||
<result column="version" property="version" />
|
||||
<result column="language" property="language" />
|
||||
<result column="name" property="name" />
|
||||
<result column="cve_id" property="cveId" />
|
||||
<result column="cnnvd_id" property="cnnvdId" />
|
||||
<result column="cnvd_id" property="cnvdId" />
|
||||
<result column="cwe_id" property="cweId" />
|
||||
<result column="description" property="description" />
|
||||
<result column="description_en" property="descriptionEn" />
|
||||
<result column="suggestion" property="suggestion" />
|
||||
<result column="attack_type" property="attackType" />
|
||||
<result column="release_date" property="releaseDate" />
|
||||
<result column="security_level_id" property="securityLevelId" />
|
||||
<result column="exploit_level_id" property="exploitLevelId" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, xmirror_id, vendor, product, version, language, name, cve_id, cnnvd_id, cnvd_id, cwe_id, description, description_en, suggestion, attack_type, release_date, security_level_id, exploit_level_id, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<select id="getAll" resultType="com.pc.crawl.vul_repo.dto.VulnerabilityRepoDTO">
|
||||
SELECT
|
||||
xmirror_id AS id,
|
||||
vendor, product, version, language, name, cve_id, cnnvd_id, cnvd_id, cwe_id, description, description_en, suggestion, attack_type, release_date, security_level_id, exploit_level_id
|
||||
FROM
|
||||
vulnerability_repo
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,13 @@
|
||||
package com.pc.crawl.vul_repo;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class VulRepoApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue