Only expose program failures for exit status 1

This CL changes the program.run function to return `(response, error)`
instead of just `response`. Previously, all failures would be rolled
into an `Ok: false` response and shown to the user. Now, it only does so
for exit status 1, and otherwise returns an error which bubbles up to a
500 Internal Server Error, with the `error` object logged on the server.

Rationale: we want to show legitimate failures to the user (e.g. fidlc
will fail if its input has a syntax error), but we do *not* want to
expose information the OS prints when programs crash. We use the exit
status as a proxy for this. For example, a segfault should cause the
program to exit with status 139, not 1.

This also makes program.run return stdout in the success case and stderr
in the failure (exit status 1) case, rather than always combining them
as before. This is a further measure to avoid leaking details that
should not be shown to the user. It also allows the logged message for
exit statuses besides 0 and 1 to show stdout/stderr separately.

Change-Id: I19173e66d37ead6989a7b45ab699976547f97267
2 files changed
tree: 115709507792cc0158af66d560e8f7067585765b
  1. backend/
  2. frontend/
  3. .dockerignore
  4. .gitignore
  5. AUTHORS
  6. CHANGELOG.md
  7. CONTRIBUTING.md
  8. Dockerfile
  9. LICENSE
  10. Makefile
  11. PATENTS
  12. prepare_deployment.sh
  13. README.md
  14. watch.sh
README.md

fidlbolt

fidlbolt is web app for exploring FIDL code and bytes, inspired by Matt Godbolt's Compiler Explorer.

Get started

To run a local fidlbolt server:

  1. Follow the Fuchsia: Get Started guide.
  2. Build FIDL tools: fx build host_x64/{fidlc,fidlgen_{llcpp,hlcpp,rust,go,dart}} zircon/tools.
  3. Ensure that you have Go and Node.js installed.
  4. Build and run with make run.
  5. View the app at http://localhost:8080.

If you don't want changes in the Fuchsia tree (e.g. rebuilding fidlc or changing FIDL libraries) to affect the running fidlbolt, run ./prepare_deployment.sh and use make run DEPLOYMENT=1 instead.

Contributing

Backend

The backend is written in Go 1.13. It uses net/http to serve static files and handle POST requests.

Frontend

The frontend is written in Elm and TypeScript. It uses webpack for bundling.

To set up the frontend:

  1. Install Node.js and npm. On Debian-based systems, use sudo apt-get install npm.
  2. cd frontend && npm ci (using ci instead of install ensures a repeatable build).

Then, use one of the commands listed in npm run:

  • npm run dev: build in development mode
  • npm run watch: rebuild in development mode on every file change
  • npm run tc: typecheck TypeScript files
  • npm run lint: run eslint on TypeScript files
  • npm run fix: format and fix lint issues in TypeScript and Elm files
  • npm run build: build in production mode

The build commands read files in frontend/src/ and generate output in frontend/dist/.

Workflow

If you are developing on Linux, ./watch.sh provides an easy workflow. It automatically watches code in the frontend (using npm run watch) and backend (using inotifywait), rebuilding and restarting the server as necessary. It does not perform hot/live reloading: you still need to refresh the browser manually to see changes.

Style

Before making a CL, always run make format.

Deployment

The project uses Docker for containerized deployment.

To build and run a new image locally:

  1. Install Docker. On Debian-based systems, use sudo apt-get install docker-ce.
  2. ./prepare_deployment.sh
  3. docker image build -t fidlbolt .
  4. docker container run --publish 8080:8080 --detach --name fb fidlbolt

You might need to use sudo with the Docker commands.