Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ v33.0.0 (next next, roadmap)
- Update ABOUT files to adapt the ABOUT File Specification.
See https://github.com/aboutcode-org/scancode-toolkit/issues/4181

- Also return sha1_git checksums for each files with ``--info`` plugin.
https://github.com/aboutcode-org/scancode-toolkit/issues/624


v32.3.3 - 2025-03-06
--------------------
Expand Down
2 changes: 2 additions & 0 deletions docs/source/cli-reference/output-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ following options.
"date": "2019-02-12",
"sha1": "fca4540d490fff36bb90fd801cf9cd8fc695bb17",
"md5": "a980b61c1e8be68d5cdb1236ba6b43e7",
"sha1_git": "d9a10c0d8e868ebf8da0b3dc95bb0be634c34bfe",
"mime_type": "text/x-c++",
"file_type": "C++ source, ASCII text",
"programming_language": "C++",
Expand Down Expand Up @@ -481,6 +482,7 @@ Comparing Different ``json`` Output Formats
- size,
- sha1,
- md5,
- sha1_git,
- files_count,
- mime_type,
- file_type,
Expand Down
1 change: 1 addition & 0 deletions docs/source/cli-reference/scan-options-post.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ To see all plugins available via command line help, use ``--plugins``.
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down
1 change: 1 addition & 0 deletions docs/source/cli-reference/synopsis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ A sample JSON output file structure will look like::
"date": "2019-02-12",
"sha1": "2e07e32c52d607204fad196052d70e3d18fb8636",
"md5": "effc6856ef85a9250fb1a470792b3f38",
"sha1_git": "d9a10c0d8e868ebf8da0b3dc95bb0be634c34bfe",
"mime_type": "text/plain",
"file_type": "ASCII text",
"programming_language": null,
Expand Down
6 changes: 5 additions & 1 deletion src/scancode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,14 @@ def get_file_info(location, **kwargs):
result['date'] = get_last_modified_date(location) or None
result['size'] = getsize(location) or 0

sha1, md5, sha256 = multi_checksums(location, ('sha1', 'md5', 'sha256')).values()
sha1, md5, sha256, sha1_git = multi_checksums(
location=location,
checksum_names=('sha1', 'md5', 'sha256', 'sha1_git')
).values()
result['sha1'] = sha1
result['md5'] = md5
result['sha256'] = sha256
result['sha1_git'] = sha1_git

collector = get_type(location)
result['mime_type'] = collector.mimetype_file or None
Expand Down
1 change: 1 addition & 0 deletions src/scancode/plugin_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class InfoScanner(ScanPlugin):
('sha1', attr.ib(default=None, repr=False)),
('md5', attr.ib(default=None, repr=False)),
('sha256', attr.ib(default=None, repr=False)),
('sha1_git', attr.ib(default=None, repr=False)),
('mime_type', attr.ib(default=None, repr=False)),
('file_type', attr.ib(default=None, repr=False)),
('programming_language', attr.ib(default=None, repr=False)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"sha1": "c4d6f133413f1ea9d3c436fb797f9060c8640c04",
"md5": "55a970437979ffe95e7b8ee6e51abb0c",
"sha256": "ebdef41bf0f5bd7d378e4f76052e02156ce1c80ce67f89209b018a3fca8a071c",
"sha1_git": "c6cc3f85376fd76bdebcc4fee6e9137e80bd8691",
"mime_type": "text/plain",
"file_type": "ASCII text",
"programming_language": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"sha1": "c43ffed01990c30300e07231790ace9f103ff7d7",
"md5": "9946f7dcaf5066f2fb17e682e0326090",
"sha256": "58416604a57e2e2625b802ac8c751c61763ae3d279c9c75d7c3bb55a3782cc6c",
"sha1_git": "9956de3f204ca2d5c46b77e70c4c6bf9509f6dd8",
"mime_type": "text/plain",
"file_type": "ASCII text",
"programming_language": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"sha1": "9db841f62fdb2372f5f474bb75366140a00c62ca",
"md5": "3fdbe85d79aa58aaeab119505f2007b6",
"sha256": "408dfe8f9a70ea7bc9feaa9f77fb731ada0c26dc39008fdc5ead52d0442c656f",
"sha1_git": "3ed0b925a62cbabad29cda7743c513d2ed557dc2",
"mime_type": "text/plain",
"file_type": "ASCII text",
"programming_language": "verilog",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"sha1": "8a2e40b4eb23cc05a0b78330d919a7ffacde7a9a",
"md5": "d5d03e14130735213e0532277df33cab",
"sha256": "e4bd79e88b577d66d351597c0d4114b9ee2e31f0544795e87a88ca1b0dd38383",
"sha1_git": "e7c0b65bcdb17888027d0b53a1f65ad61b238245",
"mime_type": "text/plain",
"file_type": "ASCII text",
"programming_language": null,
Expand Down
9 changes: 9 additions & 0 deletions tests/formattedcode/data/common/manifests-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1052,6 +1053,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1088,6 +1090,7 @@
"sha1": "82107f6781df8da9aa7cb60abc649208256af5cb",
"md5": "e79938fe4e630b02e3526c0195292cc6",
"sha256": "f94648bd92ddf2464e62c56c3833b36927fa8b9803e8ebf3e4cfa7f2d797f3ad",
"sha1_git": "614191600be349e61331a3a0eb2b883493f0db0f",
"mime_type": "text/xml",
"file_type": "XML 1.0 document, ASCII text",
"programming_language": null,
Expand Down Expand Up @@ -1216,6 +1219,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1250,6 +1254,7 @@
"sha1": "0ed61bf6912407a143ce96c95bea56ad13463f5b",
"md5": "427e6d3b579b128fed50328ac65b698e",
"sha256": "d292aa647dc82e007ba319c878ec182d6f235f0a923cfe012ffc0ae8b7fa23be",
"sha1_git": "fee016dc24204e079cb9e0217d4439d73e1398ac",
"mime_type": "application/json",
"file_type": "JSON data",
"programming_language": null,
Expand Down Expand Up @@ -1550,6 +1555,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1584,6 +1590,7 @@
"sha1": "e6acddf907b7089d197d9d46879cd18ffb8f5198",
"md5": "5ba816691af915c02567f459ae26ebd6",
"sha256": "11129bc3bbf44b2567307ad13a31bc231f08416919e36bbdeabb9195b3e6ad58",
"sha1_git": "99128a9e08f5a23c650d83af5dcf40c3b976753d",
"mime_type": "application/json",
"file_type": "JSON data",
"programming_language": null,
Expand Down Expand Up @@ -1774,6 +1781,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1808,6 +1816,7 @@
"sha1": "5507192502255517e006c531d07dd84dc2325be8",
"md5": "6795bed0c9c6b6cb915bfa959a2d1d4a",
"sha256": "4378d297df9fcb4f65fdcd1299e17eef7db86883baf149bc41b0335f943cf006",
"sha1_git": "887bd3bfe3bdba0c8f737a69df38454b3d489ac1",
"mime_type": "text/x-script.python",
"file_type": "Python script, ASCII text executable",
"programming_language": "Python",
Expand Down
15 changes: 12 additions & 3 deletions tests/formattedcode/data/common/manifests-expected.jsonlines
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"system_environment": {
"operating_system": "linux",
"cpu_architecture": "64",
"platform": "Linux-6.8.0-52-generic-x86_64-with-glibc2.35",
"platform_version": "#53~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 15 19:18:46 UTC 2",
"python_version": "3.12.9 (main, Feb 20 2025, 19:13:20) [GCC 11.4.0]"
"platform": "Linux-5.15.0-141-generic-x86_64-with-glibc2.35",
"platform_version": "#151-Ubuntu SMP Sun May 18 21:35:19 UTC 2025",
"python_version": "3.10.12 (main, Feb 4 2025, 14:57:36) [GCC 11.4.0]"
},
"spdx_license_list_version": "3.26",
"files_count": 4
Expand Down Expand Up @@ -1056,6 +1056,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1094,6 +1095,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1134,6 +1136,7 @@
"sha1": "82107f6781df8da9aa7cb60abc649208256af5cb",
"md5": "e79938fe4e630b02e3526c0195292cc6",
"sha256": "f94648bd92ddf2464e62c56c3833b36927fa8b9803e8ebf3e4cfa7f2d797f3ad",
"sha1_git": "614191600be349e61331a3a0eb2b883493f0db0f",
"mime_type": "text/xml",
"file_type": "XML 1.0 document, ASCII text",
"programming_language": null,
Expand Down Expand Up @@ -1266,6 +1269,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1304,6 +1308,7 @@
"sha1": "0ed61bf6912407a143ce96c95bea56ad13463f5b",
"md5": "427e6d3b579b128fed50328ac65b698e",
"sha256": "d292aa647dc82e007ba319c878ec182d6f235f0a923cfe012ffc0ae8b7fa23be",
"sha1_git": "fee016dc24204e079cb9e0217d4439d73e1398ac",
"mime_type": "application/json",
"file_type": "JSON data",
"programming_language": null,
Expand Down Expand Up @@ -1608,6 +1613,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1646,6 +1652,7 @@
"sha1": "e6acddf907b7089d197d9d46879cd18ffb8f5198",
"md5": "5ba816691af915c02567f459ae26ebd6",
"sha256": "11129bc3bbf44b2567307ad13a31bc231f08416919e36bbdeabb9195b3e6ad58",
"sha1_git": "99128a9e08f5a23c650d83af5dcf40c3b976753d",
"mime_type": "application/json",
"file_type": "JSON data",
"programming_language": null,
Expand Down Expand Up @@ -1840,6 +1847,7 @@
"sha1": null,
"md5": null,
"sha256": null,
"sha1_git": null,
"mime_type": null,
"file_type": null,
"programming_language": null,
Expand Down Expand Up @@ -1878,6 +1886,7 @@
"sha1": "5507192502255517e006c531d07dd84dc2325be8",
"md5": "6795bed0c9c6b6cb915bfa959a2d1d4a",
"sha256": "4378d297df9fcb4f65fdcd1299e17eef7db86883baf149bc41b0335f943cf006",
"sha1_git": "887bd3bfe3bdba0c8f737a69df38454b3d489ac1",
"mime_type": "text/x-script.python",
"file_type": "Python script, ASCII text executable",
"programming_language": "Python",
Expand Down
15 changes: 12 additions & 3 deletions tests/formattedcode/data/common/manifests-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ headers:
system_environment:
operating_system: linux
cpu_architecture: 64
platform: Linux-6.8.0-52-generic-x86_64-with-glibc2.35
platform_version: '#53~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 15 19:18:46 UTC 2'
python_version: 3.12.9 (main, Feb 20 2025, 19:13:20) [GCC 11.4.0]
platform: Linux-5.15.0-141-generic-x86_64-with-glibc2.35
platform_version: '#151-Ubuntu SMP Sun May 18 21:35:19 UTC 2025'
python_version: 3.10.12 (main, Feb 4 2025, 14:57:36) [GCC 11.4.0]
spdx_license_list_version: '3.26'
files_count: 4
summary:
Expand Down Expand Up @@ -1873,6 +1873,7 @@ files:
sha1:
md5:
sha256:
sha1_git:
mime_type:
file_type:
programming_language:
Expand Down Expand Up @@ -1912,6 +1913,7 @@ files:
sha1:
md5:
sha256:
sha1_git:
mime_type:
file_type:
programming_language:
Expand Down Expand Up @@ -1952,6 +1954,7 @@ files:
sha1: 82107f6781df8da9aa7cb60abc649208256af5cb
md5: e79938fe4e630b02e3526c0195292cc6
sha256: f94648bd92ddf2464e62c56c3833b36927fa8b9803e8ebf3e4cfa7f2d797f3ad
sha1_git: 614191600be349e61331a3a0eb2b883493f0db0f
mime_type: text/xml
file_type: XML 1.0 document, ASCII text
programming_language:
Expand Down Expand Up @@ -2087,6 +2090,7 @@ files:
sha1:
md5:
sha256:
sha1_git:
mime_type:
file_type:
programming_language:
Expand Down Expand Up @@ -2126,6 +2130,7 @@ files:
sha1: 0ed61bf6912407a143ce96c95bea56ad13463f5b
md5: 427e6d3b579b128fed50328ac65b698e
sha256: d292aa647dc82e007ba319c878ec182d6f235f0a923cfe012ffc0ae8b7fa23be
sha1_git: fee016dc24204e079cb9e0217d4439d73e1398ac
mime_type: application/json
file_type: JSON data
programming_language:
Expand Down Expand Up @@ -2398,6 +2403,7 @@ files:
sha1:
md5:
sha256:
sha1_git:
mime_type:
file_type:
programming_language:
Expand Down Expand Up @@ -2437,6 +2443,7 @@ files:
sha1: e6acddf907b7089d197d9d46879cd18ffb8f5198
md5: 5ba816691af915c02567f459ae26ebd6
sha256: 11129bc3bbf44b2567307ad13a31bc231f08416919e36bbdeabb9195b3e6ad58
sha1_git: 99128a9e08f5a23c650d83af5dcf40c3b976753d
mime_type: application/json
file_type: JSON data
programming_language:
Expand Down Expand Up @@ -2619,6 +2626,7 @@ files:
sha1:
md5:
sha256:
sha1_git:
mime_type:
file_type:
programming_language:
Expand Down Expand Up @@ -2658,6 +2666,7 @@ files:
sha1: 5507192502255517e006c531d07dd84dc2325be8
md5: 6795bed0c9c6b6cb915bfa959a2d1d4a
sha256: 4378d297df9fcb4f65fdcd1299e17eef7db86883baf149bc41b0335f943cf006
sha1_git: 887bd3bfe3bdba0c8f737a69df38454b3d489ac1
mime_type: text/x-script.python
file_type: Python script, ASCII text executable
programming_language: Python
Expand Down
Loading
Loading