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-21 19:54:37 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
13c7da23cd6960a8ed0f24d963450a577db7faf1
13c7da23
1 parent
481a43a6
중괄호 없는 if문 구분 못하는 문제 해결
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
Vulnerablity_DB/VulnCrawler/VulnC.cs
Vulnerablity_DB/VulnCrawler/VulnC.cs
View file @
13c7da2
...
...
@@ -241,36 +241,21 @@ namespace VulnCrawler
return
null
;
}
bool
hasIf
=
false
;
string
prevLine
=
string
.
Empty
;
bool
mainLine
=
true
;
/* 현재 라인이 메인 코드 라인인지 */
bool
criticalBlock
=
false
;
/* 현재 라인이 크리티컬 블록 라인인지 */
int
blockNum
=
1
;
/* 블록 번호 */
foreach
(
var
line
in
split
)
{
bool
hasRight
=
false
;
bool
hasIf2
=
false
;
string
trim
=
line
.
Trim
();
/* 중괄호 수 세기 */
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;
//}
int
subtract
=
openBracketCount
-
closeBracketCount
;
bracketCount
+=
subtract
;
...
...
@@ -284,12 +269,29 @@ namespace VulnCrawler
/* 중괄호 연산 결과 1이라는 것은 메인 라인 */
if
(
bracketCount
==
1
)
{
if
(!
hasIf
)
{
if
(
Regex
.
IsMatch
(
trim
,
@"^(if|for|while).+\)$"
))
{
prevLine
=
line
;
hasIf
=
true
;
}
}
else
{
if
(!
trim
.
StartsWith
(
"{"
))
{
hasIf2
=
true
;
builder
.
AppendLine
(
line
);
}
hasIf
=
false
;
}
/*
* 깊이가 1인데 mainLine이
* false 이면 넘어왔다는 것이니 현재까지 코드
* blockList에 추가
*/
if
(!
mainLine
)
if
(!
mainLine
||
hasIf2
)
{
string
s
=
builder
.
ToString
();
if
(!
string
.
IsNullOrWhiteSpace
(
s
))
...
...
@@ -299,6 +301,7 @@ namespace VulnCrawler
criticalBlock
=
false
;
builder
.
Clear
();
}
}
mainLine
=
true
;
}
...
...
@@ -339,7 +342,7 @@ namespace VulnCrawler
}
}
if
(!
hasRight
)
if
(!
hasRight
&&
!
hasIf2
)
{
builder
.
AppendLine
(
line
);
...
...
Please
register
or
login
to post a comment