### Start MatchCode.io server Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/getting-started/usage.rst Run this command to start the MatchCode.io server. Requires the project's make setup. ```default make run_matchcodeio ``` -------------------------------- ### Clone and set up PurlDB Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/getting-started/install.rst Clones the PurlDB repository and runs the setup commands to install dependencies, create the environment file, and start the PostgreSQL database. ```default git clone https://github.com/aboutcode-org/purldb cd purldb make dev make envfile make postgres ``` -------------------------------- ### Start PurlDB server Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/getting-started/usage.rst Run this command to start the PurlDB server. Requires the project's make setup. ```default make run ``` -------------------------------- ### Setup PurlDB and matchcode.io Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/how-to-guides/deploy_to_devel.rst Clone the PurlDB repository and run the development environment. This includes starting the PostgreSQL database and the matchcode.io service. ```default git clone https://github.com/aboutcode-org/purldb cd purldb make dev make envfile SECRET_KEY="1" make postgres_matchcodeio SECRET_KEY="1" make run_matchcodeio ``` ```default make run ``` -------------------------------- ### Run local web server Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/how-to-guides/installation.rst Start the local webserver for the web application. Access the app at http://localhost:8000/. This setup is not suitable for deployments and only supported for local development. ```default make run ``` -------------------------------- ### Setup matchcode locally for d2d analysis Source: https://github.com/aboutcode-org/purldb/blob/main/purldb-toolkit/README.rst Clone the purldb repository, set up the development environment, and start the matchcode service. This is a prerequisite for running the d2d command. ```console git clone https://github.com/aboutcode-org/purldb cd purldb make dev make envfile SECRET_KEY="1" make postgres_matchcodeio SECRET_KEY="1" make run_matchcodeio ``` -------------------------------- ### GET /api/resources/ - List resources response Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Example JSON response from the GET /api/resources/ endpoint. Shows a paginated list of resources with fields like package, purl, path, checksums, and license detections. ```json { "count": 6031130, "next": "https://public.purldb.io/api/resources/?page=2", "previous": null, "results": [ { "package": "https://public.purldb.io/api/packages/20b7d376-09c7-45ef-a102-75f7f5eef7e2/", "purl": "pkg:npm/cac@6.7.14", "path": "package/deno/CAC.ts", "type": "file", "name": "", "extension": "", "size": 8133, "md5": "969474f21d02f9a1dad6a2e85f4bbd25", "sha1": "8c7042781582df3d5f39fd2fabf7d2dd365f1669", "sha256": null, "sha512": null, "git_sha1": null, "mime_type": "", "file_type": "", "programming_language": "", "is_binary": false, "is_text": false, "is_archive": false, "is_media": false, "is_key_file": false, "detected_license_expression": "", "detected_license_expression_spdx": "", "license_detections": [ { "matches": [], "identifier": "none-f9065fa7-3897-50e1-6fe0-0d7ba36748f6", "license_expression": "None" } ], "license_clues": [], "percentage_of_license_text": null, "copyrights": [], "holders": [], "authors": [], "package_data": [], "emails": [], "urls": [], "extra_data": {} } ] } ``` -------------------------------- ### Start visiting upstream package repositories Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/getting-started/usage.rst Run this command to start visiting upstream package repositories for package metadata. ```default make run_visit ``` -------------------------------- ### Build wheel and install matchcode-toolkit Source: https://github.com/aboutcode-org/purldb/blob/main/matchcode-toolkit/README.rst Build a wheel using flot and install it. The built wheel will be in the dist/ directory. ```shell pip install flot flot --wheel --sdist # The built wheel will be in the dist/ directory pip install matchcode_toolkit-*-py3-none-any.whl ``` -------------------------------- ### JSON response for package set list Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Example response from the GET /api/package_sets/ endpoint, showing a paginated list of package sets with package details. ```json { "count": 8198, "next": "https://public.purldb.io/api/package_sets/?page=2", "previous": null, "results": [ { "uuid": "9d1655c0-16c7-424f-b027-a141cfdbf706", "packages": [ { "url": "https://public.purldb.io/api/packages/8a433f5e-372c-4fe1-9fc3-1027ecc9678b/", "uuid": "8a433f5e-372c-4fe1-9fc3-1027ecc9678b", "filename": "rfc8528-data-util-8.0.6.jar", "package_sets": [ { "uuid": "9d1655c0-16c7-424f-b027-a141cfdbf706", "packages": [ "https://public.purldb.io/api/packages/8a433f5e-372c-4fe1-9fc3-1027ecc9678b/", "https://public.purldb.io/api/packages/99b26f6e-b823-4c72-8408-9996f17d30f4/" ] } ], "package_content": "binary", "purl": "pkg:maven/org.opendaylight.yangtools/rfc8528-data-util@8.0.6", "type": "maven", "namespace": "org.opendaylight.yangtools", "name": "rfc8528-data-util", "version": "8.0.6", "qualifiers": "", "subpath": "", "primary_language": "Java", "description": "rfc8528-data-util\nRFC8528 data model utilities", "release_date": "2022-05-25T13:36:00Z", "parties": [], "keywords": [], "homepage_url": null, "download_url": "https://repo1.maven.org/maven2/org/opendaylight/yangtools/rfc8528-data-util/8.0.6/rfc8528-data-util-8.0.6.jar", "bug_tracking_url": null, "code_view_url": null, "vcs_url": null, "repository_homepage_url": null, "repository_download_url": null, "api_data_url": null, "size": null, "md5": null, "sha1": "31157249a6286d5478b5d01e8a29f5de9c33fb80", "sha256": "e1d83077ff746ccce4783971d85b5f3efecc2a5504e7ca7801e29d9f131dfdf2", "sha512": "f633bd2fa6cd1d9a36fb296c373fe750dc48f1310b13bc1d020fe8f6ab7dddaf7ff650b11b910504d25a19b205c7237660e170d19fab9b152eabc6d51bd8525a", "copyright": "Copyright (c) PANTHEON.tech, s.r.o. and others", "holder": null, "declared_license_expression": "epl-1.0", "declared_license_expression_spdx": "EPL-1.0", "license_detections": [], "other_license_expression": "((epl-2.0 OR apache-2.0) AND epl-2.0) AND (epl-1.0 AND epl-2.0)", "other_license_expression_spdx": "((EPL-2.0 OR Apache-2.0) AND EPL-2.0) AND (EPL-1.0 AND EPL-2.0)", "other_license_detections": [], "extracted_license_statement": null, "notice_text": null, "source_packages": [ "pkg:maven/org.opendaylight.yangtools/rfc8528-data-util@8.0.6?classifier=sources" ], "extra_data": {}, "package_uid": "pkg:maven/org.opendaylight.yangtools/rfc8528-data-util@8.0.6?uuid=8a433f5e-372c-4fe1-9fc3-1027ecc9678b", "datasource_id": null, "file_references": [], "dependencies": [ { "purl": "pkg:maven/com.google.guava/guava", "extracted_requirement": null, "scope": "compile", "is_runtime": true, "is_optional": false, "is_resolved": true, "is_pinned": false, "is_locked": false, "dependency_uid": "pkg:maven/com.google.guava/guava?uuid=..." } ] } ] } ] } ``` -------------------------------- ### Install Java and set up PyLucene egg Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/googlecode/downloads_apache_eclipse/apache_with_notice.html Commands to install the JRE, set PATH and PYTHONPATH, and test the import. The egg is experimental and will not work on other machines. ```bash $ chmod 755 jre-1_5_0_12-linux-amd64.bin $ ./jre-1_5_0_12-linux-amd64.bin $ export PATH=$PATH:/jre1.5.0_12/bin/ add the egg to you PYTHONPATH: $ export PYTHONPATH=$PYTHONPATH:/lucene-3.1.0-py2.5-linux-x86_64.egg $ python2.5 >>> import lucene ``` -------------------------------- ### Run the demo server Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/googlecode/homepage/nosource_longdesc.html Command to start the demo server after navigating to the bwip-js directory. ```bash $ node node-demo ``` -------------------------------- ### Install matchcode-toolkit from PyPI Source: https://github.com/aboutcode-org/purldb/blob/main/matchcode-toolkit/README.rst Install the MatchCode toolkit from PyPI. It must be installed in the same environment as ScanCode toolkit or ScanCode.io. ```shell pip install matchcode-toolkit ``` -------------------------------- ### Net::ZooTool synopsis: API usage examples Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/cpan/Net_ZooTool_search.cpan.org.html Shows how to create a Net::ZooTool object with an API key, fetch popular items, get item info, and use authenticated calls for user validation and items. Authentication is optional for some methods; public items are returned unless login is set to 'true'. ```perl my $zoo = Net::ZooTool->new({ apikey => $config{apikey} }); my $weekly_popular = $zoo->item->popular({ type => "week" }); # Info about a specific item print Dumper($zoo->item->info({ uid => "6a80z" })); # Examples with authenticated calls my $auth_zoo = Net::ZooTool->new( { apikey => $config{apikey}, user => $config{user}, password => $config{password}, } ); my $data = $auth_zoo->user->validate({ username => $config{user}, login => 'true' }); print Dumper($data); # In some methods authentication is optional. # Public items only my $public_items = $auth_zoo->user->items({ username => $config{user} }); # Include also your private items my $all_items = $auth_zoo->user->items({ username => $config{user}, login => 'true' }); ``` -------------------------------- ### Install MatchCode toolkit from repo with --editable Source: https://github.com/aboutcode-org/purldb/blob/main/matchcode-toolkit/README.rst Install a checkout of the repo into an environment using pip's --editable option. Activate the virtual environment first and change to the matchcode-toolkit directory. ```shell # Activate the virtual environment you want to install MatchCode-toolkit into, # change directories to the ``matchcode-toolkit`` directory pip install --editable . ``` -------------------------------- ### Run Elixir interactive shell in Docker Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/dockerhub/library_elixir.html Starts an interactive Elixir shell in a temporary container. Use this to experiment with Elixir commands. The example shows checking the system version and uptime. ```console $ docker run -it --rm --name elixir-inst1 -v "$PWD":/usr/src/myapp -w /usr/src/myapp elixir iex ``` ```iex iex(snode@elixir)1> System.version "1.2.1" iex(snode@elixir)2> :c.uptime 14 seconds :ok ``` -------------------------------- ### Example JSON response with source_symbols and source_strings Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/how-to-guides/symbols_and_strings.rst Example JSON response from the `/api/resources/` endpoint showing a resource file with `source_symbols` and `source_strings` arrays containing extracted symbols and strings. ```json { "package": "http://127.0.0.1:8001/api/packages/", "purl": "pkg:github/llvm/llvm-project@10.0.0", "path": "llvm-project-llvmorg-10.0.0.tar.gz-extract/llvm-project-llvmorg-10.0.0/clang/lib/Basic/Targets/BPF.cpp", "type": "file", "name": "BPF.cpp", "extension": ".cpp", "size": 1788, "md5": "382b406d1023d12cd8f28106043774ee", "sha1": "366146c8228c4e2cd46c47618fa3211ce48d96e2", "sha256": "d7609c502c7d462dcee1b631a80eb765ad7d10597991d88c3d4cd2ae0370eeba", "sha512": null, "git_sha1": null, "mime_type": "text/x-c", "file_type": "C source, ASCII text", "programming_language": "C++", "is_binary": false, "is_text": true, "is_archive": false, "is_media": false, "is_key_file": false, "detected_license_expression": "", "detected_license_expression_spdx": "", "license_detections": [], "license_clues": [], "percentage_of_license_text": null, "copyrights": [], "holders": [], "authors": [], "package_data": [], "emails": [], "urls": [], "extra_data": { "source_symbols": [ "clang", "clang", "targets", "BPFTargetInfo::getTargetDefines", "BPFTargetInfo::isValidCPUName", "BPFTargetInfo::fillValidCPUList" ], "source_strings": [ "\"", "__bpf__", "\"", "\"", "__BPF__", "\"", "\"", "generic", "\"", "\"", "v1", "\"", "\"", "v2", "\"", "\"", "v3", "\"", "\"", "probe", "\"" ] } } ``` -------------------------------- ### cURL request with API key Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Example cURL command to GET packages from the API using an API key in the Authorization header. ```console curl -X GET http://localhost/api/packages/ -H "Authorization:Token abcdef123456" ``` -------------------------------- ### Install purldb-toolkit with pip Source: https://github.com/aboutcode-org/purldb/blob/main/purldb-toolkit/README.rst Install the purldb-toolkit package using pip. ```console pip install purldb-toolkit ``` -------------------------------- ### Get purlcli help Source: https://github.com/aboutcode-org/purldb/blob/main/purldb-toolkit/README.rst Run purlcli --help to display the available subcommands and options. ```console purlcli --help Usage: purlcli [OPTIONS] COMMAND [ARGS]... Return information for a PURL or list of PURLs. Options: --help Show this message and exit. Commands: d2d Run deploy-to-devel "back2source" analysis between packages. metadata Fetch package metadata for a PURL. urls Return known URLs for a PURL. validate Validate PURL syntax and existence. versions List all known versions for a PURL. ``` -------------------------------- ### Generate main requirements with gen_requirements.py Source: https://github.com/aboutcode-org/purldb/blob/main/etc/scripts/README.rst Generate the main pip requirements file. Start with a clean virtualenv, then configure and run gen_requirements.py with the path to the site-packages directory. Optionally install or update extra main requirements after the configure step so they are included. ```bash ./configure --clean ./configure python etc/scripts/gen_requirements.py --site-packages-dir ``` -------------------------------- ### Example API response with source_strings Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/how-to-guides/symbols_and_strings.rst Example JSON response from the /api/resources/ endpoint after indexing, showing a resource with its metadata and the extracted source_strings array containing gettext strings. ```json { "package": "http://127.0.0.1:8001/api/packages/", "purl": "pkg:github/llvm/llvm-project@10.0.0", "path": "llvm-project-llvmorg-10.0.0.tar.gz-extract/llvm-project-llvmorg-10.0.0/clang/lib/Basic/Targets/BPF.cpp", "type": "file", "name": "BPF.cpp", "extension": ".cpp", "size": 1788, "md5": "382b406d1023d12cd8f28106043774ee", "sha1": "366146c8228c4e2cd46c47618fa3211ce48d96e2", "sha256": "d7609c502c7d462dcee1b631a80eb765ad7d10597991d88c3d4cd2ae0370eeba", "sha512": null, "git_sha1": null, "mime_type": "text/x-c", "file_type": "C source, ASCII text", "programming_language": "C++", "is_binary": false, "is_text": true, "is_archive": false, "is_media": false, "is_key_file": false, "detected_license_expression": "", "detected_license_expression_spdx": "", "license_detections": [], "license_clues": [], "percentage_of_license_text": null, "copyrights": [], "holders": [], "authors": [], "package_data": [], "emails": [], "urls": [], "extra_data": { "source_strings": [ "__bpf__", "__BPF__", "generic", "v", "v", "v", "probe" ] } } ``` -------------------------------- ### Create a Node.js HTTP server with bwip-js Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/googlecode/homepage/nosource_longdesc.html This example demonstrates how to use the bwip-js module to handle HTTP requests and generate barcodes. ```javascript var http = require('http'); var bwipjs = require('./node-bwipjs'); http.createServer(function(req, res) { // Send all requests to bwip-js. // In a real http server, you will want to route requests a bit more // intelligently... bwipjs(req, res); }).listen(3030); ``` -------------------------------- ### Install Linux system dependencies Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/how-to-guides/installation.rst Install the system packages required by the ScanCode toolkit on Linux before installing ScanCode.io. This command is needed for Debian-based distributions. ```default sudo apt-get install \ build-essential python3-dev libssl-dev libpq-dev \ bzip2 xz-utils zlib1g libxml2-dev libxslt1-dev libpopt0 \ libgpgme11 libdevmapper1.02.1 libguestfs-tools ``` -------------------------------- ### SBOM Response Example (CycloneDX 1.6) Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Example JSON response from the SBOM endpoint, showing the CycloneDX schema and format. The response includes the schema URL and specification version. ```json { "$schema": "http://cyclonedx.org/schema/bom-1.6.schema.json", "bomFormat": "CycloneDX", "specVersion": "1.6", } ``` -------------------------------- ### purlcli urls command example Source: https://github.com/aboutcode-org/purldb/blob/main/purldb-toolkit/README.rst Submits multiple PURLs using the urls command, with an output file specified. ```console purlcli urls --purl pkg:npm/canonical-path@1.0.0 --purl pkg:nginx/nginx@0.8.9 --purl pkg:rubygems/rails@7.0.0 --output ``` -------------------------------- ### Authorization header example Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Shows the required format for the Authorization header when authentication is enabled. The key must be prefixed with 'Token' and a space. ```default Authorization: Token abcdef123456 ``` -------------------------------- ### Install log4net 2.0.8 via Package Manager Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/nuget/log4net.html Use this command in the NuGet Package Manager console to install log4net version 2.0.8. ```powershell Install-Package log4net -Version 2.0.8 ``` -------------------------------- ### Load bwip.js in Node.js Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/googlecode/homepage/nosource_longdesc.html Example implementation for loading the primary bwip-js script in a CommonJS environment using the vm module. ```javascript var fs = require('fs'); var vm = require('vm'); function load(path) { var text = fs.readFileSync(path); if (!text) throw new Error(path + ": could not read file"); vm.runInThisContext(text, path); } // Load the primary bwip-js script load('bwip.js'); ``` -------------------------------- ### GET request to retrieve resource with symbols and strings Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/how-to-guides/symbols_and_strings.rst After indexing completes, send a GET request to `/api/resources/` with the `purl` parameter to retrieve the `source_symbols` and `source_strings` for the resources of the package. ```default /api/resources/?purl=pkg:github/llvm/llvm-project@10.0.0 ``` -------------------------------- ### Install script dependencies with pip Source: https://github.com/aboutcode-org/purldb/blob/main/etc/scripts/README.rst Install the tools required to run the scripts in this directory. This is needed for all usages except generating or updating pip requirement files, which require a clean virtualenv. ```bash pip install --requirement etc/scripts/requirements.txt ``` -------------------------------- ### GET /api/packages/ Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Lists and retrieves packages from the PurlDB. Requires authentication if the PURLDB_SETTINGS_REQUIRE_AUTHENTICATION setting is enabled. ```APIDOC ## GET /api/packages/ ### Description An API endpoint that provides the ability to list and get packages. ### Method GET ### Endpoint /api/packages/ ### Authentication If the authentication setting `PURLDB_SETTINGS_REQUIRE_AUTHENTICATION` is enabled, include an API key in the Authorization header as `Token `. ### Request Example ``` curl -X GET http://localhost/api/packages/ -H "Authorization:Token abcdef123456" ``` ### Response #### Success Response (200) Returns a list of packages. #### Response Example ```json { "results": [] } ``` ``` -------------------------------- ### Clone and configure PurlDB Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/how-to-guides/installation.rst Clone the PurlDB repository, install dependencies with `make dev`, and create an environment file with `make envfile`. The `make dev` step uses the `python3` executable by default unless `PYTHON_EXE` is specified. ```default git clone https://github.com/aboutcode-org/purldb.git && cd purldb ``` ```default make dev ``` ```default make envfile ``` -------------------------------- ### Install dependencies with custom Python version Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/how-to-guides/installation.rst Specify a Python version during the `make dev` step. When `PYTHON_EXE` is not specified, the `python3` executable is used by default. ```default make dev PYTHON_EXE=python3.11 ``` -------------------------------- ### Run PurlDB and MatchCode.io with Docker Compose Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/matchcode/index.rst Starts the PurlDB and MatchCode.io services using Docker Compose. The first command brings up the PurlDB service, and the second brings up the MatchCode.io service, both on the same Docker network with Traefik routing requests to the api/matching endpoint to MatchCode.io. ```default docker compose -f docker-compose.yml up -d docker compose -f docker-compose.matchcodeio.yml up -d ``` -------------------------------- ### Run Elixir as REPL with docker run Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/dockerhub/library_elixir.html Starts an interactive Elixir shell in a container. The output shows the Erlang/OTP version and an interactive session where you can evaluate Elixir expressions. ```console ➸ docker run -it --rm elixir Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Interactive Elixir (1.2.1) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> System.version "1.2.1" iex(2)> ➸ docker run -it --rm -h elixir.local elixir iex --sname snode Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Interactive Elixir (1.2.1) - press Ctrl+C to exit (type h() ENTER for help) iex(snode@elixir)1> System.version "1.2.1" iex(snode@elixir)2> :c.uptime 14 seconds :ok ``` ``` -------------------------------- ### Python: Get next download URL from scan_queue Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Uses the requests library to GET the get_next_download_url endpoint. Requires an Authorization token and a params variable that is not defined in the snippet. ```python import requests api_url = "https://public.purldb.io/api/scan_queue/get_next_download_url/" headers = { "Authorization": "Token abcdef123456", } response = requests.get(api_url, headers=headers, params=params) response.json() ``` -------------------------------- ### Run Elixir as REPL with docker run Source: https://github.com/aboutcode-org/purldb/blob/main/minecode/tests/testfiles/dockerhub/library_elixir.html Starts an interactive Elixir REPL container. The output shows the Erlang/OTP version and the Interactive Elixir prompt, where you can evaluate expressions like System.version. ```console ➸ docker run -it --rm elixir Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Interactive Elixir (1.2.1) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> System.version "1.2.1" iex(2)> ``` -------------------------------- ### Get package details Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Use this endpoint to retrieve all available information about a specific package. The response includes metadata such as purl, licenses, dependencies, and download URLs. ```http GET /api/projects/0bbdcf88-ad07-4970-9272-7d5f4c82cc7b/ ``` -------------------------------- ### Collect package data with GET /api/collect/ Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Sends a GET request to the collect endpoint with a purl. The response is a JSON array containing package details, including dependencies, URLs, and hashes. ```http GET /api/collect/?purl=pkg:npm/asdf@1.0.2 ``` ```json [ { "url": "https://public.purldb.io/api/packages/4f3a57de-e367-43c6-a7f1-51633d0ecd45/", "uuid": "4f3a57de-e367-43c6-a7f1-51633d0ecd45", "filename": "asdf-1.0.2.tgz", "package_sets": [], "package_content": null, "purl": "pkg:npm/asdf@1.0.2", "type": "npm", "namespace": "", "name": "asdf", "version": "1.0.2", "qualifiers": "", "subpath": "", "primary_language": "JavaScript", "description": "tiny static web server that you can launch instantly in any directory (inspired by https://github.com/ddfreyne/adsf/)", "release_date": null, "parties": [ { "type": "person", "role": "author", "name": "alsotang", "email": "alsotang@gmail.com", "url": null }, { "type": "person", "role": "maintainer", "name": "alsotang", "email": "alsotang@gmail.com", "url": null } ], "keywords": [ "static", "web", "server" ], "homepage_url": "https://github.com/alsotang/asdf", "download_url": "https://registry.npmjs.org/asdf/-/asdf-1.0.2.tgz", "bug_tracking_url": "https://github.com/alsotang/asdf/issues", "code_view_url": null, "vcs_url": "git+https://github.com/alsotang/asdf.git@53aeca5c74d3c8d1fe88c1f98f8e362fa389d1a2a", "repository_homepage_url": null, "repository_download_url": null, "api_data_url": null, "size": null, "md5": null, "sha1": "45b7468df1a6f2ec4826257535f97ea89db943e4", "sha256": null, "sha512": null, "copyright": null, "holder": null, "declared_license_expression": "mit", "declared_license_expression_spdx": "MIT", "license_detections": [], "other_license_expression": null, "other_license_expression_spdx": null, "other_license_detections": [], "extracted_license_statement": "MIT", "notice_text": null, "source_packages": [], "extra_data": {}, "package_uid": "pkg:npm/asdf@1.0.2?uuid=4f3a57de-e367-43c6-a7f1-51633d0ecd45", "datasource_id": null, "file_references": [], "dependencies": [ { "purl": "pkg:npm/express", "extracted_requirement": "^4.9.7", "scope": "dependencies", "is_runtime": true, "is_optional": false, "is_pinned": false }, { "purl": "pkg:npm/mocha", "extracted_requirement": "^1.21.5", "scope": "devDependencies", "is_runtime": false, "is_optional": true, "is_pinned": false }, { "purl": "pkg:npm/should", "extracted_requirement": "^4.0.4", "scope": "devDependencies", "is_runtime": false, "is_optional": true, "is_pinned": false }, { "purl": "pkg:npm/supertest", "extracted_requirement": "^0.14.0", "scope": "devDependencies", "is_runtime": false, "is_optional": true, "is_pinned": false } ], "resources": "https://public.purldb.io/api/packages/4f3a57de-e367-43c6-a7f1-51633d0ecd45/resources/", "history": "https://public.purldb.io/api/packages/4f3a57de-e367-43c6-a7f1-51633d0ecd45/history/" } ] ``` -------------------------------- ### GET /api/projects/{uuid}/ Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Retrieves detailed information about a specific package by its UUID. ```APIDOC ## GET /api/projects/{uuid}/ ### Description Retrieves detailed information about a specific package by its UUID. ### Method GET ### Endpoint /api/projects/{uuid}/ ### Parameters #### Path Parameters - **uuid** (string) - Required - The UUID of the package. ### Request Example ``` curl -X GET "http://localhost/api/projects/0bbdcf88-ad07-4970-9272-7d5f4c82cc7b/" -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **url** (string) - API URL of the package. - **uuid** (string) - UUID of the package. - **filename** (string) - Filename of the package. - **package_sets** (array) - List of package sets. - **package_content** (string) - Content type of the package. - **purl** (string) - Package URL. - **type** (string) - Package type. - **namespace** (string) - Package namespace. - **name** (string) - Package name. - **version** (string) - Package version. - **qualifiers** (string) - Package qualifiers. - **subpath** (string) - Package subpath. - **primary_language** (string) - Primary language. - **description** (string) - Package description. - **release_date** (string) - Release date. - **parties** (array) - List of parties. - **keywords** (array) - List of keywords. - **homepage_url** (string) - Homepage URL. - **download_url** (string) - Download URL. - **bug_tracking_url** (string) - Bug tracking URL. - **code_view_url** (string) - Code view URL. - **vcs_url** (string) - VCS URL. - **repository_homepage_url** (string) - Repository homepage URL. - **repository_download_url** (string) - Repository download URL. - **api_data_url** (string) - API data URL. - **size** (integer) - Package size. - **md5** (string) - MD5 hash. - **sha1** (string) - SHA1 hash. - **sha256** (string) - SHA256 hash. - **sha512** (string) - SHA512 hash. - **copyright** (string) - Copyright information. - **holder** (string) - Holder information. - **declared_license_expression** (string) - Declared license expression. - **declared_license_expression_spdx** (string) - Declared license expression in SPDX format. - **license_detections** (array) - License detections. - **other_license_expression** (string) - Other license expression. - **other_license_expression_spdx** (string) - Other license expression in SPDX format. - **other_license_detections** (array) - Other license detections. - **extracted_license_statement** (string) - Extracted license statement. - **notice_text** (string) - Notice text. - **source_packages** (array) - Source packages. - **extra_data** (object) - Extra data. - **package_uid** (string) - Package UID. - **datasource_id** (string) - Datasource ID. - **file_references** (array) - File references. - **dependencies** (array) - List of dependencies. - **resources** (string) - URL to resources. - **history** (string) - URL to history. #### Response Example ```json { "url": "https://public.purldb.io/api/packages/0bbdcf88-ad07-4970-9272-7d5f4c82cc7b/", "uuid": "0bbdcf88-ad07-4970-9272-7d5f4c82cc7b", "filename": "elasticsearch-cli-7.17.9.jar", "package_sets": [ { "uuid": "6d606be2-57c7-429a-a62e-d07833662c38", "packages": [ "https://public.purldb.io/api/packages/0bbdcf88-ad07-4970-9272-7d5f4c82cc7b/", "https://public.purldb.io/api/packages/055a7bab-38c6-4a1d-bb57-777b72ea4c99/" ] } ], "package_content": "binary", "purl": "pkg:maven/org.elasticsearch/elasticsearch-cli@7.17.9", "type": "maven", "namespace": "org.elasticsearch", "name": "elasticsearch-cli", "version": "7.17.9", "qualifiers": "", "subpath": "", "primary_language": "Java", "description": "elasticsearch-cli\nElasticsearch subproject :libs:elasticsearch-cli", "release_date": "2023-02-01T00:27:00Z", "parties": [ { "type": "person", "role": "developer", "name": "Elastic", "email": null, "url": "https://www.elastic.co" } ], "keywords": [], "homepage_url": "https://github.com/elastic/elasticsearch.git", "download_url": "https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch-cli/7.17.9/elasticsearch-cli-7.17.9.jar", "bug_tracking_url": null, "code_view_url": "https://github.com/elastic/elasticsearch.git", "vcs_url": "https://github.com/elastic/elasticsearch.git", "repository_homepage_url": null, "repository_download_url": null, "api_data_url": null, "size": null, "md5": null, "sha1": "9cb255ad91d178f39b2bffc9635c46caeffbd344", "sha256": "55e58a1a0b85aa771b85404782740b8cdeb4c37c88f87391e51bbf955c7af808", "sha512": "de2a7ca023b60f5d7a8c6c919495942512cfe9561230a1bf006ac160593573d81cbf356a35240dcc338c7c6aec4b79225ef2266eee5eb9b76a256c74b45e834c", "copyright": null, "holder": null, "declared_license_expression": "elastic-license-v2 AND mongodb-sspl-1.0", "declared_license_expression_spdx": "Elastic-2.0 AND SSPL-1.0", "license_detections": [], "other_license_expression": "apache-2.0 AND (mongodb-sspl-1.0 AND elastic-license-v2)", "other_license_expression_spdx": "Apache-2.0 AND (SSPL-1.0 AND Elastic-2.0)", "other_license_detections": [], "extracted_license_statement": "[{'name': 'Elastic License 2.0', 'url': 'https://raw.githubusercontent.com/elastic/elasticsearch/v7.17.9/licenses/ELASTIC-LICENSE-2.0.txt', 'comments': None, 'distribution': 'repo'}, {'name': 'Server Side Public License, v 1', 'url': 'https://www.mongodb.com/licensing/server-side-public-license', 'comments': None, 'distribution': 'repo'}]", "notice_text": null, "source_packages": [ "pkg:maven/org.elasticsearch/elasticsearch-cli@7.17.9?classifier=sources" ], "extra_data": {}, "package_uid": "pkg:maven/org.elasticsearch/elasticsearch-cli@7.17.9?uuid=0bbdcf88-ad07-4970-9272-7d5f4c82cc7b", "datasource_id": null, "file_references": [], "dependencies": [ { "purl": "pkg:maven/net.sf.jopt-simple/jopt-simple@5.0.2", "extracted_requirement": "5.0.2", "scope": "compile", "is_runtime": false, "is_optional": true, "is_pinned": true }, { "purl": "pkg:maven/org.elasticsearch/elasticsearch-core@7.17.9", "extracted_requirement": "7.17.9", "scope": "compile", "is_runtime": false, "is_optional": true, "is_pinned": true } ], "resources": "https://public.purldb.io/api/packages/0bbdcf88-ad07-4970-9272-7d5f4c82cc7b/resources/", "history": "https://public.purldb.io/api/packages/0bbdcf88-ad07-4970-9272-7d5f4c82cc7b/history/" } ``` ``` -------------------------------- ### cURL: Get next download URL from scan_queue Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Uses cURL to send a GET request to the get_next_download_url endpoint. Requires an Authorization token and returns a JSON mapping with the scannable_uri_uuid, download_url, and pipelines. ```console api_url="https://public.purldb.io/api/scan_queue/get_next_download_url/" content_type="Content-Type: application/json" authorization="Authorization:Token abcdef123456" curl -X GET "$api_url" -H "$content_type" -H "$authorization" ``` ```json { "scannable_uri_uuid": "4f3a57de-e367-43c6-a7f1-51633d0ecd45", "download_url": "https://registry.npmjs.org/asdf/-/asdf-1.0.2.tgz", "pipelines": ["scan_codebase", "fingerprint_codebase"] } ``` -------------------------------- ### Package resources JSON response Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Example response for the package resources endpoint. Contains a count, pagination links, and a list of resource objects with metadata such as path, type, and size. ```json { "count": 7556, "next": "https://public.purldb.io/api/packages/97627c6e-9acb-43e0-b8df-28bd92f2b7e5/resources/?page=2", "previous": null, "results": [ { "package": "https://public.purldb.io/api/packages/97627c6e-9acb-43e0-b8df-28bd92f2b7e5/", "purl": "pkg:maven/org.elasticsearch/elasticsearch@7.17.9", "path": "config", "type": "directory", "name": "config", "extension": "", "size": 0, "md5": "", "sha1": "", "sha256": "", "sha512": null, "git_sha1": null, "mime_type": "", "file_type": "", "programming_language": "", "is_binary": false, "is_text": false, "is_archive": false, "is_media": false, "is_key_file": false, "detected_license_expression": "", "detected_license_expression_spdx": "", "license_detections": [], "license_clues": [], "percentage_of_license_text": null, "copyrights": [], "holders": [], "authors": [], "package_data": [], "emails": [], "urls": [], "extra_data": {} } ] } ``` -------------------------------- ### Run PurlDB tests Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/getting-started/install.rst Runs the test suite to ensure PurlDB and the database are functioning correctly after setup. ```default make test ``` -------------------------------- ### Get package resources with cURL Source: https://github.com/aboutcode-org/purldb/blob/main/docs/source/purldb/rest_api.rst Retrieves the resources of a package as a list of mappings. Uses the package UUID in the URL. The response is paginated. ```console api_url="https://public.purldb.io/api/packages/0bbdcf88-ad07-4970-9272-7d5f4c82cc7b/resources/" content_type="Content-Type: application/json" curl -X GET "$api_url" -H "$content_type" ```