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-04-18 19:42:11 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7c568659333726146cf6e6859c56139a46515c9a
7c568659
1 parent
9499d019
Fixed Downloader
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
5 deletions
Vulnerablity_DB/DownloaderGithubClone/DownloaderGithubClone.csproj
Vulnerablity_DB/DownloaderGithubClone/Program.cs
Vulnerablity_DB/DownloaderGithubClone/packages.config
Vulnerablity_DB/DownloaderGithubClone/DownloaderGithubClone.csproj
View file @
7c56865
...
...
@@ -38,6 +38,9 @@
<Reference Include="LibGit2Sharp, Version=0.25.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
<HintPath>..\packages\LibGit2Sharp.0.25.0\lib\netstandard2.0\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Octokit, Version=0.29.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octokit.0.29.0\lib\net45\Octokit.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
...
...
Vulnerablity_DB/DownloaderGithubClone/Program.cs
View file @
7c56865
...
...
@@ -6,19 +6,28 @@ using System.Threading.Tasks;
namespace
DownloaderGithubClone
{
using
LibGit2Sharp
;
// using LibGit2Sharp;
using
System.IO
;
using
System.Text.RegularExpressions
;
using
LibGit2Sharp
;
class
Program
{
static
void
Main
(
string
[]
args
)
{
string
dir
=
@"c:\VulnPy"
;
if
(!
Directory
.
Exists
(
dir
))
{
Directory
.
CreateDirectory
(
dir
);
Console
.
WriteLine
(
$
"디렉토리 생성 : {dir}"
);
}
Console
.
Write
(
"Git Repository URL을 입력하세요 : "
);
string
url
=
Console
.
ReadLine
();
//https://github.com/django/django.git
string
pattern
=
@"https://github.com/
(?<ProjectName>\w+)/\w+\.git
"
;
string
pattern
=
@"https://github.com/
.+/(?<ProjectName>.+)\.(.+)
"
;
var
match
=
Regex
.
Match
(
url
,
pattern
);
...
...
@@ -26,11 +35,29 @@ namespace DownloaderGithubClone
Console
.
WriteLine
(
$
"패턴이 맞지 않습니다. Pattern : {pattern}"
);
return
;
}
string
prName
=
match
.
Groups
[
"ProjectName"
].
Value
;
Console
.
WriteLine
(
prName
);
string
clone
=
Repository
.
Clone
(
url
,
$
@"c:\VulnPy\{prName}"
,
new
CloneOptions
{
OnTransferProgress
=
TransferProgress
,
OnCheckoutProgress
=
CheckoutProcess
});
int
idx
=
1
;
string
path
=
Path
.
Combine
(
dir
,
prName
);
if
(
Directory
.
Exists
(
path
))
{
while
(
true
)
{
path
=
Path
.
Combine
(
dir
,
prName
+
idx
);
if
(!
Directory
.
Exists
(
path
))
{
Directory
.
CreateDirectory
(
path
);
Console
.
WriteLine
(
$
"레파지토리 디렉토리 생성 : {path}"
);
break
;
}
}
}
Console
.
WriteLine
(
$
"다운로드를 진행합니다. 경로 : {path}"
);
string
clone
=
Repository
.
Clone
(
url
,
$
@"{path}"
,
new
CloneOptions
{
OnTransferProgress
=
TransferProgress
,
OnCheckoutProgress
=
CheckoutProcess
});
Console
.
ResetColor
();
Console
.
WriteLine
(
clone
);
}
...
...
@@ -44,13 +71,14 @@ namespace DownloaderGithubClone
int
receivedBytes
=
progress
.
ReceivedObjects
;
long
receivedTotal
=
progress
.
ReceivedBytes
;
double
received
=
progress
.
ReceivedBytes
/
1000000
;
double
percent
=
((
double
)
receivedBytes
/
(
double
)
totalBytes
)
*
10
;
double
percent
=
((
double
)
receivedBytes
/
(
double
)
totalBytes
);
Console
.
WriteLine
(
$
"진행률: {percent.ToString("
P2
")}, 남은 파일: {receivedBytes} of {totalBytes}"
);
//, 받은 용량: {received.ToString()}MB");
Console
.
ForegroundColor
=
ConsoleColor
.
DarkGreen
;
return
true
;
}
public
static
void
CheckoutProcess
(
string
path
,
int
completedSteps
,
int
totalSteps
)
{
Console
.
WriteLine
(
$
"{completedSteps}, {totalSteps}, {path}"
);
}
...
...
Vulnerablity_DB/DownloaderGithubClone/packages.config
View file @
7c56865
...
...
@@ -2,4 +2,5 @@
<
packages
>
<
package
id
=
"LibGit2Sharp"
version
=
"0.25.0"
targetFramework
=
"net461"
/>
<
package
id
=
"LibGit2Sharp.NativeBinaries"
version
=
"1.0.210"
targetFramework
=
"net461"
/>
<
package
id
=
"Octokit"
version
=
"0.29.0"
targetFramework
=
"net461"
/>
</
packages
>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment