Repository navigation
Conversation
The qualifiers where not correct Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: OzTamari <oz.tamari@whitesourcesoftware.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: OzTamari <oz.tamari@whitesourcesoftware.com>
Reported-by: Rich Steenwyk <rich.steenwyk@gmail.com> Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: OzTamari <oz.tamari@whitesourcesoftware.com>
1. yaml creation missing encoding. 2. NoAssert cannot be written to a file (not serializable) as it does not have default repr. 3. Problem creating relationships Signed-off-by: OzTamari <oz.tamari@whitesourcesoftware.com>
Signed-off-by: OzTamari <oz.tamari@whitesourcesoftware.com>
Signed-off-by: OzTamari <oz.tamari@whitesourcesoftware.com>
1. yaml creation missing encoding. 2. NoAssert cannot be written to a file (not serializable) as it does not have default repr. 3. Problem creating relationships Signed-off-by: OzTamari <oz.tamari@whitesourcesoftware.com>
Signed-off-by: OzTamari <oz.tamari@whitesourcesoftware.com>
…ccording to SPDX 2.2 spec 7.9.1 (only for JSON, XML, YAML as it does not happen on TV)
licquia
left a comment
There was a problem hiding this comment.
I don't think we're going to add a dependency on numpy for all users of the library. Also, could you add tests for the specific deficiencies you fixed?
| from spdx.writers.tagvalue import InvalidDocumentError | ||
| from spdx.writers.jsonyamlxml import Writer | ||
| from spdx.parsers.loggers import ErrorMessages | ||
| import numpy as np |
There was a problem hiding this comment.
Can you remove the dependency on numpy? You should be able to test for regular int, float, etc.
Signed-off-by: rammatzkvosky <ram.matzkovsky@whitesourcesoftware.com>
…ue is not available at WhiteSource Updating setup.py version to '0.7.0a3.post6' Signed-off-by: rammatzkvosky <ram.matzkovsky@whitesourcesoftware.com>
nicoweidner
left a comment
There was a problem hiding this comment.
There are several valuable fixes in this PR, but several other things need more work.
@tamari-oz: Given the age of this PR, it would be greatly appreciated if you could indicate whether you are still active and will have time to finish the PR. Else I would try to take over so we can get the fixes merged.
| name='ws-spdx-tools', | ||
| version='0.7.0a3.post7', |
There was a problem hiding this comment.
I assume these changes are from the fork and shouldn't be committed?
| messages.append( | ||
| "Package checksum must be instance of spdx.checksum.Algorithm" | ||
| ) | ||
| # this check was added by the WhiteSouse PS Team ( for cases where SHA1 is not available at WhiteSource ) |
There was a problem hiding this comment.
I haven't seen such attribution comments elsewhere in the project, and I don't think they are viable. If there are many contributors, it would lead to a lot of clutter. I would be grateful if you remove them here and in other locations where they were added
There was a problem hiding this comment.
Hi @rammatzkvosky ! Since we didn't hear back for a while, @meretp took over this PR and put up a new version here. Hope that is alright!
| except: | ||
| pass |
There was a problem hiding this comment.
Just swallowing all exceptions is bad. Why was this added?
| if not self.check_sum.value: | ||
| delattr(self, 'check_sum') |
There was a problem hiding this comment.
I don't understand what this accomplishes. If a checksum object without a value is present, it gets removed - does some downstream check depend on this?
Also, if the instance check above fails, we are still adding a validation error message. Is that intended?
Sorry if I am being slow here, I just started working on this project 😅
There was a problem hiding this comment.
@nicoweidner -In our platform, there are cases where a package sha1 is missing ( empty value ).
For tv format, there is a downstream check for that which fails the report.
For that reason, we add this check.
| self.relationship_comment = relationship_comment | ||
|
|
||
| def __eq__(self, other): | ||
| return True if self.relationship == other.relationship else False |
There was a problem hiding this comment.
This should include an instance check on the other object:
| return True if self.relationship == other.relationship else False | |
| return ( | |
| isInstance(other, Relationship) | |
| and self.relationship == other.relationship | |
| ) |
| unique_doc_packages = {} | ||
| for doc_package in self.document.packages: | ||
| if doc_package.spdx_id not in unique_doc_packages.keys(): | ||
| unique_doc_packages[doc_package.spdx_id] = doc_package |
There was a problem hiding this comment.
Similar to the extracted licenses: Fine for now, but eventually I would move this to validations
| # commented by the WS PS Team | ||
| # package_objects = [] | ||
| # for package in self.document.packages: | ||
| # package_info_object = self.create_package_info(package) | ||
| # package_info_object["files"] = self.create_file_info(package) | ||
| # package_objects.append({"Package": package_info_object}) | ||
| # | ||
| # self.document_object["documentDescribes"] = package_objects | ||
|
|
||
| # the previous code block has been adjusted by the WhiteSouse PS Team. | ||
| # adding documentDescribes and packages sections. |
There was a problem hiding this comment.
Please remove the comments. It will be in the git history anyway, and the comments will just clutter the code
| package_objects.append({"Package": package_info_object}) | ||
| if package.files: | ||
| package_info_object["files"] = self.create_file_info(package) | ||
| # create a list of the packages' names for the 'documentDescribes' field |
There was a problem hiding this comment.
| # create a list of the packages' names for the 'documentDescribes' field | |
| # create a list of the packages' spdx ids for the 'documentDescribes' field |
| Return a list of relationship nodes | ||
| """ | ||
| return map(self.create_relationship_node, self.document.relationships) | ||
| return list(map(self.create_relationship_node, self.document.relationships)) |
There was a problem hiding this comment.
I don't think it makes a difference here whether we return an iterable or a list. The doc says it returns a list, but then again all other similar functions return an iterable as well, so I'm inclined to leave it that way (or fix all the docs)
| # Add relationship | ||
| for relate_node in self.relationships(): | ||
| relate_triple = (doc_node, self.spdx_namespace.relationship, relate_node) | ||
| self.graph.add(relate_triple) |
There was a problem hiding this comment.
I tried this out using
$ convertor -f tag data/SPDXTagExample -o output.rdf
and the output contained this, which doesn't seem to make sense (relationships should be separate entities):
<ns1:relationship>
<ns1:Relationship rdf:about="SPDXRef-DOCUMENT">
<ns1:relationshipType>CONTAINS</ns1:relationshipType>
<ns1:relationshipType>DESCRIBES</ns1:relationshipType>
<ns1:relationshipType>COPY_OF</ns1:relationshipType>
<ns1:relatedSpdxElement>SPDXRef-File</ns1:relatedSpdxElement>
<ns1:relatedSpdxElement>DocumentRef-spdx-tool-1.2:SPDXRef-ToolsElement</ns1:relatedSpdxElement>
<ns1:relatedSpdxElement>SPDXRef-Package</ns1:relatedSpdxElement>
</ns1:Relationship>
</ns1:relationship>
I think this either needs more work, or should be handled as a separate issue - whichever way you prefer!
|
@tamari-oz, do you plan to get back to this? |
|
I will continue this in #263, which I already rebased on |
4 fixes are addressed: