Endor Labs for PHP
PHP is a popular server-side scripting language primarily used for web development. Endor Labs supports the scanning and monitoring of PHP projects.
Using Endor Labs, developers can:
- Test their software for potential issues and violations of organizational policy
- Prioritize vulnerabilities in the context of their applications
- Understand the relationships between software components in their applications
Scan PHP projects
To successfully scan your PHP applications:
- Scan PHP projects
Install software prerequisites
- One of the following prerequisites must be fulfilled:
- The PHP project must contain a composer.json file. If the project includes the composer.lock file it is beneficial, but this is not a mandatory requirement.
- If the composer.lock file is not present in the repository, it is necessary to have PHP and Composer installed before running a scan on your local system.
- The following versions are supported for PHP and Composer:
- PHP 5.3.2 and higher versions
- Composer 2.2.0 and higher versions
Build PHP projects
You can choose to build your PHP projects before running a scan. This will ensure that composer.lock is created.
Ensure your repo has composer.json and run the following command making sure it builds the project successfully.
If the project is not built, endorctl will build the project during the scan and generate composer.lock. If the repository includes a composer.lock, endorctl uses this file for dependency resolution and does not create it again.
Configure private Composer package repositories
If you have a private registry and internal dependencies on other projects, you must configure private registries.
To configure private Composer package repositories:
- Sign in to Endor Labs and select Integrations under Manage from the left sidebar.
- From Package Managers, select Packagist and click Manage.
- Click Add Package Manager.
- In PACKAGE MANAGER HOST, enter the host domain of the package manager.
- From the available options, choose the authentication method for private repositories.
- To enable Endor Labs to authenticate to your registry, select Authenticate to this registry and enter the required details of your private package manager repository.
- Click Add Package Manager to save your configuration.
Run a scan
Perform a scan to get visibility into your software composition and resolve dependencies.
You can perform the scan from within the root directory of the git project repository, and save the local results to a results.json file. The results and related analysis information are available on the Endor Labs user interface.
endorctl scan -o json | tee /path/to/results.json
You can sign into the Endor Labs user interface, click the Projects on the left sidebar, and find your project to review its results.
Understand the scan process
Endor Labs discovers all composer.json files in your PHP project and uses these files to resolve the dependencies of your packages. Composer is a PHP dependency management tool that enables you to specify the libraries your project relies on and manages the process of installing or updating them. The dependencies and findings are listed in the Endor Labs application individually for every composer.json file.
In Endor Labs’ dependency management, the resolution of dependencies is based on both composer.json and composer.lock files. The composer.lock file is generated by Composer and includes information such as resolved versions, package information, transitive dependencies, and other details. Using the composer.lock file ensures deterministic dependency installation by recording the exact versions of installed dependencies and their transitive dependencies. If the composer.lock file is not present in the repository, Endor Labs generates the composer.lock file, and uses it to analyze the operational and security risks associated with your package’s dependencies. Endor Labs fetches the dependency information and creates a comprehensive dependency graph.
Call graphs are not supported for PHP projects.
- Unresolved dependency errors:
The composer.json is not buildable. Try running
composer installin the root project to debug this error.
- Resolved dependency errors: A version of a dependency does not exist or it cannot be found. It may have been removed from the repository.
Was this page helpful? Send your feedback to firstname.lastname@example.org