Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Address various issues
Browse files Browse the repository at this point in the history
* use hostname instead of relying on serverId as fallback (handled in backend)
* simplified quicklaunch regex to just check for white spaces
* encode URL when finding documents by url to handle special characters
  • Loading branch information
Lisa Kim committed Jul 15, 2020
1 parent 1c72635 commit c9acdc2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ import cfg from 'teleport/config';

export default function TypeCell(props: any) {
const { rowIndex, data } = props;
const { sid, serverId, login, hostname } = data[rowIndex] as Session;
const { sid, login, hostname } = data[rowIndex] as Session;

// DELETE IN: 5.2 remove check for hostname.
// Older teleport versions do not set/retrieve hostname.
const nodeDesc = hostname || serverId;
const url = cfg.getSshSessionRoute({ sid });
const theme = useTheme();
const text = `Session is in progress [${login}@${nodeDesc}]`;
const text = `Session is in progress [${login}@${hostname}]`;

return (
<Cell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import { Session } from 'teleport/services/ssh';

export default function DescCell(props: any) {
const { rowIndex, data } = props;
const { hostname, addr, serverId } = data[rowIndex] as Session;
// DELETE IN: 5.2 remove check for hostname/addr.
// Older teleport versions do not set/retrieve hostname or addr.
const nodeName = hostname || serverId;
const { hostname, addr } = data[rowIndex] as Session;
const nodeAddr = addr ? `[${addr}]` : '';

return (
<Cell>
{nodeName} {nodeAddr}
{hostname} {nodeAddr}
</Cell>
);
}
4 changes: 2 additions & 2 deletions packages/teleport/src/components/NodeList/NodeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ const LoginCell: React.FC<Required<{
[key: string]: any;
}>> = props => {
const { rowIndex, data, onOpen, onSelect } = props;
const { hostname, id } = data[rowIndex] as Node;
const serverId = hostname || id;
const { id } = data[rowIndex] as Node;
const serverId = id;
function handleOnOpen() {
return onOpen(serverId);
}
Expand Down
11 changes: 4 additions & 7 deletions packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,11 @@ export default function FieldInputSsh({
);
}

// SSH_STR_REGEX is a modified regex from teleport's lib/sshutils/scp/scp.go.
// Captures two named groups: username and host.
const SSH_STR_REGEX = /(?:(?<username>[-.\w@]+)@)(?<host>[-.\w]+)$/;
// Checks for spaces between chars, and
// captures two named groups: username and host.
const SSH_STR_REGEX = /^(?:(?<username>[^\s]+)@)(?<host>[^\s]+)$/;
const check = value => {
const hasWhiteSpace = /\s/.test(value);
if (!hasWhiteSpace) {
return SSH_STR_REGEX.exec(value);
}
return SSH_STR_REGEX.exec(value.trim());
};

const StyledInput = styled(Input)(
Expand Down
2 changes: 1 addition & 1 deletion packages/teleport/src/console/stores/storeDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class StoreDocs extends Store<State> {
}

findByUrl(url: string) {
return this.state.items.find(i => i.url === url);
return this.state.items.find(i => i.url === encodeURI(url));
}

getNodeDocuments() {
Expand Down

0 comments on commit c9acdc2

Please sign in to comment.