Skip to content

Conversation

@ahmed-ramzi
Copy link
Contributor

@ahmed-ramzi ahmed-ramzi commented Sep 29, 2025

📦 PNPM Audit Resolver Integration

This PR introduces @knime/pnpm-audit-resolver, a utility that helps manage temporary security audit exceptions in PNPM projects. It is mainly for the CVEs that has no patch version released yet.

🔍 What it does
• Reads an audit-resolve.json file in the project root.
• Applies ignore rules for vulnerabilities (GHSA IDs) with a defined expiration.
• Automatically removes expired ignores so that exceptions don’t live longer than intended.
• Updates package.json to keep pnpm.auditConfig.ignoreGhsas in sync with valid rules.

✅ Benefits
• Ensures security ignores are time-bound and enforced automatically.
• Reduces the risk of forgotten audit exceptions.
• Keeps the audit process clean and reliable in CI/CD pipelines.

🛠️ Usage
1. Add an audit-resolve.json with decisions + expiration timestamps.
2. Run the resolver via pnpm audit:resolve.
Example audit-resolve.json:

{
  "GHSA-1234-abcd-wxyz": {
    "decision": "ignore",
    "expiresAt": 1726923450122
  }
}

HUB-9924 (Implement a pnpm audit resolver script)
Copilot AI review requested due to automatic review settings September 29, 2025 14:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new package @knime/pnpm-audit-resolver that automates the management of temporary security audit exceptions in PNPM projects by reading audit rules from a configuration file and automatically expiring them based on timestamps.

  • Adds a utility that processes audit-resolve.json configurations with time-bound security ignores
  • Automatically removes expired GHSA ignores from package.json audit configuration
  • Provides a command-line tool for integration into CI/CD pipelines

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/pnpm-audit-resolver/src/index.js Main implementation that reads audit configurations and updates package.json
packages/pnpm-audit-resolver/package.json Package configuration with scripts and binary definitions
packages/pnpm-audit-resolver/README.md Documentation explaining usage and configuration format
packages/pnpm-audit-resolver/LICENSE GPL v3 license with additional KNIME permissions
packages/pnpm-audit-resolver/CHANGELOG.md Empty changelog file for the new package
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

try {
auditResolveRaw = await fs.readFile(auditResolvePath, "utf-8");
} catch {
throw "Could not find 'audit-resolve.json' file in your root directory";
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing a string is not recommended. Use a proper Error object instead: throw new Error(\"Could not find 'audit-resolve.json' file in your root directory\");

Suggested change
throw "Could not find 'audit-resolve.json' file in your root directory";
throw new Error("Could not find 'audit-resolve.json' file in your root directory");

Copilot uses AI. Check for mistakes.
{
"name": "@knime/pnpm-audit-resolver",
"version": "1.0.0",
"description": "Resolves audit issues be defining actions to it",
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammatical error in description. Should be 'by defining actions for them' instead of 'be defining actions to it'.

Suggested change
"description": "Resolves audit issues be defining actions to it",
"description": "Resolves audit issues by defining actions for them",

Copilot uses AI. Check for mistakes.
}
},
"bin": {
"audit-resolve": "./src/index.js"
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binary entry points to a file that lacks a shebang line. Add #!/usr/bin/env node as the first line of src/index.js to make it executable as a binary.

Copilot uses AI. Check for mistakes.
throw "Could not find 'audit-resolve.json' file in your root directory";
}

const auditData = JSON.parse(auditResolveRaw);
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.parse can throw if the file contains invalid JSON. Wrap this in a try-catch block to provide a more helpful error message for malformed audit-resolve.json files.

Suggested change
const auditData = JSON.parse(auditResolveRaw);
let auditData;
try {
auditData = JSON.parse(auditResolveRaw);
} catch (err) {
throw new Error(
"Malformed 'audit-resolve.json': " + err.message
);
}

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +22
const packageJsonRaw = await fs.readFile(packageJsonPath, "utf-8");
const packageJson = JSON.parse(packageJsonRaw);
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error handling for reading and parsing package.json. These operations can fail if the file doesn't exist or contains invalid JSON.

Suggested change
const packageJsonRaw = await fs.readFile(packageJsonPath, "utf-8");
const packageJson = JSON.parse(packageJsonRaw);
let packageJsonRaw;
try {
packageJsonRaw = await fs.readFile(packageJsonPath, "utf-8");
} catch {
throw "Could not find 'package.json' file in your root directory";
}
let packageJson;
try {
packageJson = JSON.parse(packageJsonRaw);
} catch {
throw "Could not parse 'package.json': invalid JSON format";
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants