Registry / devops / snyk-delta

snyk-delta

JSON →
library1.13.2jsnpmunverified

snyk-delta is a command-line interface tool designed to identify and report only *newly introduced* security vulnerabilities, license issues, and code findings in Snyk projects. It functions by comparing a current Snyk scan snapshot against a predefined baseline snapshot, making it particularly useful for integration into CI/CD pipelines, pre-commit hooks, or local development workflows where only changes since a previous state are of interest. The tool is currently at version 1.13.2 and is in maintenance mode, meaning new features are not being actively developed, though bug fixes and security patches continue to be released. Key differentiators include its ability to filter out pre-existing issues, focus on dependency changes (added/removed direct and indirect dependencies), and provide specific exit codes for automated decision-making in build systems. It supports Snyk Open Source, Container, and Code (with specific feature requirements), but not IaC.

npm install snyk-delta
INSTALL
IMPORT
SIG · SNYK-DELTA
S
snyk-delta
devopsjavascriptv1.13.2
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.

run
import { run } from 'snyk-delta';
const run = require('snyk-delta').run;
Primarily for programmatic execution of the CLI's main logic, though `snyk-delta` is most commonly run directly as a command-line utility.
getOssDelta
import { getOssDelta } from 'snyk-delta';
import { ossDelta } from 'snyk-delta';
Exports the core logic for comparing Open Source and Container vulnerability deltas. This function facilitates programmatic integration for custom analyses.
getCodeDelta
import { getCodeDelta } from 'snyk-delta';
const codeDelta = require('snyk-delta').codeDelta;
Provides the programmatic interface for comparing Snyk Code SARIF outputs to identify new code analysis findings. Requires 'Code Consistent Ignores' feature.
SnykDeltaOptions
import type { SnykDeltaOptions } from 'snyk-delta';
TypeScript type definition for the configuration options used by snyk-delta's core comparison functions, such as baseline organization and project details.

Demonstrates programmatic usage of `getCodeDelta` to compare two local SARIF files, illustrating how to identify new Snyk Code findings and exit with appropriate status codes based on the comparison result. Requires `SNYK_TOKEN` and `SNYK_ORG_ID`.

import { getCodeDelta } from 'snyk-delta'; import * as fs from 'fs'; import * as path from 'path'; const SNYK_TOKEN = process.env.SNYK_TOKEN ?? ''; // Ensure SNYK_TOKEN is set const ORG_ID = process.env.SNYK_ORG_ID ?? 'YOUR_SNYK_ORG_ID'; // Replace with your Snyk Organization ID async function compareSnykCodeResults() { if (!SNYK_TOKEN || ORG_ID === 'YOUR_SNYK_ORG_ID') { console.error('Error: Please set SNYK_TOKEN and SNYK_ORG_ID environment variables or replace placeholder.'); process.exit(1); } // Create dummy SARIF files for demonstration if they don't exist const baselineSarifPath = path.join(__dirname, 'baseline.sarif.json'); const currentSarifPath = path.join(__dirname, 'current.sarif.json'); if (!fs.existsSync(baselineSarifPath)) { fs.writeFileSync(baselineSarifPath, JSON.stringify({"runs": []}, null, 2)); } if (!fs.existsSync(currentSarifPath)) { // In a real scenario, this would be generated by `snyk code test --sarif > current.sarif.json` fs.writeFileSync(currentSarifPath, JSON.stringify({"runs": []}, null, 2)); } try { const options = { baselineOrg: ORG_ID, // Optional: target a specific baseline project, otherwise `snyk-delta` attempts to find one // baselineProject: 'your-baseline-project-uuid', // Optional: recommended for Code Analysis projects // projectName: 'owner/repo', // targetReference: 'main', // api: 'https://api.snyk.io/api/v1', // Snyk API endpoint, default value }; console.log('Comparing Snyk Code results...'); const deltaReport = await getCodeDelta(baselineSarifPath, currentSarifPath, options, SNYK_TOKEN); if (deltaReport.newFindings.length > 0) { console.log(`\nFound ${deltaReport.newFindings.length} new code findings:\n`); deltaReport.newFindings.forEach(finding => { const location = finding.locations[0]?.physicalLocation; const filePath = location?.artifactLocation?.uri || 'unknown file'; const lineNumber = location?.region?.startLine || 'unknown line'; console.log(` - [${finding.ruleId}] ${finding.message.text} (${filePath}:${lineNumber})`); }); process.exit(1); // Exit with 1 if new findings are present } else { console.log('\nNo new code findings introduced. Exiting with 0.'); process.exit(0); // Exit with 0 if no new findings } } catch (error) { console.error('An error occurred during delta comparison:', error); process.exit(2); // Exit with 2 on error } } compareSnykCodeResults();
snyk-delta --version
Debug
Known issues
gotchaThe `snyk-delta` repository is in maintenance mode. No new features are being developed; only bug and security fixes will be delivered. Contributions for small features are welcome, but breaking changes will not be accepted.
fix
Be aware that the tool's functionality will remain stable, but new capabilities aligning with future Snyk product developments may not be implemented directly within this tool.
affects: >=1.0.0
breakingUse of `snyk-delta` requires a Snyk Business or Enterprise account due to its reliance on Snyk API access for baseline comparisons. Free or Developer accounts are not supported.
fix
Ensure your Snyk account is at the Business or Enterprise tier. Refer to Snyk documentation for account plan details and feature parity.
affects: >=1.0.0
gotchaThe `SNYK_TOKEN` environment variable must be set with a valid Snyk API token, preferably from a service account. Failure to do so will result in authentication errors during API calls.
fix
Set the `SNYK_TOKEN` environment variable in your environment (e.g., `export SNYK_TOKEN=your-token`) before running `snyk-delta`. Obtain a service account token for CI/CD environments for enhanced security and manageability.
affects: >=1.0.0
gotchaSnyk IaC (Infrastructure as Code) scanning is explicitly not supported by `snyk-delta`. Attempting to use it for IaC will result in an error or incorrect behavior.
fix
Do not use `snyk-delta` for Snyk IaC projects. This tool is specifically designed for Open Source, Container, and Code findings. Consider alternative methods for delta comparison of IaC findings if available within the Snyk platform.
affects: >=1.0.0
gotchaFor Snyk Code comparison, the 'Code Consistent Ignores' feature must be enabled in your Snyk organization. Without this feature, the Code delta functionality may not work as expected or produce unreliable results.
fix
Verify and enable the 'Code Consistent Ignores' feature in your Snyk organization settings. Consult Snyk documentation for instructions on feature enablement and its impact on Snyk Code scans.
affects: >=1.0.0
Errors
Common errors & fixes
Error: SNYK_TOKEN environment variable not set. Please set the SNYK_TOKEN environment variable.
The required Snyk API token is missing from the environment variables, preventing authentication with the Snyk API.
fix
Set `SNYK_TOKEN` (e.g., `export SNYK_TOKEN="your_snyk_api_token"`) in your shell or CI/CD environment before executing `snyk-delta`.
Error: Could not find project with ID <project-uuid> in organization <org-uuid>.
The specified `--baselineProject` or `--baselineOrg` ID does not match an existing Snyk project or organization, or the `SNYK_TOKEN` lacks the necessary permissions to access them.
fix
Double-check the Snyk Organization and Project IDs for accuracy. Ensure the provided `SNYK_TOKEN` has the required read permissions for the specified resources.
Error: Snyk Code comparison requires 'Code Consistent Ignores' feature enabled in your Snyk organization.
The Snyk organization where the project resides does not have the 'Code Consistent Ignores' feature enabled, which is a prerequisite for accurate Snyk Code delta comparisons.
fix
Enable 'Code Consistent Ignores' in your Snyk Organization settings. Refer to Snyk documentation or contact Snyk support for assistance in enabling this feature.
Error: Unsupported Snyk product type for delta comparison: IaC.
The `snyk-delta` tool was executed with a Snyk Infrastructure as Code (IaC) project, a product type it explicitly does not support.
fix
Refrain from using `snyk-delta` for IaC projects. This tool's functionality is limited to Open Source, Container, and Code vulnerability types.
Upgrade
Version history
1.13.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
18
OpenAI (training)
1
Resources
snyk-delta — npm install snyk-delta · libregistry