Skip to content

Commit

Permalink
Update rubygem package building functions #74
Browse files Browse the repository at this point in the history
    * Update expected test results

Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed May 11, 2023
1 parent 5958df8 commit bc66f39
Show file tree
Hide file tree
Showing 20 changed files with 1,136 additions and 112 deletions.
16 changes: 8 additions & 8 deletions minecode/mappers/rubygems.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def build_rubygem_packages_from_api_data(metadata, name, purl=None):
party = scan_models.Party(name=author, role='author')
package['parties'].append(party)

declared_licenses = []
extracted_license_statement = []
licenses = version_details.get('licenses')
if licenses:
for lic in licenses:
declared_licenses.append(lic)
if declared_licenses:
package['declared_license'] = '\n'.join(declared_licenses)
extracted_license_statement.append(lic)
if extracted_license_statement:
package['extracted_license_statement'] = extracted_license_statement
package = PackageData(**package)
package.set_purl(purl)
yield package
Expand Down Expand Up @@ -129,13 +129,13 @@ def build_rubygem_packages_from_metadata(metadata, download_url=None, purl=None)
if download_url:
package['download_url'] = download_url

declared_licenses = []
extracted_license_statement = []
licenses = content.get('licenses')
if licenses:
for lic in licenses:
declared_licenses.append(lic)
if declared_licenses:
package['declared_license'] = '\n'.join(declared_licenses)
extracted_license_statement.append(lic)
if extracted_license_statement:
package['extracted_license_statement'] = extracted_license_statement

authors = content.get('authors')
for author in authors:
Expand Down
30 changes: 28 additions & 2 deletions minecode/tests/testfiles/rubygems/0mq-0.4.1.gem.package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,34 @@
"code_view_url": null,
"vcs_url": null,
"copyright": null,
"license_expression": null,
"declared_license": "MIT",
"holder": null,
"declared_license_expression": "mit",
"declared_license_expression_spdx": "MIT",
"license_detections": [
{
"license_expression": "mit",
"matches": [
{
"score": 100.0,
"start_line": 1,
"end_line": 1,
"matched_length": 1,
"match_coverage": 100.0,
"matcher": "1-spdx-id",
"license_expression": "mit",
"rule_identifier": "spdx-license-identifier-mit-5da48780aba670b0860c46d899ed42a0f243ff06",
"rule_relevance": 100,
"rule_url": null,
"matched_text": "MIT"
}
],
"identifier": "mit-a822f434-d61f-f2b1-c792-8b8cb9e7b9bf"
}
],
"other_license_expression": null,
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "['MIT']",
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
10 changes: 8 additions & 2 deletions minecode/tests/testfiles/rubygems/a_okay-0.1.0.gem.package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@
"code_view_url": null,
"vcs_url": null,
"copyright": null,
"license_expression": null,
"declared_license": null,
"holder": null,
"declared_license_expression": null,
"declared_license_expression_spdx": null,
"license_detections": [],
"other_license_expression": null,
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,34 @@
"code_view_url": null,
"vcs_url": null,
"copyright": null,
"license_expression": null,
"declared_license": "MIT",
"holder": null,
"declared_license_expression": "mit",
"declared_license_expression_spdx": "MIT",
"license_detections": [
{
"license_expression": "mit",
"matches": [
{
"score": 100.0,
"start_line": 1,
"end_line": 1,
"matched_length": 1,
"match_coverage": 100.0,
"matcher": "1-spdx-id",
"license_expression": "mit",
"rule_identifier": "spdx-license-identifier-mit-5da48780aba670b0860c46d899ed42a0f243ff06",
"rule_relevance": 100,
"rule_url": null,
"matched_text": "MIT"
}
],
"identifier": "mit-a822f434-d61f-f2b1-c792-8b8cb9e7b9bf"
}
],
"other_license_expression": null,
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": "['MIT']",
"notice_text": null,
"source_packages": [],
"file_references": [],
Expand Down
20 changes: 16 additions & 4 deletions minecode/tests/testfiles/rubygems/apiv1/0xffffff.api.package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@
"code_view_url":null,
"vcs_url":null,
"copyright":null,
"license_expression":null,
"declared_license":null,
"holder":null,
"declared_license_expression":null,
"declared_license_expression_spdx":null,
"license_detections":[],
"other_license_expression":null,
"other_license_expression_spdx":null,
"other_license_detections":[],
"extracted_license_statement":null,
"notice_text":null,
"source_packages":[],
"file_references":[],
Expand Down Expand Up @@ -74,8 +80,14 @@
"code_view_url":null,
"vcs_url":null,
"copyright":null,
"license_expression":null,
"declared_license":null,
"holder":null,
"declared_license_expression":null,
"declared_license_expression_spdx":null,
"license_detections":[],
"other_license_expression":null,
"other_license_expression_spdx":null,
"other_license_detections":[],
"extracted_license_statement":null,
"notice_text":null,
"source_packages":[],
"file_references":[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@
"code_view_url":null,
"vcs_url":null,
"copyright":null,
"license_expression":null,
"declared_license":null,
"holder":null,
"declared_license_expression":null,
"declared_license_expression_spdx":null,
"license_detections":[],
"other_license_expression":null,
"other_license_expression_spdx":null,
"other_license_detections":[],
"extracted_license_statement":null,
"notice_text":null,
"source_packages":[],
"file_references":[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@
"code_view_url":null,
"vcs_url":null,
"copyright":null,
"license_expression":null,
"declared_license":null,
"holder":null,
"declared_license_expression":null,
"declared_license_expression_spdx":null,
"license_detections":[],
"other_license_expression":null,
"other_license_expression_spdx":null,
"other_license_detections":[],
"extracted_license_statement":null,
"notice_text":null,
"source_packages":[],
"file_references":[],
Expand Down
Loading

0 comments on commit bc66f39

Please sign in to comment.