In updating the application Packages scanning step in the scan_codebase pipeline for #447, I noticed that the CodebaseResources of a Package are not associated with the Packages that was scanned. Looking a little deeper, I see that the Package Resources in scancode.io cannot be properly associated to the Package they are from by using the .assemble() methods from packagedcode's Package handlers. This is because of how for_packages is implemented on the CodebaseResource model in scancode.io and the Resource model in commoncode. In scancode.io, for_packages on the CodebaseResource model is a property that collects the purls for Packages that have been related to that CodebaseResource. In scancode-toolkit/commoncode, for_packages on the Resource model is a list that contains package_uid strings for the Package the Resource is from.
When you run the .assemble() methods from packagedcode Package handlers on a CodebaseResource object, it attempts to append package_uid strings to the for_packages field. This does not properly work since CodebaseResource.for_packages is a property, not an attribute that can be used the same way.
In updating the application Packages scanning step in the scan_codebase pipeline for #447, I noticed that the
CodebaseResources of aPackageare not associated with thePackages that was scanned. Looking a little deeper, I see that thePackageResources in scancode.io cannot be properly associated to thePackagethey are from by using the.assemble()methods frompackagedcode'sPackagehandlers. This is because of howfor_packagesis implemented on theCodebaseResourcemodel in scancode.io and theResourcemodel incommoncode. In scancode.io,for_packageson theCodebaseResourcemodel is a property that collects the purls forPackages that have been related to thatCodebaseResource. In scancode-toolkit/commoncode,for_packageson theResourcemodel is a list that containspackage_uidstrings for thePackagetheResourceis from.When you run the
.assemble()methods frompackagedcodePackage handlers on aCodebaseResourceobject, it attempts to appendpackage_uidstrings to thefor_packagesfield. This does not properly work sinceCodebaseResource.for_packagesis a property, not an attribute that can be used the same way.