Skip to main content
The SCANOSS pre-commit hook runs just before your changes are committed, triggering automated checks to detect undeclared open-source components. This shift-left approach helps catch compliance issues early in the development process.

Installation

Getting Started

Configure the Hook

Create .pre-commit-config.yaml at the root of your repository:

Verify Configuration

Install the Hook

Test the Hook

Configuration

Environment Variables

The hook automatically loads variables from a .env file in your project root:

How It Works

Example Workflow

Given this project structure:
When you commit:
The hook automatically:
  1. Scans staged files for open-source components
  2. Compares detected components against your scanoss.json declarations
  3. Blocks the commit if undeclared components are found

Example Output

The commit is blocked until you either:
  1. Declare the components in scanoss.json
  2. Run scanoss-cc in the terminal to review and declare the components
  3. Remove the problematic code

Troubleshooting

Enable Debug Mode

Method 1: Environment Variable
Method 2: .env File
Method 3: Command-Line Argument