Sha256: acc875299585df61aca205852db947ab394cb94a5a94754562d5ad90c9a10c3b

Contents?: true

Size: 1.95 KB

Versions: 75

Compression:

Stored size: 1.95 KB

Contents

<?php

declare(strict_types=1);

namespace Dependabot\PHP;

require __DIR__ . '/../vendor/autoload.php';

// Get details of the process to run from STDIN. It will have a `function`
// and an `args` method, as passed in by UpdateCheckers::Php
$request = json_decode(file_get_contents('php://stdin'), true);

// Increase the default memory limit. Calling `composer update` is otherwise
// vulnerable to scenarios where there are unconstrained versions, resulting in
// it checking huge numbers of dependency combinations and causing OOM issues.
$memory_limit = getenv('COMPOSER_MEMORY_LIMIT') ?: '1900M';
ini_set('memory_limit', $memory_limit);

date_default_timezone_set('Europe/London');

// This storage is freed on error (case of allowed memory exhausted)
$memory = str_repeat('*', 1024 * 1024);

register_shutdown_function(function (): void {
    $memory = null;
    $error = error_get_last();
    if (null !== $error) {
        fwrite(STDOUT, json_encode(['error' => $error['message']]));
    }
});

try {
    switch ($request['function']) {
        case 'update':
            $updatedFiles = Updater::update($request['args']);
            fwrite(STDOUT, json_encode(['result' => $updatedFiles]));
            error_clear_last();
            break;
        case 'get_latest_resolvable_version':
            $latestVersion = UpdateChecker::getLatestResolvableVersion($request['args']);
            fwrite(STDOUT, json_encode(['result' => $latestVersion]));
            error_clear_last();
            break;
        case 'get_content_hash':
            $content_hash = Hasher::getContentHash($request['args']);
            fwrite(STDOUT, json_encode(['result' => $content_hash]));
            error_clear_last();
            break;
        default:
            fwrite(STDOUT, '{"error": "Invalid function ' . $request['function'] . '" }');
            exit(1);
    }
} catch (\Exception $e) {
    fwrite(STDOUT, json_encode(['error' => $e->getMessage()]));
    error_clear_last();
    exit(1);
}

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
dependabot-core-0.87.10 helpers/php/bin/run.php
dependabot-core-0.87.9 helpers/php/bin/run.php
dependabot-core-0.87.8 helpers/php/bin/run.php
dependabot-core-0.87.7 helpers/php/bin/run.php
dependabot-core-0.87.6 helpers/php/bin/run.php
dependabot-core-0.87.5 helpers/php/bin/run.php
dependabot-core-0.87.4 helpers/php/bin/run.php
dependabot-core-0.87.3 helpers/php/bin/run.php
dependabot-core-0.87.2 helpers/php/bin/run.php
dependabot-core-0.87.1 helpers/php/bin/run.php
dependabot-core-0.87.0 helpers/php/bin/run.php
dependabot-core-0.86.25 helpers/php/bin/run.php
dependabot-core-0.86.24 helpers/php/bin/run.php
dependabot-core-0.86.23 helpers/php/bin/run.php
dependabot-core-0.86.22 helpers/php/bin/run.php
dependabot-core-0.86.21 helpers/php/bin/run.php
dependabot-core-0.86.20 helpers/php/bin/run.php
dependabot-core-0.86.19 helpers/php/bin/run.php
dependabot-core-0.86.18 helpers/php/bin/run.php
dependabot-core-0.86.17 helpers/php/bin/run.php