Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
I
inspect
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
912协同工作系统
项目监控管理工具
inspect
Commits
c5fff57b
提交
c5fff57b
authored
3月 03, 2020
作者:
马晨俊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mcj:update
上级
2c8edc5c
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
52 行增加
和
62 行删除
+52
-62
InspectController.java
...n/java/com/zjty/inspect/controller/InspectController.java
+21
-17
InspectService.java
src/main/java/com/zjty/inspect/service/InspectService.java
+1
-1
InspectServiceImpl.java
...ava/com/zjty/inspect/service/impl/InspectServiceImpl.java
+4
-6
AnalysisFile.java
src/main/java/com/zjty/inspect/utils/AnalysisFile.java
+25
-34
Inspector.java
src/main/java/com/zjty/inspect/utils/Inspector.java
+1
-4
没有找到文件。
src/main/java/com/zjty/inspect/controller/InspectController.java
浏览文件 @
c5fff57b
...
@@ -30,33 +30,37 @@ public class InspectController {
...
@@ -30,33 +30,37 @@ public class InspectController {
*/
*/
@PostMapping
(
"/path"
)
@PostMapping
(
"/path"
)
public
ResponseEntity
inspect
(
@RequestBody
InspectParameter
inspectParameter
,
MultipartFile
file
)
throws
IOException
{
public
ResponseEntity
inspect
(
@RequestBody
InspectParameter
inspectParameter
,
MultipartFile
file
)
throws
IOException
{
// File file1 = file.getResource().getFile();
File
file1
=
file
.
getResource
().
getFile
();
// if(file1.getName().endsWith("zip")){
if
(
file1
.
getName
().
endsWith
(
"zip"
)){
// FileUtil.unPackZip(file1,"", "./");
FileUtil
.
unPackZip
(
file1
,
""
,
"./"
);
// }else{
}
else
{
// FileUtil.unPackRar(file1, "./");
FileUtil
.
unPackRar
(
file1
,
"./"
);
// }
}
// String[] split = file1.getName().split("\\.");
String
[]
split
=
file1
.
getName
().
split
(
"\\."
);
// File file2 = new File("./"+split[0]);
File
file2
=
new
File
(
"./"
+
split
[
0
]);
// String path1 = file2.getPath();
String
path1
=
file2
.
getPath
();
File
file1
=
new
File
(
"/Users/mcj/IdeaProjects/inspect"
);
// File file1 = new File("/Users/mcj/IdeaProjects/inspect");
String
path1
=
file1
.
getPath
();
// String path1 = file1.getPath();
inspectService
.
inspect
(
inspectParameter
,
path1
);
inspectParameter
.
setPath
(
path1
);
inspectService
.
inspect
(
inspectParameter
);
return
ResponseEntity
.
ok
(
200
);
return
ResponseEntity
.
ok
(
200
);
}
}
/**
/**
* git下载代码进行评估
* git下载代码进行评估
* @param
path
* @param
inspectParameter 封装
* @return
* @return
*/
*/
@PostMapping
(
"/git"
)
@PostMapping
(
"/git"
)
public
ResponseEntity
inspect1
(
@RequestBody
InspectParameter
inspectParameter
,
String
path
){
public
ResponseEntity
inspect1
(
@RequestBody
InspectParameter
inspectParameter
){
inspectService
.
inspect
(
inspectParameter
);
//inspectService.inspect(inspectParameter,path);
System
.
out
.
println
(
path
);
return
ResponseEntity
.
ok
(
200
);
return
ResponseEntity
.
ok
(
200
);
}
}
@PostMapping
(
"/frontend"
)
public
ResponseEntity
inspect
(
MultipartFile
file
)
throws
IOException
{
return
ResponseEntity
.
ok
(
200
);
}
}
}
src/main/java/com/zjty/inspect/service/InspectService.java
浏览文件 @
c5fff57b
...
@@ -4,7 +4,7 @@ import com.zjty.inspect.entity.InspectParameter;
...
@@ -4,7 +4,7 @@ import com.zjty.inspect.entity.InspectParameter;
import
com.zjty.inspect.entity.Report
;
import
com.zjty.inspect.entity.Report
;
public
interface
InspectService
{
public
interface
InspectService
{
Report
inspect
(
InspectParameter
inspectParameter
,
String
path
);
Report
inspect
(
InspectParameter
inspectParameter
);
void
setTechId
(
String
id
);
void
setTechId
(
String
id
);
}
}
src/main/java/com/zjty/inspect/service/impl/InspectServiceImpl.java
浏览文件 @
c5fff57b
...
@@ -39,7 +39,7 @@ public class InspectServiceImpl implements InspectService {
...
@@ -39,7 +39,7 @@ public class InspectServiceImpl implements InspectService {
@Transactional
@Transactional
@Override
@Override
public
Report
inspect
(
InspectParameter
inspectParameter
,
String
path
)
{
public
Report
inspect
(
InspectParameter
inspectParameter
)
{
Map
<
String
,
Report
.
Language
>
suffixLanguageMapping
=
new
HashMap
<>();
Map
<
String
,
Report
.
Language
>
suffixLanguageMapping
=
new
HashMap
<>();
suffixLanguageMapping
.
put
(
"java"
,
Report
.
Language
.
JAVA
);
suffixLanguageMapping
.
put
(
"java"
,
Report
.
Language
.
JAVA
);
suffixLanguageMapping
.
put
(
"vue"
,
Report
.
Language
.
VUE
);
suffixLanguageMapping
.
put
(
"vue"
,
Report
.
Language
.
VUE
);
...
@@ -49,18 +49,16 @@ public class InspectServiceImpl implements InspectService {
...
@@ -49,18 +49,16 @@ public class InspectServiceImpl implements InspectService {
suffixLanguageMapping
.
put
(
"html"
,
Report
.
Language
.
ONLYVIEW
);
suffixLanguageMapping
.
put
(
"html"
,
Report
.
Language
.
ONLYVIEW
);
suffixLanguageMapping
.
put
(
"js"
,
Report
.
Language
.
JAVASCRIPT
);
suffixLanguageMapping
.
put
(
"js"
,
Report
.
Language
.
JAVASCRIPT
);
suffixLanguageMapping
.
put
(
"go"
,
Report
.
Language
.
GO
);
suffixLanguageMapping
.
put
(
"go"
,
Report
.
Language
.
GO
);
Path
path1
=
Paths
.
get
(
path
);
File
file
=
path1
.
toFile
();
Report
report1
=
new
Report
();
Report
report1
=
new
Report
();
report1
.
setGitAddress
(
path
);
report1
.
setGitAddress
(
inspectParameter
.
getPath
()
);
inspector
.
setTechId
(
techId
);
inspector
.
setTechId
(
techId
);
inspector
.
setInspectParameter
(
inspectParameter
);
inspector
.
setInspectParameter
(
inspectParameter
);
inspector
.
setReport
(
report1
);
inspector
.
setReport
(
report1
);
inspector
.
setSuffixLanguageMapping
(
suffixLanguageMapping
);
inspector
.
setSuffixLanguageMapping
(
suffixLanguageMapping
);
inspector
.
setPath
(
path
);
inspector
.
setPath
(
inspectParameter
.
getPath
()
);
Report
report
=
inspector
.
inspect
();
Report
report
=
inspector
.
inspect
();
reportDao
.
save
(
report
);
reportDao
.
save
(
report
);
return
null
;
return
report
;
}
}
@Override
@Override
...
...
src/main/java/com/zjty/inspect/utils/AnalysisFile.java
浏览文件 @
c5fff57b
package
com
.
zjty
.
inspect
.
utils
;
package
com
.
zjty
.
inspect
.
utils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.dao.RuleDao
;
import
com.zjty.inspect.dao.TechnologyAndReportDao
;
import
com.zjty.inspect.dao.TechnologyAndReportDao
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.entity.Properties
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.Element
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -16,7 +10,10 @@ import java.io.IOException;
...
@@ -16,7 +10,10 @@ import java.io.IOException;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Set
;
@Component
@Component
public
class
AnalysisFile
{
public
class
AnalysisFile
{
...
@@ -63,12 +60,31 @@ public class AnalysisFile {
...
@@ -63,12 +60,31 @@ public class AnalysisFile {
try
{
try
{
List
<
String
>
strings
=
Files
.
readAllLines
(
path
);
List
<
String
>
strings
=
Files
.
readAllLines
(
path
);
String
s1
=
strings
.
get
(
0
);
String
s1
=
strings
.
get
(
0
);
depTree
.
setDepName
(
s1
);
map
.
put
(
0
,
depTree
);
map
.
put
(
0
,
depTree
);
int
now
=
0
;
int
now
=
0
;
depTree
.
setDepName
(
s1
);
for
(
int
i
=
1
;
i
<=
strings
.
size
()-
1
;
i
++)
{
for
(
int
i
=
1
;
i
<=
strings
.
size
()-
1
;
i
++)
{
DepTree
depTree1
=
new
DepTree
();
DepTree
depTree1
=
new
DepTree
();
String
s
=
strings
.
get
(
i
);
String
s
=
strings
.
get
(
i
);
int
i1
=
s
.
indexOf
(
"-"
);
String
s2
=
s
.
substring
(
i1
+
1
).
replaceAll
(
"\\|"
,
""
).
replaceAll
(
"\\+"
,
""
)
.
replaceAll
(
" "
,
""
)
.
replaceAll
(
"\\\\"
,
""
);
if
(
i1
==
one
){
depTree1
.
setDepName
(
s2
);
depTree
.
getDepTreeList
().
add
(
depTree1
);
}
else
{
if
(
i1
>
now
){
depTree1
.
setDepName
(
s2
);
map
.
get
(
i1
).
getDepTreeList
().
add
(
depTree1
);
}
else
{
depTree1
.
setDepName
(
s2
);
map
.
get
(
i1
).
getDepTreeList
().
add
(
depTree1
);
}
}
for
(
Rule
rule
:
ruleList
)
{
for
(
Rule
rule
:
ruleList
)
{
if
(
KmpUtil
.
kmpMatch
(
s
,
rule
.
getTarget
())>
0
){
if
(
KmpUtil
.
kmpMatch
(
s
,
rule
.
getTarget
())>
0
){
depTree1
.
setViolation
(
1
);
depTree1
.
setViolation
(
1
);
...
@@ -84,25 +100,10 @@ public class AnalysisFile {
...
@@ -84,25 +100,10 @@ public class AnalysisFile {
technologyAndReports
.
add
(
technologyAndReport
);
technologyAndReports
.
add
(
technologyAndReport
);
}
}
}
}
int
i1
=
s
.
indexOf
(
"-"
);
if
(
i1
==
one
){
depTree1
.
setDepName
(
s
);
depTree
.
getDepTreeList
().
add
(
depTree1
);
}
else
{
if
(
i1
>
now
){
depTree1
.
setDepName
(
s
);
map
.
get
(
i1
).
getDepTreeList
().
add
(
depTree1
);
}
else
{
depTree1
.
setDepName
(
s
);
map
.
get
(
i1
).
getDepTreeList
().
add
(
depTree1
);
}
}
map
.
put
(
i1
+
3
,
depTree1
);
map
.
put
(
i1
+
3
,
depTree1
);
now
=
i1
;
now
=
i1
;
//将依赖全部放进规则库中
//将依赖全部放进规则库中
String
[]
split
=
s
.
substring
(
i1
+
1
).
replaceAll
(
"\\|"
,
""
).
replaceAll
(
"\\+"
,
""
)
String
[]
split
=
s2
.
replaceAll
(
" "
,
""
)
.
replaceAll
(
"\\\\"
,
""
)
.
split
(
":"
);
.
split
(
":"
);
StringBuilder
stringBuffer
=
new
StringBuilder
();
StringBuilder
stringBuffer
=
new
StringBuilder
();
for
(
int
i2
=
0
;
i2
<
2
;
i2
++)
{
for
(
int
i2
=
0
;
i2
<
2
;
i2
++)
{
...
@@ -146,14 +147,4 @@ public class AnalysisFile {
...
@@ -146,14 +147,4 @@ public class AnalysisFile {
public
void
setMap
(
HashMap
<
String
,
Rule
>
map
){
public
void
setMap
(
HashMap
<
String
,
Rule
>
map
){
this
.
ruleMap
=
map
;
this
.
ruleMap
=
map
;
}
}
public
static
void
main
(
String
[]
args
)
{
String
s
=
"\\gfdgdfgdfgd"
;
System
.
out
.
println
(
s
.
replaceAll
(
"\\\\"
,
""
));
StringBuilder
stringBuilder
=
new
StringBuilder
();
stringBuilder
.
append
(
1
).
append
(
2
).
append
(
"fdf"
);
stringBuilder
.
delete
(
0
,
stringBuilder
.
length
());
System
.
out
.
println
(
stringBuilder
.
toString
());
}
}
}
src/main/java/com/zjty/inspect/utils/Inspector.java
浏览文件 @
c5fff57b
...
@@ -2,13 +2,10 @@ package com.zjty.inspect.utils;
...
@@ -2,13 +2,10 @@ package com.zjty.inspect.utils;
import
com.zjty.inspect.dao.*
;
import
com.zjty.inspect.dao.*
;
import
com.zjty.inspect.entity.*
;
import
com.zjty.inspect.entity.*
;
import
io.lettuce.core.dynamic.annotation.Param
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -273,7 +270,7 @@ public class Inspector {
...
@@ -273,7 +270,7 @@ public class Inspector {
case
"json"
:
case
"json"
:
//前端依赖解析
//前端依赖解析
for
(
Path
path
:
entry
.
getValue
())
{
for
(
Path
path
:
entry
.
getValue
())
{
if
(
path
.
getFileName
().
endsWith
(
"
build.gradle
"
))
{
if
(
path
.
getFileName
().
endsWith
(
"
package.json
"
))
{
VueDep
json
=
FileUtil
.
parseJsonFile
(
path
.
toString
());
VueDep
json
=
FileUtil
.
parseJsonFile
(
path
.
toString
());
Map
<
String
,
String
>
dependencies
=
json
.
getDependencies
();
Map
<
String
,
String
>
dependencies
=
json
.
getDependencies
();
for
(
String
s
:
dependencies
.
keySet
())
{
for
(
String
s
:
dependencies
.
keySet
())
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论