grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Normalize paths before passing them to the authorization checker
16 months ago, Gary Kramlich
e33f7739ab49
Normalize paths before passing them to the authorization checker
This bug allowed attackers to bypass deny rules by adding a trailing / to the
repository which depending on the policy could grant them access to said
repository.
package
main
import
(
"os"
"github.com/alecthomas/kong"
log
"github.com/sirupsen/logrus"
"keep.imfreedom.org/grim/hgkeeper/authorized_keys"
"keep.imfreedom.org/grim/hgkeeper/globals"
"keep.imfreedom.org/grim/hgkeeper/once"
"keep.imfreedom.org/grim/hgkeeper/serve"
"keep.imfreedom.org/grim/hgkeeper/setup"
"keep.imfreedom.org/grim/hgkeeper/version"
)
type
commands
struct
{
globals
.
Globals
AuthorizedKeys
authorized_keys
.
Command
`kong:"cmd,help='output an sshd authorized keys file'"`
Once
once
.
Command
`kong:"cmd,help='run hgkeeper for one transaction. This is used when integrating with a system ssh server'"`
Serve
serve
.
Command
`kong:"cmd,help='run the ssh server'"`
Setup
setup
.
Command
`kong:"cmd,help='inital setup for the server'"`
Version
version
.
Command
`kong:"cmd,help='display the version and exit'"`
}
func
init
()
{
log
.
SetOutput
(
os
.
Stdout
)
log
.
SetLevel
(
log
.
DebugLevel
)
fmter
:=
&
log
.
TextFormatter
{
FullTimestamp
:
true
,
}
switch
os
.
Getenv
(
"TERM"
)
{
case
"win"
:
fallthrough
case
"dumb"
:
fmter
.
DisableColors
=
true
}
log
.
SetFormatter
(
fmter
)
}
func
main
()
{
cmd
:=
commands
{}
ctx
:=
kong
.
Parse
(
&
cmd
)
if
err
:=
ctx
.
Run
(
&
cmd
.
Globals
);
err
!=
nil
{
ctx
.
FatalIfErrorf
(
err
)
}
}