@scanoss_test/sdk 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/.gitkeep +0 -0
- package/dist/index.d.mts +444 -0
- package/dist/index.d.ts +444 -0
- package/dist/index.js +320 -0
- package/dist/index.mjs +298 -0
- package/package.json +67 -0
- package/src/binary.ts +57 -0
- package/src/client.ts +327 -0
- package/src/errors.ts +22 -0
- package/src/gen/.gitkeep +0 -0
- package/src/gen/scanoss/v1/commands_pb.ts +537 -0
- package/src/gen/scanoss/v1/enums_pb.ts +84 -0
- package/src/gen/scanoss/v1/types_pb.ts +191 -0
- package/src/index.ts +9 -0
- package/src/types.ts +98 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { Message } from '@bufbuild/protobuf';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Information about a file
|
|
5
|
+
*
|
|
6
|
+
* @generated from message scanoss.v1.FileInfo
|
|
7
|
+
*/
|
|
8
|
+
type FileInfo$1 = Message<"scanoss.v1.FileInfo"> & {
|
|
9
|
+
/**
|
|
10
|
+
* @generated from field: string path = 1;
|
|
11
|
+
*/
|
|
12
|
+
path: string;
|
|
13
|
+
/**
|
|
14
|
+
* @generated from field: int64 size = 2;
|
|
15
|
+
*/
|
|
16
|
+
size: bigint;
|
|
17
|
+
/**
|
|
18
|
+
* @generated from field: string extension = 3;
|
|
19
|
+
*/
|
|
20
|
+
extension: string;
|
|
21
|
+
/**
|
|
22
|
+
* @generated from field: string md5 = 4;
|
|
23
|
+
*/
|
|
24
|
+
md5: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A match found during scanning
|
|
28
|
+
*
|
|
29
|
+
* @generated from message scanoss.v1.Match
|
|
30
|
+
*/
|
|
31
|
+
type Match$1 = Message<"scanoss.v1.Match"> & {
|
|
32
|
+
/**
|
|
33
|
+
* @generated from field: string id = 1;
|
|
34
|
+
*/
|
|
35
|
+
id: string;
|
|
36
|
+
/**
|
|
37
|
+
* @generated from field: string component = 2;
|
|
38
|
+
*/
|
|
39
|
+
component: string;
|
|
40
|
+
/**
|
|
41
|
+
* @generated from field: string vendor = 3;
|
|
42
|
+
*/
|
|
43
|
+
vendor: string;
|
|
44
|
+
/**
|
|
45
|
+
* @generated from field: string version = 4;
|
|
46
|
+
*/
|
|
47
|
+
version: string;
|
|
48
|
+
/**
|
|
49
|
+
* @generated from field: string latest_version = 5;
|
|
50
|
+
*/
|
|
51
|
+
latestVersion: string;
|
|
52
|
+
/**
|
|
53
|
+
* @generated from field: string license = 6;
|
|
54
|
+
*/
|
|
55
|
+
license: string;
|
|
56
|
+
/**
|
|
57
|
+
* @generated from field: string purl = 7;
|
|
58
|
+
*/
|
|
59
|
+
purl: string;
|
|
60
|
+
/**
|
|
61
|
+
* @generated from field: string url = 8;
|
|
62
|
+
*/
|
|
63
|
+
url: string;
|
|
64
|
+
/**
|
|
65
|
+
* @generated from field: string file = 9;
|
|
66
|
+
*/
|
|
67
|
+
file: string;
|
|
68
|
+
/**
|
|
69
|
+
* Match percentage (e.g., "100%")
|
|
70
|
+
*
|
|
71
|
+
* @generated from field: string matched = 10;
|
|
72
|
+
*/
|
|
73
|
+
matched: string;
|
|
74
|
+
/**
|
|
75
|
+
* Lines in scanned file (e.g., "1-50")
|
|
76
|
+
*
|
|
77
|
+
* @generated from field: string lines = 11;
|
|
78
|
+
*/
|
|
79
|
+
lines: string;
|
|
80
|
+
/**
|
|
81
|
+
* Lines in matched OSS (e.g., "1-50")
|
|
82
|
+
*
|
|
83
|
+
* @generated from field: string oss_lines = 12;
|
|
84
|
+
*/
|
|
85
|
+
ossLines: string;
|
|
86
|
+
/**
|
|
87
|
+
* @generated from field: float score = 13;
|
|
88
|
+
*/
|
|
89
|
+
score: number;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Result for a single file scan
|
|
93
|
+
*
|
|
94
|
+
* @generated from message scanoss.v1.FileResult
|
|
95
|
+
*/
|
|
96
|
+
type FileResult$1 = Message<"scanoss.v1.FileResult"> & {
|
|
97
|
+
/**
|
|
98
|
+
* @generated from field: string path = 1;
|
|
99
|
+
*/
|
|
100
|
+
path: string;
|
|
101
|
+
/**
|
|
102
|
+
* @generated from field: string md5 = 2;
|
|
103
|
+
*/
|
|
104
|
+
md5: string;
|
|
105
|
+
/**
|
|
106
|
+
* @generated from field: repeated scanoss.v1.Match matches = 3;
|
|
107
|
+
*/
|
|
108
|
+
matches: Match$1[];
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Output format for scan results and SBOM generation
|
|
113
|
+
*
|
|
114
|
+
* @generated from enum scanoss.v1.OutputFormat
|
|
115
|
+
*/
|
|
116
|
+
declare enum OutputFormat$1 {
|
|
117
|
+
/**
|
|
118
|
+
* @generated from enum value: OUTPUT_FORMAT_UNSPECIFIED = 0;
|
|
119
|
+
*/
|
|
120
|
+
UNSPECIFIED = 0,
|
|
121
|
+
/**
|
|
122
|
+
* @generated from enum value: OUTPUT_FORMAT_JSON = 1;
|
|
123
|
+
*/
|
|
124
|
+
JSON = 1,
|
|
125
|
+
/**
|
|
126
|
+
* @generated from enum value: OUTPUT_FORMAT_SPDX = 2;
|
|
127
|
+
*/
|
|
128
|
+
SPDX = 2,
|
|
129
|
+
/**
|
|
130
|
+
* @generated from enum value: OUTPUT_FORMAT_CYCLONEDX = 3;
|
|
131
|
+
*/
|
|
132
|
+
CYCLONEDX = 3,
|
|
133
|
+
/**
|
|
134
|
+
* @generated from enum value: OUTPUT_FORMAT_CSV = 4;
|
|
135
|
+
*/
|
|
136
|
+
CSV = 4,
|
|
137
|
+
/**
|
|
138
|
+
* @generated from enum value: OUTPUT_FORMAT_WFP = 5;
|
|
139
|
+
*/
|
|
140
|
+
WFP = 5
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Scan result
|
|
145
|
+
*
|
|
146
|
+
* @generated from message scanoss.v1.ScanResult
|
|
147
|
+
*/
|
|
148
|
+
type ScanResult$1 = Message<"scanoss.v1.ScanResult"> & {
|
|
149
|
+
/**
|
|
150
|
+
* @generated from field: repeated scanoss.v1.FileResult files = 1;
|
|
151
|
+
*/
|
|
152
|
+
files: FileResult$1[];
|
|
153
|
+
/**
|
|
154
|
+
* @generated from field: int32 total_files = 2;
|
|
155
|
+
*/
|
|
156
|
+
totalFiles: number;
|
|
157
|
+
/**
|
|
158
|
+
* @generated from field: int32 files_with_matches = 3;
|
|
159
|
+
*/
|
|
160
|
+
filesWithMatches: number;
|
|
161
|
+
/**
|
|
162
|
+
* @generated from field: int32 total_matches = 4;
|
|
163
|
+
*/
|
|
164
|
+
totalMatches: number;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Filter files result
|
|
168
|
+
*
|
|
169
|
+
* @generated from message scanoss.v1.FilterFilesResult
|
|
170
|
+
*/
|
|
171
|
+
type FilterFilesResult$1 = Message<"scanoss.v1.FilterFilesResult"> & {
|
|
172
|
+
/**
|
|
173
|
+
* @generated from field: repeated scanoss.v1.FileInfo files = 1;
|
|
174
|
+
*/
|
|
175
|
+
files: FileInfo$1[];
|
|
176
|
+
/**
|
|
177
|
+
* @generated from field: int32 total_count = 2;
|
|
178
|
+
*/
|
|
179
|
+
totalCount: number;
|
|
180
|
+
/**
|
|
181
|
+
* @generated from field: int64 total_bytes = 3;
|
|
182
|
+
*/
|
|
183
|
+
totalBytes: bigint;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Fingerprint result
|
|
187
|
+
*
|
|
188
|
+
* @generated from message scanoss.v1.FingerprintResult
|
|
189
|
+
*/
|
|
190
|
+
type FingerprintResult$1 = Message<"scanoss.v1.FingerprintResult"> & {
|
|
191
|
+
/**
|
|
192
|
+
* WFP content (if no output_path)
|
|
193
|
+
*
|
|
194
|
+
* @generated from field: string wfp = 1;
|
|
195
|
+
*/
|
|
196
|
+
wfp: string;
|
|
197
|
+
/**
|
|
198
|
+
* Path where WFP was saved
|
|
199
|
+
*
|
|
200
|
+
* @generated from field: string output_path = 2;
|
|
201
|
+
*/
|
|
202
|
+
outputPath: string;
|
|
203
|
+
/**
|
|
204
|
+
* @generated from field: int32 file_count = 3;
|
|
205
|
+
*/
|
|
206
|
+
fileCount: number;
|
|
207
|
+
/**
|
|
208
|
+
* @generated from field: int64 total_bytes = 4;
|
|
209
|
+
*/
|
|
210
|
+
totalBytes: bigint;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Generate SBOM result
|
|
214
|
+
*
|
|
215
|
+
* @generated from message scanoss.v1.GenerateSbomResult
|
|
216
|
+
*/
|
|
217
|
+
type GenerateSbomResult$1 = Message<"scanoss.v1.GenerateSbomResult"> & {
|
|
218
|
+
/**
|
|
219
|
+
* SBOM content (if no output_path)
|
|
220
|
+
*
|
|
221
|
+
* @generated from field: string sbom = 1;
|
|
222
|
+
*/
|
|
223
|
+
sbom: string;
|
|
224
|
+
/**
|
|
225
|
+
* Path where SBOM was saved
|
|
226
|
+
*
|
|
227
|
+
* @generated from field: string output_path = 2;
|
|
228
|
+
*/
|
|
229
|
+
outputPath: string;
|
|
230
|
+
/**
|
|
231
|
+
* @generated from field: scanoss.v1.OutputFormat format = 3;
|
|
232
|
+
*/
|
|
233
|
+
format: OutputFormat$1;
|
|
234
|
+
/**
|
|
235
|
+
* @generated from field: int32 component_count = 4;
|
|
236
|
+
*/
|
|
237
|
+
componentCount: number;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Version result
|
|
241
|
+
*
|
|
242
|
+
* @generated from message scanoss.v1.VersionResult
|
|
243
|
+
*/
|
|
244
|
+
type VersionResult$1 = Message<"scanoss.v1.VersionResult"> & {
|
|
245
|
+
/**
|
|
246
|
+
* @generated from field: string version = 1;
|
|
247
|
+
*/
|
|
248
|
+
version: string;
|
|
249
|
+
/**
|
|
250
|
+
* @generated from field: string commit = 2;
|
|
251
|
+
*/
|
|
252
|
+
commit: string;
|
|
253
|
+
/**
|
|
254
|
+
* @generated from field: string build_date = 3;
|
|
255
|
+
*/
|
|
256
|
+
buildDate: string;
|
|
257
|
+
/**
|
|
258
|
+
* @generated from field: string go_version = 4;
|
|
259
|
+
*/
|
|
260
|
+
goVersion: string;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Type definitions for SCANOSS SDK
|
|
265
|
+
*/
|
|
266
|
+
/** Output format for scan results */
|
|
267
|
+
type OutputFormat = 'json' | 'spdx' | 'cyclonedx' | 'csv' | 'wfp';
|
|
268
|
+
/** Type of scan to perform */
|
|
269
|
+
type ScanType = 'identify' | 'blacklist';
|
|
270
|
+
/** File information */
|
|
271
|
+
interface FileInfo {
|
|
272
|
+
path: string;
|
|
273
|
+
size: number;
|
|
274
|
+
extension: string;
|
|
275
|
+
}
|
|
276
|
+
/** Match information for a component */
|
|
277
|
+
interface Match {
|
|
278
|
+
component: string;
|
|
279
|
+
version: string;
|
|
280
|
+
license: string;
|
|
281
|
+
purl: string;
|
|
282
|
+
score: number;
|
|
283
|
+
}
|
|
284
|
+
/** Result for a single file */
|
|
285
|
+
interface FileResult {
|
|
286
|
+
path: string;
|
|
287
|
+
matches: Match[];
|
|
288
|
+
}
|
|
289
|
+
/** Scan command parameters */
|
|
290
|
+
interface ScanParams {
|
|
291
|
+
path: string;
|
|
292
|
+
format?: OutputFormat;
|
|
293
|
+
scanType?: ScanType;
|
|
294
|
+
include?: string[];
|
|
295
|
+
exclude?: string[];
|
|
296
|
+
apiUrl?: string;
|
|
297
|
+
apiKey?: string;
|
|
298
|
+
}
|
|
299
|
+
/** Scan result */
|
|
300
|
+
interface ScanResult {
|
|
301
|
+
files: FileResult[];
|
|
302
|
+
totalFiles: number;
|
|
303
|
+
filesWithMatches: number;
|
|
304
|
+
totalMatches: number;
|
|
305
|
+
}
|
|
306
|
+
/** Filter files command parameters */
|
|
307
|
+
interface FilterFilesParams {
|
|
308
|
+
path: string;
|
|
309
|
+
include?: string[];
|
|
310
|
+
exclude?: string[];
|
|
311
|
+
skipHidden?: boolean;
|
|
312
|
+
}
|
|
313
|
+
/** Filter files result */
|
|
314
|
+
interface FilterFilesResult {
|
|
315
|
+
files: FileInfo[];
|
|
316
|
+
totalCount: number;
|
|
317
|
+
totalBytes: number;
|
|
318
|
+
}
|
|
319
|
+
/** Fingerprint command parameters */
|
|
320
|
+
interface FingerprintParams {
|
|
321
|
+
path: string;
|
|
322
|
+
include?: string[];
|
|
323
|
+
exclude?: string[];
|
|
324
|
+
}
|
|
325
|
+
/** Fingerprint result */
|
|
326
|
+
interface FingerprintResult {
|
|
327
|
+
wfp: string;
|
|
328
|
+
fileCount: number;
|
|
329
|
+
}
|
|
330
|
+
/** Generate SBOM command parameters */
|
|
331
|
+
interface GenerateSbomParams {
|
|
332
|
+
path: string;
|
|
333
|
+
format?: 'spdx' | 'cyclonedx';
|
|
334
|
+
}
|
|
335
|
+
/** Generate SBOM result */
|
|
336
|
+
interface GenerateSbomResult {
|
|
337
|
+
sbom: string;
|
|
338
|
+
format: string;
|
|
339
|
+
componentCount: number;
|
|
340
|
+
}
|
|
341
|
+
/** Version information */
|
|
342
|
+
interface VersionResult {
|
|
343
|
+
version: string;
|
|
344
|
+
commit: string;
|
|
345
|
+
buildDate: string;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* SCANOSS SDK client using protobuf binary protocol
|
|
350
|
+
*/
|
|
351
|
+
|
|
352
|
+
/** Options for creating a Scanoss instance */
|
|
353
|
+
interface ScanossOptions {
|
|
354
|
+
/** Path to the scanoss binary. If not provided, will be auto-detected. */
|
|
355
|
+
binaryPath?: string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* SCANOSS SDK client.
|
|
359
|
+
*
|
|
360
|
+
* This client communicates with the SCANOSS daemon process via stdin/stdout
|
|
361
|
+
* using length-prefixed protobuf binary protocol.
|
|
362
|
+
*
|
|
363
|
+
* Wire format:
|
|
364
|
+
* ```
|
|
365
|
+
* ┌──────────────────┬─────────────────────────┐
|
|
366
|
+
* │ 4 bytes (BE) │ N bytes │
|
|
367
|
+
* │ message length │ protobuf binary data │
|
|
368
|
+
* └──────────────────┴─────────────────────────┘
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const scanoss = new Scanoss();
|
|
374
|
+
* const result = await scanoss.scan({ path: '/path/to/project' });
|
|
375
|
+
* console.log(result);
|
|
376
|
+
* await scanoss.close();
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
declare class Scanoss {
|
|
380
|
+
private process;
|
|
381
|
+
private requestId;
|
|
382
|
+
private pending;
|
|
383
|
+
private binaryPath;
|
|
384
|
+
private closed;
|
|
385
|
+
private buffer;
|
|
386
|
+
private expectedLength;
|
|
387
|
+
constructor(options?: ScanossOptions);
|
|
388
|
+
private start;
|
|
389
|
+
private processBuffer;
|
|
390
|
+
private rejectAllPending;
|
|
391
|
+
private send;
|
|
392
|
+
/**
|
|
393
|
+
* Scan files for open source matches.
|
|
394
|
+
*/
|
|
395
|
+
scan(params: ScanParams): Promise<ScanResult$1>;
|
|
396
|
+
/**
|
|
397
|
+
* Filter files in a directory.
|
|
398
|
+
*/
|
|
399
|
+
filterFiles(params: FilterFilesParams): Promise<FilterFilesResult$1>;
|
|
400
|
+
/**
|
|
401
|
+
* Generate WFP fingerprints for files.
|
|
402
|
+
*/
|
|
403
|
+
fingerprint(params: FingerprintParams): Promise<FingerprintResult$1>;
|
|
404
|
+
/**
|
|
405
|
+
* Generate SBOM from scan results.
|
|
406
|
+
*/
|
|
407
|
+
generateSbom(params: GenerateSbomParams): Promise<GenerateSbomResult$1>;
|
|
408
|
+
/**
|
|
409
|
+
* Get version information.
|
|
410
|
+
*/
|
|
411
|
+
version(): Promise<VersionResult$1>;
|
|
412
|
+
/**
|
|
413
|
+
* Close the daemon process.
|
|
414
|
+
*/
|
|
415
|
+
close(): Promise<void>;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Error types for SCANOSS SDK
|
|
420
|
+
*/
|
|
421
|
+
/**
|
|
422
|
+
* Error thrown by SCANOSS operations
|
|
423
|
+
*/
|
|
424
|
+
declare class ScanossError extends Error {
|
|
425
|
+
/** Error code from the daemon */
|
|
426
|
+
readonly code: number;
|
|
427
|
+
constructor(code: number, message: string);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Binary resolution for SCANOSS daemon.
|
|
432
|
+
*
|
|
433
|
+
* The binary is provided by platform-specific packages (@scanoss_test/linux-x64, etc.).
|
|
434
|
+
* npm will automatically install the correct one based on the user's OS and CPU.
|
|
435
|
+
*/
|
|
436
|
+
/**
|
|
437
|
+
* Get the path to the SCANOSS binary.
|
|
438
|
+
*
|
|
439
|
+
* @returns Path to the scanoss binary
|
|
440
|
+
* @throws Error if no binary package is installed
|
|
441
|
+
*/
|
|
442
|
+
declare function getBinaryPath(): string;
|
|
443
|
+
|
|
444
|
+
export { type FileInfo, type FileResult, type FilterFilesParams, type FilterFilesResult, type FingerprintParams, type FingerprintResult, type GenerateSbomParams, type GenerateSbomResult, type Match, type OutputFormat, type ScanParams, type ScanResult, type ScanType, Scanoss, ScanossError, type ScanossOptions, type VersionResult, getBinaryPath };
|