CodeQL documentation

database index-files

Synopsis

codeql database index-files --language=<lang> <options>... [--] <database>

Description

[Plumbing] Index standalone files with a given CodeQL extractor.

This command selects a set of files under the specified working directory, and applies the given extractor to them. By default, all files are selected. Typical invocations will specify options to restrict the set of included files.

The --include, --exclude, and --prune options all take glob patterns, which can use the following wildcard characters:

  • A single “?” matches any character other than a forward/backward slash;
  • A single “*” matches any number of characters other than a forward/backward slash;
  • The pattern “**” matches zero or more complete directory components.

Options

<database>

[Mandatory] Path to the CodeQL database under construction. This must have been prepared for extraction with codeql database init.

-l, --language=<lang>

[Mandatory] The extractor that should be used to index matching files.

--working-dir=<dir>

[Advanced] The directory in which the specified command should be executed. If this argument is not provided, the command is executed in the value of --source-root passed to codeql database create, if one exists. If no --source-root argument is provided, the command is executed in the current working directory.

Options for limiting the set of indexed files

--include-extension=<.ext>

If one or more extensions are explicitly included, only files whose names end in one of those extensions will be included. Typically, you should include the dot before the extension. For example, passing --include-extension .xml will collect only files with the “.xml” extension.

--include=<glob>

If one or more --include options are specified, then files will only be included if their paths relative to the search directory match at least one of the provided globs. Globs can begin with a ! character to indicate that the glob should exclude matching files rather than include them.

--include options are processed in the order in which they are specified, with later patterns taking precedence over earlier patterns. For example, --include \*\* --include !sub/\*.ts --include sub/main.\* would include sub/main.ts because it is included by sub/main.\*, exclude sub/index.ts because it is excluded by !sub/\*.ts, and include sub/test.js because it is included by \*\* without being subsequently excluded.

--exclude=<glob>

If one or more --exclude options are specified, then files will be excluded when their paths relative to the search directory match any of the provided globs, even if they would be otherwise included.

--prune=<glob>

If one or more --prune options are specified, then directories will be excluded from consideration if they match any of the provided globs. The directory traversal will not enter such directories at all, and so files nested within them are ignored, even if they would otherwise be included.

--size-limit=<bytes>

If a size limit is specified, then files whose size on disk is greater than the limit will not be reported. The size is given in bytes, though suffixes of “k”, “m” or “g” can be used to select kilobytes, megabytes, or gigabytes respectively.

Follow any symbolic links to their targets.

Common options

-h, --help

Show this help text.

-J=<opt>

[Advanced] Give option to the JVM running the command.

(Beware that options containing spaces will not be handled correctly.)

-v, --verbose

Incrementally increase the number of progress messages printed.

-q, --quiet

Incrementally decrease the number of progress messages printed.

--verbosity=<level>

[Advanced] Explicitly set the verbosity level to one of errors, warnings, progress, progress+, progress++, progress+++. Overrides -v and -q.

--logdir=<dir>

[Advanced] Write detailed logs to one or more files in the given directory, with generated names that include timestamps and the name of the running subcommand.

(To write a log file with a name you have full control over, instead give --log-to-stderr and redirect stderr as desired.)