Skip to content

Commit

Permalink
Fix packages bug for single file resources
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
AyanSinhaMahapatra committed Sep 29, 2021
1 parent 46f4b69 commit 7d668cb
Show file tree
Hide file tree
Showing 12 changed files with 558 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/packagedcode/plugin_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ def process_codebase(self, codebase, **kwargs):
"""
Set the package root given a package "type".
"""
create_packages_from_manifests(codebase, **kwargs)

if codebase.has_single_resource:
# What if we scanned a single file and we do not have a root proper?
return

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

create_packages_from_manifests(codebase, **kwargs)


def create_packages_from_manifests(codebase, **kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/packagedcode/data/plugin/about-package-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"errors": [],
"extra_data": {
"spdx_license_list_version": "3.14",
"files_count": 4
"files_count": 2
}
}
],
Expand Down
51 changes: 50 additions & 1 deletion tests/packagedcode/data/plugin/com-package-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,56 @@
}
}
],
"packages": [],
"packages": [
{
"type": "winexe",
"namespace": null,
"name": "Microsoft\u00ae Windows\u00ae Operating System",
"version": "10.0.17763.1",
"qualifiers": {},
"subpath": null,
"primary_language": null,
"description": "Change CodePage Utility",
"release_date": null,
"parties": [
{
"type": "organization",
"role": "author",
"name": "Microsoft Corporation",
"email": null,
"url": null
}
],
"keywords": [],
"homepage_url": null,
"download_url": null,
"size": null,
"sha1": null,
"md5": null,
"sha256": null,
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
"vcs_url": null,
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"license_expression": "unknown",
"declared_license": {
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"LegalTrademarks": "",
"License": null
},
"notice_text": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
"extra_data": {},
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%[email protected]",
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null
}
],
"files": [
{
"path": "chcp.com",
Expand Down
51 changes: 50 additions & 1 deletion tests/packagedcode/data/plugin/mui-package-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,56 @@
}
}
],
"packages": [],
"packages": [
{
"type": "winexe",
"namespace": null,
"name": "Microsoft\u00ae Windows\u00ae Operating System",
"version": "10.0.18362.1256",
"qualifiers": {},
"subpath": null,
"primary_language": null,
"description": "Common Log File System Driver",
"release_date": null,
"parties": [
{
"type": "organization",
"role": "author",
"name": "Microsoft Corporation",
"email": null,
"url": null
}
],
"keywords": [],
"homepage_url": null,
"download_url": null,
"size": null,
"sha1": null,
"md5": null,
"sha256": null,
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
"vcs_url": null,
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"license_expression": "unknown",
"declared_license": {
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"LegalTrademarks": "",
"License": null
},
"notice_text": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
"extra_data": {},
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%[email protected]",
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null
}
],
"files": [
{
"path": "clfs.sys.mui",
Expand Down
47 changes: 46 additions & 1 deletion tests/packagedcode/data/plugin/mum-package-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,52 @@
}
}
],
"packages": [],
"packages": [
{
"type": "windows-update",
"namespace": null,
"name": "Package_1_for_KB4601060",
"version": "10.0.3770.4",
"qualifiers": {},
"subpath": null,
"primary_language": null,
"description": "Fix for KB4601060",
"release_date": null,
"parties": [
{
"type": "organization",
"role": "owner",
"name": "Microsoft Corporation",
"email": null,
"url": null
}
],
"keywords": [],
"homepage_url": "http://support.microsoft.com/?kbid=4601060",
"download_url": null,
"size": null,
"sha1": null,
"md5": null,
"sha256": null,
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
"vcs_url": null,
"copyright": "Microsoft Corporation",
"license_expression": null,
"declared_license": null,
"notice_text": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
"extra_data": {},
"purl": "pkg:windows-update/[email protected]",
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null
}
],
"files": [
{
"path": "test.mum",
Expand Down
51 changes: 50 additions & 1 deletion tests/packagedcode/data/plugin/mun-package-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,56 @@
}
}
],
"packages": [],
"packages": [
{
"type": "winexe",
"namespace": null,
"name": "Microsoft\u00ae Windows\u00ae Operating System",
"version": "10.0.18362.1256",
"qualifiers": {},
"subpath": null,
"primary_language": null,
"description": "Crypto API32",
"release_date": null,
"parties": [
{
"type": "organization",
"role": "author",
"name": "Microsoft Corporation",
"email": null,
"url": null
}
],
"keywords": [],
"homepage_url": null,
"download_url": null,
"size": null,
"sha1": null,
"md5": null,
"sha256": null,
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
"vcs_url": null,
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"license_expression": "unknown",
"declared_license": {
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"LegalTrademarks": "",
"License": null
},
"notice_text": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
"extra_data": {},
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%[email protected]",
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null
}
],
"files": [
{
"path": "crypt32.dll.mun",
Expand Down
51 changes: 50 additions & 1 deletion tests/packagedcode/data/plugin/sys-package-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,56 @@
}
}
],
"packages": [],
"packages": [
{
"type": "winexe",
"namespace": null,
"name": "Microsoft\u00ae Windows\u00ae Operating System",
"version": "10.0.17763.1697",
"qualifiers": {},
"subpath": null,
"primary_language": null,
"description": "Export driver for kernel mode TPM API",
"release_date": null,
"parties": [
{
"type": "organization",
"role": "author",
"name": "Microsoft Corporation",
"email": null,
"url": null
}
],
"keywords": [],
"homepage_url": null,
"download_url": null,
"size": null,
"sha1": null,
"md5": null,
"sha256": null,
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
"vcs_url": null,
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"license_expression": "unknown",
"declared_license": {
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"LegalTrademarks": "",
"License": null
},
"notice_text": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
"extra_data": {},
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%[email protected]",
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null
}
],
"files": [
{
"path": "tbs.sys",
Expand Down
51 changes: 50 additions & 1 deletion tests/packagedcode/data/plugin/tlb-package-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,56 @@
}
}
],
"packages": [],
"packages": [
{
"type": "winexe",
"namespace": null,
"name": "Microsoft\u00ae Windows\u00ae Operating System",
"version": "10.0.18362.1256",
"qualifiers": {},
"subpath": null,
"primary_language": null,
"description": "STDOLE2.TLB",
"release_date": null,
"parties": [
{
"type": "organization",
"role": "author",
"name": "Microsoft Corporation",
"email": null,
"url": null
}
],
"keywords": [],
"homepage_url": null,
"download_url": null,
"size": null,
"sha1": null,
"md5": null,
"sha256": null,
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
"vcs_url": null,
"copyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"license_expression": "unknown",
"declared_license": {
"LegalCopyright": "\u00a9 Microsoft Corporation. All rights reserved.",
"LegalTrademarks": "",
"License": null
},
"notice_text": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
"extra_data": {},
"purl": "pkg:winexe/Microsoft%C2%AE%20Windows%C2%AE%20Operating%[email protected]",
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null
}
],
"files": [
{
"path": "stdole2.tlb",
Expand Down
Loading

0 comments on commit 7d668cb

Please sign in to comment.