scanoss 0.2.26 → 0.3.0
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/.github/workflows/reuse.yml +15 -0
- package/.github/workflows/scanoss.yml +24 -0
- package/.gitignore +0 -1
- package/.idea/.gitignore +5 -0
- package/.idea/codeStyles/Project.xml +61 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/scanoss.js.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +366 -0
- package/.nyc_output/a25d3ac4-ee71-4c5e-926e-3a17714555cd.json +1 -0
- package/.nyc_output/processinfo/a25d3ac4-ee71-4c5e-926e-3a17714555cd.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/.reuse/dep5 +16 -0
- package/LICENSES/CC0-1.0.txt +121 -0
- package/LICENSES/MIT.txt +9 -0
- package/README.md +9 -0
- package/build/main/bin/cli-bin.js +5 -3
- package/build/main/commands/dep.js +1 -2
- package/build/main/commands/fingerprint.js +20 -12
- package/build/main/commands/helpers.js +1 -2
- package/build/main/commands/scan.js +7 -2
- package/build/main/index.js +1 -2
- package/build/main/lib/dependencies/DependencyScanner.d.ts +1 -1
- package/build/main/lib/dependencies/DependencyScanner.js +23 -12
- package/build/main/lib/dependencies/DependencyScannerCfg.js +1 -2
- package/build/main/lib/dependencies/DependencyTypes.js +0 -1
- package/build/main/lib/dependencies/LocalDependency/DependencyTypes.js +0 -1
- package/build/main/lib/dependencies/LocalDependency/LocalDependency.js +3 -2
- package/build/main/lib/dependencies/LocalDependency/parsers/golangParser.d.ts +1 -0
- package/build/main/lib/dependencies/LocalDependency/parsers/golangParser.js +50 -16
- package/build/main/lib/dependencies/LocalDependency/parsers/mavenParser.js +130 -15
- package/build/main/lib/dependencies/LocalDependency/parsers/npmParser.d.ts +10 -0
- package/build/main/lib/dependencies/LocalDependency/parsers/npmParser.js +146 -10
- package/build/main/lib/dependencies/LocalDependency/parsers/pyParser.js +1 -2
- package/build/main/lib/dependencies/LocalDependency/parsers/rubyParser.js +1 -2
- package/build/main/lib/dependencies/LocalDependency/parsers/utils.js +1 -2
- package/build/main/lib/filters/defaultFilter.js +1 -2
- package/build/main/lib/filters/filtering.js +1 -2
- package/build/main/lib/grpc/GrpcDependencyService.js +1 -2
- package/build/main/lib/grpc/scanoss/api/components/v2/scanoss-components_grpc_pb.d.ts +62 -0
- package/build/main/lib/grpc/scanoss/api/components/v2/scanoss-components_grpc_pb.js +128 -0
- package/build/main/lib/grpc/scanoss/api/components/v2/scanoss-components_pb.d.ts +1 -0
- package/build/main/lib/grpc/scanoss/api/components/v2/scanoss-components_pb.js +1403 -0
- package/build/main/lib/scanner/Dispatcher/DispatchableItem.d.ts +14 -5
- package/build/main/lib/scanner/Dispatcher/DispatchableItem.js +30 -10
- package/build/main/lib/scanner/Dispatcher/Dispatcher.d.ts +2 -2
- package/build/main/lib/scanner/Dispatcher/Dispatcher.js +10 -15
- package/build/main/lib/scanner/Dispatcher/DispatcherResponse.js +1 -2
- package/build/main/lib/scanner/Dispatcher/GlobalControllerAborter.js +1 -2
- package/build/main/lib/scanner/Scannable/ScannableItem.js +1 -2
- package/build/main/lib/scanner/Scanner.js +13 -9
- package/build/main/lib/scanner/ScannerCfg.js +2 -3
- package/build/main/lib/scanner/ScannerQueue.d.ts +3 -0
- package/build/main/lib/scanner/ScannerQueue.js +8 -0
- package/build/main/lib/scanner/ScannerTypes.d.ts +9 -2
- package/build/main/lib/scanner/ScannerTypes.js +8 -3
- package/build/main/lib/scanner/WfpProvider/FingerprintPackage.d.ts +9 -0
- package/build/main/lib/scanner/WfpProvider/FingerprintPackage.js +31 -0
- package/build/main/lib/scanner/WfpProvider/WfpCalculator/WfpCalculator.js +178 -21
- package/build/main/lib/scanner/WfpProvider/WfpCalculator/Winnower.d.ts +3 -0
- package/build/main/lib/scanner/WfpProvider/WfpCalculator/Winnower.js +211 -0
- package/build/main/lib/scanner/WfpProvider/WfpProvider.d.ts +2 -2
- package/build/main/lib/scanner/WfpProvider/WfpProvider.js +6 -7
- package/build/main/lib/scanner/WfpProvider/WfpSplitter/WfpSplitter.js +1 -2
- package/build/main/lib/tree/File.js +1 -2
- package/build/main/lib/tree/Folder.js +1 -2
- package/build/main/lib/tree/Node.js +1 -2
- package/build/main/lib/tree/Tree.js +1 -2
- package/build/module/bin/cli-bin.js +5 -2
- package/build/module/commands/fingerprint.js +25 -16
- package/build/module/commands/scan.js +8 -2
- package/build/module/lib/dependencies/DependencyScanner.d.ts +1 -1
- package/build/module/lib/dependencies/DependencyScanner.js +23 -11
- package/build/module/lib/dependencies/LocalDependency/LocalDependency.js +5 -3
- package/build/module/lib/dependencies/LocalDependency/parsers/golangParser.d.ts +1 -0
- package/build/module/lib/dependencies/LocalDependency/parsers/golangParser.js +47 -14
- package/build/module/lib/dependencies/LocalDependency/parsers/mavenParser.js +130 -14
- package/build/module/lib/dependencies/LocalDependency/parsers/npmParser.d.ts +10 -0
- package/build/module/lib/dependencies/LocalDependency/parsers/npmParser.js +140 -8
- package/build/module/lib/grpc/scanoss/api/components/v2/scanoss-components_grpc_pb.d.ts +62 -0
- package/build/module/lib/grpc/scanoss/api/components/v2/scanoss-components_grpc_pb.js +128 -0
- package/build/module/lib/grpc/scanoss/api/components/v2/scanoss-components_pb.d.ts +1 -0
- package/build/module/lib/grpc/scanoss/api/components/v2/scanoss-components_pb.js +1403 -0
- package/build/module/lib/scanner/Dispatcher/DispatchableItem.d.ts +14 -5
- package/build/module/lib/scanner/Dispatcher/DispatchableItem.js +32 -10
- package/build/module/lib/scanner/Dispatcher/Dispatcher.d.ts +2 -2
- package/build/module/lib/scanner/Dispatcher/Dispatcher.js +10 -14
- package/build/module/lib/scanner/Scanner.js +12 -8
- package/build/module/lib/scanner/ScannerCfg.js +2 -2
- package/build/module/lib/scanner/ScannerQueue.d.ts +3 -0
- package/build/module/lib/scanner/ScannerQueue.js +4 -0
- package/build/module/lib/scanner/ScannerTypes.d.ts +9 -2
- package/build/module/lib/scanner/ScannerTypes.js +7 -1
- package/build/module/lib/scanner/WfpProvider/FingerprintPackage.d.ts +9 -0
- package/build/module/lib/scanner/WfpProvider/FingerprintPackage.js +30 -0
- package/build/module/lib/scanner/WfpProvider/WfpCalculator/WfpCalculator.js +178 -20
- package/build/module/lib/scanner/WfpProvider/WfpCalculator/Winnower.d.ts +3 -0
- package/build/module/lib/scanner/WfpProvider/WfpCalculator/Winnower.js +211 -0
- package/build/module/lib/scanner/WfpProvider/WfpProvider.d.ts +2 -2
- package/build/module/lib/scanner/WfpProvider/WfpProvider.js +6 -6
- package/build/tsconfig.module.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -17
- package/src/bin/cli-bin.ts +4 -1
- package/src/commands/fingerprint.ts +26 -17
- package/src/commands/scan.ts +16 -3
- package/src/lib/dependencies/DependencyScanner.ts +20 -13
- package/src/lib/dependencies/LocalDependency/LocalDependency.ts +8 -2
- package/src/lib/dependencies/LocalDependency/parsers/golangParser.ts +67 -15
- package/src/lib/dependencies/LocalDependency/parsers/mavenParser.ts +143 -16
- package/src/lib/dependencies/LocalDependency/parsers/npmParser.ts +182 -7
- package/src/lib/scanner/Dispatcher/DispatchableItem.ts +45 -11
- package/src/lib/scanner/Dispatcher/Dispatcher.ts +11 -14
- package/src/lib/scanner/Scanner.ts +17 -13
- package/src/lib/scanner/ScannerCfg.ts +2 -1
- package/src/lib/scanner/ScannerTypes.ts +10 -2
- package/src/lib/scanner/WfpProvider/{FingerprintPacket.ts → FingerprintPackage.ts} +4 -14
- package/src/lib/scanner/WfpProvider/WfpCalculator/WfpCalculator.ts +177 -20
- package/src/lib/scanner/WfpProvider/WfpProvider.ts +5 -5
- package/tests/WfpCalculator.spec.ts +103 -0
- package/tests/data/dependencies/Gemfile/1/Gemfile +6 -0
- package/tests/data/dependencies/Gemfile/1/Gemfile~ +0 -0
- package/tests/data/dependencies/Gemfile/2/Gemfile +3 -0
- package/tests/data/dependencies/Gemfile/2/Gemfile~ +6 -0
- package/tests/data/dependencies/Gemfile/3/Gemfile +7 -0
- package/tests/data/dependencies/Gemfile/3/Gemfile~ +6 -0
- package/tests/data/dependencies/Gemfile/4/Gemfile +31 -0
- package/tests/data/dependencies/Gemfile/4/Gemfile~ +7 -0
- package/tests/data/dependencies/Gemfile.lock/1/Gemfile.lock +180 -0
- package/tests/data/dependencies/Gemfile.lock/2/Gemfile.lock +60 -0
- package/tests/data/dependencies/Gemfile.lock/2/Gemfile.lock~ +0 -0
- package/tests/data/dependencies/go.sum/1/go.sum +119 -0
- package/tests/data/dependencies/go.sum/depJSON.sh +23 -0
- package/tests/data/dependencies/package-lock/1/package-lock.json +715 -0
- package/tests/data/dependencies/package-lock/2/package-lock.json +32069 -0
- package/tests/data/dependencies/package-lock/3/package-lock.json +9013 -0
- package/tests/data/dependencies/pom.xml/1/pom.xml +162 -0
- package/tests/data/dependencies/yarn-lock/generate_expected_output.sh +4 -0
- package/tests/data/dependencies/yarn-lock/v1/yarn.lock +50 -0
- package/tests/data/dependencies/yarn-lock/v1/yarn.lock-expected +13 -0
- package/tests/data/dependencies/yarn-lock/v1-complex/yarn.lock +27 -0
- package/tests/data/dependencies/yarn-lock/v1-complex/yarn.lock-expected +8 -0
- package/tests/data/dependencies/yarn-lock/v1-complex2/yarn.lock +220 -0
- package/tests/data/dependencies/yarn-lock/v2/yarn.lock +31 -0
- package/tests/data/dependencies/yarn-lock/v2/yarn.lock-expected +57 -0
- package/tests/data/dependencies/yarn-lock/v2-local/yarn.lock +11 -0
- package/tests/data/dependencies/yarn-lock/v2-local/yarn.lock-expected +27204 -0
- package/tests/data/scanner/file1.c +41 -0
- package/tests/data/scanner/file2.go +87 -0
- package/tests/dependencies/golangParser.goModParser.specs.ts +146 -0
- package/tests/dependencies/npmParser.spec.ts +133 -0
- package/tsconfig.json +4 -3
- package/yarn.lock +4596 -5321
- package/examples/defaultFilter.json +0 -203
- package/package-lock.json +0 -18588
- package/src/lib/scanner/Winnower/WinnowerExtractor.ts +0 -37
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
typedef struct
|
|
2
|
+
|
|
3
|
+
unsigned long used_memory;
|
|
4
|
+
|
|
5
|
+
unsigned int uint_max;
|
|
6
|
+
unsigned long ulong_max;
|
|
7
|
+
|
|
8
|
+
json_settings settings;
|
|
9
|
+
int first_pass;
|
|
10
|
+
|
|
11
|
+
const json_char *ptr;
|
|
12
|
+
unsigned int cur_line, cur_col;
|
|
13
|
+
|
|
14
|
+
} json_state;
|
|
15
|
+
|
|
16
|
+
static void *default_alloc(size_t size, int zero, void *user_data)
|
|
17
|
+
{
|
|
18
|
+
return zero ? calloc(1, size) : malloc(size);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static void default_free(void *ptr, void *user_data)
|
|
22
|
+
{
|
|
23
|
+
free(ptr);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static void *json_alloc(json_state *state, unsigned long size, int zero)
|
|
27
|
+
{
|
|
28
|
+
if ((state->ulong_max - state->used_memory) < size)
|
|
29
|
+
return 0;
|
|
30
|
+
|
|
31
|
+
if (state->settings.max_memory && (state->used_memory += size) > state->settings.max_memory)
|
|
32
|
+
{
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return state->settings.mem_alloc(size, zero, state->settings.user_data);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static int new_value(json_state *state,
|
|
40
|
+
json_value **top, json_value **root, json_value **alloc,
|
|
41
|
+
json_type type) {}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
|
2
|
+
|
|
3
|
+
/* package command-line-arguments */
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#line 1 "cgo-builtin-export-prolog"
|
|
7
|
+
|
|
8
|
+
#include <stddef.h> /* for ptrdiff_t below */
|
|
9
|
+
|
|
10
|
+
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
11
|
+
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
12
|
+
|
|
13
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
14
|
+
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
/* Start of preamble from import "C" comments. */
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
#line 3 "libhpsm.go"
|
|
23
|
+
|
|
24
|
+
struct ranges{
|
|
25
|
+
char *local;
|
|
26
|
+
char *remote;
|
|
27
|
+
char *matched;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
#line 1 "cgo-generated-wrapper"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/* End of preamble from import "C" comments. */
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/* Start of boilerplate cgo prologue. */
|
|
38
|
+
#line 1 "cgo-gcc-export-header-prolog"
|
|
39
|
+
|
|
40
|
+
#ifndef GO_CGO_PROLOGUE_H
|
|
41
|
+
#define GO_CGO_PROLOGUE_H
|
|
42
|
+
|
|
43
|
+
typedef signed char GoInt8;
|
|
44
|
+
typedef unsigned char GoUint8;
|
|
45
|
+
typedef short GoInt16;
|
|
46
|
+
typedef unsigned short GoUint16;
|
|
47
|
+
typedef int GoInt32;
|
|
48
|
+
typedef unsigned int GoUint32;
|
|
49
|
+
typedef long long GoInt64;
|
|
50
|
+
typedef unsigned long long GoUint64;
|
|
51
|
+
typedef GoInt64 GoInt;
|
|
52
|
+
typedef GoUint64 GoUint;
|
|
53
|
+
typedef __SIZE_TYPE__ GoUintptr;
|
|
54
|
+
typedef float GoFloat32;
|
|
55
|
+
typedef double GoFloat64;
|
|
56
|
+
typedef float _Complex GoComplex64;
|
|
57
|
+
typedef double _Complex GoComplex128;
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
static assertion to make sure the file is being used on architecture
|
|
61
|
+
at least with matching size of GoInt.
|
|
62
|
+
*/
|
|
63
|
+
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
64
|
+
|
|
65
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
66
|
+
typedef _GoString_ GoString;
|
|
67
|
+
#endif
|
|
68
|
+
typedef void *GoMap;
|
|
69
|
+
typedef void *GoChan;
|
|
70
|
+
typedef struct { void *t; void *v; } GoInterface;
|
|
71
|
+
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
72
|
+
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
/* End of boilerplate cgo prologue. */
|
|
76
|
+
|
|
77
|
+
#ifdef __cplusplus
|
|
78
|
+
extern "C" {
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
extern char* HashFileContents(char* data);
|
|
82
|
+
extern struct ranges HPSM(char* data, char* md5);
|
|
83
|
+
extern struct ranges ProcessHPSM(unsigned char* data, int length, char* md5);
|
|
84
|
+
|
|
85
|
+
#ifdef __cplusplus
|
|
86
|
+
}
|
|
87
|
+
#endif
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { goSumParser } from '../../src/lib/dependencies/LocalDependency/parsers/golangParser'
|
|
3
|
+
import { ILocalDependency } from '../../src/lib/dependencies/LocalDependency/DependencyTypes'
|
|
4
|
+
import { expect } from 'chai';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe('Suit test for go sum parser', function() {
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
it('Testing valids go.sum files', function (){
|
|
11
|
+
const tests: [{
|
|
12
|
+
inputPath: string;
|
|
13
|
+
expectedResult: ILocalDependency;
|
|
14
|
+
}] = [{
|
|
15
|
+
inputPath: "./tests/data/dependencies/go.sum/1/go.sum",
|
|
16
|
+
expectedResult: {file: 'go.sum', purls: [
|
|
17
|
+
{purl:"pkg:golang/cloud.google.com/go", requirement:"v0.26.0"},
|
|
18
|
+
{purl:"pkg:golang/cloud.google.com/go", requirement:"v0.34.0"},
|
|
19
|
+
{purl:"pkg:golang/github.com/BurntSushi/toml", requirement:"v0.3.1"},
|
|
20
|
+
{purl:"pkg:golang/github.com/antihax/optional", requirement:"v1.0.0"},
|
|
21
|
+
{purl:"pkg:golang/github.com/census-instrumentation/opencensus-proto", requirement:"v0.2.1"},
|
|
22
|
+
{purl:"pkg:golang/github.com/cespare/xxhash/v2", requirement:"v2.1.1"},
|
|
23
|
+
{purl:"pkg:golang/github.com/client9/misspell", requirement:"v0.3.4"},
|
|
24
|
+
{purl:"pkg:golang/github.com/cncf/udpa/go", requirement:"v0.0.0-20191209042840-269d4d468f6f"},
|
|
25
|
+
{purl:"pkg:golang/github.com/cncf/udpa/go", requirement:"v0.0.0-20201120205902-5459f2c99403"},
|
|
26
|
+
{purl:"pkg:golang/github.com/cncf/udpa/go", requirement:"v0.0.0-20210930031921-04548b0d99d4"},
|
|
27
|
+
{purl:"pkg:golang/github.com/cncf/xds/go", requirement:"v0.0.0-20210805033703-aa0b78936158"},
|
|
28
|
+
{purl:"pkg:golang/github.com/cncf/xds/go", requirement:"v0.0.0-20210922020428-25de7278fc84"},
|
|
29
|
+
{purl:"pkg:golang/github.com/cncf/xds/go", requirement:"v0.0.0-20211011173535-cb28da3451f1"},
|
|
30
|
+
{purl:"pkg:golang/github.com/davecgh/go-spew", requirement:"v1.1.0"},
|
|
31
|
+
{purl:"pkg:golang/github.com/envoyproxy/go-control-plane", requirement:"v0.9.0"},
|
|
32
|
+
{purl:"pkg:golang/github.com/envoyproxy/go-control-plane", requirement:"v0.9.1-0.20191026205805-5f8ba28d4473"},
|
|
33
|
+
{purl:"pkg:golang/github.com/envoyproxy/go-control-plane", requirement:"v0.9.4"},
|
|
34
|
+
{purl:"pkg:golang/github.com/envoyproxy/go-control-plane", requirement:"v0.9.9-0.20201210154907-fd9021fe5dad"},
|
|
35
|
+
{purl:"pkg:golang/github.com/envoyproxy/go-control-plane", requirement:"v0.9.10-0.20210907150352-cf90f659a021"},
|
|
36
|
+
{purl:"pkg:golang/github.com/envoyproxy/protoc-gen-validate", requirement:"v0.1.0"},
|
|
37
|
+
{purl:"pkg:golang/github.com/ghodss/yaml", requirement:"v1.0.0"},
|
|
38
|
+
{purl:"pkg:golang/github.com/golang/glog", requirement:"v0.0.0-20160126235308-23def4e6c14b"},
|
|
39
|
+
{purl:"pkg:golang/github.com/golang/mock", requirement:"v1.1.1"},
|
|
40
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.2.0"},
|
|
41
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.3.2"},
|
|
42
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.3.3"},
|
|
43
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.4.0-rc.1"},
|
|
44
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.4.0-rc.1.0.20200221234624-67d41d38c208"},
|
|
45
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.4.0-rc.2"},
|
|
46
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.4.0-rc.4.0.20200313231945-b860323f09d0"},
|
|
47
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.4.0"},
|
|
48
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.4.1"},
|
|
49
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.4.2"},
|
|
50
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.4.3"},
|
|
51
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.5.0"},
|
|
52
|
+
{purl:"pkg:golang/github.com/golang/protobuf", requirement:"v1.5.0"},
|
|
53
|
+
{purl:"pkg:golang/github.com/google/go-cmp", requirement:"v0.2.0"},
|
|
54
|
+
{purl:"pkg:golang/github.com/google/go-cmp", requirement:"v0.3.0"},
|
|
55
|
+
{purl:"pkg:golang/github.com/google/go-cmp", requirement:"v0.3.1"},
|
|
56
|
+
{purl:"pkg:golang/github.com/google/go-cmp", requirement:"v0.4.0"},
|
|
57
|
+
{purl:"pkg:golang/github.com/google/go-cmp", requirement:"v0.5.0"},
|
|
58
|
+
{purl:"pkg:golang/github.com/google/go-cmp", requirement:"v0.5.5"},
|
|
59
|
+
{purl:"pkg:golang/github.com/google/go-cmp", requirement:"v0.5.5"},
|
|
60
|
+
{purl:"pkg:golang/github.com/google/uuid", requirement:"v1.1.2"},
|
|
61
|
+
{purl:"pkg:golang/github.com/grpc-ecosystem/grpc-gateway", requirement:"v1.16.0"},
|
|
62
|
+
{purl:"pkg:golang/github.com/pmezard/go-difflib", requirement:"v1.0.0"},
|
|
63
|
+
{purl:"pkg:golang/github.com/prometheus/client_model", requirement:"v0.0.0-20190812154241-14fe0d1b01d4"},
|
|
64
|
+
{purl:"pkg:golang/github.com/rogpeppe/fastuuid", requirement:"v1.2.0"},
|
|
65
|
+
{purl:"pkg:golang/github.com/stretchr/objx", requirement:"v0.1.0"},
|
|
66
|
+
{purl:"pkg:golang/github.com/stretchr/testify", requirement:"v1.5.1"},
|
|
67
|
+
{purl:"pkg:golang/github.com/stretchr/testify", requirement:"v1.7.0"},
|
|
68
|
+
{purl:"pkg:golang/go.opentelemetry.io/proto/otlp", requirement:"v0.7.0"},
|
|
69
|
+
{purl:"pkg:golang/golang.org/x/crypto", requirement:"v0.0.0-20190308221718-c2843e01d9a2"},
|
|
70
|
+
{purl:"pkg:golang/golang.org/x/crypto", requirement:"v0.0.0-20200622213623-75b288015ac9"},
|
|
71
|
+
{purl:"pkg:golang/golang.org/x/exp", requirement:"v0.0.0-20190121172915-509febef88a4"},
|
|
72
|
+
{purl:"pkg:golang/golang.org/x/lint", requirement:"v0.0.0-20181026193005-c67002cb31c3"},
|
|
73
|
+
{purl:"pkg:golang/golang.org/x/lint", requirement:"v0.0.0-20190227174305-5b3e6a55c961"},
|
|
74
|
+
{purl:"pkg:golang/golang.org/x/lint", requirement:"v0.0.0-20190313153728-d0100b6bd8b3"},
|
|
75
|
+
{purl:"pkg:golang/golang.org/x/net", requirement:"v0.0.0-20180724234803-3673e40ba225"},
|
|
76
|
+
{purl:"pkg:golang/golang.org/x/net", requirement:"v0.0.0-20180826012351-8a410e7b638d"},
|
|
77
|
+
{purl:"pkg:golang/golang.org/x/net", requirement:"v0.0.0-20190108225652-1e06a53dbb7e"},
|
|
78
|
+
{purl:"pkg:golang/golang.org/x/net", requirement:"v0.0.0-20190213061140-3a22650c66bd"},
|
|
79
|
+
{purl:"pkg:golang/golang.org/x/net", requirement:"v0.0.0-20190311183353-d8887717615a"},
|
|
80
|
+
{purl:"pkg:golang/golang.org/x/net", requirement:"v0.0.0-20190404232315-eb5bcb51f2a3"},
|
|
81
|
+
{purl:"pkg:golang/golang.org/x/net", requirement:"v0.0.0-20200822124328-c89045814202"},
|
|
82
|
+
{purl:"pkg:golang/golang.org/x/net", requirement:"v0.0.0-20200822124328-c89045814202"},
|
|
83
|
+
{purl:"pkg:golang/golang.org/x/oauth2", requirement:"v0.0.0-20180821212333-d2e6202438be"},
|
|
84
|
+
{purl:"pkg:golang/golang.org/x/oauth2", requirement:"v0.0.0-20200107190931-bf48bf16ab8d"},
|
|
85
|
+
{purl:"pkg:golang/golang.org/x/sync", requirement:"v0.0.0-20180314180146-1d60e4601c6f"},
|
|
86
|
+
{purl:"pkg:golang/golang.org/x/sync", requirement:"v0.0.0-20181108010431-42b317875d0f"},
|
|
87
|
+
{purl:"pkg:golang/golang.org/x/sync", requirement:"v0.0.0-20181221193216-37e7f081c4d4"},
|
|
88
|
+
{purl:"pkg:golang/golang.org/x/sync", requirement:"v0.0.0-20190423024810-112230192c58"},
|
|
89
|
+
{purl:"pkg:golang/golang.org/x/sys", requirement:"v0.0.0-20180830151530-49385e6e1522"},
|
|
90
|
+
{purl:"pkg:golang/golang.org/x/sys", requirement:"v0.0.0-20190215142949-d0b11bdaac8a"},
|
|
91
|
+
{purl:"pkg:golang/golang.org/x/sys", requirement:"v0.0.0-20190412213103-97732733099d"},
|
|
92
|
+
{purl:"pkg:golang/golang.org/x/sys", requirement:"v0.0.0-20200323222414-85ca7c5b95cd"},
|
|
93
|
+
{purl:"pkg:golang/golang.org/x/sys", requirement:"v0.0.0-20200323222414-85ca7c5b95cd"},
|
|
94
|
+
{purl:"pkg:golang/golang.org/x/text", requirement:"v0.3.0"},
|
|
95
|
+
{purl:"pkg:golang/golang.org/x/text", requirement:"v0.3.0"},
|
|
96
|
+
{purl:"pkg:golang/golang.org/x/tools", requirement:"v0.0.0-20190114222345-bf090417da8b"},
|
|
97
|
+
{purl:"pkg:golang/golang.org/x/tools", requirement:"v0.0.0-20190226205152-f727befe758c"},
|
|
98
|
+
{purl:"pkg:golang/golang.org/x/tools", requirement:"v0.0.0-20190311212946-11955173bddd"},
|
|
99
|
+
{purl:"pkg:golang/golang.org/x/tools", requirement:"v0.0.0-20190524140312-2c0ae7006135"},
|
|
100
|
+
{purl:"pkg:golang/golang.org/x/xerrors", requirement:"v0.0.0-20191204190536-9bdfabe68543"},
|
|
101
|
+
{purl:"pkg:golang/golang.org/x/xerrors", requirement:"v0.0.0-20200804184101-5ec99f83aff1"},
|
|
102
|
+
{purl:"pkg:golang/golang.org/x/xerrors", requirement:"v0.0.0-20200804184101-5ec99f83aff1"},
|
|
103
|
+
{purl:"pkg:golang/google.golang.org/appengine", requirement:"v1.1.0"},
|
|
104
|
+
{purl:"pkg:golang/google.golang.org/appengine", requirement:"v1.4.0"},
|
|
105
|
+
{purl:"pkg:golang/google.golang.org/genproto", requirement:"v0.0.0-20180817151627-c66870c02cf8"},
|
|
106
|
+
{purl:"pkg:golang/google.golang.org/genproto", requirement:"v0.0.0-20190819201941-24fa4b261c55"},
|
|
107
|
+
{purl:"pkg:golang/google.golang.org/genproto", requirement:"v0.0.0-20200513103714-09dca8ec2884"},
|
|
108
|
+
{purl:"pkg:golang/google.golang.org/genproto", requirement:"v0.0.0-20200526211855-cb27e3aa2013"},
|
|
109
|
+
{purl:"pkg:golang/google.golang.org/genproto", requirement:"v0.0.0-20200526211855-cb27e3aa2013"},
|
|
110
|
+
{purl:"pkg:golang/google.golang.org/grpc", requirement:"v1.19.0"},
|
|
111
|
+
{purl:"pkg:golang/google.golang.org/grpc", requirement:"v1.23.0"},
|
|
112
|
+
{purl:"pkg:golang/google.golang.org/grpc", requirement:"v1.25.1"},
|
|
113
|
+
{purl:"pkg:golang/google.golang.org/grpc", requirement:"v1.27.0"},
|
|
114
|
+
{purl:"pkg:golang/google.golang.org/grpc", requirement:"v1.33.1"},
|
|
115
|
+
{purl:"pkg:golang/google.golang.org/grpc", requirement:"v1.36.0"},
|
|
116
|
+
{purl:"pkg:golang/google.golang.org/grpc", requirement:"v1.42.0"},
|
|
117
|
+
{purl:"pkg:golang/google.golang.org/grpc", requirement:"v1.42.0"},
|
|
118
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v0.0.0-20200109180630-ec00e32a8dfd"},
|
|
119
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v0.0.0-20200221191635-4d8936d0db64"},
|
|
120
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v0.0.0-20200228230310-ab0ca4ff8a60"},
|
|
121
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.20.1-0.20200309200217-e05f789c0967"},
|
|
122
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.21.0"},
|
|
123
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.22.0"},
|
|
124
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.23.0"},
|
|
125
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.23.1-0.20200526195155-81db48ad09cc"},
|
|
126
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.25.0"},
|
|
127
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.26.0-rc.1"},
|
|
128
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.27.1"},
|
|
129
|
+
{purl:"pkg:golang/google.golang.org/protobuf", requirement:"v1.27.1"},
|
|
130
|
+
{purl:"pkg:golang/gopkg.in/check.v1", requirement:"v0.0.0-20161208181325-20d25e280405"},
|
|
131
|
+
{purl:"pkg:golang/gopkg.in/yaml.v2", requirement:"v2.2.2"},
|
|
132
|
+
{purl:"pkg:golang/gopkg.in/yaml.v2", requirement:"v2.2.3"},
|
|
133
|
+
{purl:"pkg:golang/gopkg.in/yaml.v3", requirement:"v3.0.0-20200313102051-9f266ea9e77c"},
|
|
134
|
+
{purl:"pkg:golang/honnef.co/go/tools", requirement:"v0.0.0-20190102054323-c2f93a96b099"},
|
|
135
|
+
{purl:"pkg:golang/honnef.co/go/tools", requirement:"v0.0.0-20190523083050-ea95bdfd59fc"},
|
|
136
|
+
]}
|
|
137
|
+
}];
|
|
138
|
+
|
|
139
|
+
for (const test of tests) {
|
|
140
|
+
const fileContent = fs.readFileSync(test.inputPath, {encoding:'utf-8'});
|
|
141
|
+
const result = goSumParser(fileContent, 'go.sum');
|
|
142
|
+
expect(result).to.deep.equal(test.expectedResult)
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import {
|
|
3
|
+
packagelockParser,
|
|
4
|
+
yarnLockParser
|
|
5
|
+
} from '../../src/lib/dependencies/LocalDependency/parsers/npmParser';
|
|
6
|
+
import { ILocalDependency } from '../../src/lib/dependencies/LocalDependency/DependencyTypes'
|
|
7
|
+
import { expect } from 'chai';
|
|
8
|
+
|
|
9
|
+
describe('Suit test for package lock parser', function() {
|
|
10
|
+
|
|
11
|
+
it('Testing valids package-lock.json files', function (){
|
|
12
|
+
const tests: [{
|
|
13
|
+
inputPath: string;
|
|
14
|
+
expectedResult: ILocalDependency;
|
|
15
|
+
}] = [{
|
|
16
|
+
inputPath: "./tests/data/dependencies/package-lock/1/package-lock.json",
|
|
17
|
+
expectedResult: {file: 'package-lock.json', purls: [
|
|
18
|
+
{purl: "pkg:npm/ansi-regex", requirement: "3.0.1"},
|
|
19
|
+
{purl: "pkg:npm/ansi-styles",requirement: "4.3.0"},
|
|
20
|
+
{purl: "pkg:npm/camelcase", requirement: "5.3.1"},
|
|
21
|
+
{purl: "pkg:npm/cliui", requirement: "6.0.0"},
|
|
22
|
+
{purl: "pkg:npm/ansi-regex", requirement: "5.0.1"},
|
|
23
|
+
{purl: "pkg:npm/is-fullwidth-code-point", requirement: "3.0.0"},
|
|
24
|
+
{purl: "pkg:npm/string-width", requirement: "4.2.3"},
|
|
25
|
+
{purl: "pkg:npm/strip-ansi", requirement: "6.0.1"},
|
|
26
|
+
{purl: "pkg:npm/color-convert", requirement: "2.0.1"},
|
|
27
|
+
{purl: "pkg:npm/color-name", requirement: "1.1.4"},
|
|
28
|
+
{purl: "pkg:npm/cowsay", requirement: "1.5.0"},
|
|
29
|
+
{purl: "pkg:npm/decamelize", requirement: "1.2.0"},
|
|
30
|
+
{purl: "pkg:npm/emoji-regex", requirement: "8.0.0"},
|
|
31
|
+
{purl: "pkg:npm/find-up", requirement: "4.1.0"},
|
|
32
|
+
{purl: "pkg:npm/get-caller-file", requirement: "2.0.5"},
|
|
33
|
+
{purl: "pkg:npm/get-stdin", requirement: "8.0.0"},
|
|
34
|
+
{purl: "pkg:npm/is-fullwidth-code-point", requirement: "2.0.0"},
|
|
35
|
+
{purl: "pkg:npm/locate-path", requirement: "5.0.0"},
|
|
36
|
+
{purl: "pkg:npm/p-limit", requirement: "2.3.0"},
|
|
37
|
+
{purl: "pkg:npm/p-locate", requirement: "4.1.0"},
|
|
38
|
+
{purl: "pkg:npm/p-try", requirement: "2.2.0"},
|
|
39
|
+
{purl: "pkg:npm/path-exists", requirement: "4.0.0"},
|
|
40
|
+
{purl: "pkg:npm/require-directory", requirement: "2.1.1"},
|
|
41
|
+
{purl: "pkg:npm/require-main-filename", requirement: "2.0.0"},
|
|
42
|
+
{purl: "pkg:npm/set-blocking", requirement: "2.0.0"},
|
|
43
|
+
{purl: "pkg:npm/string-width", requirement: "2.1.1"},
|
|
44
|
+
{purl: "pkg:npm/strip-ansi", requirement: "4.0.0"},
|
|
45
|
+
{purl: "pkg:npm/strip-final-newline", requirement: "2.0.0"},
|
|
46
|
+
{purl: "pkg:npm/which-module", requirement: "2.0.0"},
|
|
47
|
+
{purl: "pkg:npm/wrap-ansi", requirement: "6.2.0"},
|
|
48
|
+
{purl: "pkg:npm/ansi-regex", requirement: "5.0.1"},
|
|
49
|
+
{purl: "pkg:npm/is-fullwidth-code-point", requirement: "3.0.0"},
|
|
50
|
+
{purl: "pkg:npm/string-width", requirement: "4.2.3"},
|
|
51
|
+
{purl: "pkg:npm/strip-ansi", requirement: "6.0.1"},
|
|
52
|
+
{purl: "pkg:npm/y18n", requirement: "4.0.3"},
|
|
53
|
+
{purl: "pkg:npm/yargs", requirement: "15.4.1"},
|
|
54
|
+
{purl: "pkg:npm/yargs-parser", requirement: "18.1.3"},
|
|
55
|
+
{purl: "pkg:npm/ansi-regex", requirement: "5.0.1"},
|
|
56
|
+
{purl: "pkg:npm/is-fullwidth-code-point", requirement: "3.0.0"},
|
|
57
|
+
{purl: "pkg:npm/string-width", requirement: "4.2.3"},
|
|
58
|
+
{purl: "pkg:npm/strip-ansi", requirement: "6.0.1"}
|
|
59
|
+
]}
|
|
60
|
+
}];
|
|
61
|
+
|
|
62
|
+
for (const test of tests) {
|
|
63
|
+
const fileContent = fs.readFileSync(test.inputPath, {encoding:'utf-8'});
|
|
64
|
+
const result = packagelockParser(fileContent, 'package-lock.json');
|
|
65
|
+
expect(test.expectedResult).to.deep.equal(result)
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
it('Testing invalid package-lock.json', function () {
|
|
71
|
+
const packageLock = {
|
|
72
|
+
name: "broken",
|
|
73
|
+
version: "1.0.0",
|
|
74
|
+
lockfileVersion: 2,
|
|
75
|
+
requires: true,
|
|
76
|
+
packages: {
|
|
77
|
+
"": {},
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const outputExpected: ILocalDependency = {file: 'package-lock.json', purls: []};
|
|
82
|
+
const deps = packagelockParser(JSON.stringify(packageLock), 'package-lock.json')
|
|
83
|
+
expect(outputExpected).to.deep.equal(deps)
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
it('Testing invalid name', function () {
|
|
88
|
+
const outputExpected: ILocalDependency = {file: '.json', purls: []};
|
|
89
|
+
const deps = packagelockParser(JSON.stringify({}), '.json')
|
|
90
|
+
expect(outputExpected).to.deep.equal(deps)
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
it('Testing broken JSON', function () {
|
|
95
|
+
const emptyPackageLock = "{}" ;
|
|
96
|
+
const outputExpected: ILocalDependency = {file: 'package-lock.json', purls: []};
|
|
97
|
+
const deps = packagelockParser(JSON.stringify(emptyPackageLock), 'package-lock.json')
|
|
98
|
+
expect(outputExpected).to.deep.equal(deps)
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('Testing broken JSON', function () {
|
|
102
|
+
const emptyPackageLock = "{{asddsasdasaddsa,.,..,00045g{}" ;
|
|
103
|
+
const outputExpected: ILocalDependency = {file: 'package-lock.json', purls: []};
|
|
104
|
+
const deps = packagelockParser(JSON.stringify(emptyPackageLock), 'package-lock.json')
|
|
105
|
+
expect(outputExpected).to.deep.equal(deps)
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
// Command used to generate the expected output
|
|
112
|
+
// scancode --json-pp - --package yarn.lock | jq -c '.files[0].packages[0].dependencies[] | { "purl": .purl , "requirement": .requirement }'
|
|
113
|
+
describe('Suit test for yarn lock files', function() {
|
|
114
|
+
|
|
115
|
+
it('Testing yarn lock file v1', function() {
|
|
116
|
+
const expectedOutput = JSON.parse(fs.readFileSync('./tests/data/dependencies/yarn-lock/v1/yarn.lock-expected', 'utf-8'));
|
|
117
|
+
const yarnLock = fs.readFileSync('./tests/data/dependencies/yarn-lock/v1/yarn.lock', 'utf-8')
|
|
118
|
+
const results = yarnLockParser(yarnLock, 'yarn.lock');
|
|
119
|
+
|
|
120
|
+
expect(results).to.be.deep.equal(expectedOutput)
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('Testing yarn lock file v1 complex', function() {
|
|
124
|
+
const expectedOutput = JSON.parse(fs.readFileSync('./tests/data/dependencies/yarn-lock/v1-complex/yarn.lock-expected', 'utf-8'));
|
|
125
|
+
const yarnLock = fs.readFileSync('./tests/data/dependencies/yarn-lock/v1-complex/yarn.lock', 'utf-8')
|
|
126
|
+
const results = yarnLockParser(yarnLock, 'yarn.lock');
|
|
127
|
+
|
|
128
|
+
expect(results).to.be.deep.equal(expectedOutput)
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
12
12
|
"resolveJsonModule": true /* Include modules imported with .json extension. */,
|
|
13
13
|
|
|
14
|
-
"allowJs":
|
|
14
|
+
"allowJs": false,
|
|
15
15
|
"checkJs": false,
|
|
16
|
+
"noImplicitUseStrict": true,
|
|
16
17
|
|
|
17
18
|
/* Debugging Options */
|
|
18
19
|
"traceResolution": false /* Report module resolution log messages. */,
|
|
@@ -21,10 +22,10 @@
|
|
|
21
22
|
"pretty": true /* Stylize errors and messages using color and context. */,
|
|
22
23
|
|
|
23
24
|
"lib": ["es2017"],
|
|
24
|
-
"types": ["node"],
|
|
25
|
+
"types": ["mocha","node"],
|
|
25
26
|
"typeRoots": ["node_modules/@types", "src/types"]
|
|
26
27
|
},
|
|
27
28
|
"include": ["./src" , "./src/**/*.ts", "./src/scanoss/*" ],
|
|
28
|
-
"exclude": ["node_modules"],
|
|
29
|
+
"exclude": ["node_modules", "tests/data/*"],
|
|
29
30
|
"compileOnSave": false
|
|
30
31
|
}
|