Dinghy
← works
2023 · Program Analysis · Dockerfile · AST

Dinghy

A versatile AST parser for shell scripts and Dockerfiles.

github ↗ website ↗ parse · traverse · query

The problem

Analysing a Dockerfile means analysing two languages at once: the Dockerfile instructions, and the shell embedded inside every RUN. Most tooling sees only the surface and misses what the commands actually do.

The approach

Dinghy parses shell scripts and Dockerfiles into a single, well-typed Abstract Syntax Tree that you can traverse, query, and modify. It captures the structure of complex Dockerfiles and the shell within them, giving analysis and rewriting tools one consistent model to work against.

In practice

Dinghy is the parsing engine behind docker-parfum, and is published on npm as @tdurieux/dinghy with full API documentation.

Highlights

  • One AST for both shell scripts and Dockerfiles
  • Traverse and query commands, arguments, and structure
  • TypeScript-first, modular, and easy to extend