Toggle navigation
Toggle navigation
This project
Loading...
Sign in
노현종
/
2018-1-Capstone1-VulnNotti
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
노현종
2018-05-23 00:56:19 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
4b7e2f371650dbf5e1f5ea67a6b9ce3f285c74d1
4b7e2f37
2 parents
a417248e
c6a2bab8
Merge branch 'master' into master3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
176 additions
and
77 deletions
VulnNotti/templates/registration/logged_out.html
Vulnerablity_DB/VulnCrawler/VulnAbstractCrawler.cs
Vulnerablity_DB/VulnCrawler/VulnC.cs
_config.yml
VulnNotti/templates/registration/logged_out.html
deleted
100644 → 0
View file @
a417248
File mode changed
Vulnerablity_DB/VulnCrawler/VulnAbstractCrawler.cs
View file @
4b7e2f3
...
...
@@ -382,11 +382,18 @@ namespace VulnCrawler
{
return
false
;
}
/* 대문자로 구성된 변수면 넘어감 */
if
(
m
.
Value
.
All
(
c
=>
char
.
IsUpper
(
c
)
||
!
char
.
IsLetter
(
c
)))
{
return
false
;
}
/* 제일 앞자리가 숫자로 시작하면 넘어감 */
if
(
Regex
.
IsMatch
(
m
.
Value
,
invalidPattern
))
{
return
false
;
}
/* 전 단계에서 구한 메서드 목록에 있으면 넘어감 */
if
(
methodSets
.
Contains
(
m
.
Value
))
{
...
...
@@ -403,6 +410,8 @@ namespace VulnCrawler
{
return
false
;
}
return
true
;
})
.
Distinct
(
new
MatchComparer
());
...
...
Vulnerablity_DB/VulnCrawler/VulnC.cs
View file @
4b7e2f3
...
...
@@ -232,7 +232,6 @@ namespace VulnCrawler
// srcCode = Regex.Replace(srcCode, @"if.+\n\{", @"if.+\{", RegexOptions.Multiline);
var
split
=
srcCode
.
Split
(
'\n'
);
int
bracketCount
=
0
;
var
blockList
=
new
List
<
Block
>();
StringBuilder
builder
=
new
StringBuilder
();
var
crList
=
criticalList
as
HashSet
<
string
>;
...
...
@@ -240,121 +239,211 @@ namespace VulnCrawler
{
return
null
;
}
bool
hasIf
=
false
;
bool
mainLine
=
true
;
/* 현재 라인이 메인 코드 라인인지 */
bool
criticalBlock
=
false
;
/* 현재 라인이 크리티컬 블록 라인인지 */
int
blockNum
=
1
;
/* 블록 번호 */
var
mainQ
=
new
Queue
<
string
>();
var
groupQ
=
new
Queue
<
string
>();
bool
mainLine
=
true
;
int
crNum
=
1
;
int
bracketCount
=
1
;
bool
prevStartBlock
=
false
;
foreach
(
var
line
in
split
)
{
bool
hasRight
=
false
;
bool
criticalBlock
=
false
;
string
trimLine
=
line
.
Trim
();
if
(
mainLine
)
{
if
(
trimLine
.
EndsWith
(
"&&"
)
||
trimLine
.
EndsWith
(
"||"
))
{
mainQ
.
Enqueue
(
line
);
continue
;
}
string
trim
=
line
.
Trim
();
if
(
trimLine
.
StartsWith
(
"&&"
)
||
trimLine
.
StartsWith
(
"||"
))
{
groupQ
.
Enqueue
(
line
);
continue
;
}
/* 중괄호 수 세기 */
int
openBracketCount
=
trim
.
Count
(
c
=>
c
==
'{'
);
int
closeBracketCount
=
trim
.
Count
(
c
=>
c
==
'}'
);
//if (!hasIf)
//{
// if (Regex.IsMatch(trim, @"^if.+\)$"))
// {
// // Console.WriteLine("if 들어감");
// hasIf = true;
// }
//}
//else
//{
// if (!Regex.IsMatch(trim, @"^\{"))
// {
// openBracketCount++;
// }
// hasIf = false;
//}
bracketCount
=
1
;
StringBuilder
groupBuilder
=
new
StringBuilder
();
while
(
groupQ
.
Count
>
0
)
{
string
s
=
groupQ
.
Dequeue
();
if
(!
criticalBlock
)
{
foreach
(
var
item
in
ExtractCriticalVariant
(
s
))
{
if
(
crList
.
Contains
(
item
))
{
criticalBlock
=
true
;
break
;
}
}
}
groupBuilder
.
AppendLine
(
s
);
}
if
(
groupBuilder
.
Length
>
0
)
{
blockList
.
Add
(
new
Block
{
Code
=
groupBuilder
.
ToString
(),
HasCritical
=
criticalBlock
,
Num
=
crNum
++});
}
if
(
Regex
.
IsMatch
(
trimLine
,
@"(if|for|while|switch|do)\s*"
))
{
if
(!
trimLine
.
EndsWith
(
"{"
))
{
mainLine
=
false
;
prevStartBlock
=
true
;
}
else
if
(
trimLine
.
EndsWith
(
";"
))
{
mainLine
=
true
;
}
else
{
mainLine
=
false
;
bracketCount
++;
}
groupQ
.
Enqueue
(
line
);
continue
;
}
mainQ
.
Enqueue
(
line
);
}
else
{
/* 중괄호 수 세기 */
int
openBracketCount
=
trimLine
.
Count
(
c
=>
c
==
'{'
);
int
closeBracketCount
=
trimLine
.
Count
(
c
=>
c
==
'}'
);
int
subtract
=
openBracketCount
-
closeBracketCount
;
bracketCount
+=
subtract
;
if
(
trim
.
Equals
(
"}
"
))
if
(
trimLine
.
EndsWith
(
"&&"
)
||
trimLine
.
EndsWith
(
"||
"
))
{
builder
.
AppendLin
e
(
line
);
hasRight
=
tr
ue
;
groupQ
.
Enqueu
e
(
line
);
contin
ue
;
}
/* 중괄호 연산 결과 1이라는 것은 메인 라인 */
if
(
bracketCount
==
1
)
//if (trimLine.StartsWith("&&") || trimLine.StartsWith("||"))
//{
// mainQ.Enqueue(line);
// continue;
//}
groupQ
.
Enqueue
(
line
);
if
(
prevStartBlock
)
{
/*
* 깊이가 1인데 mainLine이
* false 이면 넘어왔다는 것이니 현재까지 코드
* blockList에 추가
*/
if
(!
mainLine
)
prevStartBlock
=
false
;
if
(
Regex
.
IsMatch
(
trimLine
,
@"(if|for|while|switch|do)\s*\("
))
{
string
s
=
builder
.
ToString
();
if
(!
string
.
IsNullOrWhiteSpace
(
s
))
prevStartBlock
=
true
;
continue
;
}
else
if
(
trimLine
.
EndsWith
(
";"
))
{
blockList
.
Add
(
new
Block
()
{
HasCritical
=
criticalBlock
,
Code
=
s
,
Num
=
blockNum
});
blockNum
++;
criticalBlock
=
false
;
builder
.
Clear
();
bracketCount
--;
}
}
if
(
bracketCount
<=
1
)
{
if
(
trimLine
.
Contains
(
"else"
))
{
bracketCount
++;
prevStartBlock
=
true
;
continue
;
}
mainLine
=
true
;
}
/* 2 이상이라는 건 메인 라인 X */
else
if
(
bracketCount
>=
2
)
StringBuilder
mainBuilder
=
new
StringBuilder
();
while
(
mainQ
.
Count
>
0
)
{
/*
* 깊이가 2 이상인데 mainLine이
* true면 넘어왔다는 것이니 현재까지 코드
* blockList에 추가
*/
if
(
mainLine
)
string
s
=
mainQ
.
Dequeue
();
if
(!
criticalBlock
)
{
string
s
=
builder
.
ToString
();
if
(!
string
.
IsNullOrWhiteSpace
(
s
))
foreach
(
var
item
in
ExtractCriticalVariant
(
s
))
{
blockList
.
Add
(
new
Block
()
{
HasCritical
=
criticalBlock
,
Code
=
s
,
Num
=
blockNum
});
blockNum
++;
criticalBlock
=
fals
e
;
builder
.
Clear
()
;
if
(
crList
.
Contains
(
item
))
{
criticalBlock
=
tru
e
;
break
;
}
}
mainLine
=
false
;
}
/* 이도 저도 아니면 그냥 넘어감 */
else
mainBuilder
.
AppendLine
(
s
);
}
if
(
mainBuilder
.
Length
>
0
)
{
continue
;
blockList
.
Add
(
new
Block
{
Code
=
mainBuilder
.
ToString
(),
HasCritical
=
criticalBlock
,
Num
=
crNum
++
});
}
}
/* 현재 코드 라인에서 변수 추출시켜서 크리티컬 리스트와 대조 */
foreach
(
var
var
in
ExtractCriticalVariant
(
line
))
}
bool
cb
=
false
;
if
(
mainQ
.
Count
>
0
)
{
/* 크리티컬 리스트에 추출한 변수가 들어있다면 추가 */
if
(
criticalList
.
Contains
(
var
)
)
StringBuilder
mainBuilder
=
new
StringBuilder
();
while
(
mainQ
.
Count
>
0
)
{
criticalBlock
=
true
;
string
s
=
mainQ
.
Dequeue
();
if
(!
cb
)
{
foreach
(
var
item
in
ExtractCriticalVariant
(
s
))
{
if
(
crList
.
Contains
(
item
))
{
cb
=
true
;
break
;
}
}
}
mainBuilder
.
AppendLine
(
s
);
}
if
(
!
hasRight
)
if
(
mainBuilder
.
Length
>
0
)
{
builder
.
AppendLine
(
line
);
blockList
.
Add
(
new
Block
{
Code
=
mainBuilder
.
ToString
(),
HasCritical
=
cb
,
Num
=
crNum
++
});
}
}
else
{
StringBuilder
groupBuilder
=
new
StringBuilder
();
while
(
groupQ
.
Count
>
0
)
{
string
s
=
groupQ
.
Dequeue
();
if
(!
cb
)
{
foreach
(
var
item
in
ExtractCriticalVariant
(
s
))
{
if
(
crList
.
Contains
(
item
))
{
cb
=
true
;
break
;
}
}
}
groupBuilder
.
AppendLine
(
s
);
}
/* 마지막 남은게 있을 수 있으니 추가 */
string
fs
=
builder
.
ToString
();
if
(!
string
.
IsNullOrWhiteSpace
(
fs
))
if
(
groupBuilder
.
Length
>
0
)
{
blockList
.
Add
(
new
Block
()
{
HasCritical
=
criticalBlock
,
Code
=
fs
,
Num
=
blockNum
});
blockNum
++;
criticalBlock
=
false
;
builder
.
Clear
();
blockList
.
Add
(
new
Block
{
Code
=
groupBuilder
.
ToString
(),
HasCritical
=
cb
,
Num
=
crNum
++
});
}
}
return
blockList
;
...
...
_config.yml
0 → 100644
View file @
4b7e2f3
theme
:
jekyll-theme-midnight
\ No newline at end of file
Please
register
or
login
to post a comment