Interactive mode¶
Universal Ctags can be run with --_interactive
, which enters a REPL that
can be used programmatically to control ctags generation. In this mode, json
commands are received over stdin, and corresponding responses are emitted over
stdout.
This feature needs ctags to be built with json support and this requires libjansson to be installed
at build-time. If it’s supported it will be listed in the output of --list-features
:
$ ctags --list-features | grep json
json
Communication with Universal Ctags over stdio uses the json lines format, where each json object appears on a single line and is terminated with a newline.
When ctags --_interactive
is invoked, it will emit a single json object to stdout announcing
its name and version. This signals the start of the interactive loop, and the user can begin sending
commands over stdin.
$ ctags --_interactive
{"_type": "program", "name": "Universal Ctags", "version": "0.0.0"}
The following commands are currently supported in interactive mode:
sandbox submode¶
sandbox
submode can be used with --_interactive=sandbox
. This
submode will activate a sandbox, to this limits the damage that the
can be achieved when exploiting a buffer overflow in Universal Ctags.
In the sandbox submode ctags can generate tags only for inline requests because ctags has to use open system call to handle file requests. The open system call is not allowed in the sandbox.
This feature uses Seccomp BPF (SECure COMPuting with filters),
and is only supported on Linux. To use the sandbox submode libseccomp is needed at build-time. If ctags was
built with seccomp support, sandbox
is listed in the output of
--list-features
option.
$ ctags --list-features | grep sandbox
sandbox
$ (
echo '{"command":"generate-tags", "filename":"test.rb", "size": 17}'
echo 'def foobaz() end'
) | ctags --_interactive=sandbox
{"_type": "program", "name": "Universal Ctags", "version": "0.0.0"}
{"_type": "tag", "name": "foobaz", "path": "test.rb", "pattern": "/^def foobaz() end$/", "kind": "method"}
{"_type": "completed", "command": "generate-tags"}