index
Classes
SecurityArchive
Defined in: src/security-archive/src/index.ts:85
A database of security information for given packages from a list of nodes.
Using the SecurityArchive.refresh() method will update the local cache
with information from the socket.dev APIs or load from the local storage
if available. Information about package security is then available
using the SecurityArchive.get() method. Remote requests are bounded
by the timeout option.
Extends
Implements
Constructors
new SecurityArchive()
new SecurityArchive(options): SecurityArchiveDefined in: src/security-archive/src/index.ts:139
Parameters
| Parameter | Type |
|---|---|
options | SecurityArchiveOptions |
Returns
Overrides
LRUCache<DepID, PackageReportData>.constructorProperties
| Property | Type | Default value | Description |
|---|---|---|---|
ok | boolean | false | True if the refresh process was successful and report data is available for all public registry packages from the initial list of nodes. |
timedOut | boolean | false | True if the last refresh() timed out waiting for the remote API. |
Accessors
defaultMax
Get Signature
get static defaultMax(): numberDefined in: src/security-archive/src/index.ts:121
By default, limits to 100K entries in the in-memory archive.
Returns
number
defaultTimeout
Get Signature
get static defaultTimeout(): numberDefined in: src/security-archive/src/index.ts:135
By default, remote requests time out after 30 seconds.
Returns
number
defaultTtl
Get Signature
get static defaultTtl(): numberDefined in: src/security-archive/src/index.ts:128
By default, entries are cached for 3 hours.
Returns
number
Methods
delete()
delete(k): booleanDefined in: src/security-archive/src/index.ts:192
Delete the report data stored under the base DepID.
Parameters
| Parameter | Type |
|---|---|
k | DepID |
Returns
boolean
Implementation of
Overrides
LRUCache.deleteget()
get(k, options?): undefined | PackageReportDataDefined in: src/security-archive/src/index.ts:159
Get the report data for a node, keyed by its base DepID.
Parameters
| Parameter | Type |
|---|---|
k | DepID |
options? | GetOptions<DepID, PackageReportData, unknown> |
Returns
undefined | PackageReportData
Implementation of
Overrides
LRUCache.gethas()
has(k): booleanDefined in: src/security-archive/src/index.ts:171
Check for report data, keyed by the base DepID.
Parameters
| Parameter | Type |
|---|---|
k | DepID |
Returns
boolean
Implementation of
Overrides
LRUCache.hasrefresh()
refresh(__namedParameters): Promise<void>Defined in: src/security-archive/src/index.ts:517
Starts the security archive by providing an array of NodeLike instances, its registry-based nodes are going to be used as valid potential entries.
Any entry that is missing from the persisted cached values are going to be requested in a batch-request to the remote socket.dev API.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | SecurityArchiveRefreshOptions |
Returns
Promise<void>
set()
set(
k,
v,
setOptions?): SecurityArchiveDefined in: src/security-archive/src/index.ts:179
Store report data for a node, keyed by its base DepID so peer-suffixed copies of the same package share one entry.
Parameters
| Parameter | Type |
|---|---|
k | DepID |
v | PackageReportData |
setOptions? | SetOptions<DepID, PackageReportData, unknown> |
Returns
Implementation of
Overrides
LRUCache.settoJSON()
toJSON(): Record<DepID, PackageReportData>Defined in: src/security-archive/src/index.ts:572
Outputs the current in-memory cache as a JSON object.
Returns
Record<DepID, PackageReportData>
start()
static start(options): Promise<SecurityArchive>Defined in: src/security-archive/src/index.ts:110
Creates a new security archive instance and starts the refresh process.
Parameters
| Parameter | Type |
|---|---|
options | OptionsBase<DepID, PackageReportData, unknown> & object & SecurityArchiveRefreshOptions |
Returns
Promise<SecurityArchive>
Interfaces
SecurityArchiveLike
Defined in: src/security-archive/src/types.ts:19
An interface for interacting with a security archive.
Properties
| Property | Type |
|---|---|
clear | () => void |
delete | (depId: DepID) => void |
get | (depId: DepID) => undefined | PackageReportData |
has | (depId: DepID) => boolean |
ok? | boolean |
set | (depId: DepID, data: PackageReportData) => void |
Type Aliases
DBReadEntry
type DBReadEntry = object;Defined in: src/security-archive/src/index.ts:39
Type declaration
| Name | Type |
|---|---|
depID | string |
now | number |
report | string |
start | number |
ttl | number |
DBWriteEntry
type DBWriteEntry = [string, string, number, number];Defined in: src/security-archive/src/index.ts:47
JSONItemResponse
type JSONItemResponse = object;Defined in: src/security-archive/src/types.ts:143
A single line of the NDJSON stream returned by the socket.dev
batch purl API. Besides package artifacts, the stream can carry
purlError and summary wrapper items, and a package that was
published recently enough to not have been analyzed yet comes back
as an artifact with no score object at all.
Type declaration
| Name | Type |
|---|---|
_type? | "purlError" | "summary" |
name? | string |
namespace? | `@${string}` |
score? | object |
score.license | number |
score.maintenance | number |
score.overall? | number |
score.quality | number |
score.supplyChain | number |
score.vulnerability | number |
version? | string |
PackageAlert
type PackageAlert = object;Defined in: src/security-archive/src/types.ts:60
A known alert for a given package.
Type declaration
| Name | Type |
|---|---|
category | string |
key | string |
props? | PackageAlertProps |
severity | "low" | "medium" | "high" | "critical" |
type | string |
PackageAlertProps
type PackageAlertProps = object;Defined in: src/security-archive/src/types.ts:51
Package alert extra information.
Type declaration
| Name | Type |
|---|---|
cveId? | `CVE-${string}` |
cwes? | object[] |
lastPublish | string |
PackageReportData
type PackageReportData = object;Defined in: src/security-archive/src/types.ts:101
The report data for a given package.
Type declaration
| Name | Type |
|---|---|
alerts | PackageAlert[] |
author | string[] |
id | string |
license | string |
name | string |
namespace? | `@${string}` |
score | PackageScore |
size | number |
type | "npm" |
version | string |
PackageScore
type PackageScore = object;Defined in: src/security-archive/src/types.ts:71
The scores for a given package
Type declaration
| Name | Type | Description |
|---|---|---|
license | number | Score factors relating to package licensing (0-1) |
maintenance | number | Score factors relating to package maintenance (0-1) |
overall | number | The average of all score factors. (0-1) |
quality | number | Score factors relating to code quality (0-1) |
supplyChain | number | Score factors relating to supply chain security (0-1) |
vulnerability | number | Score factors relating to package vulnerabilities (0-1) |
SecurityArchiveOptions
type SecurityArchiveOptions = LRUCache.OptionsBase<DepID, PackageReportData, unknown> & object;Defined in: src/security-archive/src/index.ts:49
Type declaration
| Name | Type | Description |
|---|---|---|
fetchMethod? | undefined | Security archive does not supports a fetch-on-demand model. |
path? | string | An optional value for the path in which to store the sqlite db. |
retries? | number | Number of retries attempts to reach the remote security API. |
timeout? | number | Max ms to wait for the remote security API, incl. retries. Defaults to VLT_SECURITY_ARCHIVE_TIMEOUT env or SecurityArchive.defaultTimeout. Positive integers only, other values are ignored. On timeout, missing packages are left unscanned and a warning is printed. |
SecurityArchiveRefreshOptions
type SecurityArchiveRefreshOptions = object;Defined in: src/security-archive/src/types.ts:8
Parameter options for initializing a security archive.
Type declaration
| Name | Type | Description |
|---|---|---|
nodes | NodeLike[] | A @link{GraphLike} instance to find what packages the security archive should have. |
Functions
asPackageReportData()
function asPackageReportData(o): PackageReportDataDefined in: src/security-archive/src/types.ts:127
Parameters
| Parameter | Type |
|---|---|
o | unknown |
Returns
asSecurityArchiveLike()
function asSecurityArchiveLike(o): SecurityArchiveLikeDefined in: src/security-archive/src/types.ts:39
Parameters
| Parameter | Type |
|---|---|
o | unknown |
Returns
getItemScore()
function getItemScore(data): undefined | PackageScoreDefined in: src/security-archive/src/types.ts:163
Returns the score of a response item with its overall value
recalculated as the average of the individual components, or
undefined when the item is not a scored package artifact.
Parameters
| Parameter | Type |
|---|---|
data | JSONItemResponse |
Returns
undefined | PackageScore
isPackageReportData()
function isPackageReportData(o): o is PackageReportDataDefined in: src/security-archive/src/types.ts:114
Parameters
| Parameter | Type |
|---|---|
o | unknown |
Returns
o is PackageReportData
isSecurityArchiveLike()
function isSecurityArchiveLike(o): o is SecurityArchiveLikeDefined in: src/security-archive/src/types.ts:28
Parameters
| Parameter | Type |
|---|---|
o | unknown |
Returns
o is SecurityArchiveLike
References
npmRegistryURL
Re-exports npmRegistryURL
usesNpmRegistry
Re-exports usesNpmRegistry