Registry / devops / snyk-mvn-plugin

snyk-mvn-plugin

JSON →
library4.6.1jsnpmunverified

The `snyk-mvn-plugin` is an internal JavaScript/TypeScript component primarily designed to be used by the Snyk CLI tool. Its core function is to analyze Maven project dependencies by inspecting `pom.xml` files and archive files (like JAR/WAR) to build detailed dependency graphs. It supports optional inclusion of test-scoped dependencies, provides verbose output for comprehensive version resolution, and can generate cryptographic artifact fingerprints for supply chain integrity. The current stable version is 4.6.1, released on 2026-03-23, with a frequent release cadence indicating active development and continuous feature enhancements and bug fixes. This plugin is distinct from the `snyk-maven-plugin`, which is a native Maven plugin for integrating Snyk tasks directly into a Maven build process. This package specifically focuses on providing dependency metadata to the Snyk CLI for vulnerability scanning and requires Node.js 20 or higher for execution.

npm install snyk-mvn-plugin
INSTALL
IMPORT
SIG · SNYK-MVN-PLUGIN
S
snyk-mvn-plugin
devopsjavascriptv4.6.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

inspect
import { inspect } from 'snyk-mvn-plugin';
const { inspect } = require('snyk-mvn-plugin');
The package primarily exports an `inspect` function. As of Node.js 20+ requirement, it is best used with ESM `import` syntax. Direct `require` might fail if the package is pure ESM.
MavenOptions
import type { MavenOptions } from 'snyk-mvn-plugin';
For TypeScript users, import `MavenOptions` (and potentially `InspectResult` or other types) for type safety when configuring the `inspect` function.

Demonstrates how to use the `inspect` function to analyze a Maven `pom.xml` file, including options for provenance and algorithm selection.

import { inspect } from 'snyk-mvn-plugin'; import * as path from 'path'; import * as fs from 'fs'; async function runSnykMavenInspection() { const projectRoot = process.cwd(); // Assume running from project root const targetPom = path.join(projectRoot, 'pom.xml'); if (!fs.existsSync(targetPom)) { console.error(`Error: pom.xml not found at ${targetPom}`); console.error('Please ensure you run this from a Maven project root or specify targetFile.'); process.exit(1); } console.log(`Inspecting Maven project at: ${projectRoot}`); console.log(`Using target file: ${targetPom}`); try { const options = { dev: false, // Do not include development dependencies includeProvenance: true, // Generate cryptographic fingerprints for artifacts fingerprintAlgorithm: 'sha256', // Use SHA-256 for fingerprinting // mavenRepository: '/path/to/custom/repo' // Uncomment and adjust if you have a custom local Maven repository }; const result = await inspect(projectRoot, targetPom, options); console.log('Inspection complete.'); console.log(`Found ${result.pkgs ? result.pkgs.length : 0} packages.`); if (result.pkgs && result.pkgs.length > 0 && result.pkgs[0].info.purl) { console.log('First package PURL with checksum:', result.pkgs[0].info.purl); } // Uncomment the line below for full JSON output // console.log(JSON.stringify(result, null, 2)); } catch (error: any) { console.error('Error during inspection:', error.message); process.exit(1); } } runSnykMavenInspection();
Debug
Known issues
gotchaThis package (`snyk-mvn-plugin`) is an internal component intended for use by the Snyk CLI tool. It is not designed for standalone vulnerability scanning without the Snyk CLI. For direct Maven build integration, refer to the `snyk-maven-plugin`.
fix
Ensure the Snyk CLI is installed and configured if attempting to perform security analysis. If integrating with Maven builds, consider using `io.snyk:snyk-maven-plugin` directly in your `pom.xml`.
affects: >=1.0.0
breakingThe package explicitly requires Node.js v20 or higher, as indicated by its `engines` field. Running with older Node.js versions (e.g., v18) will result in runtime errors.
fix
Upgrade your Node.js environment to version 20 or newer. Use a Node.js version manager like `nvm` to easily switch versions.
affects: >=4.0.0
gotchaThe `inspect` function relies on a local Maven installation (or `mvnw` wrapper) being available in the environment and accessible in the system PATH to perform dependency resolution.
fix
Ensure Maven is installed and configured in your system's PATH, or that a `mvnw` executable exists and is runnable in your project's root directory.
affects: >=1.0.0
gotchaWhen enabling `includeProvenance` for artifact fingerprinting, the Maven artifacts must already be downloaded and available in the configured local or custom Maven repository. The plugin does not perform artifact downloads itself.
fix
Run a standard Maven build command (e.g., `mvn install` or `mvn dependency:resolve`) beforehand to ensure all necessary artifacts are present in your local Maven repository.
affects: >=4.3.0
breakingVersions prior to `2.31.3` (specifically `2.2.0` to `2.31.2`) were vulnerable to Command Injection (CVE-2022-40764, CVE-2022-22984) due to an incomplete fix. This could allow attackers to run arbitrary commands on the host system, particularly in CI/CD pipelines.
fix
Upgrade to `snyk-mvn-plugin` version `2.31.3` or higher immediately. For CI/CD environments, ensure Snyk Docker images are updated as of 2022-11-29 or later.
affects: <2.31.3
Errors
Common errors & fixes
Error: Cannot find module 'snyk-mvn-plugin' or its corresponding type declarations.
The package is not installed in the project or the import path is incorrect.
fix
Install the package using `npm install snyk-mvn-plugin` or `yarn add snyk-mvn-plugin`. Verify the import path is exactly `snyk-mvn-plugin`.
Error: Must be run with Node.js version >= 20.0.0
The Node.js version in use is older than the minimum required by the package.
fix
Upgrade your Node.js environment to version 20 or newer. Use a Node.js version manager (like `nvm` or `volta`) to manage different Node.js versions.
Error: Command failed: mvn -B dependency:tree
The Maven executable (`mvn` or `mvnw`) was not found in the system PATH or is not accessible, preventing dependency tree analysis.
fix
Ensure that Maven is installed on your system and its binary directory is added to your system's PATH environment variable. Alternatively, ensure `mvnw` is present and executable in the project root.
TypeError: inspect is not a function
Attempting to use a CommonJS `require` syntax with an ESM-only package, or incorrect named import for an ESM module.
fix
Use ESM `import { inspect } from 'snyk-mvn-plugin';` syntax. Ensure your project's `package.json` specifies `"type": "module"` if it's a pure ESM project, or use a bundler that correctly handles ESM/CJS interop.
Upgrade
Version history
4.6.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
15
OpenAI (training)
1
Resources