Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fuzzBackEnd
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钱炳权
fuzzBackEnd
Commits
41283d5e
Commit
41283d5e
authored
May 13, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kitty测试结果持久化完成
parent
00d5206b
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
280 additions
and
21 deletions
+280
-21
pom.xml
fuzzIntegration/pom.xml
+6
-0
AflnetProperties.java
.../java/com/example/fuzzControll/conf/AflnetProperties.java
+11
-2
IntegrationPathProperties.java
.../example/fuzzControll/conf/IntegrationPathProperties.java
+2
-2
AflnetDataController.java
...troll/controller/dataController/AflnetDataController.java
+15
-0
KittyDataController.java
...ntroll/controller/dataController/KittyDataController.java
+34
-0
AflnetMapper.java
...in/java/com/example/fuzzControll/mapper/AflnetMapper.java
+21
-0
KittyMapper.java
...ain/java/com/example/fuzzControll/mapper/KittyMapper.java
+5
-1
AflnetResult.java
...n/java/com/example/fuzzControll/pojo/vo/AflnetResult.java
+20
-0
KittyResult.java
...in/java/com/example/fuzzControll/pojo/vo/KittyResult.java
+10
-0
AflnetPersistenceService.java
...xample/fuzzControll/service/AflnetPersistenceService.java
+7
-0
FuzzPersistenceService.java
.../example/fuzzControll/service/FuzzPersistenceService.java
+10
-0
AflnetPersistenceServiceImpl.java
...zzControll/service/impl/AflnetPersistenceServiceImpl.java
+23
-0
FuzzPersistenceServiceImpl.java
...fuzzControll/service/impl/FuzzPersistenceServiceImpl.java
+21
-0
TestServiceImpl.java
...om/example/fuzzControll/service/impl/TestServiceImpl.java
+1
-1
CmdTools.java
...rc/main/java/com/example/fuzzControll/tools/CmdTools.java
+23
-4
FileTools.java
...c/main/java/com/example/fuzzControll/tools/FileTools.java
+25
-6
SqlTools.java
...rc/main/java/com/example/fuzzControll/tools/SqlTools.java
+14
-0
application-dev.yml
fuzzIntegration/src/main/resources/application-dev.yml
+3
-3
AflnetMapper.xml
fuzzIntegration/src/main/resources/mapper/AflnetMapper.xml
+23
-0
KittyMapper.xml
fuzzIntegration/src/main/resources/mapper/KittyMapper.xml
+6
-2
No files found.
fuzzIntegration/pom.xml
View file @
41283d5e
...
...
@@ -113,6 +113,12 @@
<artifactId>
mysql-connector-java
</artifactId>
<scope>
runtime
</scope>
</dependency>
<!--PageHelper-->
<dependency>
<groupId>
com.github.pagehelper
</groupId>
<artifactId>
pagehelper-spring-boot-starter
</artifactId>
<version>
1.4.6
</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/conf/
Seed
Properties.java
→
fuzzIntegration/src/main/java/com/example/fuzzControll/conf/
Aflnet
Properties.java
View file @
41283d5e
...
...
@@ -4,9 +4,18 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import
org.springframework.stereotype.Component
;
@Component
(
"seedProperties"
)
@ConfigurationProperties
(
prefix
=
"
filepath
"
)
public
class
Seed
Properties
{
@ConfigurationProperties
(
prefix
=
"
aflnet
"
)
public
class
Aflnet
Properties
{
String
seedPath
;
String
outputPath
;
public
String
getOutputPath
()
{
return
outputPath
;
}
public
void
setOutputPath
(
String
outputPath
)
{
this
.
outputPath
=
outputPath
;
}
public
String
getSeedPath
()
{
return
seedPath
;
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/conf/PathProperties.java
→
fuzzIntegration/src/main/java/com/example/fuzzControll/conf/
Integration
PathProperties.java
View file @
41283d5e
...
...
@@ -4,8 +4,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import
org.springframework.stereotype.Component
;
@Component
(
"PathProperties"
)
@ConfigurationProperties
(
prefix
=
"path"
)
public
class
PathProperties
{
@ConfigurationProperties
(
prefix
=
"
integration
path"
)
public
class
Integration
PathProperties
{
String
webSocketUri
;
public
String
getWebSocketUri
()
{
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/dataController/AflnetDataController.java
0 → 100644
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
controller
.
dataController
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/aflnet"
)
@Slf4j
public
class
AflnetDataController
{
@Autowired
AflnetPersistenceService
aflnetPersistenceService
;
}
fuzzIntegration/src/main/java/com/example/fuzzControll/controller/dataController/KittyDataController.java
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
controller
.
dataController
;
import
com.example.fuzzControll.exception.CmdException
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.service.FuzzPersistenceService
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/kittyServer"
)
@Slf4j
public
class
KittyDataController
{
@Autowired
FuzzPersistenceService
fuzzPersistenceService
;
/**
* 查询kitty结果
*/
@RequestMapping
(
value
=
"/KittyResultSelect"
,
method
=
RequestMethod
.
GET
)
public
AjaxResult
KittyResultSelect
(
){
List
<
KittyResult
>
results
;
try
{
results
=
fuzzPersistenceService
.
getKittyResults
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
AjaxResult
.
error
();
}
return
AjaxResult
.
success
(
results
);
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/mapper/AflnetMapper.java
0 → 100644
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
mapper
;
import
com.example.fuzzControll.pojo.vo.AflnetResult
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Mapper
@Component
(
"AflnetMapper"
)
public
interface
AflnetMapper
{
/**
* 查询kitty模糊测试结果
*/
// List<KittyResult> getKittyResults();
/**
* 存储alfnet测试结果
*/
void
aflnetOutputBackup
(
AflnetResult
aflnetResult
);
}
fuzzIntegration/src/main/java/com/example/fuzzControll/mapper/KittyMapper.java
View file @
41283d5e
...
...
@@ -4,15 +4,19 @@ package com.example.fuzzControll.mapper;
import
com.example.fuzzControll.pojo.vo.KittyLog
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Mapper
@Component
(
"KittyMapper"
)
public
interface
KittyMapper
{
/**
* 查询kitty模糊测试结果
*/
List
<
KittyResult
>
selectAll
();
List
<
KittyResult
>
getKittyResults
();
void
kittyResultsBackup
(
KittyResult
kittyResult
);
/**
* 查询kitty日志
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/pojo/vo/AflnetResult.java
0 → 100644
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
pojo
.
vo
;
import
lombok.Data
;
@Data
public
class
AflnetResult
{
private
int
id
;
private
int
missionId
;
private
byte
[]
file
;
private
String
fileName
;
public
AflnetResult
(
int
missionId
,
byte
[]
file
,
String
fileName
)
{
this
.
missionId
=
missionId
;
this
.
file
=
file
;
this
.
fileName
=
fileName
;
}
public
AflnetResult
()
{
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/pojo/vo/KittyResult.java
View file @
41283d5e
...
...
@@ -5,6 +5,16 @@ import lombok.Data;
@Data
public
class
KittyResult
{
private
int
id
;
private
int
missionId
;
private
String
resultOut
;
private
String
resultError
;
public
KittyResult
()
{
}
public
KittyResult
(
int
missionId
,
String
resultOut
,
String
resultError
)
{
this
.
missionId
=
missionId
;
this
.
resultOut
=
resultOut
;
this
.
resultError
=
resultError
;
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/AflnetPersistenceService.java
0 → 100644
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
service
;
import
com.example.fuzzControll.pojo.vo.AflnetResult
;
public
interface
AflnetPersistenceService
{
public
void
aflnetResultBackup
(
String
filename
);
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/FuzzPersistenceService.java
0 → 100644
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
service
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
java.util.List
;
public
interface
FuzzPersistenceService
{
List
<
KittyResult
>
getKittyResults
();
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/AflnetPersistenceServiceImpl.java
0 → 100644
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.mapper.AflnetMapper
;
import
com.example.fuzzControll.pojo.vo.AflnetResult
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
com.example.fuzzControll.tools.FileTools
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
@Slf4j
public
class
AflnetPersistenceServiceImpl
implements
AflnetPersistenceService
{
@Autowired
AflnetMapper
AflnetMapper
;
FileTools
fileTools
=
new
FileTools
();
@Override
public
void
aflnetResultBackup
(
String
filename
)
{
//todo 需要传入任务id
AflnetResult
result
=
new
AflnetResult
(
1
,
fileTools
.
fileReadAndBackup
(
filename
),
filename
);
AflnetMapper
.
aflnetOutputBackup
(
result
);
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/FuzzPersistenceServiceImpl.java
0 → 100644
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
service
.
impl
;
import
com.example.fuzzControll.mapper.KittyMapper
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.service.FuzzPersistenceService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
@Slf4j
public
class
FuzzPersistenceServiceImpl
implements
FuzzPersistenceService
{
@Autowired
KittyMapper
kittyMapper
;
@Override
public
List
<
KittyResult
>
getKittyResults
()
{
return
kittyMapper
.
getKittyResults
();
}
}
fuzzIntegration/src/main/java/com/example/fuzzControll/service/impl/TestServiceImpl.java
View file @
41283d5e
...
...
@@ -34,7 +34,7 @@ public class TestServiceImpl implements TestService {
String
outputPathName
=
df
.
format
(
date
)+
cmdStartParams
.
getProtopcol
()+
"-output"
;
String
finalCmd
=
CmdConstent
.
RUN_AFLNET_BEFORE
+
outputPathName
+
CmdConstent
.
RUN_AFLNET_AFTER
+
cmd
+
kittyProperties
.
getAflnetPath
()
+
"live555/testProgs/testOnDemandRTSPServer 8554"
;
log
.
info
(
"The cmd is [{}]"
,
finalCmd
);
cmdTools
.
runProgramCmd
(
finalCmd
);
cmdTools
.
runProgramCmd
(
finalCmd
,
outputPathName
);
}
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/CmdTools.java
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
tools
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.fuzzControll.conf.SpringContextUtil
;
import
com.example.fuzzControll.exception.AflnetException
;
import
com.example.fuzzControll.exception.CmdException
;
import
com.example.fuzzControll.mapper.KittyMapper
;
import
com.example.fuzzControll.pojo.vo.CmdStartParams
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
import
com.example.fuzzControll.pojo.vo.TestReturnEntity
;
import
com.example.fuzzControll.service.AflnetPersistenceService
;
import
com.example.fuzzControll.service.impl.websocketClientServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.swing.*
;
import
java.io.*
;
import
java.util.*
;
...
...
@@ -20,7 +25,8 @@ public class CmdTools {
Boolean
show
=
true
;
SqlTools
sqlTools
=
new
SqlTools
();
AflnetPersistenceService
AflnetPersistenceService
=
(
AflnetPersistenceService
)
SpringContextUtil
.
getBean
(
"AflnetPersistenceService"
);
/**
* 运行不需要后台运行cmd
*/
...
...
@@ -44,12 +50,13 @@ public class CmdTools {
* 运行需要后台运行cmd
* 通过websocket返回数据
*/
public
void
runProgramCmd
(
String
cmd
)
throws
AflnetException
{
public
void
runProgramCmd
(
String
cmd
,
String
outputPathName
)
throws
AflnetException
{
try
{
Process
process
=
Runtime
.
getRuntime
().
exec
(
cmd
);
printMessageToWeb
(
process
.
getInputStream
());
printMessage
(
process
.
getErrorStream
(),
new
ArrayList
<
String
>());
process
.
waitFor
();
AflnetPersistenceService
.
aflnetResultBackup
(
outputPathName
);
log
.
info
(
"Aflnet cmd have been run."
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -70,12 +77,22 @@ public class CmdTools {
printMessageByProgramCmd
(
process
.
getInputStream
(),
out
);
printMessageByProgramCmd
(
process
.
getErrorStream
(),
error
);
process
.
waitFor
();
//todo 对于无法运行和数据较长的还需要观察
try
{
KittyResult
kittyResult
=
new
KittyResult
(
1
,
out
.
toString
(),
error
.
toString
());
sqlTools
.
kittyBackup
(
kittyResult
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"kitty backup error!"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
CmdException
(
"run fuzz error !"
);
}
result
.
put
(
"out"
,
out
);
result
.
put
(
"error"
,
error
);
//todo 需要传入任务参数,后期再开发
return
result
;
}
...
...
@@ -237,11 +254,13 @@ public class CmdTools {
public
String
parse
(
CmdStartParams
cmdStartParams
)
throws
AflnetException
{
if
(
cmdStartParams
==
null
)
{
throw
new
AflnetException
(
"CmdStartParams is null!"
);
throw
new
AflnetException
(
"CmdStartParams is null
!"
);
}
StringBuilder
cmd
=
new
StringBuilder
();
if
(
cmdStartParams
.
getNetinfo
()
!=
""
)
{
if
(
cmdStartParams
.
getNetinfo
()
!=
""
&&
cmdStartParams
.
getNetinfo
()
!=
null
)
{
cmd
.
append
(
" -N "
+
cmdStartParams
.
getNetinfo
());
}
else
{
throw
new
AflnetException
(
"There is no netinfo !"
);
}
if
(
cmdStartParams
.
getProtopcol
()
!=
""
)
{
cmd
.
append
(
" -P "
+
cmdStartParams
.
getProtopcol
());
...
...
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/FileTools.java
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
tools
;
import
com.example.fuzzControll.conf.AflnetProperties
;
import
com.example.fuzzControll.conf.SpringContextUtil
;
import
com.example.fuzzControll.conf.SeedProperties
;
import
com.example.fuzzControll.exception.FileException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.io.*
;
@Slf4j
public
class
FileTools
{
SeedProperties
properties
=
(
SeedProperties
)
SpringContextUtil
.
getBean
(
"seed
Properties"
);
AflnetProperties
properties
=
(
AflnetProperties
)
SpringContextUtil
.
getBean
(
"Aflnet
Properties"
);
public
void
load
(
MultipartFile
file
)
throws
FileException
{
if
(
file
==
null
)
{
...
...
@@ -34,4 +31,25 @@ public class FileTools {
}
}
public
byte
[]
fileReadAndBackup
(
String
filename
)
{
File
file
=
new
File
(
properties
.
getOutputPath
()
+
"/"
+
filename
);
try
(
FileInputStream
inputStream
=
new
FileInputStream
(
file
);
BufferedInputStream
bufferedInputStream
=
new
BufferedInputStream
(
inputStream
);)
{
if
(
file
.
length
()
>
Integer
.
MAX_VALUE
)
{
throw
new
IOException
();
}
byte
[]
buffer
=
new
byte
[(
int
)
file
.
length
()];
int
bytesRead
;
while
((
bytesRead
=
bufferedInputStream
.
read
(
buffer
))
!=
-
1
)
{
bufferedInputStream
.
read
(
buffer
,
0
,
bytesRead
);
}
return
buffer
;
}
catch
(
FileNotFoundException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"File is to large "
+
file
.
getName
());
}
}
}
\ No newline at end of file
fuzzIntegration/src/main/java/com/example/fuzzControll/tools/SqlTools.java
0 → 100644
View file @
41283d5e
package
com
.
example
.
fuzzControll
.
tools
;
import
com.example.fuzzControll.conf.KittyProperties
;
import
com.example.fuzzControll.conf.SpringContextUtil
;
import
com.example.fuzzControll.mapper.KittyMapper
;
import
com.example.fuzzControll.pojo.vo.KittyResult
;
public
class
SqlTools
{
KittyMapper
kittyMapper
=
(
KittyMapper
)
SpringContextUtil
.
getBean
(
"KittyMapper"
);
public
void
kittyBackup
(
KittyResult
kittyResult
)
{
kittyMapper
.
kittyResultsBackup
(
kittyResult
);
}
}
fuzzIntegration/src/main/resources/application-dev.yml
View file @
41283d5e
...
...
@@ -19,9 +19,9 @@ logging:
rollingPolicy
:
max-file-size
:
10MB
filepath
:
aflnet
:
seedPath
:
"
/usr/fuzzenv/fuzzenv/aflnet/tutorials/live555/in-rtsp"
outputPath
:
"
D:/code/companyProjects/files"
#D:/code/companyProjects/files
kitty
:
aflnetPath
:
"
/usr/fuzzenv/fuzzenv/"
#alfnet路径
outputPath
:
"
/home/"
#alfnet输出路径
...
...
@@ -44,7 +44,7 @@ spring:
username
:
root
password
:
123456
driver-class-name
:
com.mysql.cj.jdbc.Driver
path
:
integration
path
:
webSocketUri
:
ws://${fuzzmaster-docker.ip}:8101/websocket/testResult/
nacos-docker
:
...
...
fuzzIntegration/src/main/resources/mapper/AflnetMapper.xml
0 → 100644
View file @
41283d5e
<?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.example.fuzzControll.mapper.AflnetMapper"
>
<resultMap
type=
"com.example.fuzzControll.pojo.vo.AflnetResult"
id=
"AflnetResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"missionId"
column=
"missionId"
/>
<result
property=
"file"
column=
"file"
/>
<result
property=
"fileName"
column=
"fileName"
/>
</resultMap>
<sql
id=
"selectKittyResult"
>
select id, missionId,file, fileName from kittyResult;
</sql>
<insert
id=
"aflnetOutputBackup"
>
insert into alfnetResult(id,missionId, file, fileName) values(#{id}, #{missionId},#{file}, #{fileName})
</insert>
</mapper>
\ No newline at end of file
fuzzIntegration/src/main/resources/mapper/KittyMapper.xml
View file @
41283d5e
...
...
@@ -6,15 +6,19 @@
<resultMap
type=
"com.example.fuzzControll.pojo.vo.KittyResult"
id=
"KittyResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"missionId"
column=
"missionId"
/>
<result
property=
"resultOut"
column=
"resultOut"
/>
<result
property=
"resultError"
column=
"resultError"
/>
</resultMap>
<sql
id=
"selectKittyResult"
>
select id, resultOut, resultError from kittyResult;
select id,
missionId,
resultOut, resultError from kittyResult;
</sql>
<insert
id=
"kittyResultsBackup"
>
insert into kittyResult(id,missionId, resultOut, resultError) values(#{id}, #{missionId},#{resultOut}, #{resultError})
</insert>
<select
id=
"
selectAll
"
resultMap=
"KittyResult"
>
<select
id=
"
getKittyResults
"
resultMap=
"KittyResult"
>
<include
refid=
"selectKittyResult"
/>
</select>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment