# Monitor ## Usage `snyk monitor []` ## Description The `snyk monitor` command creates a project in your Snyk account to be continuously monitored for open source vulnerabilities and license issues. After running this command, log in to the Snyk website and view your projects to see the monitor. For Snyk Container see [`snyk container` help](https://docs.snyk.io/snyk-cli/commands/container) For Snyk Infrastructure as Code follow the instructions in "Regularly testing IaC files" on [Snyk CLI for Infrastructure as Code](https://docs.snyk.io/products/snyk-infrastructure-as-code/snyk-cli-for-infrastructure-as-code) ## Exit codes Possible exit codes and their meaning: **0**: success, snapshot created\ **2**: failure, try to re-run command\ **3**: failure, no supported projects detected ## Configure the Snyk CLI You can use environment variables to configure the Snyk CLI and and set variables for connecting with the Snyk API. See [Configure the Snyk CLI](https://docs.snyk.io/features/snyk-cli/configure-the-snyk-cli) ## Debug Use the `-d` option to output the debug logs. ## Options See also subsequent sections for options for specific build environments, package managers, languages and `[]` which you specify last. ### `--all-projects` Auto-detect all projects in the working directory (including Yarn workspaces). For more information see the article [Does the Snyk CLI support monorepos or multiple manifest files?](https://support.snyk.io/hc/en-us/articles/360000910577-Does-the-Snyk-CLI-support-monorepos-or-multiple-manifest-files-) ### `--detection-depth=` Use with `--all-projects` or `--yarn-workspaces` to indicate how many subdirectories to search. `DEPTH` must be a number, `1` or greater; zero (0) is the current directory. Default: 4, the current working directory (0) and 4 subdirectories. Example: `--detection-depth=3` limits search to the specified directory (or the current directory if no `` is specified) plus three levels of subdirectories; zero (0) is the current directory. ### `--exclude=[,]...>` Can be used with `--all-projects` and `--yarn-workspaces` to indicate directory names and file names to exclude. Must be comma separated. Example: `$ snyk test --all-projects --exclude=dir1,file2` This will exclude any directories and files named "dir1" and "file2" when scanning for project manifest files. Such as: "./dir1", "./src/dir1", "./file2", "./src/file2", and so on. ### `--prune-repeated-subdependencies`, `-p` Prune dependency trees, removing duplicate sub-dependencies. Continues to find all vulnerabilities, but may not find all of the vulnerable paths. ### `--print-deps` Print the dependency tree before sending it for analysis. ### `--remote-repo-url=` Set or override the remote URL for the repository that you would like to monitor. ### `--dev` Include development-only dependencies. Applicable only for some package managers, for example, `devDependencies` in npm or `:development` dependencies in Gemfile. Default: scan only production dependencies. ### `--org=` Specify the `` to run Snyk commands tied to a specific organization. The `` influences some features availability and private test limits. If you have multiple organizations, you can set a default from the CLI using: `$ snyk config set org=` Set a default to ensure all newly monitored projects are created under your default organization. If you need to override the default, use the `--org=` option. Default: `` that is the current preferred organization in your [Account settings](https://app.snyk.io/account) For more information see the article [How to select the organization to use in the CLI](https://support.snyk.io/hc/en-us/articles/360000920738-How-to-select-the-organization-to-use-in-the-CLI) ### `--file=` Specify a package file. When testing locally or monitoring a project, you can specify the file that Snyk should inspect for package information. When the file is not specified, Snyk tries to detect the appropriate file for your project. ### `--package-manager=` Specify the name of the package manager when the filename specified with the `--file=` option is not standard. This allows Snyk to find the file. Example: `$ snyk monitor --file=req.txt --package-manager=pip` ### `--unmanaged` For C++ only, scan all files for known open source dependencies. For options you can use with `--unmanaged` see [Options for scanning using `--unmanaged`](https://docs.snyk.io/snyk-cli/commands/monitor#options-for-scanning-using-unmanaged)\`\` For more information see [Snyk for C/C++](https://docs.snyk.io/products/snyk-open-source/language-and-package-manager-support/snyk-for-c-c++)\`\` ### `--ignore-policy` Ignore all set policies, the current policy in the `.snyk` file, org level ignores, and the project policy on snyk.io. ### `--trust-policies` Apply and use ignore rules from the Snyk policies your dependencies; otherwise ignore rules in the dependencies are only shown as a suggestion. ### `--project-name=` Specify a custom Snyk project name. Example: `$ snyk monitor --project-name=my-project` ### `--target-reference=` Specify a reference which differentiates this project, for example, a branch name or version. Projects having the same reference can be grouped based on that reference. Supported for Snyk Open Source and use with `--unmanaged`. For more information see [Separating projects by branch or version](https://docs.snyk.io/snyk-cli/secure-your-projects-in-the-long-term/grouping-projects-by-branch-or-version) ### `--policy-path=` Manually pass a path to a `.snyk` policy file. ### `--json` Print results in JSON format. ### `--project-environment=[,]...>` Set the project environment project attribute to one or more values (comma-separated). To clear the project environment set `--project-environment=` Allowed values: `frontend, backend, internal, external, mobile, saas, onprem, hosted, distributed` For more information see [Project attributes](https://docs.snyk.io/getting-started/introduction-to-snyk-projects/view-project-information/project-attributes) ### `--project-lifecycle=[,]...>` Set the project lifecycle project attribute to one or more values (comma-separated). To clear the project lifecycle set `--project-lifecycle=` Allowed values: `production, development, sandbox` For more information see [Project attributes](https://docs.snyk.io/getting-started/introduction-to-snyk-projects/view-project-information/project-attributes) ### `--project-business-criticality=[,]...>` Set the project business criticality project attribute to one or more values (comma-separated). To clear the project business criticality set `--project-business-criticality=` Allowed values: `critical, high, medium, low` For more information see [Project attributes](https://docs.snyk.io/getting-started/introduction-to-snyk-projects/view-project-information/project-attributes) ### `--project-tags=[,]...>` Set the project tags to one or more values (comma-separated key value pairs with an "=" separator), for example, `--project-tags=department=finance,team=alpha` To clear the project tags set `--project-tags=` ### `--tags=[,]...>` This is an alias for `--project-tags` ## Option for Maven projects For more information about Maven CLI options see [Snyk for Java and Kotlin](https://docs.snyk.io/products/snyk-open-source/language-and-package-manager-support/snyk-for-java-gradle-maven) ### `--scan-all-unmanaged` Auto-detect maven jars, aars, and wars in given directory. To monitor individually use `--file=` **Note**: Custom-built jar files, even with open source dependencies, are out of scope. ## Options for Gradle projects For more information about Gradle CLI options see [Snyk for Java and Kotlin](https://docs.snyk.io/products/snyk-open-source/language-and-package-manager-support/snyk-for-java-gradle-maven) ### `--sub-project=`, `--gradle-sub-project=` For Gradle "multi project" configurations, monitor a specific sub-project. ### `--all-sub-projects` For "multi project" configurations, monitor all sub-projects. ### `--configuration-matching=` Resolve dependencies using only configuration(s) that match the specified Java regular expression. Example: `^releaseRuntimeClasspath$` ### `--configuration-attributes=[,]...` Select certain values of configuration attributes to install dependencies and perform dependency resolution. Example: `buildtype:release,usage:java-runtime` ### `--init-script=` When monitoring a .NET project, use this option to add a custom prefix to the name of files inside a project along with any desired separators. Example: `snyk monitor --file=my-project.sln --project-name-prefix=my-group/` This is useful when you have multiple projects with the same name in other `.sln` files. ## Option for npm projects ### `--strict-out-of-sync=true|false` Control monitoring out-of-sync lockfiles. Default: true ## Options for Yarn projects ### `--strict-out-of-sync=true|false` Control monitoring out-of-sync lockfiles. Default: true ### `--yarn-workspaces` Detect and scan Yarn workspaces. You can specify how many sub-directories to search using `--detection-depth` and exclude directories and files using `--exclude`. Alternatively scan Yarn workspaces with other projects using `--all-projects` ## Option for CocoaPods projects ### `--strict-out-of-sync=true|false` Control monitoring out-of-sync lockfiles. Default: false ## Options for Python projects ### `--command=` Indicate which specific Python commands to use based on Python version. The default is `python` which executes your default python version. Run 'python -V' to find out what version it is. If you are using multiple Python versions, use this parameter to specify the correct Python command for execution. Default: `python` Example: `--command=python3` ### `--skip-unresolved=true|false` Allow skipping packages that are not found in the environment. ## Options for scanning using `--unmanaged` The following `snyk monitor` options can be used with `--unmanaged` as documented in this help. `--org=` `--json` `--remote-repo-url=` `--target-reference=` There are also special options. ### `--target-dir` Scan the path specified in the argument instead of the current directory. Alternatively, run `snyk test --unmanaged` ### `--max-depth` Specify the maximum level of archive extraction. Usage: `--max-depth=1` Use 0 to disable archive extraction completely. ### `--print-dep-paths` Display dependencies. Use use this option to see what files contributed to each dependency identified. To see how confident Snyk is about the identified dependency and its version, use the `--print-deps` or `--print-dep-paths` option. For more information on uses of CLI options for C/C++ projects see [Snyk for C / C++](https://docs.snyk.io/products/snyk-open-source/language-and-package-manager-support/snyk-for-c-c++) ### `--project-name=c-project` Use with the `snyk monitor --unmanaged` command to override the default name Snyk gives your snapshots by entering the desired name. ## Options for build tools ### `-- []` Use a double dash (`--`) after the complete Snyk command to pass options (arguments, flags) that follow directly to the build tool, for example Gradle or Maven. The format is `snyk -- []` Example: `snyk monitor -- --build-cache`