nassh: expose connected hostname as a URL query parameter

Chrome Enterprise data controls (e.g. clipboard DLP rules) are keyed
off the page URL, so record the ssh host we connect to as
?canonicalized-hostname=<host>.  The parameter is output only; nassh
never reads it.  The user-facing contract is documented in the FAQ
alongside the rest of the nassh.html URI spec.

navigate_() is unchanged: it still swaps the #hash via
location.replace(), which is a same-document (fragment) navigation.
The query string can't take that path -- a query change through
location.replace() is a cross-document navigation that would reload
the page and kill the session -- so a new setHostnameParam_() helper
updates it with history.replaceState() instead: no reload and no new
history entry.

The hostname is written twice.  First from the profile/destination
before connecting, i.e. whatever the user typed.  Then, since
ssh_config may rewrite that (HostName) or it may be an IP literal, a
new onConnectAttempt hook in the wassh syscall handler refines it with
the address ssh actually tries to reach on its first AF_INET/AF_INET6
connect.  The hook only touches the URL in place; it never navigates,
and exceptions in it cannot affect the connect.

Change-Id: I131f0bf0907f4309b5a808b13986ff9a69660001
Reviewed-on: https://chromium-review.googlesource.com/c/apps/libapps/+/8487515
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
7 files changed
tree: f4005a0d910d464e68a1a0a5d267f4c226049738
  1. hterm/
  2. kokoro/
  3. libdot/
  4. nassh/
  5. ssh_client/
  6. terminal/
  7. wasi-js-bindings/
  8. wassh/
  9. .clang-format
  10. .gitignore
  11. .markdownlintrc
  12. .pylintrc
  13. CPPLINT.cfg
  14. DIR_METADATA
  15. Dockerfile
  16. eslint.config.js
  17. HACK.md
  18. LICENSE
  19. METADATA
  20. navbar.md
  21. OWNERS
  22. package.json
  23. PRESUBMIT.cfg
  24. prettier.config.js
  25. pyproject.toml
  26. README.md
  27. unblocked_terms.txt
README.md

Hello

This repository contains the libdot JavaScript library and some web applications that make use of it.

The official copy of this repository is hosted at https://chromium.googlesource.com/apps/libapps.

There is also a mirror on github at https://github.com/libapps/libapps-mirror. A few subprojects are also extracted out into their own git repo and mirrored. Keep in mind that these mirrors may occasionally be behind the official repository.

All changes must go through the Gerrit code review server on https://chromium-review.googlesource.com. Github pull requests cannot be accepted. Please see the HACK.md document in this directory for the details.

Top level directories

  • libdot/ is a small set of JS libraries initially developed as part of hterm, now available as shared code.

  • hterm/ is a JS library that provides a terminal emulator. It is reasonably fast, reasonably correct, and reasonably portable across browsers.

  • nassh/ is the Chrome Secure Shell extension that combines hterm with a build of OpenSSH to provide a PuTTY-like app for Chrome users.

  • ssh_client/ is the WASM port of OpenSSH.

  • terminal/ is the ChromeOS Terminal application.

  • wassh/ is the JS part of the WASM OpenSSH port.

  • wasi-js-bindings/ provides JS bindings for WASI which is used by the WASM port.