diff --git a/src/packagedcode/__init__.py b/src/packagedcode/__init__.py index 093fd9940f..b5f94d982e 100644 --- a/src/packagedcode/__init__.py +++ b/src/packagedcode/__init__.py @@ -12,6 +12,7 @@ from packagedcode import alpine from packagedcode import bower from packagedcode import build +from packagedcode import buildpack from packagedcode import build_gradle from packagedcode import cargo from packagedcode import chef @@ -62,6 +63,8 @@ build.BuckMetadataBzlHandler, build.BuckPackageHandler, + buildpack.BuildpackHandler, + cargo.CargoLockHandler, cargo.CargoTomlHandler, diff --git a/src/packagedcode/buildpack.py b/src/packagedcode/buildpack.py new file mode 100644 index 0000000000..ac6f4b0de9 --- /dev/null +++ b/src/packagedcode/buildpack.py @@ -0,0 +1,143 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# ScanCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/scancode-toolkit for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + +import toml +from packagedcode import models +from packageurl import PackageURL + +class BuildpackHandler(models.DatafileHandler): + """ + Handle buildpack.toml manifests. + See https://buildpacks.io/ for details on buildpack format. + """ + datasource_id = "buildpack_toml" + path_patterns = ("*buildpack.toml",) + default_package_type = "buildpack" + description = "Cloud Native Buildpack manifest" + documentation_url = "https://buildpacks.io/" + + @classmethod + def parse(cls, location, package_only=False): + """ + Parse the buildpack.toml file at `location` and yield PackageData. + """ + with open(location, "r", encoding="utf-8") as f: + data = toml.load(f) + + # Extract required fields + api_version = data.get("api") + buildpack = data.get("buildpack", {}) + if not buildpack: + return + + name = buildpack.get("name") + if not name: + return + + # Initialize common package data + package_data = dict( + datasource_id=cls.datasource_id, + type=cls.default_package_type, + name=name, + version="unknown", + description=None, + homepage_url=None, + keywords=[], + declared_license_expression=None, + dependencies=[], + ) + + # Handle Paketo-specific fields if present + if "api" in data: + cls.handle_paketo_buildpack(data, buildpack, package_data) + + # Handle Heroku-specific fields if present + elif "publish" in data and "Ignore" in data["publish"]: + cls.handle_heroku_buildpack(data, buildpack, package_data) + + yield models.PackageData.from_data(package_data, package_only) + + @staticmethod + def handle_paketo_buildpack(data, buildpack, package_data): + buildpack_id = buildpack.get("id") + if buildpack_id: + package_data["extra_data"] = {"id": buildpack_id} + + package_data.update({ + "version": buildpack.get("version", "unknown"), + "description": buildpack.get("description"), + "homepage_url": buildpack.get("homepage"), + "keywords": buildpack.get("keywords", []), + }) + + licenses = buildpack.get("licenses", []) + license_expressions = [ + license_entry.get("type") for license_entry in licenses if license_entry.get("type") + ] + if license_expressions: + package_data["declared_license_expression"] = " AND ".join(license_expressions) + + dependencies = [] + metadata = data.get("metadata", {}) + metadata_dependencies = metadata.get("dependencies", []) + for dep in metadata_dependencies: + dep_purl = dep.get("purl") + dep_name = dep.get("name") + dep_version = dep.get("version") + if dep_purl: + dependencies.append( + models.DependentPackage( + purl=dep_purl, + scope="runtime", + is_runtime=True, + is_optional=False, + ) + ) + elif dep_name and dep_version: + dependencies.append( + models.DependentPackage( + purl=PackageURL(type="generic", name=dep_name, version=dep_version).to_string(), + scope="runtime", + is_runtime=True, + is_optional=False, + ) + ) + + orders = data.get("order", []) + for order in orders: + for group in order.get("group", []): + group_id = group.get("id") + group_version = group.get("version") + if group_id and group_version: + dependencies.append( + models.DependentPackage( + purl=PackageURL(type="buildpack", name=group_id, version=group_version).to_string(), + scope="runtime", + is_runtime=True, + is_optional=group.get("optional", False), + ) + ) + + package_data["dependencies"] = dependencies + + @staticmethod + def handle_heroku_buildpack(data, buildpack, package_data): + publish_section = data.get("publish", {}) + if "Ignore" in publish_section: + ignore_files = publish_section["Ignore"].get("files", []) + if ignore_files: # Only add if files are found + package_data["extra_data"] = {"ignore_files": ignore_files} + else: + package_data["extra_data"] = {"ignore_files": []} + else: + package_data["extra_data"] = {"ignore_files": []} + + # Add description for Heroku buildpack + package_data["description"] = f"Heroku buildpack for {buildpack.get('name')}" + \ No newline at end of file diff --git a/src/packagedcode/models.py b/src/packagedcode/models.py index ae0adb95f2..64bbce23d0 100644 --- a/src/packagedcode/models.py +++ b/src/packagedcode/models.py @@ -582,7 +582,7 @@ class PackageData(IdentifiablePackageData): download_url = String( label='Download URL', help='A direct download URL.') - + size = Integer( default=None, label='download size', diff --git a/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-java/buildpack.toml b/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-java/buildpack.toml new file mode 100644 index 0000000000..8493df2987 --- /dev/null +++ b/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-java/buildpack.toml @@ -0,0 +1,14 @@ +[buildpack] +name = "Java" + + [publish.Ignore] + files = [ + "etc/", + "spec/", + "test/", + ".gitignore", + ".github/", + "hatchet.json", + "Gemfile", + "Gemfile.lock" + ] \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-java/expectedbuildpack.json b/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-java/expectedbuildpack.json new file mode 100644 index 0000000000..5e27d3d224 --- /dev/null +++ b/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-java/expectedbuildpack.json @@ -0,0 +1,131 @@ +{ + "packages": [ + { + "type": "buildpack", + "namespace": null, + "name": "Java", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "Heroku buildpack for Java", + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": 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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "ignore_files": [ + "etc/", + "spec/", + "test/", + ".gitignore", + ".github/", + "hatchet.json", + "Gemfile", + "Gemfile.lock" + ] + }, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:buildpack/Java@unknown?uuid=d332d23b-1b4e-415a-96a8-141416e7e7f2", + "datafile_paths": [ + "buildpack.toml" + ], + "datasource_ids": [ + "buildpack_toml" + ], + "purl": "pkg:buildpack/Java@unknown" + } + ], + "dependencies": [], + "files": [ + { + "path": "buildpack.toml", + "type": "file", + "package_data": [ + { + "type": "buildpack", + "namespace": null, + "name": "Java", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "Heroku buildpack for Java", + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": 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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "ignore_files": [ + "etc/", + "spec/", + "test/", + ".gitignore", + ".github/", + "hatchet.json", + "Gemfile", + "Gemfile.lock" + ] + }, + "dependencies": [], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "buildpack_toml", + "purl": "pkg:buildpack/Java@unknown" + } + ], + "for_packages": [ + "pkg:buildpack/Java@unknown?uuid=d332d23b-1b4e-415a-96a8-141416e7e7f2" + ], + "scan_errors": [] + } + ] + } \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-php/buildpack.toml b/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-php/buildpack.toml new file mode 100644 index 0000000000..78e59ee392 --- /dev/null +++ b/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-php/buildpack.toml @@ -0,0 +1,17 @@ +[buildpack] +name = "PHP" + + [publish.Ignore] + files = [ + ".github/", + ".gitignore", + ".rspec_parallel", + "support/build/", + "support/devcenter/", + "test/", + "Gemfile", + "Gemfile.lock", + "hatchet.json", + "hatchet.lock", + "requirements.txt", + ] \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-php/expectedbuildpack.json b/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-php/expectedbuildpack.json new file mode 100644 index 0000000000..bd798d5fef --- /dev/null +++ b/tests/packagedcode/data/buildpack/heroku-buildpacks/heroku-buildpack-php/expectedbuildpack.json @@ -0,0 +1,137 @@ +{ + "packages": [ + { + "type": "buildpack", + "namespace": null, + "name": "PHP", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "Heroku buildpack for PHP", + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": 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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "ignore_files": [ + ".github/", + ".gitignore", + ".rspec_parallel", + "support/build/", + "support/devcenter/", + "test/", + "Gemfile", + "Gemfile.lock", + "hatchet.json", + "hatchet.lock", + "requirements.txt" + ] + }, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:buildpack/PHP@unknown?uuid=62dfc37b-8be2-4509-87b3-5b5b25260da5", + "datafile_paths": [ + "buildpack.toml" + ], + "datasource_ids": [ + "buildpack_toml" + ], + "purl": "pkg:buildpack/PHP@unknown" + } + ], + "dependencies": [], + "files": [ + { + "path": "buildpack.toml", + "type": "file", + "package_data": [ + { + "type": "buildpack", + "namespace": null, + "name": "PHP", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "Heroku buildpack for PHP", + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": 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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "ignore_files": [ + ".github/", + ".gitignore", + ".rspec_parallel", + "support/build/", + "support/devcenter/", + "test/", + "Gemfile", + "Gemfile.lock", + "hatchet.json", + "hatchet.lock", + "requirements.txt" + ] + }, + "dependencies": [], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "buildpack_toml", + "purl": "pkg:buildpack/PHP@unknown" + } + ], + "for_packages": [ + "pkg:buildpack/PHP@unknown?uuid=62dfc37b-8be2-4509-87b3-5b5b25260da5" + ], + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/dotnet-execute/buildpack.toml b/tests/packagedcode/data/buildpack/paketo-buildpacks/dotnet-execute/buildpack.toml new file mode 100644 index 0000000000..bb87a31580 --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/dotnet-execute/buildpack.toml @@ -0,0 +1,20 @@ +api = "0.8" + +[buildpack] + description = "A buildpack for running the `dotnet execute` command for an app" + homepage = "https://github.com/paketo-buildpacks/dotnet-execute" + id = "paketo-buildpacks/dotnet-execute" + keywords = ["dotnet"] + name = "Paketo Buildpack for .NET Execute" + sbom-formats = ["application/vnd.cyclonedx+json", "application/spdx+json", "application/vnd.syft+json"] + + [[buildpack.licenses]] + type = "Apache-2.0" + uri = "https://github.com/paketo-buildpacks/dotnet-execute/blob/main/LICENSE" + +[metadata] + include-files = ["bin/build", "bin/detect", "bin/run", "bin/port-chooser", "buildpack.toml"] + pre-package = "./scripts/build.sh" + +[[stacks]] + id = "*" \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/dotnet-execute/expectedbuildpack.json b/tests/packagedcode/data/buildpack/paketo-buildpacks/dotnet-execute/expectedbuildpack.json new file mode 100644 index 0000000000..a52a173f8d --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/dotnet-execute/expectedbuildpack.json @@ -0,0 +1,117 @@ +{ + "packages": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for .NET Execute", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "A buildpack for running the `dotnet execute` command for an app", + "release_date": null, + "parties": [], + "keywords": [ + "dotnet" + ], + "homepage_url": "https://github.com/paketo-buildpacks/dotnet-execute", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "Apache-2.0", + "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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/dotnet-execute" + }, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20.NET%20Execute@unknown?uuid=269fba9a-5182-4434-a4e5-e00840e4c545", + "datafile_paths": [ + "buildpack.toml" + ], + "datasource_ids": [ + "buildpack_toml" + ], + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20.NET%20Execute@unknown" + } + ], + "dependencies": [], + "files": [ + { + "path": "buildpack.toml", + "type": "file", + "package_data": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for .NET Execute", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "A buildpack for running the `dotnet execute` command for an app", + "release_date": null, + "parties": [], + "keywords": [ + "dotnet" + ], + "homepage_url": "https://github.com/paketo-buildpacks/dotnet-execute", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "Apache-2.0", + "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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/dotnet-execute" + }, + "dependencies": [], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "buildpack_toml", + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20.NET%20Execute@unknown" + } + ], + "for_packages": [ + "pkg:buildpack/Paketo%20Buildpack%20for%20.NET%20Execute@unknown?uuid=269fba9a-5182-4434-a4e5-e00840e4c545" + ], + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/git/buildpack.toml b/tests/packagedcode/data/buildpack/paketo-buildpacks/git/buildpack.toml new file mode 100644 index 0000000000..fcc9c97c38 --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/git/buildpack.toml @@ -0,0 +1,13 @@ +api = "0.7" + +[buildpack] + homepage = "https://github.com/paketo-buildpacks/git" + id = "paketo-buildpacks/git" + name = "Paketo Buildpack for Git" + +[metadata] + include-files = ["bin/run", "bin/build", "bin/detect", "buildpack.toml"] + pre-package = "./scripts/build.sh" + +[[stacks]] + id = "*" \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/git/expectedbuildpack.json b/tests/packagedcode/data/buildpack/paketo-buildpacks/git/expectedbuildpack.json new file mode 100644 index 0000000000..99aae72844 --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/git/expectedbuildpack.json @@ -0,0 +1,113 @@ +{ + "packages": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for Git", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": "https://github.com/paketo-buildpacks/git", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": 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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/git" + }, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20Git@unknown?uuid=d949b01b-4db7-4fbd-a85b-c23ff707444d", + "datafile_paths": [ + "buildpack.toml" + ], + "datasource_ids": [ + "buildpack_toml" + ], + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20Git@unknown" + } + ], + "dependencies": [], + "files": [ + { + "path": "buildpack.toml", + "type": "file", + "package_data": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for Git", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": "https://github.com/paketo-buildpacks/git", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": 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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/git" + }, + "dependencies": [], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "buildpack_toml", + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20Git@unknown" + } + ], + "for_packages": [ + "pkg:buildpack/Paketo%20Buildpack%20for%20Git@unknown?uuid=d949b01b-4db7-4fbd-a85b-c23ff707444d" + ], + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/java-memory-assistant/buildpack.toml b/tests/packagedcode/data/buildpack/paketo-buildpacks/java-memory-assistant/buildpack.toml new file mode 100644 index 0000000000..8f315e6e54 --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/java-memory-assistant/buildpack.toml @@ -0,0 +1,83 @@ +# Copyright 2018-2021 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +api = "0.7" + +[buildpack] + description = "A Cloud Native Buildpack that installs the Java Memory Assistant agent" + homepage = "https://github.com/paketo-buildpacks/java-memory-assistant" + id = "paketo-buildpacks/java-memory-assistant" + keywords = ["agent"] + name = "Paketo Buildpack for Java Memory Assistant" + sbom-formats = ["application/vnd.syft+json", "application/vnd.cyclonedx+json"] + version = "{{.version}}" + + [[buildpack.licenses]] + type = "Apache-2.0" + uri = "https://github.com/paketo-buildpacks/java-memory-assistant/blob/main/LICENSE" + +[metadata] + include-files = ["LICENSE", "NOTICE", "README.md", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/main", "linux/amd64/bin/helper", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/main", "linux/arm64/bin/helper", "buildpack.toml"] + pre-package = "scripts/build.sh" + + [[metadata.configurations]] + build = true + default = "false" + description = "whether to contribute the JMA agent at build time" + name = "BP_JMA_ENABLED" + + [[metadata.configurations]] + default = "false" + description = "whether to enable the JMA agent at runtime" + launch = true + name = "BPL_JMA_ENABLED" + + [[metadata.configurations]] + default = "check_interval=5s,log_level=ERROR,max_frequency=1/1m,heap_dump_folder=/tmp,thresholds.heap=80%" + description = "arguments to configure the JMA agent" + launch = true + name = "BPL_JMA_ARGS" + + [[metadata.dependencies]] + cpes = ["cpe:2.3:a:sap:java-memory-assistant:0.5.0:*:*:*:*:*:*:*"] + id = "java-memory-assistant" + name = "Java Memory Assistant Agent" + purl = "pkg:generic/sap-java-memory-assistant@0.5.0?arch=amd64" + sha256 = "9c5ffb4bdeec5ed6b4f1d734469500754a857d1452c3d253d89e2315addb04c5" + source = "https://github.com/sap/java-memory-assistant/archive/refs/tags/0.5.0.tar.gz" + source-sha256 = "dedf82a5c10df5b12e602c1237f00a459a38b6a55c0ff8d671fa0d3909dfe4fc" + stacks = ["io.buildpacks.stacks.bionic", "io.paketo.stacks.tiny", "*"] + uri = "https://github.com/SAP-archive/java-memory-assistant/releases/download/0.5.0/java-memory-assistant-0.5.0.jar" + version = "0.5.0" + + [[metadata.dependencies.licenses]] + type = "Apache-2.0" + uri = "https://github.com/SAP/java-memory-assistant/blob/master/LICENSE" + +[[stacks]] + id = "io.buildpacks.stacks.bionic" + +[[stacks]] + id = "io.paketo.stacks.tiny" + +[[stacks]] + id = "*" + +[[targets]] + arch = "amd64" + os = "linux" + +[[targets]] + arch = "arm64" + os = "linux" \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/java-memory-assistant/expectedbuildpack.json b/tests/packagedcode/data/buildpack/paketo-buildpacks/java-memory-assistant/expectedbuildpack.json new file mode 100644 index 0000000000..43f35d93db --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/java-memory-assistant/expectedbuildpack.json @@ -0,0 +1,145 @@ +{ + "packages": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for Java Memory Assistant", + "version": "{{.version}}", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "A Cloud Native Buildpack that installs the Java Memory Assistant agent", + "release_date": null, + "parties": [], + "keywords": [ + "agent" + ], + "homepage_url": "https://github.com/paketo-buildpacks/java-memory-assistant", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "Apache-2.0", + "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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/java-memory-assistant" + }, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20Java%20Memory%20Assistant@%7B%7B.version%7D%7D?uuid=d197d3a7-e7df-49a2-8b79-a74156b545bc", + "datafile_paths": [ + "buildpack.toml" + ], + "datasource_ids": [ + "buildpack_toml" + ], + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20Java%20Memory%20Assistant@%7B%7B.version%7D%7D" + } + ], + "dependencies": [ + { + "purl": "pkg:generic/sap-java-memory-assistant@0.5.0?arch=amd64", + "extracted_requirement": null, + "scope": "runtime", + "is_runtime": true, + "is_optional": false, + "is_pinned": false, + "is_direct": true, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:generic/sap-java-memory-assistant@0.5.0?arch=amd64&uuid=69e1a8c3-e31c-4e85-8255-463ae5fe8797", + "for_package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20Java%20Memory%20Assistant@%7B%7B.version%7D%7D?uuid=d197d3a7-e7df-49a2-8b79-a74156b545bc", + "datafile_path": "buildpack.toml", + "datasource_id": "buildpack_toml" + } + ], + "files": [ + { + "path": "buildpack.toml", + "type": "file", + "package_data": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for Java Memory Assistant", + "version": "{{.version}}", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "A Cloud Native Buildpack that installs the Java Memory Assistant agent", + "release_date": null, + "parties": [], + "keywords": [ + "agent" + ], + "homepage_url": "https://github.com/paketo-buildpacks/java-memory-assistant", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "Apache-2.0", + "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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/java-memory-assistant" + }, + "dependencies": [ + { + "purl": "pkg:generic/sap-java-memory-assistant@0.5.0?arch=amd64", + "extracted_requirement": null, + "scope": "runtime", + "is_runtime": true, + "is_optional": false, + "is_pinned": false, + "is_direct": true, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "buildpack_toml", + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20Java%20Memory%20Assistant@%7B%7B.version%7D%7D" + } + ], + "for_packages": [ + "pkg:buildpack/Paketo%20Buildpack%20for%20Java%20Memory%20Assistant@%7B%7B.version%7D%7D?uuid=d197d3a7-e7df-49a2-8b79-a74156b545bc" + ], + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/opentelemetry/buildpack.toml b/tests/packagedcode/data/buildpack/paketo-buildpacks/opentelemetry/buildpack.toml new file mode 100644 index 0000000000..d9a2b2733f --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/opentelemetry/buildpack.toml @@ -0,0 +1,65 @@ +# Copyright 2018-2024 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +api = "0.7" + +[buildpack] + description = "A Cloud Native Buildpack that contributes and configures the OpenTelemetry Agent" + homepage = "https://github.com/paketo-buildpacks/opentelemetry" + id = "paketo-buildpacks/opentelemetry" + keywords = ["java", "apm", "trace", "opentelemetry"] + name = "Paketo Buildpack for OpenTelemetry" + sbom-formats = ["application/vnd.cyclonedx+json", "application/vnd.syft+json"] + version = "{{.version}}" + + [[buildpack.licenses]] + type = "Apache-2.0" + uri = "https://github.com/paketo-buildpacks/opentelemetry/blob/main/LICENSE" + +[metadata] + include-files = ["LICENSE", "NOTICE", "README.md", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/main", "linux/amd64/bin/helper", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/main", "linux/arm64/bin/helper", "buildpack.toml"] + pre-package = "scripts/build.sh" + + [[metadata.configurations]] + build = true + default = "false" + description = "enable the OpenTelemetry Java Trace Agent" + name = "BP_OPENTELEMETRY_ENABLED" + + [[metadata.dependencies]] + cpes = ["cpe:2.3:a:open-telemetry:opentelemetry-java-agent:2.10.0:*:*:*:*:*:*:*"] + id = "opentelemetry-java" + name = "OpenTelemetry Java Agent" + purl = "pkg:generic/opentelemetry-java@2.10.0" + sha256 = "d05f6e36fac8db629263a6aaec2841cc934d064d7b19bfe38425b604b8b54926" + source = "https://github.com/open-telemetry/opentelemetry-java-instrumentation/archive/refs/tags/v2.10.0.tar.gz" + source-sha256 = "3a921baa391e9fa3f3622bedf1770567bcfed2a13de07642a2273b8beeca934a" + stacks = ["*"] + uri = "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.10.0/opentelemetry-javaagent.jar" + version = "2.10.0" + + [[metadata.dependencies.licenses]] + type = "Apache-2.0" + uri = "https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/LICENSE" + +[[stacks]] + id = "*" + +[[targets]] + arch = "amd64" + os = "linux" + +[[targets]] + arch = "arm64" + os = "linux" \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/opentelemetry/expectedbuildpack.json b/tests/packagedcode/data/buildpack/paketo-buildpacks/opentelemetry/expectedbuildpack.json new file mode 100644 index 0000000000..793a001e47 --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/opentelemetry/expectedbuildpack.json @@ -0,0 +1,151 @@ +{ + "packages": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for OpenTelemetry", + "version": "{{.version}}", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "A Cloud Native Buildpack that contributes and configures the OpenTelemetry Agent", + "release_date": null, + "parties": [], + "keywords": [ + "java", + "apm", + "trace", + "opentelemetry" + ], + "homepage_url": "https://github.com/paketo-buildpacks/opentelemetry", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "Apache-2.0", + "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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/opentelemetry" + }, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20OpenTelemetry@%7B%7B.version%7D%7D?uuid=01957db3-05cb-464d-94ab-5818aa169b41", + "datafile_paths": [ + "buildpack.toml" + ], + "datasource_ids": [ + "buildpack_toml" + ], + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20OpenTelemetry@%7B%7B.version%7D%7D" + } + ], + "dependencies": [ + { + "purl": "pkg:generic/opentelemetry-java@2.10.0", + "extracted_requirement": null, + "scope": "runtime", + "is_runtime": true, + "is_optional": false, + "is_pinned": false, + "is_direct": true, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:generic/opentelemetry-java@2.10.0?uuid=6d44ed4b-f22b-43d0-a7ab-e98529e1a112", + "for_package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20OpenTelemetry@%7B%7B.version%7D%7D?uuid=01957db3-05cb-464d-94ab-5818aa169b41", + "datafile_path": "buildpack.toml", + "datasource_id": "buildpack_toml" + } + ], + "files": [ + { + "path": "buildpack.toml", + "type": "file", + "package_data": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for OpenTelemetry", + "version": "{{.version}}", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "A Cloud Native Buildpack that contributes and configures the OpenTelemetry Agent", + "release_date": null, + "parties": [], + "keywords": [ + "java", + "apm", + "trace", + "opentelemetry" + ], + "homepage_url": "https://github.com/paketo-buildpacks/opentelemetry", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "Apache-2.0", + "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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/opentelemetry" + }, + "dependencies": [ + { + "purl": "pkg:generic/opentelemetry-java@2.10.0", + "extracted_requirement": null, + "scope": "runtime", + "is_runtime": true, + "is_optional": false, + "is_pinned": false, + "is_direct": true, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "buildpack_toml", + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20OpenTelemetry@%7B%7B.version%7D%7D" + } + ], + "for_packages": [ + "pkg:buildpack/Paketo%20Buildpack%20for%20OpenTelemetry@%7B%7B.version%7D%7D?uuid=01957db3-05cb-464d-94ab-5818aa169b41" + ], + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/pipeline-builder-canary/buildpack.toml b/tests/packagedcode/data/buildpack/paketo-buildpacks/pipeline-builder-canary/buildpack.toml new file mode 100644 index 0000000000..744b17ed61 --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/pipeline-builder-canary/buildpack.toml @@ -0,0 +1,64 @@ +# Copyright 2018-2021 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +api = "0.7" + +[buildpack] + description = "A Cloud Native Buildpack that provides/does nothing. For testing only." + homepage = "https://github.com/paketo-buildpacks/pipeline-builder-canary" + id = "paketo-buildpacks/pipeline-builder-canary" + keywords = ["nothing"] + name = "Paketo Buildpack for Pipeline Builder Canary" + version = "{{.version}}" + + [[buildpack.licenses]] + type = "Apache-2.0" + uri = "https://github.com/paketo-buildpacks/pipeline-builder-canary/blob/main/LICENSE" + +[metadata] + include-files = ["LICENSE", "NOTICE", "README.md", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/main", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/main", "buildpack.toml"] + pre-package = "scripts/build.sh" + + [[metadata.dependencies]] + cpes = ["cpe:2.3:a:apache:maven:3.9.9:*:*:*:*:*:*:*"] + id = "maven" + name = "Apache Maven" + purl = "pkg:generic/apache-maven@3.9.9" + sha256 = "7a9cdf674fc1703d6382f5f330b3d110ea1b512b51f1652846d9e4e8a588d766" + source = "https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-src.tar.gz" + source-sha256 = "8a24c448d4ac397e6b0c019a4d7250068c02d1cdb553299e6bb71c3ccca78b2c" + stacks = ["io.buildpacks.stacks.bionic", "io.paketo.stacks.tiny", "*"] + uri = "https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.tar.gz" + version = "3.9.9" + + [[metadata.dependencies.licenses]] + type = "Apache-2.0" + uri = "https://www.apache.org/licenses/" + +[[stacks]] + id = "io.buildpacks.stacks.bionic" + +[[stacks]] + id = "io.paketo.stacks.tiny" + +[[stacks]] + id = "*" + +[[targets]] + arch = "amd64" + os = "linux" + +[[targets]] + arch = "arm64" + os = "linux" \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/pipeline-builder-canary/expectedbuildpack.json b/tests/packagedcode/data/buildpack/paketo-buildpacks/pipeline-builder-canary/expectedbuildpack.json new file mode 100644 index 0000000000..97808da3ca --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/pipeline-builder-canary/expectedbuildpack.json @@ -0,0 +1,145 @@ +{ + "packages": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for Pipeline Builder Canary", + "version": "{{.version}}", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "A Cloud Native Buildpack that provides/does nothing. For testing only.", + "release_date": null, + "parties": [], + "keywords": [ + "nothing" + ], + "homepage_url": "https://github.com/paketo-buildpacks/pipeline-builder-canary", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "Apache-2.0", + "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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/pipeline-builder-canary" + }, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20Pipeline%20Builder%20Canary@%7B%7B.version%7D%7D?uuid=5645b40a-3914-435b-af7a-ee5cafef162b", + "datafile_paths": [ + "buildpack.toml" + ], + "datasource_ids": [ + "buildpack_toml" + ], + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20Pipeline%20Builder%20Canary@%7B%7B.version%7D%7D" + } + ], + "dependencies": [ + { + "purl": "pkg:generic/apache-maven@3.9.9", + "extracted_requirement": null, + "scope": "runtime", + "is_runtime": true, + "is_optional": false, + "is_pinned": false, + "is_direct": true, + "resolved_package": {}, + "extra_data": {}, + "dependency_uid": "pkg:generic/apache-maven@3.9.9?uuid=75bc22b3-e9f7-4e63-b9a8-679269bbe48a", + "for_package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20Pipeline%20Builder%20Canary@%7B%7B.version%7D%7D?uuid=5645b40a-3914-435b-af7a-ee5cafef162b", + "datafile_path": "buildpack.toml", + "datasource_id": "buildpack_toml" + } + ], + "files": [ + { + "path": "buildpack.toml", + "type": "file", + "package_data": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for Pipeline Builder Canary", + "version": "{{.version}}", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": "A Cloud Native Buildpack that provides/does nothing. For testing only.", + "release_date": null, + "parties": [], + "keywords": [ + "nothing" + ], + "homepage_url": "https://github.com/paketo-buildpacks/pipeline-builder-canary", + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": null, + "holder": null, + "declared_license_expression": "Apache-2.0", + "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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/pipeline-builder-canary" + }, + "dependencies": [ + { + "purl": "pkg:generic/apache-maven@3.9.9", + "extracted_requirement": null, + "scope": "runtime", + "is_runtime": true, + "is_optional": false, + "is_pinned": false, + "is_direct": true, + "resolved_package": {}, + "extra_data": {} + } + ], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "buildpack_toml", + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20Pipeline%20Builder%20Canary@%7B%7B.version%7D%7D" + } + ], + "for_packages": [ + "pkg:buildpack/Paketo%20Buildpack%20for%20Pipeline%20Builder%20Canary@%7B%7B.version%7D%7D?uuid=5645b40a-3914-435b-af7a-ee5cafef162b" + ], + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/source-removal/buildpack.toml b/tests/packagedcode/data/buildpack/paketo-buildpacks/source-removal/buildpack.toml new file mode 100644 index 0000000000..01a51bfaed --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/source-removal/buildpack.toml @@ -0,0 +1,12 @@ +api = "0.7" + +[buildpack] +id = "paketo-buildpacks/source-removal" +name = "Paketo Buildpack for Source Removal" + +[metadata] +include-files = ["bin/run", "bin/build","bin/detect","buildpack.toml"] +pre-package = "./scripts/build.sh" + +[[stacks]] +id = "*" \ No newline at end of file diff --git a/tests/packagedcode/data/buildpack/paketo-buildpacks/source-removal/expectedbuildpack.json b/tests/packagedcode/data/buildpack/paketo-buildpacks/source-removal/expectedbuildpack.json new file mode 100644 index 0000000000..bead54efff --- /dev/null +++ b/tests/packagedcode/data/buildpack/paketo-buildpacks/source-removal/expectedbuildpack.json @@ -0,0 +1,113 @@ +{ + "packages": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for Source Removal", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": 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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/source-removal" + }, + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "package_uid": "pkg:buildpack/Paketo%20Buildpack%20for%20Source%20Removal@unknown?uuid=24557330-563d-4a75-909f-b60c6e517a27", + "datafile_paths": [ + "buildpack.toml" + ], + "datasource_ids": [ + "buildpack_toml" + ], + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20Source%20Removal@unknown" + } + ], + "dependencies": [], + "files": [ + { + "path": "buildpack.toml", + "type": "file", + "package_data": [ + { + "type": "buildpack", + "namespace": null, + "name": "Paketo Buildpack for Source Removal", + "version": "unknown", + "qualifiers": {}, + "subpath": null, + "primary_language": null, + "description": null, + "release_date": null, + "parties": [], + "keywords": [], + "homepage_url": null, + "download_url": null, + "size": null, + "sha1": null, + "md5": null, + "sha256": null, + "sha512": null, + "bug_tracking_url": null, + "code_view_url": null, + "vcs_url": null, + "copyright": 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": [], + "is_private": false, + "is_virtual": false, + "extra_data": { + "id": "paketo-buildpacks/source-removal" + }, + "dependencies": [], + "repository_homepage_url": null, + "repository_download_url": null, + "api_data_url": null, + "datasource_id": "buildpack_toml", + "purl": "pkg:buildpack/Paketo%20Buildpack%20for%20Source%20Removal@unknown" + } + ], + "for_packages": [ + "pkg:buildpack/Paketo%20Buildpack%20for%20Source%20Removal@unknown?uuid=24557330-563d-4a75-909f-b60c6e517a27" + ], + "scan_errors": [] + } + ] +} \ No newline at end of file diff --git a/tests/packagedcode/test_buildpack.py b/tests/packagedcode/test_buildpack.py new file mode 100644 index 0000000000..eb19ec6b29 --- /dev/null +++ b/tests/packagedcode/test_buildpack.py @@ -0,0 +1,258 @@ +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# ScanCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/scancode-toolkit for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + +import os +from packagedcode import buildpack +from commoncode.testcase import FileBasedTesting +from packageurl import PackageURL +from packagedcode import models +from packages_test_utils import compare_package_results +from scancode.cli_test_utils import check_json_scan +from scancode.cli_test_utils import run_scan_click +from scancode_config import REGEN_TEST_FIXTURES + +class TestBuildpack(FileBasedTesting): + test_data_dir = os.path.join(os.path.dirname(__file__), 'data') + + + def test_scanworks_on_buildpack_heroku_java(self): + test_file = self.get_test_loc('buildpack/heroku-buildpacks/heroku-buildpack-java/buildpack.toml') + expected_file = self.get_test_loc('buildpack/heroku-buildpacks/heroku-buildpack-java/expectedbuildpack.json') + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', test_file, '--json-pp', result_file]) + check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES) + + def test_scanworks_on_buildpack_heroku_php(self): + test_file = self.get_test_loc('buildpack/heroku-buildpacks/heroku-buildpack-php/buildpack.toml') + expected_file = self.get_test_loc('buildpack/heroku-buildpacks/heroku-buildpack-php/expectedbuildpack.json') + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', test_file, '--json-pp', result_file]) + check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES) + + def test_scanworks_on_buildpack_paketo_dotnet_execute(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/dotnet-execute/buildpack.toml') + expected_file = self.get_test_loc('buildpack/paketo-buildpacks/dotnet-execute/expectedbuildpack.json') + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', test_file, '--json-pp', result_file]) + check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES) + + def test_scanworks_on_buildpack_paketo_java_memory_assistant(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/java-memory-assistant/buildpack.toml') + expected_file = self.get_test_loc('buildpack/paketo-buildpacks/java-memory-assistant/expectedbuildpack.json') + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', test_file, '--json-pp', result_file]) + check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES) + + def test_scanworks_on_buildpack_paketo_git(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/git/buildpack.toml') + expected_file = self.get_test_loc('buildpack/paketo-buildpacks/git/expectedbuildpack.json') + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', test_file, '--json-pp', result_file]) + check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES) + + def test_scanworks_on_buildpack_paketo_opentelemetry(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/opentelemetry/buildpack.toml') + expected_file = self.get_test_loc('buildpack/paketo-buildpacks/opentelemetry/expectedbuildpack.json') + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', test_file, '--json-pp', result_file]) + check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES) + + def test_scanworks_on_buildpack_paketo_pipeline_builder_canary(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/pipeline-builder-canary/buildpack.toml') + expected_file = self.get_test_loc('buildpack/paketo-buildpacks/pipeline-builder-canary/expectedbuildpack.json') + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', test_file, '--json-pp', result_file]) + check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES) + + def test_scanworks_on_buildpack_paketo_source_removal(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/source-removal/buildpack.toml') + expected_file = self.get_test_loc('buildpack/paketo-buildpacks/source-removal/expectedbuildpack.json') + result_file = self.get_temp_file('results.json') + run_scan_click(['--package', test_file, '--json-pp', result_file]) + check_json_scan(expected_file, result_file, regen=REGEN_TEST_FIXTURES) + + def test_parse_heroku_buildpack_java_toml(self): + test_file = self.get_test_loc('buildpack/heroku-buildpacks/heroku-buildpack-java/buildpack.toml') + result_packages = list(buildpack.BuildpackHandler.parse(test_file)) + expected_packages = [ + models.PackageData( + type=buildpack.BuildpackHandler.default_package_type, + datasource_id=buildpack.BuildpackHandler.datasource_id, + description="Heroku buildpack for Java", + name="Java", + version="unknown", + extra_data={ + "ignore_files": [ + "etc/", + "spec/", + "test/", + ".gitignore", + ".github/", + "hatchet.json", + "Gemfile", + "Gemfile.lock" + ] + } + ) + ] + compare_package_results(expected_packages, result_packages) + + def test_parse_heroku_buildpack_php_toml(self): + test_file = self.get_test_loc('buildpack/heroku-buildpacks/heroku-buildpack-php/buildpack.toml') + result_packages = list(buildpack.BuildpackHandler.parse(test_file)) + expected_packages = [ + models.PackageData( + type=buildpack.BuildpackHandler.default_package_type, + datasource_id=buildpack.BuildpackHandler.datasource_id, + description= "Heroku buildpack for PHP", + name="PHP", + version="unknown", + extra_data={ + "ignore_files": [ + ".github/", + ".gitignore", + ".rspec_parallel", + "support/build/", + "support/devcenter/", + "test/", + "Gemfile", + "Gemfile.lock", + "hatchet.json", + "hatchet.lock", + "requirements.txt" + ] + } + ) + ] + compare_package_results(expected_packages, result_packages) + + def test_parse_paketo_dotnet_execute_buildpack_toml(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/dotnet-execute/buildpack.toml') + result_packages = list(buildpack.BuildpackHandler.parse(test_file)) + expected_packages = [ + models.PackageData( + type=buildpack.BuildpackHandler.default_package_type, + datasource_id=buildpack.BuildpackHandler.datasource_id, + name="Paketo Buildpack for .NET Execute", + version="unknown", + description="A buildpack for running the `dotnet execute` command for an app", + homepage_url="https://github.com/paketo-buildpacks/dotnet-execute", + keywords=["dotnet"], + declared_license_expression="Apache-2.0", + extra_data={"id": "paketo-buildpacks/dotnet-execute"} + ) + ] + compare_package_results(expected_packages, result_packages) + + def test_parse_paketo_java_memory_assistant_buildpack_toml(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/java-memory-assistant/buildpack.toml') + result_packages = list(buildpack.BuildpackHandler.parse(test_file)) + expected_packages = [ + models.PackageData( + type=buildpack.BuildpackHandler.default_package_type, + datasource_id=buildpack.BuildpackHandler.datasource_id, + name="Paketo Buildpack for Java Memory Assistant", + version="{{.version}}", + description="A Cloud Native Buildpack that installs the Java Memory Assistant agent", + homepage_url="https://github.com/paketo-buildpacks/java-memory-assistant", + keywords=["agent"], + declared_license_expression="Apache-2.0", + dependencies=[ + models.DependentPackage( + purl="pkg:generic/sap-java-memory-assistant@0.5.0?arch=amd64", + scope="runtime", + is_runtime=True, + is_optional=False + ) + ], + extra_data={"id": "paketo-buildpacks/java-memory-assistant"} + ) + ] + compare_package_results(expected_packages, result_packages) + + def test_parse_paketo_git_buildpack_toml(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/git/buildpack.toml') + result_packages = list(buildpack.BuildpackHandler.parse(test_file)) + expected_packages = [ + models.PackageData( + type=buildpack.BuildpackHandler.default_package_type, + datasource_id=buildpack.BuildpackHandler.datasource_id, + name="Paketo Buildpack for Git", + version="unknown", + homepage_url="https://github.com/paketo-buildpacks/git", + extra_data={"id": "paketo-buildpacks/git"} + ) + ] + compare_package_results(expected_packages, result_packages) + + def test_parse_paketo_opentelemetry_buildpack_toml(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/opentelemetry/buildpack.toml') + result_packages = list(buildpack.BuildpackHandler.parse(test_file)) + expected_packages = [ + models.PackageData( + type=buildpack.BuildpackHandler.default_package_type, + datasource_id=buildpack.BuildpackHandler.datasource_id, + name="Paketo Buildpack for OpenTelemetry", + version="{{.version}}", + description="A Cloud Native Buildpack that contributes and configures the OpenTelemetry Agent", + homepage_url="https://github.com/paketo-buildpacks/opentelemetry", + keywords=["java", "apm", "trace", "opentelemetry"], + declared_license_expression="Apache-2.0", + dependencies=[ + models.DependentPackage( + purl="pkg:generic/opentelemetry-java@2.10.0", + scope="runtime", + is_runtime=True, + is_optional=False + ) + ], + extra_data={"id": "paketo-buildpacks/opentelemetry"} + ) + ] + compare_package_results(expected_packages, result_packages) + + def test_parse_paketo_pipeline_builder_canary_buildpack_toml(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/pipeline-builder-canary/buildpack.toml') + result_packages = list(buildpack.BuildpackHandler.parse(test_file)) + expected_packages = [ + models.PackageData( + type=buildpack.BuildpackHandler.default_package_type, + datasource_id=buildpack.BuildpackHandler.datasource_id, + name="Paketo Buildpack for Pipeline Builder Canary", + version="{{.version}}", + description="A Cloud Native Buildpack that provides/does nothing. For testing only.", + homepage_url="https://github.com/paketo-buildpacks/pipeline-builder-canary", + keywords=["nothing"], + declared_license_expression="Apache-2.0", + dependencies=[ + models.DependentPackage( + purl="pkg:generic/apache-maven@3.9.9", + scope="runtime", + is_runtime=True, + is_optional=False + ) + ], + extra_data={"id": "paketo-buildpacks/pipeline-builder-canary"} + ) + ] + compare_package_results(expected_packages, result_packages) + + def test_parse_paketo_source_removal_buildpack_toml(self): + test_file = self.get_test_loc('buildpack/paketo-buildpacks/source-removal/buildpack.toml') + result_packages = list(buildpack.BuildpackHandler.parse(test_file)) + expected_packages = [ + models.PackageData( + type=buildpack.BuildpackHandler.default_package_type, + datasource_id=buildpack.BuildpackHandler.datasource_id, + name="Paketo Buildpack for Source Removal", + version="unknown", + extra_data={"id": "paketo-buildpacks/source-removal"} + ) + ] + compare_package_results(expected_packages, result_packages)