update docs24368dc20 days ago40 lines · 1.6 KB | 1 | /** Ghost answers an SSH session with text and an exit code. Nothing here reaches a shell - these are string lookups, which is the whole point. */ |
| 2 | const GHOST = [ |
| 3 | ' .-""""""-.', |
| 4 | " .' '.", |
| 5 | ' | | | | ghost', |
| 6 | ' | | git in, git out', |
| 7 | ' | |', |
| 8 | ' \\_/\\_/\\_/\\ |
| 9 | ].join('\n') |
| 10 | |
| 11 | export function greeting(username |
| 12 | return [ |
| 13 | GHOST, |
| 14 | '', |
| 15 | `Hi ${username}! You have authenticated, but Ghost does not provide shell access.` |
| 16 | 'Use this connection for `git clone`, `git fetch` and `git push` instead.', |
| 17 | '', |
| 18 | ].join('\n' |
| 19 | } |
| 20 | |
| 21 | /** Answers for the handful of things people type at a server that does not want them to type anything. */ |
| 22 | const REPLIES: Record |
| 23 | whoami: (username) |
| 24 | ls: () => |
| 25 | 'ls -la': () => |
| 26 | pwd: () => |
| 27 | uptime: () => |
| 28 | fortune: () => |
| 29 | sudo: () => |
| 30 | 'rm -rf /': () => |
| 31 | exit: () => |
| 32 | help: () => |
| 33 | ghost: () => |
| 34 | }; |
| 35 | |
| 36 | export function replyTo(command |
| 37 | const reply = |
| 38 | if (reply) return |
| 39 | return `ghost: I only speak git, and "${command |
| 40 | } |
_/
'
,
;
:
string
)
{
,
)
;
<
string
,
(
username
:
string
)
=>
string
>
=
{
=>
username
,
'
Your repositories are on the web. This door only opens for git.
'
,
'
Still nothing. Impressively thorough, though.
'
,
'
/dev/null
'
,
'
Haunting continuously since the last deploy.
'
,
'
A commit you cannot reproduce is a rumour.
'
,
'
Ghost is already dead. There is nothing left to escalate to.
'
,
'
Object storage keeps the truth, and it is not here.
'
,
'
You were never in.
'
,
'
git-upload-pack and git-receive-pack. That is the whole menu.
'
,
GHOST
,
:
string
,
username
:
string
)
{
REPLIES
[
command
.
trim
()
.
replace
(
/
\s
+
/
g
,
'
'
)
.
toLowerCase
()]
;
reply
(
username
)
;
.
trim
()
}
" is not git.
`
;