Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
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
lvzhengyang
git2
Commits
ad3799e8
Commit
ad3799e8
authored
Sep 20, 2023
by
Carlos Martín Nieto
Committed by
Carlos Martín Nieto
Sep 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: add tests for injection rejection in ssh exec
parent
517bd0d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
tests/libgit2/transport/ssh_exec.c
+79
-0
No files found.
tests/libgit2/transport/ssh_exec.c
0 → 100644
View file @
ad3799e8
#include "clar_libgit2.h"
#include "git2/sys/remote.h"
#include "git2/sys/transport.h"
void
test_transport_ssh_exec__reject_injection_username
(
void
)
{
#ifndef GIT_SSH_EXEC
cl_skip
();
#else
git_remote
*
remote
;
git_repository
*
repo
;
git_transport
*
transport
;
const
char
*
url
=
"-oProxyCommand=git@somehost:somepath"
;
git_remote_connect_options
opts
=
GIT_REMOTE_CONNECT_OPTIONS_INIT
;
cl_git_pass
(
git_repository_init
(
&
repo
,
"./transport-username"
,
0
));
cl_git_pass
(
git_remote_create
(
&
remote
,
repo
,
"test"
,
cl_fixture
(
"testrepo.git"
)));
cl_git_pass
(
git_transport_new
(
&
transport
,
remote
,
url
));
cl_git_fail_with
(
-
1
,
transport
->
connect
(
transport
,
url
,
GIT_SERVICE_UPLOADPACK_LS
,
&
opts
));
transport
->
free
(
transport
);
git_remote_free
(
remote
);
git_repository_free
(
repo
);
#endif
}
void
test_transport_ssh_exec__reject_injection_hostname
(
void
)
{
#ifndef GIT_SSH_EXEC
cl_skip
();
#else
git_remote
*
remote
;
git_repository
*
repo
;
git_transport
*
transport
;
const
char
*
url
=
"-oProxyCommand=somehost:somepath-hostname"
;
git_remote_connect_options
opts
=
GIT_REMOTE_CONNECT_OPTIONS_INIT
;
cl_git_pass
(
git_repository_init
(
&
repo
,
"./transport-hostname"
,
0
));
cl_git_pass
(
git_remote_create
(
&
remote
,
repo
,
"test"
,
cl_fixture
(
"testrepo.git"
)));
cl_git_pass
(
git_transport_new
(
&
transport
,
remote
,
url
));
cl_git_fail_with
(
-
1
,
transport
->
connect
(
transport
,
url
,
GIT_SERVICE_UPLOADPACK_LS
,
&
opts
));
transport
->
free
(
transport
);
git_remote_free
(
remote
);
git_repository_free
(
repo
);
#endif
}
void
test_transport_ssh_exec__reject_injection_path
(
void
)
{
#ifndef GIT_SSH_EXEC
cl_skip
();
#else
git_remote
*
remote
;
git_repository
*
repo
;
git_transport
*
transport
;
const
char
*
url
=
"git@somehost:-somepath"
;
git_remote_connect_options
opts
=
GIT_REMOTE_CONNECT_OPTIONS_INIT
;
cl_git_pass
(
git_repository_init
(
&
repo
,
"./transport-path"
,
0
));
cl_git_pass
(
git_remote_create
(
&
remote
,
repo
,
"test"
,
cl_fixture
(
"testrepo.git"
)));
cl_git_pass
(
git_transport_new
(
&
transport
,
remote
,
url
));
cl_git_fail_with
(
-
1
,
transport
->
connect
(
transport
,
url
,
GIT_SERVICE_UPLOADPACK_LS
,
&
opts
));
transport
->
free
(
transport
);
git_remote_free
(
remote
);
git_repository_free
(
repo
);
#endif
}
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