From ced8f38318bbc202f6731bae8a26ac030dc2ee00 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Tue, 3 Aug 2021 12:21:56 -0700 Subject: [PATCH] Add is_media field to CodebaseResource #238 * Update test results Signed-off-by: Jono Yang --- .../0011_codebaseresource_is_media.py | 18 + scanpipe/models.py | 1 + scanpipe/pipes/scancode.py | 1 - scanpipe/pipes/windows.py | 16 +- .../tests/data/is-npm-1.0.0_scancode.json | 13 +- scanpipe/tests/data/is-npm-1.0.0_summary.json | 710 +++++++++--------- scanpipe/tests/test_api.py | 2 +- 7 files changed, 384 insertions(+), 377 deletions(-) create mode 100644 scanpipe/migrations/0011_codebaseresource_is_media.py diff --git a/scanpipe/migrations/0011_codebaseresource_is_media.py b/scanpipe/migrations/0011_codebaseresource_is_media.py new file mode 100644 index 000000000..f52ef769d --- /dev/null +++ b/scanpipe/migrations/0011_codebaseresource_is_media.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.6 on 2021-08-03 18:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('scanpipe', '0010_codebaseresource_is_key_file'), + ] + + operations = [ + migrations.AddField( + model_name='codebaseresource', + name='is_media', + field=models.BooleanField(default=False), + ), + ] diff --git a/scanpipe/models.py b/scanpipe/models.py index 9d5a4a205..2994776a2 100644 --- a/scanpipe/models.py +++ b/scanpipe/models.py @@ -1036,6 +1036,7 @@ class Type(models.TextChoices): is_text = models.BooleanField(default=False) is_archive = models.BooleanField(default=False) is_key_file = models.BooleanField(default=False) + is_media = models.BooleanField(default=False) class Compliance(models.TextChoices): OK = "ok" diff --git a/scanpipe/pipes/scancode.py b/scanpipe/pipes/scancode.py index 75cde0331..e2b9ec585 100644 --- a/scanpipe/pipes/scancode.py +++ b/scanpipe/pipes/scancode.py @@ -104,7 +104,6 @@ def get_resource_info(location): # Missing fields on CodebaseResource model returned by `get_file_info`. unsupported_fields = [ - "is_media", "is_source", "is_script", "date", diff --git a/scanpipe/pipes/windows.py b/scanpipe/pipes/windows.py index eb7359eab..7a9853a52 100644 --- a/scanpipe/pipes/windows.py +++ b/scanpipe/pipes/windows.py @@ -126,10 +126,10 @@ def _tag_python_software(project): python_root_pattern_compiled = re.compile(python_root_pattern) python_versions_by_path = {} - for python_resource in qs.filter(rootfs_path__regex=r"(^/(Files/)?Python(\d+)?)/.*$"): - match = python_root_pattern_compiled.match( - python_resource.rootfs_path - ) + for python_resource in qs.filter( + rootfs_path__regex=r"(^/(Files/)?Python(\d+)?)/.*$" + ): + match = python_root_pattern_compiled.match(python_resource.rootfs_path) if not match: continue @@ -167,7 +167,9 @@ def _tag_python_software(project): def _tag_openjdk_software(project): qs = project.codebaseresources.no_status() - openjdk_root_pattern = r"^(?P/(Files/)?(open)?jdk(-(?P(\d*)(\.\d+)*))*)/.*$" + openjdk_root_pattern = ( + r"^(?P/(Files/)?(open)?jdk(-(?P(\d*)(\.\d+)*))*)/.*$" + ) openjdk_root_pattern_compiled = re.compile(openjdk_root_pattern) openjdk_versions_by_path = {} @@ -247,9 +249,7 @@ def tag_program_files(project): program_files_dirname_by_path = {} for program_file in qs.filter(rootfs_path__regex=r"^.*/Program Files( \(x86\))?"): - match = program_files_subdir_pattern_compiled.match( - program_file.rootfs_path - ) + match = program_files_subdir_pattern_compiled.match(program_file.rootfs_path) if not match: continue diff --git a/scanpipe/tests/data/is-npm-1.0.0_scancode.json b/scanpipe/tests/data/is-npm-1.0.0_scancode.json index 4ff86abaf..1ce03638c 100644 --- a/scanpipe/tests/data/is-npm-1.0.0_scancode.json +++ b/scanpipe/tests/data/is-npm-1.0.0_scancode.json @@ -2,10 +2,10 @@ "headers": [ { "tool_name": "scancode-toolkit", - "tool_version": "21.6.7", + "tool_version": "21.7.30", "options": { "input": [ - "/Volumes/nexB/var/projects/wdsdadsadasd-bc9f8ade/codebase" + "/tmp/tmpkzp1f_pw/projects/analysis-03087122/codebase" ], "--classify": true, "--consolidate": true, @@ -13,20 +13,19 @@ "--email": true, "--info": true, "--is-license-text": true, - "--json-pp": "/Volumes/nexB/var/projects/wdsdadsadasd-bc9f8ade/output/scancode-2021-07-07-11-18-49.json", + "--json-pp": "/tmp/tmpkzp1f_pw/projects/analysis-03087122/output/scancode-2021-08-03-19-09-26.json", "--license": true, "--license-clarity-score": true, "--license-text": true, "--package": true, - "--processes": "4", "--summary": true, "--summary-key-files": true, "--url": true }, "notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.", - "start_timestamp": "2021-07-07T111850.232385", - "end_timestamp": "2021-07-07T111856.279366", - "duration": 6.047006845474243, + "start_timestamp": "2021-08-03T190927.407466", + "end_timestamp": "2021-08-03T190932.182255", + "duration": 4.774801015853882, "message": null, "errors": [], "extra_data": { diff --git a/scanpipe/tests/data/is-npm-1.0.0_summary.json b/scanpipe/tests/data/is-npm-1.0.0_summary.json index 93ad1d6f6..2ca0337bf 100644 --- a/scanpipe/tests/data/is-npm-1.0.0_summary.json +++ b/scanpipe/tests/data/is-npm-1.0.0_summary.json @@ -1,385 +1,375 @@ { - "license_expressions": [ - { - "value": "mit", - "count": 2 - }, - { - "value": null, - "count": 1 - } - ], - "copyrights": [ - { - "value": null, - "count": 2 - }, - { - "value": "(c) Sindre Sorhus (http://sindresorhus.com)", - "count": 1 - } - ], - "holders": [ - { - "value": null, - "count": 2 - }, - { - "value": "Sindre Sorhus", - "count": 1 - } - ], - "authors": [ - { - "value": null, - "count": 3 - } - ], - "programming_language": [ - { - "value": null, - "count": 2 - }, - { - "value": "JavaScript", - "count": 1 - } - ], - "packages": [ - { - "type": "npm", - "namespace": null, - "name": "is-npm", - "version": "1.0.0", - "qualifiers": {}, - "subpath": null, - "primary_language": "JavaScript", - "description": "Check if your code is running as an npm script", - "release_date": null, - "parties": [ + "license_expressions": [ { - "type": "person", - "role": "author", - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" - } - ], - "keywords": [ - "npm", - "is", - "check", - "detect", - "env", - "environment" - ], - "homepage_url": null, - "download_url": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", - "size": null, - "sha1": null, - "md5": null, - "sha256": null, - "sha512": null, - "bug_tracking_url": null, - "code_view_url": null, - "vcs_url": "https://github.com/sindresorhus/is-npm", - "copyright": null, - "license_expression": "mit", - "declared_license": [ - "MIT" - ], - "notice_text": null, - "root_path": "codebase/package", - "dependencies": [ + "value": "mit", + "count": 2 + }, { - "purl": "pkg:npm/ava", - "requirement": "0.0.3", - "scope": "devDependencies", - "is_runtime": false, - "is_optional": true, - "is_resolved": false + "value": null, + "count": 1 } - ], - "contains_source_code": null, - "source_packages": [], - "extra_data": {}, - "purl": "pkg:npm/is-npm@1.0.0", - "repository_homepage_url": "https://www.npmjs.com/package/is-npm", - "repository_download_url": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", - "api_data_url": "https://registry.npmjs.org/is-npm/1.0.0", - "files": [ + ], + "copyrights": [ { - "path": "codebase/package/package.json", - "type": "file" - } - ] - } - ], - "license_clarity_score": { - "score": 30, - "declared": true, - "discovered": 0, - "consistency": false, - "spdx": false, - "license_texts": false - }, - "license_matches": { - "mit": [ - { - "path": "package/package.json", - "matched_text": " \"license\": \"MIT\"," - }, - { - "path": "package/readme.md", - "matched_text": "## License\n\nMIT \u00a9 [Sindre Sorhus](http://sindresorhus.com)" - } - ] - }, - "key_files": [ - { - "for_packages": [ - "pkg:npm/is-npm@1.0.0" - ], - "compliance_alert": "ok", - "path": "package/package.json", - "size": 563, - "sha1": "943efb8abda9b9cdaa4ea73f5709563b948af50b", - "md5": "c843e88ecb274d5d573c71be330bff8b", - "extra_data": {}, - "copyrights": [], - "holders": [], - "authors": [], - "licenses": [ + "value": null, + "count": 2 + }, { - "key": "mit", - "name": "MIT License", - "owner": "MIT", - "score": 100.0, - "policy": { - "icon": "far fa-thumbs-up", - "label": "Recommended License", - "color_code": "#002fff", - "license_key": "mit", - "compliance_alert": "" - }, - "category": "Permissive", - "end_line": 5, - "spdx_url": "https://spdx.org/licenses/MIT", - "text_url": "http://opensource.org/licenses/mit-license.php", - "short_name": "MIT License", - "start_line": 5, - "homepage_url": "http://opensource.org/licenses/mit-license.php", - "is_exception": false, - "matched_rule": { - "matcher": "2-aho", - "licenses": [ - "mit" - ], - "identifier": "mit_30.RULE", - "rule_length": 2, - "is_license_tag": true, - "match_coverage": 100.0, - "matched_length": 2, - "rule_relevance": 100, - "is_license_text": false, - "is_license_intro": false, - "is_license_notice": false, - "license_expression": "mit", - "is_license_reference": false - }, - "matched_text": " \"license\": \"MIT\",", - "reference_url": "https://scancode-licensedb.aboutcode.org/mit", - "spdx_license_key": "MIT", - "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", - "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE" + "value": "(c) Sindre Sorhus (http://sindresorhus.com)", + "count": 1 } - ], - "license_expressions": [ - "mit" - ], - "emails": [ + ], + "holders": [ { - "email": "sindresorhus@gmail.com", - "end_line": 9, - "start_line": 9 - } - ], - "urls": [ + "value": null, + "count": 2 + }, { - "url": "http://sindresorhus.com/", - "end_line": 10, - "start_line": 10 + "value": "Sindre Sorhus", + "count": 1 } - ], - "status": "application-package", - "type": "file", - "name": "package.json", - "extension": ".json", - "programming_language": "", - "mime_type": "application/json", - "file_type": "JSON data", - "is_binary": false, - "is_text": true, - "is_archive": false, - "is_key_file": true, - "content": "{\n \"name\": \"is-npm\",\n \"version\": \"1.0.0\",\n \"description\": \"Check if your code is running as an npm script\",\n \"license\": \"MIT\",\n \"repository\": \"sindresorhus/is-npm\",\n \"author\": {\n \"name\": \"Sindre Sorhus\",\n \"email\": \"sindresorhus@gmail.com\",\n \"url\": \"http://sindresorhus.com\"\n },\n \"engines\": {\n \"node\": \">=0.10.0\"\n },\n \"scripts\": {\n \"test\": \"node test.js\"\n },\n \"files\": [\n \"index.js\"\n ],\n \"keywords\": [\n \"npm\",\n \"is\",\n \"check\",\n \"detect\",\n \"env\",\n \"environment\"\n ],\n \"devDependencies\": {\n \"ava\": \"0.0.3\"\n }\n}\n" - }, - { - "for_packages": [], - "compliance_alert": "ok", - "path": "package/readme.md", - "size": 477, - "sha1": "b77832e53cb8239edd733c2ca02b1fc01ca3c2b6", - "md5": "a743e0abf08c28a37ecc4bef4dc02f8c", - "extra_data": {}, - "copyrights": [ + ], + "authors": [ { - "value": "(c) Sindre Sorhus (http://sindresorhus.com)", - "end_line": 30, - "start_line": 30 + "value": null, + "count": 3 } - ], - "holders": [ + ], + "programming_language": [ + { + "value": null, + "count": 2 + }, { - "value": "Sindre Sorhus", - "end_line": 30, - "start_line": 30 + "value": "JavaScript", + "count": 1 } - ], - "authors": [], - "licenses": [ + ], + "packages": [ { - "key": "mit", - "name": "MIT License", - "owner": "MIT", - "score": 100.0, - "policy": { - "icon": "far fa-thumbs-up", - "label": "Recommended License", - "color_code": "#002fff", - "license_key": "mit", - "compliance_alert": "" - }, - "category": "Permissive", - "end_line": 30, - "spdx_url": "https://spdx.org/licenses/MIT", - "text_url": "http://opensource.org/licenses/mit-license.php", - "short_name": "MIT License", - "start_line": 28, - "homepage_url": "http://opensource.org/licenses/mit-license.php", - "is_exception": false, - "matched_rule": { - "matcher": "2-aho", - "licenses": [ - "mit" + "type": "npm", + "namespace": null, + "name": "is-npm", + "version": "1.0.0", + "qualifiers": {}, + "subpath": null, + "primary_language": "JavaScript", + "description": "Check if your code is running as an npm script", + "release_date": null, + "parties": [ + { + "type": "person", + "role": "author", + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + } + ], + "keywords": [ + "npm", + "is", + "check", + "detect", + "env", + "environment" ], - "identifier": "mit_30.RULE", - "rule_length": 2, - "is_license_tag": true, - "match_coverage": 100.0, - "matched_length": 2, - "rule_relevance": 100, - "is_license_text": false, - "is_license_intro": false, - "is_license_notice": false, + "homepage_url": null, + "download_url": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": "https://github.com/sindresorhus/is-npm", + "copyright": null, "license_expression": "mit", - "is_license_reference": false - }, - "matched_text": "## License\n\nMIT \u00a9 [Sindre Sorhus](http://sindresorhus.com)", - "reference_url": "https://scancode-licensedb.aboutcode.org/mit", - "spdx_license_key": "MIT", - "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", - "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE" + "declared_license": [ + "MIT" + ], + "notice_text": null, + "root_path": "codebase/package", + "dependencies": [ + { + "purl": "pkg:npm/ava", + "requirement": "0.0.3", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false + } + ], + "contains_source_code": null, + "source_packages": [], + "extra_data": {}, + "purl": "pkg:npm/is-npm@1.0.0", + "repository_homepage_url": "https://www.npmjs.com/package/is-npm", + "repository_download_url": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", + "api_data_url": "https://registry.npmjs.org/is-npm/1.0.0", + "files": [ + { + "path": "codebase/package/package.json", + "type": "file" + } + ] } - ], - "license_expressions": [ - "mit" - ], - "emails": [], - "urls": [ - { - "url": "https://travis-ci.org/sindresorhus/is-npm.svg?branch=master", - "end_line": 1, - "start_line": 1 - }, - { - "url": "https://travis-ci.org/sindresorhus/is-npm", - "end_line": 1, - "start_line": 1 - }, + ], + "license_clarity_score": { + "score": 30, + "declared": true, + "discovered": 0, + "consistency": false, + "spdx": false, + "license_texts": false + }, + "license_matches": { + "mit": [ + { + "path": "package/package.json", + "matched_text": " \"license\": \"MIT\"," + }, + { + "path": "package/readme.md", + "matched_text": "## License\n\nMIT \u00a9 [Sindre Sorhus](http://sindresorhus.com)" + } + ] + }, + "key_files": [ { - "url": "https://www.npmjs.org/doc/misc/npm-scripts.html", - "end_line": 3, - "start_line": 3 + "for_packages": [ + "pkg:npm/is-npm@1.0.0" + ], + "compliance_alert": "missing", + "path": "package/package.json", + "size": 563, + "sha1": "943efb8abda9b9cdaa4ea73f5709563b948af50b", + "md5": "c843e88ecb274d5d573c71be330bff8b", + "extra_data": {}, + "copyrights": [], + "holders": [], + "authors": [], + "licenses": [ + { + "key": "mit", + "name": "MIT License", + "owner": "MIT", + "score": 100.0, + "policy": null, + "category": "Permissive", + "end_line": 5, + "spdx_url": "https://spdx.org/licenses/MIT", + "text_url": "http://opensource.org/licenses/mit-license.php", + "short_name": "MIT License", + "start_line": 5, + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "is_exception": false, + "matched_rule": { + "matcher": "2-aho", + "licenses": [ + "mit" + ], + "identifier": "mit_30.RULE", + "rule_length": 2, + "is_license_tag": true, + "match_coverage": 100.0, + "matched_length": 2, + "rule_relevance": 100, + "is_license_text": false, + "is_license_intro": false, + "is_license_notice": false, + "license_expression": "mit", + "is_license_reference": false + }, + "matched_text": " \"license\": \"MIT\",", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "spdx_license_key": "MIT", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE" + } + ], + "license_expressions": [ + "mit" + ], + "emails": [ + { + "email": "sindresorhus@gmail.com", + "end_line": 9, + "start_line": 9 + } + ], + "urls": [ + { + "url": "http://sindresorhus.com/", + "end_line": 10, + "start_line": 10 + } + ], + "status": "application-package", + "type": "file", + "name": "package.json", + "extension": ".json", + "programming_language": "", + "mime_type": "application/json", + "file_type": "JSON data", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_key_file": true, + "is_media": false, + "content": "{\n \"name\": \"is-npm\",\n \"version\": \"1.0.0\",\n \"description\": \"Check if your code is running as an npm script\",\n \"license\": \"MIT\",\n \"repository\": \"sindresorhus/is-npm\",\n \"author\": {\n \"name\": \"Sindre Sorhus\",\n \"email\": \"sindresorhus@gmail.com\",\n \"url\": \"http://sindresorhus.com\"\n },\n \"engines\": {\n \"node\": \">=0.10.0\"\n },\n \"scripts\": {\n \"test\": \"node test.js\"\n },\n \"files\": [\n \"index.js\"\n ],\n \"keywords\": [\n \"npm\",\n \"is\",\n \"check\",\n \"detect\",\n \"env\",\n \"environment\"\n ],\n \"devDependencies\": {\n \"ava\": \"0.0.3\"\n }\n}\n" }, { - "url": "http://sindresorhus.com/", - "end_line": 30, - "start_line": 30 + "for_packages": [], + "compliance_alert": "missing", + "path": "package/readme.md", + "size": 477, + "sha1": "b77832e53cb8239edd733c2ca02b1fc01ca3c2b6", + "md5": "a743e0abf08c28a37ecc4bef4dc02f8c", + "extra_data": {}, + "copyrights": [ + { + "value": "(c) Sindre Sorhus (http://sindresorhus.com)", + "end_line": 30, + "start_line": 30 + } + ], + "holders": [ + { + "value": "Sindre Sorhus", + "end_line": 30, + "start_line": 30 + } + ], + "authors": [], + "licenses": [ + { + "key": "mit", + "name": "MIT License", + "owner": "MIT", + "score": 100.0, + "policy": null, + "category": "Permissive", + "end_line": 30, + "spdx_url": "https://spdx.org/licenses/MIT", + "text_url": "http://opensource.org/licenses/mit-license.php", + "short_name": "MIT License", + "start_line": 28, + "homepage_url": "http://opensource.org/licenses/mit-license.php", + "is_exception": false, + "matched_rule": { + "matcher": "2-aho", + "licenses": [ + "mit" + ], + "identifier": "mit_30.RULE", + "rule_length": 2, + "is_license_tag": true, + "match_coverage": 100.0, + "matched_length": 2, + "rule_relevance": 100, + "is_license_text": false, + "is_license_intro": false, + "is_license_notice": false, + "license_expression": "mit", + "is_license_reference": false + }, + "matched_text": "## License\n\nMIT \u00a9 [Sindre Sorhus](http://sindresorhus.com)", + "reference_url": "https://scancode-licensedb.aboutcode.org/mit", + "spdx_license_key": "MIT", + "scancode_data_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.yml", + "scancode_text_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/mit.LICENSE" + } + ], + "license_expressions": [ + "mit" + ], + "emails": [], + "urls": [ + { + "url": "https://travis-ci.org/sindresorhus/is-npm.svg?branch=master", + "end_line": 1, + "start_line": 1 + }, + { + "url": "https://travis-ci.org/sindresorhus/is-npm", + "end_line": 1, + "start_line": 1 + }, + { + "url": "https://www.npmjs.org/doc/misc/npm-scripts.html", + "end_line": 3, + "start_line": 3 + }, + { + "url": "http://sindresorhus.com/", + "end_line": 30, + "start_line": 30 + } + ], + "status": "", + "type": "file", + "name": "readme.md", + "extension": ".md", + "programming_language": "", + "mime_type": "text/plain", + "file_type": "UTF-8 Unicode text", + "is_binary": false, + "is_text": true, + "is_archive": false, + "is_key_file": true, + "is_media": false, + "content": "# is-npm [![Build Status](https://travis-ci.org/sindresorhus/is-npm.svg?branch=master)](https://travis-ci.org/sindresorhus/is-npm)\n\n> Check if your code is running as an [npm script](https://www.npmjs.org/doc/misc/npm-scripts.html)\n\n\n## Install\n\n```sh\n$ npm install --save is-npm\n```\n\n\n## Usage\n\n```js\nvar isNpm = require('is-npm');\nconsole.log(isNpm);\n```\n\n```sh\n$ node foo.js\n#=> false\n$ npm run foo\n#=> true\n```\n\n\n## License\n\nMIT \u00a9 [Sindre Sorhus](http://sindresorhus.com)\n" } - ], - "status": "", - "type": "file", - "name": "readme.md", - "extension": ".md", - "programming_language": "", - "mime_type": "text/plain", - "file_type": "UTF-8 Unicode text", - "is_binary": false, - "is_text": true, - "is_archive": false, - "is_key_file": true, - "content": "# is-npm [![Build Status](https://travis-ci.org/sindresorhus/is-npm.svg?branch=master)](https://travis-ci.org/sindresorhus/is-npm)\n\n> Check if your code is running as an [npm script](https://www.npmjs.org/doc/misc/npm-scripts.html)\n\n\n## Install\n\n```sh\n$ npm install --save is-npm\n```\n\n\n## Usage\n\n```js\nvar isNpm = require('is-npm');\nconsole.log(isNpm);\n```\n\n```sh\n$ node foo.js\n#=> false\n$ npm run foo\n#=> true\n```\n\n\n## License\n\nMIT \u00a9 [Sindre Sorhus](http://sindresorhus.com)\n" - } - ], - "key_files_packages": [ - { - "purl": "pkg:npm/is-npm@1.0.0", - "type": "npm", - "namespace": "", - "name": "is-npm", - "version": "1.0.0", - "qualifiers": "", - "subpath": "", - "primary_language": "JavaScript", - "description": "Check if your code is running as an npm script", - "release_date": null, - "homepage_url": "", - "download_url": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", - "size": null, - "sha1": "", - "md5": "", - "bug_tracking_url": "", - "code_view_url": "", - "vcs_url": "https://github.com/sindresorhus/is-npm", - "copyright": "", - "license_expression": "mit", - "declared_license": "['MIT']", - "notice_text": "", - "manifest_path": "", - "contains_source_code": null, - "extra_data": {}, - "missing_resources": [], - "modified_resources": [], - "dependencies": [ + ], + "key_files_packages": [ { - "purl": "pkg:npm/ava", - "scope": "devDependencies", - "is_runtime": false, - "is_optional": true, - "is_resolved": false, - "requirement": "0.0.3" + "purl": "pkg:npm/is-npm@1.0.0", + "type": "npm", + "namespace": "", + "name": "is-npm", + "version": "1.0.0", + "qualifiers": "", + "subpath": "", + "primary_language": "JavaScript", + "description": "Check if your code is running as an npm script", + "release_date": null, + "homepage_url": "", + "download_url": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", + "size": null, + "sha1": "", + "md5": "", + "bug_tracking_url": "", + "code_view_url": "", + "vcs_url": "https://github.com/sindresorhus/is-npm", + "copyright": "", + "license_expression": "mit", + "declared_license": "['MIT']", + "notice_text": "", + "manifest_path": "", + "contains_source_code": null, + "extra_data": {}, + "missing_resources": [], + "modified_resources": [], + "dependencies": [ + { + "purl": "pkg:npm/ava", + "scope": "devDependencies", + "is_runtime": false, + "is_optional": true, + "is_resolved": false, + "requirement": "0.0.3" + } + ], + "keywords": [ + "npm", + "is", + "check", + "detect", + "env", + "environment" + ], + "source_packages": [] } - ], - "keywords": [ - "npm", - "is", - "check", - "detect", - "env", - "environment" - ], - "source_packages": [] - } - ] + ] } \ No newline at end of file diff --git a/scanpipe/tests/test_api.py b/scanpipe/tests/test_api.py index be5d07a98..7b56046d0 100644 --- a/scanpipe/tests/test_api.py +++ b/scanpipe/tests/test_api.py @@ -391,7 +391,7 @@ def test_scanpipe_api_serializer_get_model_serializer(self): def test_scanpipe_api_serializer_get_serializer_fields(self): self.assertEqual(30, len(get_serializer_fields(DiscoveredPackage))) - self.assertEqual(25, len(get_serializer_fields(CodebaseResource))) + self.assertEqual(26, len(get_serializer_fields(CodebaseResource))) with self.assertRaises(LookupError): get_serializer_fields(None)