2017 © Pedro Peláez
 

library soter-core

A very basic library for interacting with the WPScan Vulnerability Database API.

image

ssnepenthe/soter-core

A very basic library for interacting with the WPScan Vulnerability Database API.

  • Sunday, September 24, 2017
  • by ssnepenthe
  • Repository
  • 0 Watchers
  • 0 Stars
  • 65 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 6 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

soter-core

Soter Core is a simple library for interacting with the WPScan Vulnerability Database API., (*1)

It contains the core logic for Soter and Soter Command., (*2)

Requirements

This package requires Composer. It should work down to PHP 5.3, however it is only properly tested down to PHP 5.6 since that is now the minimum required version for 10up/WP_Mock., (*3)

Installation

composer require ssnepenthe/soter-core

Usage

Depending on your use-case, you should be interacting with either the Api_Client class or the Checker class., (*4)

API Client

$client = new Soter_Core\Api_Client(
    new Soter_Core\Cached_Http_Client(
        new Soter_Core\WP_Http_Client( 'Some user agent string' ),
        new Soter_Core\WP_Transient_Cache( 'unique-prefix', HOUR_IN_SECONDS )
    )
);

The API client exposes a ->check() method which can be used to check a Soter_Core\Package instance against the API:, (*5)

$plugin = new Soter_Core\Package( 'contact-form-7', Soter_Core\Package::TYPE_PLUGIN, '4.9' );
$response = $client->check( $plugin );

$theme = new Soter_Core\Package( 'twentyfifteen', Soter_Core\Package::TYPE_THEME, '1.8' );
$response = $client->check( $theme );

// WordPress "slug" is the version string stripped of periods.
$wordpress = new Soter_Core\Package( '481', Soter_Core\Package::TYPE_WORDPRESS, '4.8.1' );
$response = $client->check( $wordpress );

Responses will be an instance of Soter_Core\Response. You can check package vulnerabilities using the following methods:, (*6)

->has_vulnerabilities() - Returns a boolean value indicating whether there are any recorded vulnerabilities for a given package., (*7)

->get_vulnerabilities() - Returns an instance of Soter_Core\Vulnerabilities representing all vulnerabilities that have ever affected a given package., (*8)

->get_vulnerabilities_by_version( string $version = null ) - Returns an instance of Soter_Core\Vulnerabilities representing all vulnerabilities which affect a given package at the given version., (*9)

->get_vulnerabilities_for_current_version() - Returns an instance of Soter_Core\Vulnerabilities representing all vulnerabilities which affect a given package at the version checked against the API., (*10)

Checker

$checker = new Soter_Core\Checker(
    new Soter_Core\Api_Client(
        new Soter_Core\Cached_Http_Client(
            new Soter_Core\WP_Http_Client( 'Some user agent string' ),
            new Soter_Core\WP_Transient_Cache( 'unique-prefix', HOUR_IN_SECONDS )
        )
    ),
    new Soter_Core\WP_Package_Manager()
);

The following methods are available on a checker instance:, (*11)

->check_site( array $ignored = array() ) - Checks the current version of all installed packages (plugins, themes and core) and returns an instance of Soter_Core\Vulnerabilities. An optional array of package slugs that should not be checked can be provided., (*12)

->check_plugins( array $ignored = array() ) - Checks the current version of all installed plugins and returns an instance of Soter_Core\Vulnerabilities. An optional array of plugin slugs that should not be checked can be provided., (*13)

->check_themes( array $ignored = array() ) - Checks the current version of all installed themes and returns an instance of Soter_Core\Vulnerabilities. An optional array of theme slugs that should not be checked can be provided., (*14)

->check_wordpress( array $ignored = array() ) - Checks the current version of WordPress and returns an instance of Soter_Core\Vulnerabilities. An optional array of WordPress "slugs" that should not be checked can be provided. Keep in mind that the slug used for WordPress is the version string stripped of periods (e.g. '475' for version 4.7.5)., (*15)

You can also add any number of callbacks to be run after each package is checked., (*16)

Each callback will be called with a Soter_Core\Vulnerabilities instance and a Soter_Core\Response instance., (*17)

As a simple example, you might do something like the following to log error responses for debugging purposes:, (*18)

$checker->add_post_check_callback( function( $vulnerabilities, $response ) {
    if ( ! $response->is_error() ) {
        return;
    }

    // Ex: "Error checking plugin not-a-real-plugin with message: Non-200 status code received"
    $this->logger->debug( 'Error checking {type} {slug} with message: {message}', [
        'message' => $response->error['message'],
        'slug' => $response->get_package()->get_slug(),
        'type' => $response->get_package()->get_type(),
    ] );
} );

The Versions

24/09 2017

dev-master

9999999-dev https://github.com/ssnepenthe/soter-core

A very basic library for interacting with the WPScan Vulnerability Database API.

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3

 

The Development Requires

24/09 2017

0.2.0

0.2.0.0 https://github.com/ssnepenthe/soter-core

A very basic library for interacting with the WPScan Vulnerability Database API.

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3

 

The Development Requires

24/05 2017

0.1.0

0.1.0.0 https://github.com/ssnepenthe/soter-core

@todo

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3

 

The Development Requires