|
2 | 2 |
|
3 | 3 | Sonatype provides software supply chain security and repository management tools to help organizations manage risks in their open source dependencies. |
4 | 4 |
|
5 | | -### Implementation Notes |
| 5 | +## Implementation Notes |
6 | 6 |
|
7 | 7 | The Sonatype integration uses the REST API (v3) available at [ossindex.sonatype.org](https://ossindex.sonatype.org/api/v3/component-report). |
8 | 8 |
|
| 9 | +### Authentication |
| 10 | + |
| 11 | +`Sonatype` supports optional basic auth credentials for higher rate limits. Without credentials, the API is still accessible at reduced rate limits. |
| 12 | + |
9 | 13 | ### Format |
10 | 14 |
|
11 | | -the Sonatype interface is exported as root like `SonatypeResponse`. |
| 15 | +The Sonatype interface is exported as root like `SonatypeResponse`. |
| 16 | + |
| 17 | +```ts |
| 18 | +export type SonatypeResponse = { |
| 19 | + coordinates: string; |
| 20 | + vulnerabilities: SonatypeVulnerability[]; |
| 21 | +}; |
| 22 | +``` |
| 23 | + |
| 24 | +## API |
| 25 | + |
| 26 | +### Constructor |
| 27 | + |
| 28 | +```ts |
| 29 | +import * as vulnera from "@nodesecure/vulnera"; |
| 30 | + |
| 31 | +const db = new vulnera.Database.Sonatype({ |
| 32 | + credential: new vulnera.ApiCredential({ |
| 33 | + type: "basic", |
| 34 | + username: process.env.SONATYPE_USERNAME, |
| 35 | + password: process.env.SONATYPE_PASSWORD |
| 36 | + }) |
| 37 | +}); |
| 38 | +``` |
12 | 39 |
|
13 | 40 | ```ts |
14 | | -export type SonatypeResponse = { |
15 | | - coordinates: string; vulnerabilities: SonatypeVulnerability[]; |
16 | | - }; |
| 41 | +export interface SonatypeOptions { |
| 42 | + credential?: ApiCredential; |
| 43 | +} |
17 | 44 | ``` |
18 | | -### API |
19 | 45 |
|
20 | | -### findOne(parameters: SonaTypeFindOneParameters): Promise< SonatypeResponse[] > |
| 46 | +### `findOne(parameters: SonaTypeFindOneParameters): Promise<SonatypeResponse[]>` |
| 47 | + |
| 48 | +Find the vulnerabilities of a given package using available Sonatype API parameters. |
21 | 49 |
|
22 | 50 | ```ts |
23 | 51 | export type SonaTypeFindOneParameters = { |
24 | 52 | coordinates: string[]; |
25 | 53 | }; |
26 | 54 | ``` |
27 | 55 |
|
28 | | -Find the vulnerabilities of a given package using available Sonatype API parameters. |
| 56 | +```ts |
| 57 | +import * as vulnera from "@nodesecure/vulnera"; |
29 | 58 |
|
30 | | -### findMany(parameters: SonaTypeFindManyParameters): Promise< SonatypeResponse[] > > |
| 59 | +const db = new vulnera.Database.Sonatype(); |
| 60 | +const vulns = await db.findOne({ coordinates: ["pkg:npm/express@4.0.0"] }); |
| 61 | +console.log(vulns); |
| 62 | +``` |
| 63 | + |
| 64 | +### `findMany(parameters: SonaTypeFindManyParameters): Promise<SonatypeResponse[]>` |
| 65 | + |
| 66 | +Find the vulnerabilities of many packages. |
31 | 67 |
|
32 | 68 | ```ts |
33 | 69 | export type SonaTypeFindManyParameters = { |
34 | 70 | coordinates: string[][]; |
35 | 71 | }; |
36 | 72 | ``` |
37 | 73 |
|
38 | | -Find the vulnerabilities of many packages. |
| 74 | +```ts |
| 75 | +import * as vulnera from "@nodesecure/vulnera"; |
| 76 | + |
| 77 | +const db = new vulnera.Database.Sonatype(); |
| 78 | +const vulns = await db.findMany({ |
| 79 | + coordinates: [ |
| 80 | + ["pkg:npm/express@4.0.0"], |
| 81 | + ["pkg:npm/lodash@4.17.0"] |
| 82 | + ] |
| 83 | +}); |
| 84 | +console.log(vulns); |
| 85 | +``` |
0 commit comments