Skip to content

Commit 3a8e01e

Browse files
committed
Use detected holders from package resources #2972
* If no explicit copyright was detected from Package datafiles, then we take the holder detections from those files instead Signed-off-by: Jono Yang <jyang@nexb.com>
1 parent 7c39db9 commit 3a8e01e

File tree

6 files changed

+394
-8
lines changed

6 files changed

+394
-8
lines changed

src/summarycode/summarizer.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ def get_origin_info_from_top_level_packages(top_level_packages, codebase):
225225
programming_languages = []
226226
copyrights = []
227227

228-
for package_mapping in top_level_packages:
229-
package = models.Package.from_dict(package_mapping)
230-
# we are only interested in key packages
231-
if not is_key_package(package, codebase):
232-
continue
233-
228+
top_level_packages = [
229+
models.Package.from_dict(package_mapping)
230+
for package_mapping in top_level_packages
231+
]
232+
key_file_packages = [p for p in top_level_packages if is_key_package(p, codebase)]
233+
for package in key_file_packages:
234234
license_expression = package.license_expression
235235
if license_expression:
236236
license_expressions.append(license_expression)
@@ -261,7 +261,17 @@ def get_origin_info_from_top_level_packages(top_level_packages, codebase):
261261
declared_holders = []
262262
if holders:
263263
declared_holders = holders
264-
264+
else:
265+
# If the package data does not contain an explicit copyright, check the
266+
# key files where the package data was detected from and see if there
267+
# are any holder detections that can be used.
268+
for package in key_file_packages:
269+
for datafile_path in package.datafile_paths:
270+
key_file_resource = codebase.get_resource(path=datafile_path)
271+
if not key_file_resource:
272+
continue
273+
holders = [h['holder'] for h in key_file_resource.holders]
274+
declared_holders.extend(holders)
265275
declared_holders = unique(declared_holders)
266276

267277
# Programming language

tests/summarycode/data/summary/multiple_package_data/multiple_package_data.expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"conflicting_license_categories": false,
112112
"ambiguous_compound_licensing": false
113113
},
114-
"declared_holder": "Demo Corporation, Example Corp.",
114+
"declared_holder": "Example Corp.",
115115
"primary_language": "Python",
116116
"other_license_expressions": [
117117
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Copyright (c) Example Corporation
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2020 Google LLC
2+
# Copyright 2021 Fraunhofer FKIE
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
setup(
17+
name="atheris",
18+
version=__version__,
19+
author="Bitshift",
20+
author_email="atheris@google.com",
21+
url="https://github.com/google/atheris/",
22+
description="A coverage-guided fuzzer for Python and Python extensions.",
23+
long_description=open("README.md", "r").read(),
24+
long_description_content_type="text/markdown",
25+
packages=["atheris"],
26+
package_dir={"atheris": "src"},
27+
py_modules=["atheris_no_libfuzzer"],
28+
ext_modules=ext_modules,
29+
setup_requires=["pybind11>=2.5.0"],
30+
cmdclass={"build_ext": BuildExt},
31+
zip_safe=False,
32+
)

0 commit comments

Comments
 (0)