Download the PHP package phphleb/maskolog without Composer

On this page you can find all versions of the php package phphleb/maskolog. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package maskolog

Maskolog

version License: MIT tests

PSR-3 decorator for the Monolog logger with log-masking capabilities.

maskolog

Supports PHP versions v7.3, v7.4 - 8.0 and v8.1+

From the author:

When I joined a second relatively large company and faced the same requirement to mask logs on production servers, it became clear that this application security issue was broader and warranted a public library. This repository implements the concrete rules we needed to roll out across projects.

This library is intended for corporate environments; you should be familiar enough to handle installation and usage details not covered in this brief guide.

Installation

Installation is performed using Composer:

Logger Assembly

The logger is built from two parts — a factory that creates Monolog instances and an initializer that uses that factory to construct the masking logger itself.

Since this library only provides the abstract AbstractManagedLoggerFactory for creating and configuring a factory, the repository includes an ExampleManagedLoggerFactory demonstrating its use. The repository also includes an ExampleLogger showing how to extend the logger with additional masking capabilities.

Log Masking Methods

Whether an added item participates in the masking strategy depends on which logger method is used

Masking logger methods return a new instance of the logger with the added properties.

You can find examples of these processors in the /src/Processors/Masking/ folder, and also create your own. If such a record seems long to you and the names of the placeholder fields in the project will be standardized, create a shortened method in the class inherited from the logger and use it. For example:

Now you can use password masking like this:

This example is in the ExampleLogger class.

Masking Data According to the Project Configuration

For masking according to the values from the transferred list, a separate masking processor has been created, which is best assigned globally in the factory:

This processor is intended to prevent raw configuration data from appearing in error messages and contexts; therefore, by default it is limited to error levels only. Enabling informational levels in the processor constructor can cause performance issues when logging large volumes, because each message will require substring searches.

The project is expected to catch exceptions and log them via the masking logger.

Specifying Exact Fields to Mask

In the examples above, masking processors were configured with field names that were searched throughout the entire context, regardless of nesting. But what if the log context contains a nested array (for example, an API response) and you need to mask a specific field while leaving another field with the same name unmasked? This is a rare case, but you can specify a field for masking more precisely:

If you need to target a field at the top level, wrap it in array brackets — ['key']. To mask all nested values under a given key, provide an empty array for that key — ['list' => []]. You can also use numeric target keys (for example, ['list' => [0]]), although this is not recommended.

Masking for Objects in the Context

By default, the logger converts objects to arrays, so an object will be masked like a regular associative array of data. However, this conversion changes the nesting structure, and you must take that into account when specifying masks directly for fields. Global replacements at the logger level work the same as before (the field name becomes a key in the resulting array).

Direct indication of the target:

If automatic conversion is disabled, target objects will be passed to masking processors in their original form, so you will need to provide individual masks for each object. As an example for repository usage, there are examples for converting a specific object type to the required array format - these are the Psr7RequestProcessor and Psr7ResponseProcessor classes.

Masking Object Fields According to Attributes

To automatically mask an object's fields in log context, add the special Mask attribute.

If a specific masking processor is not specified in the attribute, the default one will be used.

Simplified Example of Integration in Symfony

Initializing the Standard Monolog Logger

From this wrapper logger you can retrieve the currently initialized Monolog instance at any time, including all associated processors and handlers.

Notes

Conclusion

If you have suggestions to improve or extend the logger, contact the author or the Telegram community.


All versions of maskolog with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
monolog/monolog Version ^3.0
ext-mbstring Version *
psr/http-message Version ^1.0 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phphleb/maskolog contains the following files

Loading the files please wait ...