{"meta":{"title":"database index-files","intro":"[Plumbing] Index standalone files with a given CodeQL extractor.","product":"Security and code quality","breadcrumbs":[{"href":"/en/code-security","title":"Security and code quality"},{"href":"/en/code-security/reference","title":"Reference"},{"href":"/en/code-security/reference/code-scanning","title":"Code scanning"},{"href":"/en/code-security/reference/code-scanning/codeql","title":"CodeQL"},{"href":"/en/code-security/reference/code-scanning/codeql/codeql-cli-manual","title":"CodeQL CLI manual"},{"href":"/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-index-files","title":"database index-files"}],"documentType":"article"},"body":"# database index-files\n\n\\[Plumbing] Index standalone files with a given CodeQL extractor.\n\n> \\[!NOTE]\n> This content describes the most recent release of the CodeQL CLI. For more information about this release, see <https://github.com/github/codeql-cli-binaries/releases>.\n>\n> To see details of the options available for this command in an earlier release, run the command with the <span style=\"white-space: nowrap;\">`--help`</span> option in your terminal.\n\n## Synopsis\n\n```shell copy\ncodeql database index-files --language=<lang> [--threads=<num>] [--ram=<MB>] [--extractor-option=<extractor-option-name=value>] <options>... -- <database>\n```\n\n## Description\n\n\\[Plumbing] Index standalone files with a given CodeQL extractor.\n\nThis command selects a set of files under the specified working\ndirectory, and applies the given extractor to them. By default, all\nfiles are selected. Typical invocations will specify options to restrict\nthe set of included files.\n\nThe `--include`, `--exclude`, and `--prune` options all take glob\npatterns, which can use the following wildcard characters:\n\n* A single \"?\" matches any character other than a forward/backward\n  slash;\n* A single \"\\*\" matches any number of characters other than a\n  forward/backward slash;\n* The pattern \"\\*\\*\" matches zero or more complete directory\n  components.\n\n## Options\n\n### Primary Options\n\n#### `<database>`\n\n\\[Mandatory] Path to the CodeQL database under construction. This must\nhave been prepared for extraction with [codeql database init](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-init).\n\n#### `-l, --language=<lang>`\n\n\\[Mandatory] The extractor that should be used to index matching files.\n\n#### `-j, --threads=<num>`\n\nAsk the extractor to use this many threads. This option is passed to the\nextractor as a suggestion. If the CODEQL\\_THREADS environment variable is\nset, the environment variable value takes precedence over this option.\n\nYou can pass 0 to use one thread per core on the machine, or -*N* to\nleave *N* cores unused (except still use at least one thread).\n\n#### `-M, --ram=<MB>`\n\nAsk the extractor to use this much memory. This option is passed to the\nextractor as a suggestion. If the CODEQL\\_RAM environment variable is\nset, the environment variable value takes precedence over this option.\n\n#### `--working-dir=<dir>`\n\n\\[Advanced] The directory in which the specified command should be\nexecuted. If this argument is not provided, the command is executed in\nthe value of `--source-root` passed to [codeql database create](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-create), if one exists. If no `--source-root` argument is provided, the command is executed in the\ncurrent working directory.\n\n### Options to control extractor behavior\n\n#### `-O, --extractor-option=<extractor-option-name=value>`\n\nSet options for CodeQL extractors. `extractor-option-name` should be of\nthe form extractor\\_name.group1.group2.option\\_name or\ngroup1.group2.option\\_name. If `extractor_option_name` starts with an\nextractor name, the indicated extractor must declare the option\ngroup1.group2.option\\_name. Otherwise, any extractor that declares the\noption group1.group2.option\\_name will have the option set. `value` can\nbe any string that does not contain a newline.\n\nYou can use this command-line option repeatedly to set multiple\nextractor options. If you provide multiple values for the same extractor\noption, the behavior depends on the type that the extractor option\nexpects. String options will use the last value provided. Array options\nwill use all the values provided, in order. Extractor options specified\nusing this command-line option are processed after extractor options\ngiven via `--extractor-options-file`.\n\nWhen passed to [codeql database init](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-init) or `codeql database begin-tracing`, the options will only be\napplied to the indirect tracing environment. If your workflow also makes\ncalls to\n[codeql database trace-command](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-trace-command) then the options also need to be passed there if desired.\n\nSee <https://codeql.github.com/docs/codeql-cli/extractor-options> for\nmore information on CodeQL extractor options, including how to list the\noptions declared by each extractor.\n\n#### `--extractor-options-file=<extractor-options-bundle-file>`\n\nSpecify extractor option bundle files. An extractor option bundle file\nis a JSON file (extension `.json`) or YAML file (extension `.yaml` or\n`.yml`) that sets extractor options. The file must have the top-level\nmap key 'extractor' and, under it, extractor names as second-level map\nkeys. Further levels of maps represent nested extractor groups, and\nstring and array options are map entries with string and array values.\n\nExtractor option bundle files are read in the order they are specified.\nIf different extractor option bundle files specify the same extractor\noption, the behavior depends on the type that the extractor option\nexpects. String options will use the last value provided. Array options\nwill use all the values provided, in order. Extractor options specified\nusing this command-line option are processed before extractor options\ngiven via `--extractor-option`.\n\nWhen passed to [codeql database init](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-init) or `codeql database begin-tracing`, the options will only be\napplied to the indirect tracing environment. If your workflow also makes\ncalls to\n[codeql database trace-command](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-trace-command) then the options also need to be passed there if desired.\n\nSee <https://codeql.github.com/docs/codeql-cli/extractor-options> for\nmore information on CodeQL extractor options, including how to list the\noptions declared by each extractor.\n\n### Options for limiting the set of indexed files\n\n#### `--include-extension=<.ext>`\n\nInclude all files in the search directory tree that have the given\nextension. Typically, you should include the dot before the extension.\nFor example, passing `--include-extension .xml` will include all files\nwith the \".xml\" extension. This option is incompatible with negated\n`--include` options.\n\n#### `--include=<glob>`\n\nInclude all files and directories in the search directory tree that\nmatch the given glob, using each file and directory's relative path\nfrom the search directory. If the glob begins with a `!` character, the\nmatching files and directories would instead be excluded.\n\n`--include` options are processed in order, with later options\noverriding earlier ones. For example,\n`--include ** --include !sub/*.ts --include sub/main.*` would include\n`sub/main.ts` (because it is included by `sub/main.*`), exclude\n`sub/index.ts` (because it is excluded by `!sub/*.ts`), and include\n`sub/test.js` (because it is included by `**` without being subsequently\nexcluded.)\n\n#### `--also-match=<glob>`\n\nRequire all results to also match the given glob, using each file and\ndirectory's relative path from the search directory. This option has\nthe same structure and the same interpretation as `--include` but\nspecifies a separate sequence of globs that are applied in conjunction\nwith `--include`.\n\n#### `--exclude=<glob>`\n\nExclude all files and directories that match the given glob, using each\nfile and directory's relative path from the search directory. This\noption overrides all include options. This option is incompatible with\nnegated `--include` options.\n\n#### `--prune=<glob>`\n\nExclude all files and directories that match the given glob, using each\nfile and directory's relative path from the search directory. This\noption overrides all include options. This option is incompatible with\nnegated `--include` options.\n\n#### `--size-limit=<bytes>`\n\nExclude all files whose size exceeds the given limit. The size limit is\nin bytes, or in kibibytes (KiB) with the \"k\" suffix, in mebibytes\n(MiB) with the \"m\" suffix, and in gibibytes (GiB) with the \"g\"\nsuffix. This option overrides all include options.\n\n#### `--total-size-limit=<bytes>`\n\nMake the command exit with an error if the combined size of all resolved\nfiles would exceed the given limit. The size limit is in bytes, or in\nkibibytes (KiB) with the \"k\" suffix, in mebibytes (MiB) with the \"m\"\nsuffix, and in gibibytes (GiB) with the \"g\" suffix.\n\n#### `--[no-]follow-symlinks`\n\nFollow any symbolic links to their targets.\n\n#### `--[no-]find-any`\n\nFind at most one match (as opposed to all matches).\n\nAvailable since `v2.11.3`.\n\n### Common options\n\n#### `-h, --help`\n\nShow this help text.\n\n#### `-J=<opt>`\n\n\\[Advanced] Give option to the JVM running the command.\n\n(Beware that options containing spaces will not be handled correctly.)\n\n#### `-v, --verbose`\n\nIncrementally increase the number of progress messages printed.\n\n#### `-q, --quiet`\n\nIncrementally decrease the number of progress messages printed.\n\n#### `--verbosity=<level>`\n\n\\[Advanced] Explicitly set the verbosity level to one of errors,\nwarnings, progress, progress+, progress++, progress+++. Overrides `-v`\nand `-q`.\n\n#### `--logdir=<dir>`\n\n\\[Advanced] Write detailed logs to one or more files in the given\ndirectory, with generated names that include timestamps and the name of\nthe running subcommand.\n\n(To write a log file with a name you have full control over, instead\ngive `--log-to-stderr` and redirect stderr as desired.)\n\n#### `--common-caches=<dir>`\n\n\\[Advanced] Controls the location of cached data on disk that will\npersist between several runs of the CLI, such as downloaded QL packs and\ncompiled query plans. If not set explicitly, this defaults to a\ndirectory named `.codeql` in the user's home directory; it will be\ncreated if it doesn't already exist.\n\nAvailable since `v2.15.2`."}