Skip to content

Switch to Packagist api v2 for Composer package metadata #2337

Closed

Description

@valentijnscholten

Current Behavior

Compose Packagist api v1 is deprecated.
API v2 also handles non-existing packages better, see #2134 And it helps packagist to reduce server load on their end.

Proposed Behavior

Use API v2. It's a very small change as far as I can see in https://packagist.org/apidoc#get-package-data.

Now that we are caching metadata, we could use the If-Modified-Since header to hel preduce load on their server.
In theory also on our end because if the metadata is not modified since we last cached it, we don't have to process the response. But this might be micro optimizing, probably requires a change to the parameters passed into the analyze method and we need to persist the new lastOccurrence timestamp to the database anyway.

Checklist

Activity

  1. added
    enhancement
    on Dec 29, 2022
  2. changed the title [-]Switch to Packagist api v2 for Compose package metadata[/-] [+]Switch to Packagist api v2 for Composer package metadata[/+] on Dec 29, 2022
  3. valentijnscholten commented on Dec 4, 2024

    @valentijnscholten
    ContributorAuthor

    From the blog post:

    • February 1st, 2025: Composer 1.x metadata will become read-only. No new packages or new versions will be visible for Composer 1.x users after this date.
    • August 1st, 2025: Composer 1.x metadata access will be entirely shut down. Attempting to update packages using Composer 1.x will no longer work.
  4. valentijnscholten commented on Dec 15, 2024

    @valentijnscholten
    ContributorAuthor

    When implementing V2 we should consider also getting the Vulnerabity information from the package repository. This will show more vulnerabilities, for example the Drupal advisories which don't have a CVE/GHSA/... identifier.

    From: https://packagist.org/apidoc#get-package-data:

    List security advisories
    This endpoint provides a list of security advisories. Either a list of packages as query or request parameter or a timestamp as updatedSince query parameter need to be passed.

    When querying with a list of packages, known packages will be included in the response with an empty array if they don't have any listed vulnerability. Package names which are not known to have no vulnerability will not be included at all to show that we do not have data on those.

    GET https://packagist.org/api/security-advisories/?updatedSince=[timestamp]&packages[]=[vendor/package]
    
    {
      "advisories": {
        "[vendor]/[package]": [
          {
            "advisoryId": "[unique id]",
            "packageName": "[vendor]/[package]",
            "remoteId": "[deprecated, use sources instead]",
            "title": "[title]",
            "link": "[url to issue disclosure]",
            "cve": "[cve if available]",
            "affectedVersions": [affected version in form of a composer constraint]",
            "source": "[deprecated, use sources instead]",
            "sources": [
                {
                    "name": "[Name of the source where the advisory was found e.g. GitHub or FriendsOfPHP/security-advisories]"
                    "remoteId": "[A reference to identify the advisory in the source e.g. the GitHub advisory id]"
                }
            ],
            "reportedAt": "[date the issue was reported]",
            "composerRepository": "[composer repository the package can be found in]",
            "severity": [severity if available, following the CVSS3 spec]
          }
        ]
      }
    }
    

    Working example: https://packagist.org/api/security-advisories/?packages[]=monolog/monolog

    In fact, Drupal has its own package repository that DT should index / query as well. And it returns vulnerabilities in the same response as for other package metadata: https://packages.drupal.org/files/packages/8/p2/drupal/mollie.json

    I think supported v2 and also supporting vulnerabilities are two separate tasks, so I created #4465 for the vulnerability support.

  5. jkowalleck commented on Dec 15, 2024

    @jkowalleck
    Contributor

    When implementing V2 we should consider also getting the Vulnerabity information from the package repository. This will show more vulnerabilities, for example the Drupal advisories which don't have a CVE/GHSA/... identifief.

    I'd support this idea. Thank you for creating #4465

  6. jkowalleck commented on Dec 15, 2024

    @jkowalleck
    Contributor

    In fact, Drupal has its own package repository that DT should index / query as well. And it returns vulnerabilities in the same response as for other package metadata: https://packages.drupal.org/files/packages/8/p2/drupal/mollie.json

    Implementation-wise, I would go like it currently is: have the base url configurable, so that multiple clients for this API spec could be enabled in DT.

    see

    private static final String DEFAULT_BASE_URL = "https://repo.packagist.org";

  7. github-actions commented on Jan 29, 2025

    @github-actions
    Contributor

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  8. locked as resolved and limited conversation to collaborators on Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions