sandboxed-api/oss-internship-2020/guetzli
2020-08-17 13:29:07 -07:00
..
external Update after code review 2020-08-17 13:29:07 -07:00
tests Update after code review 2020-08-17 13:29:07 -07:00
.bazelrc First version of guetzli sandbox 2020-08-11 15:48:48 -07:00
BUILD.bazel Update after code review 2020-08-17 13:29:07 -07:00
guetzli_entry_points.cc Update after code review 2020-08-17 13:29:07 -07:00
guetzli_entry_points.h Codestyle update 2020-08-12 14:09:40 -07:00
guetzli_sandbox.h Update after code review 2020-08-17 13:29:07 -07:00
guetzli_sandboxed.cc Update after code review 2020-08-17 13:29:07 -07:00
guetzli_transaction.cc Update after code review 2020-08-17 13:29:07 -07:00
guetzli_transaction.h Update after code review 2020-08-17 13:29:07 -07:00
README.md Update after code review 2020-08-17 13:29:07 -07:00
WORKSPACE Update after code review 2020-08-17 13:29:07 -07:00

Guetzli Sandboxed

This is an example implementation of a sandbox for the Guetzli library using Sandboxed API. Please read Guetzli's documentation to learn more about it.

Implementation details

Because Guetzli provides C++ API and SAPI requires functions to be extern "C" a wrapper library has been written for the compatibility. SAPI provides a Transaction class, which is a convenient way to create a wrapper for your sandboxed API that handles internal errors. Original Guetzli has command-line utility to encode images, so fully compatible utility that uses sandboxed Guetzli is provided.

Wrapper around Guetzli uses file descriptors to pass data to the sandbox. This approach restricts the sandbox from using open() syscall and also helps to prevent making copies of data, because you need to synchronize it between processes.

Build Guetzli Sandboxed

Right now Sandboxed API support only Linux systems, so you need one to build it. Guetzli sandboxed uses Bazel as a build system so you need to install it before building.

To build Guetzli sandboxed encoding utility you can use this command: bazel build //:guetzli_sandboxed

Than you can use it in this way:

guetzli_sandboxed [--quality Q] [--verbose] original.png output.jpg
guetzli_sandboxed [--quality Q] [--verbose] original.jpg output.jpg

Refer to Guetzli's documentation to read more about usage.

Examples

There are two different sets of unit tests which demonstrate how to use different parts of Guetzli sandboxed:

  • tests/guetzli_sapi_test.cc - example usage of Guetzli sandboxed API.
  • tests/guetzli_transaction_test.cc - example usage of Guetzli transaction.

Also, there is an example of custom security policy for your sandbox in guetzli_sandbox.h