Skip to content

Commit c3cbd41

Browse files
Fix packages bug for single file resources
Package_manifests were not being collected when there was a single file in the codebase, this fixes the bug and regenerates tests. Signed-off-by: Ayan Sinha <ayansmahapatra@gmail.com>
1 parent 46f4b69 commit c3cbd41

13 files changed

Lines changed: 631 additions & 14 deletions

src/packagedcode/plugin_package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ def process_codebase(self, codebase, **kwargs):
8787
"""
8888
Set the package root given a package "type".
8989
"""
90+
create_packages_from_manifests(codebase, **kwargs)
91+
9092
if codebase.has_single_resource:
9193
# What if we scanned a single file and we do not have a root proper?
9294
return
9395

9496
for resource in codebase.walk(topdown=False):
9597
set_packages_root(resource, codebase)
9698

97-
create_packages_from_manifests(codebase, **kwargs)
98-
9999

100100
def create_packages_from_manifests(codebase, **kwargs):
101101
"""

tests/licensedcode/data/plugin_license/package/package.expected.json

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,79 @@
1818
}
1919
}
2020
],
21-
"packages": [],
21+
"packages": [
22+
{
23+
"type": "npm",
24+
"namespace": null,
25+
"name": "busboy",
26+
"version": "0.2.14",
27+
"qualifiers": {},
28+
"subpath": null,
29+
"primary_language": "JavaScript",
30+
"description": "A streaming parser for HTML form data for node.js",
31+
"release_date": null,
32+
"parties": [
33+
{
34+
"type": "person",
35+
"role": "author",
36+
"name": "Brian White",
37+
"email": "mscdex@mscdex.net",
38+
"url": null
39+
}
40+
],
41+
"keywords": [
42+
"uploads",
43+
"forms",
44+
"multipart",
45+
"form-data"
46+
],
47+
"homepage_url": null,
48+
"download_url": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
49+
"size": null,
50+
"sha1": null,
51+
"md5": null,
52+
"sha256": null,
53+
"sha512": null,
54+
"bug_tracking_url": null,
55+
"code_view_url": null,
56+
"vcs_url": "git+http://github.com/mscdex/busboy.git",
57+
"copyright": null,
58+
"license_expression": "mit",
59+
"declared_license": [
60+
{
61+
"type": "MIT",
62+
"url": "http://github.com/mscdex/busboy/raw/master/LICENSE"
63+
}
64+
],
65+
"notice_text": null,
66+
"root_path": null,
67+
"dependencies": [
68+
{
69+
"purl": "pkg:npm/dicer",
70+
"requirement": "0.2.5",
71+
"scope": "dependencies",
72+
"is_runtime": true,
73+
"is_optional": false,
74+
"is_resolved": false
75+
},
76+
{
77+
"purl": "pkg:npm/readable-stream",
78+
"requirement": "1.1.x",
79+
"scope": "dependencies",
80+
"is_runtime": true,
81+
"is_optional": false,
82+
"is_resolved": false
83+
}
84+
],
85+
"contains_source_code": null,
86+
"source_packages": [],
87+
"extra_data": {},
88+
"purl": "pkg:npm/busboy@0.2.14",
89+
"repository_homepage_url": "https://www.npmjs.com/package/busboy",
90+
"repository_download_url": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
91+
"api_data_url": "https://registry.npmjs.org/busboy/0.2.14"
92+
}
93+
],
2294
"files": [
2395
{
2496
"path": "package.json",

tests/packagedcode/data/plugin/about-package-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"errors": [],
1616
"extra_data": {
1717
"spdx_license_list_version": "3.14",
18-
"files_count": 4
18+
"files_count": 2
1919
}
2020
}
2121
],

tests/packagedcode/data/plugin/com-package-expected.json

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,56 @@
1919
}
2020
}
2121
],
22-
"packages": [],
22+
"packages": [
23+
{
24+
"type": "winexe",
25+
"namespace": null,
26+
"name": "Microsoft\u00ae Windows\u00ae Operating System",
27+
"version": "10.0.17763.1",
28+
"qualifiers": {},
29+
"subpath": null,
30+
"primary_language": null,
31+
"description": "Change CodePage Utility",
32+
"release_date": null,
33+
"parties": [
34+
{
35+
"type": "organization",
36+
"role": "author",
37+
"name": "Microsoft Corporation",
38+
"email": null,
39+
"url": null
40+
}
41+
],
42+
"keywords": [],
43+
"homepage_url": null,
44+
"download_url": null,
45+
"size": null,
46+
"sha1": null,
47+
"md5": null,
48+
"sha256": null,
49+
"sha512": null,
50+
"bug_tracking_url": null,
51+
"code_view_url": null,
52+
"vcs_url": null,
53+
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
54+
"license_expression": "unknown",
55+
"declared_license": {
56+
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
57+
"LegalTrademarks": "",
58+
"License": null
59+
},
60+
"notice_text": null,
61+
"root_path": null,
62+
"dependencies": [],
63+
"contains_source_code": null,
64+
"source_packages": [],
65+
"extra_data": {},
66+
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%20System@10.0.17763.1",
67+
"repository_homepage_url": null,
68+
"repository_download_url": null,
69+
"api_data_url": null
70+
}
71+
],
2372
"files": [
2473
{
2574
"path": "chcp.com",

tests/packagedcode/data/plugin/mui-package-expected.json

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,56 @@
1919
}
2020
}
2121
],
22-
"packages": [],
22+
"packages": [
23+
{
24+
"type": "winexe",
25+
"namespace": null,
26+
"name": "Microsoft\u00ae Windows\u00ae Operating System",
27+
"version": "10.0.18362.1256",
28+
"qualifiers": {},
29+
"subpath": null,
30+
"primary_language": null,
31+
"description": "Common Log File System Driver",
32+
"release_date": null,
33+
"parties": [
34+
{
35+
"type": "organization",
36+
"role": "author",
37+
"name": "Microsoft Corporation",
38+
"email": null,
39+
"url": null
40+
}
41+
],
42+
"keywords": [],
43+
"homepage_url": null,
44+
"download_url": null,
45+
"size": null,
46+
"sha1": null,
47+
"md5": null,
48+
"sha256": null,
49+
"sha512": null,
50+
"bug_tracking_url": null,
51+
"code_view_url": null,
52+
"vcs_url": null,
53+
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
54+
"license_expression": "unknown",
55+
"declared_license": {
56+
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
57+
"LegalTrademarks": "",
58+
"License": null
59+
},
60+
"notice_text": null,
61+
"root_path": null,
62+
"dependencies": [],
63+
"contains_source_code": null,
64+
"source_packages": [],
65+
"extra_data": {},
66+
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%20System@10.0.18362.1256",
67+
"repository_homepage_url": null,
68+
"repository_download_url": null,
69+
"api_data_url": null
70+
}
71+
],
2372
"files": [
2473
{
2574
"path": "clfs.sys.mui",

tests/packagedcode/data/plugin/mum-package-expected.json

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,52 @@
1919
}
2020
}
2121
],
22-
"packages": [],
22+
"packages": [
23+
{
24+
"type": "windows-update",
25+
"namespace": null,
26+
"name": "Package_1_for_KB4601060",
27+
"version": "10.0.3770.4",
28+
"qualifiers": {},
29+
"subpath": null,
30+
"primary_language": null,
31+
"description": "Fix for KB4601060",
32+
"release_date": null,
33+
"parties": [
34+
{
35+
"type": "organization",
36+
"role": "owner",
37+
"name": "Microsoft Corporation",
38+
"email": null,
39+
"url": null
40+
}
41+
],
42+
"keywords": [],
43+
"homepage_url": "http://support.microsoft.com/?kbid=4601060",
44+
"download_url": null,
45+
"size": null,
46+
"sha1": null,
47+
"md5": null,
48+
"sha256": null,
49+
"sha512": null,
50+
"bug_tracking_url": null,
51+
"code_view_url": null,
52+
"vcs_url": null,
53+
"copyright": "Microsoft Corporation",
54+
"license_expression": null,
55+
"declared_license": null,
56+
"notice_text": null,
57+
"root_path": null,
58+
"dependencies": [],
59+
"contains_source_code": null,
60+
"source_packages": [],
61+
"extra_data": {},
62+
"purl": "pkg:windows-update/Package_1_for_KB4601060@10.0.3770.4",
63+
"repository_homepage_url": null,
64+
"repository_download_url": null,
65+
"api_data_url": null
66+
}
67+
],
2368
"files": [
2469
{
2570
"path": "test.mum",

tests/packagedcode/data/plugin/mun-package-expected.json

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,56 @@
1919
}
2020
}
2121
],
22-
"packages": [],
22+
"packages": [
23+
{
24+
"type": "winexe",
25+
"namespace": null,
26+
"name": "Microsoft\u00ae Windows\u00ae Operating System",
27+
"version": "10.0.18362.1256",
28+
"qualifiers": {},
29+
"subpath": null,
30+
"primary_language": null,
31+
"description": "Crypto API32",
32+
"release_date": null,
33+
"parties": [
34+
{
35+
"type": "organization",
36+
"role": "author",
37+
"name": "Microsoft Corporation",
38+
"email": null,
39+
"url": null
40+
}
41+
],
42+
"keywords": [],
43+
"homepage_url": null,
44+
"download_url": null,
45+
"size": null,
46+
"sha1": null,
47+
"md5": null,
48+
"sha256": null,
49+
"sha512": null,
50+
"bug_tracking_url": null,
51+
"code_view_url": null,
52+
"vcs_url": null,
53+
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
54+
"license_expression": "unknown",
55+
"declared_license": {
56+
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
57+
"LegalTrademarks": "",
58+
"License": null
59+
},
60+
"notice_text": null,
61+
"root_path": null,
62+
"dependencies": [],
63+
"contains_source_code": null,
64+
"source_packages": [],
65+
"extra_data": {},
66+
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%20System@10.0.18362.1256",
67+
"repository_homepage_url": null,
68+
"repository_download_url": null,
69+
"api_data_url": null
70+
}
71+
],
2372
"files": [
2473
{
2574
"path": "crypt32.dll.mun",

tests/packagedcode/data/plugin/sys-package-expected.json

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,56 @@
1919
}
2020
}
2121
],
22-
"packages": [],
22+
"packages": [
23+
{
24+
"type": "winexe",
25+
"namespace": null,
26+
"name": "Microsoft\u00ae Windows\u00ae Operating System",
27+
"version": "10.0.17763.1697",
28+
"qualifiers": {},
29+
"subpath": null,
30+
"primary_language": null,
31+
"description": "Export driver for kernel mode TPM API",
32+
"release_date": null,
33+
"parties": [
34+
{
35+
"type": "organization",
36+
"role": "author",
37+
"name": "Microsoft Corporation",
38+
"email": null,
39+
"url": null
40+
}
41+
],
42+
"keywords": [],
43+
"homepage_url": null,
44+
"download_url": null,
45+
"size": null,
46+
"sha1": null,
47+
"md5": null,
48+
"sha256": null,
49+
"sha512": null,
50+
"bug_tracking_url": null,
51+
"code_view_url": null,
52+
"vcs_url": null,
53+
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
54+
"license_expression": "unknown",
55+
"declared_license": {
56+
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
57+
"LegalTrademarks": "",
58+
"License": null
59+
},
60+
"notice_text": null,
61+
"root_path": null,
62+
"dependencies": [],
63+
"contains_source_code": null,
64+
"source_packages": [],
65+
"extra_data": {},
66+
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%20System@10.0.17763.1697",
67+
"repository_homepage_url": null,
68+
"repository_download_url": null,
69+
"api_data_url": null
70+
}
71+
],
2372
"files": [
2473
{
2574
"path": "tbs.sys",

0 commit comments

Comments
 (0)