UNPKG

@candrewsintegralblue/snyk

Version:

snyk library and cli utility

226 lines (114 loc) 8.19 kB
# Deps ## Usage `snyk client-sbom [<OPTIONS>]` ## Description The `snyk client-sbom` command outputs dependencies of projects. The client-sbom command tries to auto-detect supported manifest files with dependencies and analyze those. ## Exit codes Possible exit codes and their meaning: **0**: success, dependencies determined\ **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 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 `[<CONTEXT-SPECIFIC OPTIONS>]` 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-) ### `--fail-fast` Use with `--all-projects` to cause scans to be interrupted when errors occur and to report these errors back to the user. The exit code is 2 and the scan ends. No dependency information is reported for projects that did not produce errors. To perform the scan, resolve the error and scan again. Note: If you do not use `--fail-fast`, Snyk scans all the projects but does not report any dependencies for projects it could not scan due to misconfiguration or another error. ### `--detection-depth=<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 `<PATH>` is specified) plus three levels of subdirectories; zero (0) is the current directory. ### `--exclude=<NAME>[,<NAME>]...>` Can be used with `--all-projects` and `--yarn-workspaces` to indicate directory names and file names to exclude. Must be comma separated. Example: `$ snyk client-sbom --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 dependencies, but may not find all of the dependency paths. ### `--print-deps` Print the dependency tree. ### `--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. ### `--file=<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=<PACKAGE_MANAGER_NAME>` Specify the name of the package manager when the filename specified with the `--file=<FILE>` option is not standard. This allows Snyk to find the file. Example: `$ snyk client-sbom --file=req.txt --package-manager=pip` ### `--cyclonedx-json` Print dependencies in CycloneDX JSON format. Example: `$ snyk client-sbom --cyclonedx-json` ### `--cyclonedx-json-file-output=<OUTPUT_FILE_PATH>` Save CycloneDX dependencies output in JSON format directly to the specified file, regardless of whether or not you use the `--cyclonedx-json` option. This is useful if you want to display the human-readable dependency output using stdout and at the same time save the JSON format output to a file. Example: `$ snyk client-sbom --cyclonedx-json-file-output=bom.json` ## Options 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) ### `--maven-aggregate-project` Use `--maven-aggregate-project` instead of `--all-projects` when scanning Maven aggregate projects, that is, ones that use modules and inheritance. When scanning these types of projects, Snyk performs a compile to ensure all modules are resolvable by the Maven reactor.&#x20; Be sure to run the scan in the same directory as the root pom.xml file.&#x20; Snyk reports test results per pom.xml file. ### `--scan-all-unmanaged` Auto-detect maven jars, aars, and wars in given directory. To test individually use `--file=<JAR_FILE_NAME>` **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=<NAME>`, `--gradle-sub-project=<NAME>` For Gradle "multi project" configurations, test a specific sub-project. ### `--all-sub-projects` For "multi project" configurations, test all sub-projects. ### `--configuration-matching=<CONFIGURATION_REGEX>` Resolve dependencies using only configuration(s) that match the specified Java regular expression Example: `^releaseRuntimeClasspath$` ### `--configuration-attributes=<ATTRIBUTE>[,<ATTRIBUTE>]...` Select certain values of configuration attributes to install dependencies and perform dependency resolution. Example: `buildtype:release,usage:java-runtime` ### `--init-script=<FILE` Use for projects that contain a Gradle initialization script. ## Options for NuGet projects ### `--assets-project-name` When monitoring a .NET project using NuGet `PackageReference` use the project name in `project.assets.json` if found. ### `--packages-folder` Specify a custom path to the packages folder. ### `--project-name-prefix=<PREFIX_STRING>` 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 testing out-of-sync lockfiles. Default: true ## Options for Yarn projects ### `--strict-out-of-sync=true|false` Control testing 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 testing out-of-sync lockfiles. Default: false ## Options for Python projects ### `--command=<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 build tools ### `-- [<CONTEXT-SPECIFIC_OPTIONS>]` 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 <command> -- [<context-specific_options>]` Example: `snyk client-sbom -- --build-cache` ## Examples for the snyk client-sbom command Display dependencies of a project in the current folder: `$ snyk client-sbom`