Skip to content

Commit 7d668cb

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 7d668cb

12 files changed

Lines changed: 558 additions & 13 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/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",

tests/packagedcode/data/plugin/tlb-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": "STDOLE2.TLB",
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": "stdole2.tlb",

0 commit comments

Comments
 (0)