From 681a35f196eeeca5855c12fc1716724ae4bfe6bd Mon Sep 17 00:00:00 2001 From: hrithik yadav Date: Thu, 15 Aug 2024 19:48:45 +0530 Subject: [PATCH] adding tests for deep license scanning --- .../analyzer/language/dotnet/nuget/nuget.go | 2 - .../analyzer/language/nodejs/npm/npm_test.go | 284 ++++++++++++++++++ .../npm/testdata/deep-license-scan/LICENSE | 27 ++ .../node_modules/babel-runtime/LICENSE | 27 ++ .../node_modules/core-js/test2.go | 29 ++ .../node_modules/regenerator-runtime/LICENSE | 27 ++ .../regenerator-runtime/package.json | 19 ++ .../node_modules/regenerator-runtime/test1.go | 21 ++ .../node_modules/babel-runtime/package.json | 16 + .../node_modules/babel-runtime/temp_1.txt | 1 + .../node_modules/babel-runtime/temp_2.txt | 1 + .../jiti/node_modules/ninja/LICENSE | 6 + .../jiti/node_modules/ninja/package.json | 17 ++ .../node_modules/jiti/package.json | 15 + .../node_modules/jiti/temp_3.text | 0 .../node_modules/jujutsu/LICENSE | 27 ++ .../node_modules/regenerator-runtime/LICENSE | 27 ++ .../node_modules/core-js/LICENSE | 19 ++ .../node_modules/core-js/package.json | 73 +++++ .../node_modules/core-js/test2.go | 29 ++ .../regenerator-runtime/package.json | 19 ++ .../node_modules/regenerator-runtime/test1.go | 21 ++ .../node_modules/jujutsu/package.json | 15 + .../node_modules/jujutsu/test.go | 1 + .../deep-license-scan/package-lock.json | 65 ++++ .../npm/testdata/deep-license-scan/test.js | 1 + .../npm/testdata/deep-license-scan/test2.go | 25 ++ 27 files changed, 812 insertions(+), 2 deletions(-) create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/LICENSE create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/LICENSE create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/core-js/test2.go create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/LICENSE create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/package.json create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/test1.go create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/package.json create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/temp_1.txt create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/temp_2.txt create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/node_modules/ninja/LICENSE create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/node_modules/ninja/package.json create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/package.json create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/temp_3.text create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/LICENSE create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/LICENSE create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/LICENSE create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/package.json create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/test2.go create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/package.json create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/test1.go create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/package.json create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/test.go create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/package-lock.json create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/test.js create mode 100644 pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/test2.go diff --git a/pkg/fanal/analyzer/language/dotnet/nuget/nuget.go b/pkg/fanal/analyzer/language/dotnet/nuget/nuget.go index 8c4acaff7fd9..891eda26bd5f 100644 --- a/pkg/fanal/analyzer/language/dotnet/nuget/nuget.go +++ b/pkg/fanal/analyzer/language/dotnet/nuget/nuget.go @@ -135,8 +135,6 @@ func (a *nugetLibraryAnalyzer) PostAnalyze(_ context.Context, input analyzer.Pos return xerrors.Errorf("license find error: %w", err) } - a.logger.Info("Number of root path licenses found: ", log.Any("Count", len(rootPathLicenses))) - for _, license := range rootPathLicenses { looseLicense := types.LicenseFile{ Type: license.Type, diff --git a/pkg/fanal/analyzer/language/nodejs/npm/npm_test.go b/pkg/fanal/analyzer/language/nodejs/npm/npm_test.go index 695fa80e040d..e0cd3d3639d3 100644 --- a/pkg/fanal/analyzer/language/nodejs/npm/npm_test.go +++ b/pkg/fanal/analyzer/language/nodejs/npm/npm_test.go @@ -2,7 +2,9 @@ package npm import ( "context" + "encoding/json" "os" + "slices" "sort" "testing" @@ -288,3 +290,285 @@ func Test_nodePkgLibraryAnalyzer_Required(t *testing.T) { }) } } + +func TestDeepLicenseScanning(t *testing.T) { + tests := []struct { + name string + dir string + want *analyzer.AnalysisResult + }{ + { + name: "deep-license-scan", + dir: "testdata/deep-license-scan", + want: &analyzer.AnalysisResult{ + Applications: []types.Application{ + { + Type: types.Npm, + FilePath: "package-lock.json", + Packages: types.Packages{ + { + ID: "babel-runtime@6.26.0", + Name: "babel-runtime", + Version: "6.26.0", + Licenses: []string{ + "MIT", + }, + ConcludedLicenses: []types.License{ + { + Name: "Apache-2.0", + Type: "header", + IsDeclared: false, + FilePath: "node_modules/babel-runtime/node_modules/core-js/test2.go", + LicenseTextChecksum: "bdc80008ee57ce3815ac3d8be33e4bad3508d5729dd8cbbbe6c799245ee77edd", + CopyrightText: "", + }, + { + Name: "BSD-3-Clause", + Type: "license-file", + IsDeclared: false, + FilePath: "node_modules/babel-runtime/LICENSE", + LicenseTextChecksum: "385bce4f8bf50fb890c351674d4eac08fae03de787f2b37332f6184245706df6", + CopyrightText: "", + }, + }, + + Indirect: true, + Relationship: types.RelationshipIndirect, + DependsOn: []string{ + "core-js@2.6.12", + "regenerator-runtime@0.11.1", + }, + Locations: []types.Location{ + { + StartLine: 11, + EndLine: 19, + }, + }, + ExternalReferences: []types.ExternalRef{ + { + Type: types.RefOther, + URL: "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + }, + }, + }, + { + ID: "core-js@2.6.12", + Name: "core-js", + Version: "2.6.12", + Indirect: true, + Relationship: types.RelationshipIndirect, + Locations: []types.Location{ + { + StartLine: 20, + EndLine: 26, + }, + { + StartLine: 59, + EndLine: 63, + }, + }, + ExternalReferences: []types.ExternalRef{ + { + Type: types.RefOther, + URL: "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + }, + { + Type: types.RefOther, + URL: "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + }, + }, + }, + { + ID: "jiti@1.21.0", + Name: "jiti", + Version: "1.21.0", + Licenses: []string{ + "MIT", + }, + Indirect: true, + Relationship: types.RelationshipIndirect, + DependsOn: []string{ + "ninja@6.26.0", + }, + Locations: []types.Location{ + { + StartLine: 32, + EndLine: 39, + }, + }, + ExternalReferences: []types.ExternalRef{ + { + Type: types.RefOther, + URL: "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + }, + }, + }, + { + ID: "jujutsu@1.20.20", + Name: "jujutsu", + Version: "1.20.20", + Indirect: true, + Relationship: types.RelationshipIndirect, + DependsOn: []string{ + "regenerator-runtime@0.11.1", + }, + Locations: []types.Location{ + { + StartLine: 45, + EndLine: 53, + }, + }, + ExternalReferences: []types.ExternalRef{ + { + Type: types.RefOther, + URL: "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + }, + }, + }, + { + ID: "ninja@6.26.0", + Name: "ninja", + Version: "6.26.0", + Licenses: []string{ + "MIT", + }, + ConcludedLicenses: []types.License{ + { + Name: "GPL-2.0", + Type: "header", + IsDeclared: false, + FilePath: "node_modules/jiti/node_modules/ninja/LICENSE", + LicenseTextChecksum: "1d1291699fa1a23d6414a3a3994dcf8db6bacf6c5ab6624a7231b1543e6dfe27", + CopyrightText: "", + }, + }, + Indirect: true, + Relationship: types.RelationshipIndirect, + Locations: []types.Location{ + { + StartLine: 40, + EndLine: 44, + }, + }, + ExternalReferences: []types.ExternalRef{ + { + Type: types.RefOther, + URL: "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + }, + }, + }, + { + ID: "regenerator-runtime@0.11.1", + Name: "regenerator-runtime", + Version: "0.11.1", + Licenses: []string{ + "MIT", + "MIT", + }, + ConcludedLicenses: []types.License{ + { + Name: "BSD-3-Clause", + Type: "license-file", + IsDeclared: false, + FilePath: "node_modules/babel-runtime/node_modules/regenerator-runtime/LICENSE", + LicenseTextChecksum: "385bce4f8bf50fb890c351674d4eac08fae03de787f2b37332f6184245706df6", + CopyrightText: "", + }, + { + Name: "Apache-2.0", + Type: "header", + IsDeclared: false, + FilePath: "node_modules/babel-runtime/node_modules/regenerator-runtime/test1.go", + LicenseTextChecksum: "3ecd2b1a881c13670817e5db77bcfeaa3b76e318ca96037301d6488ff5cd71d6", + CopyrightText: "", + }, + { + Name: "BSD-3-Clause", + Type: "license-file", + IsDeclared: false, + FilePath: "node_modules/babel-runtime/node_modules/regenerator-runtime/.git/LICENSE", + LicenseTextChecksum: "0497daad1a4b665867ffbc3c7e23a4d3bc9f40b8f0f18647c991353176606784", + CopyrightText: "", + }, + }, + Indirect: true, + Relationship: types.RelationshipIndirect, + Locations: []types.Location{ + { + StartLine: 27, + EndLine: 31, + }, + { + StartLine: 54, + EndLine: 58, + }, + }, + ExternalReferences: []types.ExternalRef{ + { + Type: types.RefOther, + URL: "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + }, + }, + }, + }, + }, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + a, err := newNpmLibraryAnalyzer(analyzer.AnalyzerOptions{ + LicenseScannerOption: analyzer.LicenseScannerOption{ + Enabled: true, + Full: true, + LicenseScanWorkers: 5, + ClassifierConfidenceLevel: 0.75, + }, + }) + require.NoError(t, err) + + got, err := a.PostAnalyze(context.Background(), analyzer.PostAnalysisInput{ + FS: os.DirFS(tt.dir), + }) + require.NoError(t, err) + + if len(got.Applications) > 0 { + sort.Sort(got.Applications[0].Packages) + } + + // sort the licenses + for _, app := range got.Applications { + packages := app.Packages + for _, pkg := range packages { + slices.Sort(pkg.Licenses) + sort.SliceStable(pkg.ConcludedLicenses, func(i, j int) bool { + return pkg.ConcludedLicenses[i].Name <= pkg.ConcludedLicenses[j].Name && + pkg.ConcludedLicenses[i].FilePath < pkg.ConcludedLicenses[j].FilePath + }) + } + } + + for _, app := range tt.want.Applications { + packages := app.Packages + for _, pkg := range packages { + slices.Sort(pkg.Licenses) + sort.SliceStable(pkg.ConcludedLicenses, func(i, j int) bool { + return pkg.ConcludedLicenses[i].Name <= pkg.ConcludedLicenses[j].Name && + pkg.ConcludedLicenses[i].FilePath < pkg.ConcludedLicenses[j].FilePath + }) + } + } + + // compared the serialized jsons + serializedGot, err := json.Marshal(got.Applications) + require.NoError(t, err) + + serializedWant, err := json.Marshal(tt.want.Applications) + require.NoError(t, err) + + assert.Equal(t, string(serializedWant), string(serializedGot)) + }) + } +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/LICENSE b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/LICENSE new file mode 100644 index 000000000000..3fb52175f3dd --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. +- Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/LICENSE b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/LICENSE new file mode 100644 index 000000000000..3fb52175f3dd --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. +- Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/core-js/test2.go b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/core-js/test2.go new file mode 100644 index 000000000000..19dc488f3df8 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/core-js/test2.go @@ -0,0 +1,29 @@ +package main + +import ( + "context" + + "gorm.io/gorm/logger" +) + +func MyTestFunc2() { + logger.Info(context.Background(), "In MyTestFunc2 function") +} + +// Copyright 2020 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +func MyTestFunc3() { + logger.Info(context.Background(), "In MyTestFunc3 function") +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/LICENSE b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/LICENSE new file mode 100644 index 000000000000..3fb52175f3dd --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. +- Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/package.json b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/package.json new file mode 100644 index 000000000000..a61d3d555e97 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/package.json @@ -0,0 +1,19 @@ +{ + "name": "regenerator-runtime", + "author": "Ben Newman ", + "description": "Runtime for Regenerator-compiled generator and async functions.", + "version": "0.11.1", + "main": "runtime-module.js", + "keywords": [ + "regenerator", + "runtime", + "generator", + "async" + ], + "repository": { + "type": "git", + "url": "https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime" + }, + "license": "MIT" + } + \ No newline at end of file diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/test1.go b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/test1.go new file mode 100644 index 000000000000..2de6bea269e8 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/node_modules/regenerator-runtime/test1.go @@ -0,0 +1,21 @@ +// Copyright 2020 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import "fmt" + +func MyTestFunc() { + fmt.Println("In MyTestFunc function") +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/package.json b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/package.json new file mode 100644 index 000000000000..c17eb9a34f10 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/package.json @@ -0,0 +1,16 @@ +{ + "name": "babel-runtime", + "version": "6.26.0", + "description": "babel selfContained runtime", + "license": "MIT", + "repository": "https://github.com/babel/babel/tree/master/packages/babel-runtime", + "author": "Sebastian McKenzie ", + "dependencies": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + }, + "devDependencies": { + "babel-helpers": "^6.22.0", + "babel-plugin-transform-runtime": "^6.23.0" + } +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/temp_1.txt b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/temp_1.txt new file mode 100644 index 000000000000..d5b39b3ba986 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/temp_1.txt @@ -0,0 +1 @@ +Hey this is a temporary text file diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/temp_2.txt b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/temp_2.txt new file mode 100644 index 000000000000..d5b39b3ba986 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/babel-runtime/temp_2.txt @@ -0,0 +1 @@ +Hey this is a temporary text file diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/node_modules/ninja/LICENSE b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/node_modules/ninja/LICENSE new file mode 100644 index 000000000000..b916e6784038 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/node_modules/ninja/LICENSE @@ -0,0 +1,6 @@ +Copyright (C) 2023 hrithik yadav +This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program. If not, see . \ No newline at end of file diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/node_modules/ninja/package.json b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/node_modules/ninja/package.json new file mode 100644 index 000000000000..d2d4080ca30f --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/node_modules/ninja/package.json @@ -0,0 +1,17 @@ +{ + "name": "ninja", + "version": "6.26.0", + "description": "Ninja runtime", + "license": "MIT", + "repository": "https://github.com/babel/babel/tree/master/packages/babel-runtime", + "author": "Sebastian McKenzie ", + "dependencies": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + }, + "devDependencies": { + "babel-helpers": "^6.22.0", + "babel-plugin-transform-runtime": "^6.23.0" + } + } + \ No newline at end of file diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/package.json b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/package.json new file mode 100644 index 000000000000..92631473e525 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/package.json @@ -0,0 +1,15 @@ +{ + "name": "jiti", + "version": "1.21.0", + "description": "Runtime typescript and ESM support for Node.js", + "repository": "unjs/jiti", + "license": "MIT", + "main": "./lib/index.js", + "types": "dist/jiti.d.ts", + "bin": "bin/jiti.js", + "files": [ + "lib", + "dist", + "register.js" + ] +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/temp_3.text b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jiti/temp_3.text new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/LICENSE b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/LICENSE new file mode 100644 index 000000000000..3fb52175f3dd --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. +- Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/LICENSE b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/LICENSE new file mode 100644 index 000000000000..3fb52175f3dd --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. +- Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/LICENSE b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/LICENSE new file mode 100644 index 000000000000..9c4e4e17e9bd --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014-2020 Denis Pushkarev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/package.json b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/package.json new file mode 100644 index 000000000000..7869f22d7412 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/package.json @@ -0,0 +1,73 @@ +{ + "name": "core-js", + "description": "Standard library", + "version": "2.6.12", + "repository": { + "type": "git", + "url": "https://github.com/zloirock/core-js.git" + }, + "main": "index.js", + "devDependencies": { + "LiveScript": "1.3.x", + "es-observable-tests": "0.2.x", + "eslint": "4.19.x", + "eslint-plugin-import": "2.12.x", + "grunt": "^1.0.2", + "grunt-cli": "^1.2.0", + "grunt-contrib-clean": "^1.1.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "3.3.x", + "grunt-contrib-watch": "^1.0.0", + "grunt-karma": "^2.0.0", + "grunt-livescript": "0.6.x", + "karma": "^2.0.0", + "karma-qunit": "^2.1.0", + "karma-chrome-launcher": "^2.2.0", + "karma-firefox-launcher": "^1.0.1", + "karma-ie-launcher": "^1.0.0", + "karma-phantomjs-launcher": "1.0.x", + "phantomjs-prebuilt": "2.1.x", + "promises-aplus-tests": "^2.1.2", + "qunit": "2.6.x", + "temp": "^0.8.3", + "webpack": "^3.11.0" + }, + "scripts": { + "grunt": "grunt", + "lint": "eslint ./", + "promises-tests": "promises-aplus-tests tests/promises-aplus/adapter", + "observables-tests": "node tests/observables/adapter && node tests/observables/adapter-library", + "test": "npm run grunt clean copy && npm run lint && npm run grunt livescript client karma:default && npm run grunt library karma:library && npm run promises-tests && npm run observables-tests && lsc tests/commonjs", + "postinstall": "node -e \"try{require('./postinstall')}catch(e){}\"" + }, + "license": "MIT", + "keywords": [ + "ES3", + "ES5", + "ES6", + "ES7", + "ES2015", + "ES2016", + "ES2017", + "ECMAScript 3", + "ECMAScript 5", + "ECMAScript 6", + "ECMAScript 7", + "ECMAScript 2015", + "ECMAScript 2016", + "ECMAScript 2017", + "Harmony", + "Strawman", + "Map", + "Set", + "WeakMap", + "WeakSet", + "Promise", + "Symbol", + "TypedArray", + "setImmediate", + "Dict", + "polyfill", + "shim" + ] +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/test2.go b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/test2.go new file mode 100644 index 000000000000..19dc488f3df8 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js/test2.go @@ -0,0 +1,29 @@ +package main + +import ( + "context" + + "gorm.io/gorm/logger" +) + +func MyTestFunc2() { + logger.Info(context.Background(), "In MyTestFunc2 function") +} + +// Copyright 2020 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +func MyTestFunc3() { + logger.Info(context.Background(), "In MyTestFunc3 function") +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/package.json b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/package.json new file mode 100644 index 000000000000..a61d3d555e97 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/package.json @@ -0,0 +1,19 @@ +{ + "name": "regenerator-runtime", + "author": "Ben Newman ", + "description": "Runtime for Regenerator-compiled generator and async functions.", + "version": "0.11.1", + "main": "runtime-module.js", + "keywords": [ + "regenerator", + "runtime", + "generator", + "async" + ], + "repository": { + "type": "git", + "url": "https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime" + }, + "license": "MIT" + } + \ No newline at end of file diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/test1.go b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/test1.go new file mode 100644 index 000000000000..2de6bea269e8 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/node_modules/regenerator-runtime/test1.go @@ -0,0 +1,21 @@ +// Copyright 2020 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import "fmt" + +func MyTestFunc() { + fmt.Println("In MyTestFunc function") +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/package.json b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/package.json new file mode 100644 index 000000000000..9f508e0cd676 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/package.json @@ -0,0 +1,15 @@ +{ + "name": "kaisen-jujutsu", + "version": "1.20.20", + "description": "The great jujutsu kaisen", + "license": "Apache-2.0", + "author": "Sebastian McKenzie ", + "dependencies": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + }, + "devDependencies": { + "babel-helpers": "^6.22.0", + "babel-plugin-transform-runtime": "^6.23.0" + } +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/test.go b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/test.go new file mode 100644 index 000000000000..06ab7d0f9a35 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/node_modules/jujutsu/test.go @@ -0,0 +1 @@ +package main diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/package-lock.json b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/package-lock.json new file mode 100644 index 000000000000..b7804bf1e72c --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/package-lock.json @@ -0,0 +1,65 @@ +{ + "name": "license-classifier-test", + "version": "1.21.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "license-classifier-test", + "version": "1.21.0" + }, + "node_modules/babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "dependencies": { + "core-js": "^2.6.12", + "regenerator-runtime": "^0.11.1" + } + }, + "node_modules/babel-runtime/node_modules/core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", + "hasInstallScript": true + }, + "node_modules/babel-runtime/node_modules/regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + }, + "node_modules/jiti": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "dependencies": { + "ninja": "^6.26.0" + } + }, + "node_modules/jiti/node_modules/ninja": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==" + }, + "node_modules/jujutsu": { + "version": "1.20.20", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "dependencies": { + "regenerator-runtime": "^0.11.1", + "core-js": "^2.6.12" + } + }, + "node_modules/jujutsu/node_modules/regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + }, + "node_modules/jujutsu/node_modules/regenerator-runtime/node_modules/core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + } + } +} diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/test.js b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/test.js new file mode 100644 index 000000000000..aa0c1c9cfe5b --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/test.js @@ -0,0 +1 @@ +"Copyright 2019 Google LLC\\n\\n Use of this source code is governed by an MIT-style\\n license that can be found in the LICENSE file or at\\n https://opensource.org/licenses/MIT.\\n*/\\nimport './_version.js';\\n/**\\n * Sends a data object to a service worker via postMessage and resolves with\\n * a response (if any).\\n *\\n * A response can be set in a message handler in the service worker by\\n * calling event.ports[0].postMessage(...), which will resolve the promise\\n * returned by messageSW(). If no response is set, the promise will not\\n * resolve.\\n *\\n * @param {ServiceWorker} sw The service worker to send the message to.\\n * @param {Object} data An object to send to the service worker.\\n * @return {Promise\u003cObject|undefined\u003e}\\n * @memberof workbox-window\\n */\\n// Better not change type of data.\\n// eslint-disable-next-line @typescript-eslint/ban-types\\nfunction messageSW(sw, data) {\\n return new Promise((resolve) =\u003e {\\n const messageChannel = new MessageChannel();\\n messageChannel.port1.onmessage = (event) =\u003e {\\n resolve(event.data);\\n };\\n sw.postMessage(data, [messageChannel.port2]);\\n });\\n}\\nexport { messageSW };\\n\",\"\\\"use strict\\\";\\n// @ts-ignore\\ntry {\\n self['workbox:core:6.5.4'] \u0026\u0026 _();\\n}\\ncatch (e) { }\\n\",\"/*\\n Copyright 2018 Google LLC\\n\\n Use of this source code is governed by an MIT-style\\n license that can be found in the LICENSE file or at\\n https://opensource.org/licenses/MIT.\\n*/\\nimport '../_version.js';\\n/**\\n * The Deferred class composes Promises in a way that allows for them to be\\n * resolved or rejected from outside the constructor. In most cases promises\\n * should be used directly, but Deferreds can be necessary when the logic to\\n * resolve a promise must be separate.\\n *\\n * @private\\n */\\nclass Deferred {\\n /**\\n * Creates a promise and exposes its resolve and reject functions as methods.\\n */\\n constructor() {\\n this.promise = new Promise((resolve, reject) =\u003e {\\n this.resolve = resolve;\\n this.reject = reject;\\n });\\n }\\n}\\nexport { Deferred };\\n\",\"/*\\n Copyright 2019 Google LLC\\n Use of this source code is governed by an MIT-style\\n license that can be found in the LICENSE file or at\\n https://opensource.org/licenses/MIT.\\n*/\\nimport '../_version.js';\\n/**\\n * A helper function that prevents a promise from being flagged as unused.\\n *\\n * @private\\n **/\\nexport function dontWaitFor(promise) {\\n // Effective no-op.\\n void promise.then(() =\u003e { });\\n}\\n\",\"/*\\n Copyright 2019 Google LLC\\n Use of this source code is governed by an MIT-style\\n license that can be found in the LICENSE file or at\\n https://opensource.org/licenses/MIT.\\n*/\\nimport '../_version.js';\\nconst logger = (process.env.NODE_ENV === 'production'\\n ? null\\n : (() =\u003e {\\n // Don't overwrite this value if it's already set.\\n // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923\\n if (!('__WB_DISABLE_DEV_LOGS' in globalThis)) {\\n self.__WB_DISABLE_DEV_LOGS = false;\\n }\\n let inGroup = false;\\n const methodToColorMap = {\\n debug: #7f8c8d,\\n log: #2ecc71,\\n warn: #f39c12,\\n error: #c0392b,\\n groupCollapsed: #3498db,\\n groupEnd: null, // No colored prefix on groupEnd\\n };\\n const print = function (method, args) {\\n if (self.__WB_DISABLE_DEV_LOGS) {\\n return;\\n }\\n if (method === 'groupCollapsed') {\\n // Safari doesn't print all console.groupCollapsed() arguments:\\n // https://bugs.webkit.org/show_bug.cgi?id=182754\\n if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {\\n console[method](...args);\\n return;\\n }\\n }\\n const styles = [\\n background: ${methodToColorMap[method]},\\n border-radius: 0.5em,\\n color: white,\\n font-weight: bold,\\n padding: 2px 0.5em,\\n ];\\n // When in a group, the workbox prefix is not displayed.\\n const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];\\n console[method](...logPrefix, ...args);\\n if (method === 'groupCollapsed') {\\n inGroup = true;\\n }\\n if (method === 'groupEnd') {\\n inGroup = false;\\n }\\n };\\n // eslint-disable-next-line @typescript-eslint/ban-types\\n const api = {};\\n const loggerMethods = Object.keys(methodToColorMap);\\n for (const key of loggerMethods) {\\n const method = key;\\n api[method] = (...args) =\u003e {\\n print(method, args);\\n };\\n }\\n return api;\\n })());\\nexport { logger };\\n\",\"/*\\n Copyright 2019 Google LLC\\n\\n Use of this source code is governed by an MIT-style\\n license that can be found in the LICENSE file or at\\n https://opensource.org/licenses/MIT.\\n*/\\n/**\\n * A minimal EventTarget shim.\\n * This is necessary because not all browsers support constructable\\n * EventTarget, so using a real EventTarget will error.\\n * @private\\n */\\nexport class WorkboxEventTarget {\\n constructor() {\\n this._eventListenerRegistry = new Map();\\n }\\n /**\\n * @param {string} type\\n * @param {Function} listener\\n * @private\\n */\\n addEventListener(type, listener) {\\n const foo = this._getEventListenersByType(type);\\n foo.add(listener);\\n }\\n /**\\n * @param {string} type\\n * @param {Function} listener\\n * @private\\n */\\n removeEventListener(type, listener) {\\n this._getEventListenersByType(type).delete(listener);\\n }\\n /**\\n * @param {Object} event\\n * @private\\n */\\n dispatchEvent(event) {\\n event.target = this;\\n const listeners = this._getEventListenersByType(event.type);\\n for (const listener of listeners) {\\n listener(event);\\n }\\n }\\n /**\\n * Returns a Set of listeners associated with the passed event type.\\n * If no handlers have been registered, an empty Set is returned.\\n *\\n * @param {string} type The event type.\\n * @return {Set\u003cListenerCallback\u003e} An array of handler functions.\\n * @private\\n */\\n _getEventListenersByType(type) {\\n if (!this._eventListenerRegistry.has(type)) {\\n this._eventListenerRegistry.set(type, new Set());\\n }\\n return this._eventListenerRegistry.get(type);\\n }\\n}\\n\",\"/*\\n Copyright 2019 Google LLC\\n\\n Use of this source code is governed by an MIT-style\\n license that can be found in the LICENSE file or at\\n https://opensource.org/licenses/MIT.\\n*/\\nimport '../_version.js';\\n/**\\n * Returns true if two URLs have the same .href property. The URLS can be\\n * relative, and if they are the current location href is used to resolve URLs.\\n *\\n * @private\\n * @param {string} url1\\n * @param {string} url2\\n * @return {boolean}\\n */\\nexport function urlsMatch(url1, url2) {\\n const { href } = location;\\n return new URL(url1, href).href === new URL(url2, href).href;\\n}\\n\",\"/*\\n Copyright 2019 Google LLC\\n\\n Use of this source code is governed by an MIT-style\\n license that can be found in the LICENSE file or at\\n https://opensource.org/licenses/MIT.\\n*/\\nimport '../_version.js';\\n/**\\n * A minimal Event subclass shim.\\n * This doesn't *actually* subclass Event because not all browsers support\\n * constructable EventTarget, and using a real Event will error.\\n * @private\\n */\\nexport class WorkboxEvent {\\n constructor(type, props) {\\n this.type = type;\\n Object.assign(this, props);\\n }\\n}\\n\",\"/*\\n Copyright 2019 Google LLC\\n\\n Use of this source code is governed by an MIT-style\\n license that can be found in the LICENSE file or at\\n https://opensource.org/licenses/MIT.\\n*/\\nimport { Deferred } from 'workbox-core/_private/Deferred.js';\\nimport { dontWaitFor } from 'workbox-core/_private/dontWaitFor.js';\\nimport { logger } from 'workbox-core/_private/logger.js';\\nimport { messageSW } from './messageSW.js';\\nimport { WorkboxEventTarget } from './utils/WorkboxEventTarget.js';\\nimport { urlsMatch } from './utils/urlsMatch.js';\\nimport { WorkboxEvent } from './utils/WorkboxEvent.js';\\nimport './_version.js';\\n// The time a SW must be in the waiting phase before we can conclude\\n// skipWaiting() wasn't called. This 200 amount wasn't scientifically\\n// chosen, but it seems to avoid false positives in my testing.\\nconst WAITING_TIMEOUT_DURATION = 200;\\n// The amount of time after a registration that we can reasonably conclude\\n// that the registration didn't trigger an update.\\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\\n// The de facto standard message that a service worker should be listening for\\n// to trigger a call to skipWaiting().\\nconst SKIP_WAITING_MESSAGE = { type: 'SKIP_WAITING' };\\n/**\\n * A class to aid in handling service worker registration, updates, and\\n * reacting to service worker lifecycle events.\\n *\\n * @fires {@link workbox-window.Workbox#message}\\n * @fires {@link workbox-window.Workbox#installed}\\n * @fires {@link workbox-window.Workbox#waiting}\\n * @fires {@link workbox-window.Workbox#controlling}\\n * @fires {@link workbox-window.Workbox#activated}\\n * @fires {@link workbox-window.Workbox#redundant}\\n" \ No newline at end of file diff --git a/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/test2.go b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/test2.go new file mode 100644 index 000000000000..9ff160bedd42 --- /dev/null +++ b/pkg/fanal/analyzer/language/nodejs/npm/testdata/deep-license-scan/test2.go @@ -0,0 +1,25 @@ +package main + +import "context" + +func MyTestFunc2() { + logger.Info(context.Background(), "In MyTestFunc2 function") +} + +// Copyright 2020 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +func MyTestFunc3() { + logger.Info(context.Background(), "In MyTestFunc3 function") +}