0.11.5 • Published 11 days ago

scanoss v0.11.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

REUSE status Build and Test status

Scanoss JS Package

The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.

It can be installed on your system and used as a CLI or installed directly into your Node.js project.

Installation

You can install the Scanoss package using npm (the Node Package Manager). Note that you will need to install Node.js and npm. Installing Node.js should install npm as well.

To download and install the Scanoss CLI run the following command: npm install -g scanoss

On the other hand, if you need to install the module in your own Node.js project and consume it as a dependency, execute the following command npm install scanoss

CLI Usage

Running the bare command will list the available sub-commands:

Usage: scanoss-js [options] [command]

The SCANOSS JS package provides a simple, easy to consume module for interacting with SCANOSS APIs/Engine.

Options:
  -V, --version            output the version number
  -h, --help               display help for command

Commands:
  scan [options] <source>  Scan a folder/file
  dep [options] <source>   Scan for dependencies
  wfp [options] <source>   Generates fingerprints for a folder/file
  help [command]           display help for command

Command scan

  • For a quick and free analysis of your project, simply input: scanoss-js scan -o results.json <source-folder>
  • Using an API Token for Scanning: scanoss-js scan -o results.json --key <your_token> --apiurl <your_apiurl> <source-folder>
  • Include Dependency detection in scanning: scanoss-js scan -o results.json --dependencies <source-folder>

Command wfp

  • Generate Hashes without analysis: scanoss-js wfp -o fingerprints.wfp <source-folder>

  • Subsequent scanning of previously generated Hashes: scanoss-js scan -w fingerprints.wfp -o results.json

Note: the --dependencies flag is not applicable here, given that manifest files aren't encompassed within the hashes.

Command dep

  • Focus Exclusively on Dependencies: scanoss-js dep .

The manifest files acknowledged during the scanning process are:

* Python: requirements.txt, pyproject.toml
* Java: pom.xml
* Javascript: package.json, package-lock.json, yarn.lock
* Ruby: Gemfile, Gemfile.lock
* Golang: go.mod, go.sum
* .NET/NuGet: *.csproj, packages.config
* Gradle: build.gradle

SDK Usage

The SDK provides a simple way to interact with the Scanoss APIs from your JS code. Here are two examples for performing code scanning and dependency scanning

Code Scanning

// Import as ES6
import { Scanner, ScannerEvents, ScannerTypes } from 'scanoss';

// Import as CommonJS
// const { Scanner, ScannerEvents } = require('scanoss');

const scanner = new Scanner();

// Set the folder path where the module will save the scan results and fingerprints
// If is not specified, the module will create a folder on tmp
// directory using a timestamp as a name
scanner.setWorkDirectory('/yourProjectFolder/ScanResults/');

// Set the scanner log event handler
scanner.on(ScannerEvents.SCANNER_LOG, (logTxt) => console.log(logTxt));

// Set the scanner finish event handler
scanner.on(ScannerEvents.SCAN_DONE, (resultPath) => {
  console.log('Path to results: ', resultPath);
});

const scannerInput = {
  fileList: ['/yourProjectFolder/example1.c', '/yourProjectFolder/example2.c'],
};

// Launch the scanner
scanner.scan([scannerInput]);

The scanner object provides a set of events that can be used to trigger custom actions. These events are listed in the table above and were previously mentioned.

Event NameDescription
SCANNER_LOGReport any internal scanner events
SCAN_DONEScan completed
DISPATCHER_NEW_DATANew data received but not persisted
RESULTS_APPENDEDResults added to scan report file

Local Development and Usage

If you want to develop this package and use it locally in your project (without publishing it), follow these steps:

1 - Creating a Symbolic Link for the Development Package:

In the root of the scanoss.js package, run the command:

npm install && npm run build && npm link . 

This command creates a global symbolic link in your system that points to the local location of your package. This means you can use the package in any other Node.js project on your machine as if it were installed globally.

2 - Using the Package in Your Project:

In the root of the project where you want to use the scanoss package, run the command:

npm link scanoss

This will create a symbolic link in your project to the globally linked scanoss package. Any changes made in the package will be immediately reflected in the consuming project.

3 - Disconnecting the Link:

Remember that once you finish developing or using the package locally, you should break the link to avoid potential issues with future versions or with installing other packages. To do this, simply run:

npm unlink scanoss

in both the project and the scanoss package. This will remove the symbolic links and restore the normal state of the packages.

0.11.5

11 days ago

0.11.4

17 days ago

0.11.3

1 month ago

0.11.2

1 month ago

0.11.1

4 months ago

0.11.0

4 months ago

0.10.4

4 months ago

0.10.5

4 months ago

0.10.3

4 months ago

0.10.2

5 months ago

0.9.3

7 months ago

0.10.1

5 months ago

0.10.0

5 months ago

0.9.2

7 months ago

0.8.8

1 year ago

0.8.5

1 year ago

0.8.4

1 year ago

0.8.7

1 year ago

0.8.6

1 year ago

0.9.0

1 year ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.4

1 year ago

0.9.1

12 months ago

0.7.3

1 year ago

0.7.0

1 year ago

0.7.11

1 year ago

0.7.10

1 year ago

0.7.9

1 year ago

0.7.13

1 year ago

0.7.12

1 year ago

0.7.5

1 year ago

0.7.8

1 year ago

0.7.18

1 year ago

0.7.15

1 year ago

0.7.14

1 year ago

0.7.17

1 year ago

0.7.16

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.8.3

1 year ago

0.8.2

1 year ago

0.4.10-beta

1 year ago

0.4.4-beta

2 years ago

0.4.9-beta

1 year ago

0.4.6-beta

2 years ago

0.4.12-beta

1 year ago

0.5.4

1 year ago

0.5.3

1 year ago

0.5.6

1 year ago

0.4.5-beta

2 years ago

0.5.5

1 year ago

0.5.0

1 year ago

0.4.11-beta

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.8

1 year ago

0.5.7

1 year ago

0.4.8-beta

2 years ago

0.4.7-beta

2 years ago

0.6.2

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.4.0-alpha.3

2 years ago

0.4.0-alpha.2

2 years ago

0.4.0-alpha.1

2 years ago

0.4.0-beta

2 years ago

0.4.1

2 years ago

0.4.0-rc1

2 years ago

0.4.0

2 years ago

0.4.0-rc0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.0-alpha.0

2 years ago

0.3.0

2 years ago

0.2.3

2 years ago

0.2.27

2 years ago

0.2.28

2 years ago

0.2.26

2 years ago

0.2.25

2 years ago

0.2.24

2 years ago

0.2.23

2 years ago

0.2.22

2 years ago

0.2.21

2 years ago

0.2.20

2 years ago

0.2.19

2 years ago

0.2.18

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago