Skip to content

Commit

Permalink
Release 2.1.0
Browse files Browse the repository at this point in the history
Bugfix: sanatise usernames before spawning processes
Bugfix: remove empty spaces from ssh args
Bugfix: remove unneeded arg for github publish action
  • Loading branch information
butlerx committed Aug 24, 2021
1 parent 294faca commit c897f2f
Show file tree
Hide file tree
Showing 8 changed files with 1,895 additions and 1,377 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ jobs:
env:
CI: true
- name: Publish if version has been updated
uses: pascalgn/[email protected].6
uses: pascalgn/[email protected].8
with:
tag_name: "v%s"
tag_message: "v%s"
create_tag: "true"
commit_pattern: "^Release (\\S+)"
workspace: "."
publish_command: "yarn"
publish_args: "--non-interactive"
env:
GITHUB_TOKEN: ${{ secrets.node_github_token }}
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Create Release
on:
push:
tags:
- 'v*'
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
4 changes: 2 additions & 2 deletions containers/wetty/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM node:current-alpine as builder
RUN apk add -U build-base python
RUN apk add -U build-base python3
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN yarn && \
Expand All @@ -14,7 +14,7 @@ EXPOSE 3000
COPY --from=builder /usr/src/app/build /usr/src/app/build
COPY --from=builder /usr/src/app/node_modules /usr/src/app/node_modules
COPY package.json /usr/src/app
RUN apk add -U openssh-client sshpass && \
RUN apk add -U coreutils openssh-client sshpass && \
mkdir ~/.ssh

ENTRYPOINT [ "yarn" , "docker-entrypoint"]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wetty",
"version": "2.0.4",
"version": "2.1.0",
"description": "WeTTY = Web + TTY. Terminal access in browser over http/https",
"homepage": "https://github.com/butlerx/wetty",
"license": "MIT",
Expand Down Expand Up @@ -111,7 +111,7 @@
"helmet": "^4.1.0",
"json5": "^2.1.3",
"lodash": "^4.17.20",
"node-pty": "^0.9.0",
"node-pty": "^0.10.0",
"parseurl": "^1.3.3",
"sass": "^1.26.10",
"socket.io": "^2.3.0",
Expand Down
3 changes: 2 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
forceSSHDefault,
defaultCommand,
} from './shared/defaults.js';
import { escapeShell } from './server/shared/shell.js';

/**
* Starts WeTTy Server
Expand Down Expand Up @@ -58,7 +59,7 @@ export async function start(
} else {
try {
const username = await login(socket);
args[1] = `${username.trim()}@${args[1]}`;
args[1] = `${escapeShell(username.trim())}@${args[1]}`;
logger.debug('Spawning term', {
username: username.trim(),
cmd: args.join(' '),
Expand Down
11 changes: 8 additions & 3 deletions src/server/command/address.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { escapeShell } from '../shared/shell.js';

export function address(
headers: Record<string, string>,
user: string,
Expand All @@ -6,9 +8,12 @@ export function address(
// Check request-header for username
const remoteUser = headers['remote-user'];
if (remoteUser) {
return `${remoteUser}@${host}`;
return `${escapeShell(remoteUser)}@${host}`;
}
const match = headers.referer.match('.+/ssh/([^/]+)$');
const fallback = user ? `${user}@${host}` : host;
return match ? `${match[1].split('?')[0]}@${host}` : fallback;
if (match) {
const username = escapeShell(match[1].split('?')[0]);
return `${username}@${host}`;
}
return user ? `${escapeShell(user)}@${host}` : host;
}
2 changes: 2 additions & 0 deletions src/server/shared/shell.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const escapeShell = (username: string): string =>
username.replace(/[^a-zA-Z0-9-_]/g, '');
3,222 changes: 1,857 additions & 1,365 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit c897f2f

Please sign in to comment.