Prerequisites
Before you begin, ensure you have:- Python 3.9 or later
- Git installed and configured
- Project directory to scan
- (Optional) SCANOSS API key for enterprise features
You can check if Python or Git is already installed by running these commands in your terminal or command prompt:
Install SCANOSS-PY and SCANOSS-CC
SCANOSS provides the following tools for local testing:Install SCANOSS-PY
Open your terminal or command prompt, then run: Standard Installation:Install SCANOSS-CC
Open your terminal (macOS/Linux) or PowerShell (Windows), and run the one that applies to your system. macOS / Linux:Configure API Access
While SCANOSS works without an API key, the free tier has usage limitations. To avoid hitting these limits, configure your API key before scanning.Add Your API Key
Add your API key to your shell profile:scanoss-py automatically detects the SCANOSS_API_KEY environment variable when set.
You can also pass the API key directly with --key $SCANOSS_API_KEY when running either tool.
Navigate to Your Project Directory
In your terminal navigate to the project you want to scan:package.json, pom.xml, requirements.txt, or similar project configuration files.
You can confirm you’re in the right place by running:
Run Your First Scan
You can run scans using either SCANOSS-PY (command-line) or SCANOSS-CC (desktop GUI).Using SCANOSS-PY (Command Line)
Basic Scan:-o option when running the scan.
If you’d like to include declared dependencies from manifest files (e.g. package.json, requirements.txt etc.), install the scancode-toolkit dependency and use the -D flag:
Using SCANOSS-CC (Desktop GUI)
Before scanning, configure your API credentials:- Click Run a new scan
- Make sure the Directory to scan points to your project’s root folder
- Click Start Scan
- When the scan finishes, you should see Scan completed successfully! in the Console Output.
- Exit the application
Understanding the Results
After running a scan, SCANOSS generates aresults.json file containing all detected open source code in your project.
Component Identification:
- component: Name of the detected open source component
- file: The file in your project where open source code was detected
- file_hash: Unique identifier for the exact file content
- id: Match type - how the code was detected:
snippet- Part of a file matches known open source codefile- An entire file matches a known component
- matched: Similarity percentage
- lines: Line range in your file where the match was found
- oss_lines: Corresponding line range in the original open source component
- status: Current state of the finding:
pending- Newly detected, needs your reviewidentified- Properly documented in yourscanoss.json
- vendor: Component maintainer or organisation
- version: Detected version
- latest: Most recent available version
- url: Repository URL
- purl: Package URL
- release_date: When this version was released
- name: License identifier
- copyleft: Whether derivative works must use the same license
- patent_hints: Whether license contains patent clauses
- source: Where license was detected:
component_declared- From the component’s metadatafile_spdx_tag- From SPDX tags in the filelicense_file- From a LICENSE filefile_header- From file header comments
- incompatible_with: Licenses that conflict with this one
- url: Link to SPDX license definition
- checklist_url: Link to OSADL compliance checklist
- copyrights: Copyright statements found in the code
- cryptography: Cryptographic algorithms detected
- dependencies: Dependencies declared in the component
- health: Repository health metrics
- quality: Code quality scores
- vulnerabilities: Known CVEs affecting this component
"status": "pending" requires a decision. Review the match and decide:
- Include it in your
scanoss.jsonto declare intentional use - Dismiss it if it’s a false positive or your own code
- Replace it if the license is incompatible with your project
Declare Components
After reviewing scan results, you need to make decisions about detected components. Choose your workflow based on how you scanned:SCANOSS-CC
Make sure you’re in your project directory where the scan results are located:.scanoss/results.json in the current directory.
Launch SCANOSS-CC to review results and make decisions interactively:
- Review Results: View side-by-side code comparisons showing your code matched against the detected open source component
- Make Decisions: Use the action icons at the top of the dashboard to:
- Include: Accept and declare the component as an intentional dependency
- Dismiss: Mark as false positive or your own code
- Replace: Flag for replacement with alternative code or different license
- Save Changes: Your decisions are saved to
scanoss.jsonat your project root. Future scans will remember these decisions.
SCANOSS-PY
You need to manually create ascanoss.json file at your project root.
Step 1: Identify Undeclared Components
Use the inspect command to find components that need to be declared:
scanoss.json:
scanoss.json file in your project root directory (the same directory you scanned).
Add the self section with your project information and expand the bom.include entries with comments:
scanoss.json settings:
Setup Pre-Commit Hooks
SCANOSS Pre-Commit Hooks ensures that before you push any code to your repository, SCANOSS automatically checks for undeclared open source components. This shift-left approach helps you catch compliance issues early in the development process, before code reaches your team or production.Install Pre-Commit Framework
Open your terminal or command prompt and install the pre-commit framework:Configure the Hook
Navigate to your project root directory and create a new file named.pre-commit-config.yaml.
Add the following configuration to the file:
Install the Hook
In your terminal, while still in your project directory, run:.git/hooks directory. Once installed, the hook runs automatically before every git commit.
You should see output like:
Configure .gitignore
Before committing, you need to configure your.gitignore file to exclude SCANOSS generated files from version control.
Open your .gitignore file (or create one if it doesn’t exist) in your project root and add:
Configure Environment Variables (Optional)
Open your IDE or text editor and create a new file named.env in your project root directory.
Add your configuration:
.env to your .gitignore to avoid committing sensitive API keys:
Commit Changes
Now test the hook to ensure it’s working correctly. Stage your files:Undeclared Components
If undeclared components are found, the commit will be blocked and you’ll see a summary table in your terminal:.scanoss/results.json in your project directory.
To resolve this:
The commit is blocked until you review the findings and declare the components. Follow the same workflow mentioned earlier:
-
Review the results: The detailed findings are in
.scanoss/results.jsonSee Understanding the Results to understand what each field means - Declare the components: Follow the Declare Components section to properly declare the detected components
-
Check in scanoss.json: After updating
scanoss.jsonwith your component declarations, stage the file: -
Retry your commit: Now retry the commit with your updated declarations: