index
Classes
SecurityArchive
Defined in: src/security-archive/src/index.ts:81
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.
Extends
Implements
Constructors
new SecurityArchive()
new SecurityArchive(options): SecurityArchiveDefined in: src/security-archive/src/index.ts:122
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. |
Accessors
defaultMax
Get Signature
get static defaultMax(): numberDefined in: src/security-archive/src/index.ts:111
By default, limits to 100K entries in the in-memory archive.
Returns
number
defaultTtl
Get Signature
get static defaultTtl(): numberDefined in: src/security-archive/src/index.ts:118
By default, entries are cached for 3 hours.
Returns
number
Methods
delete()
delete(k): booleanDefined in: src/security-archive/src/index.ts:171
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:138
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:150
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:478
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:158
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:533
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:100
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:44
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:52
JSONItemResponse
type JSONItemResponse = object;Defined in: src/security-archive/src/index.ts:30
Type declaration
| Name | Type |
|---|---|
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:54
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. |
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
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