GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch v2 (b7a21f)
by Oliver
06:19 queued 03:39
created

PharMetaDataInterceptor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A baseFileDoesNotHaveMetaDataIssues() 0 14 3
A assert() 0 11 2
1
<?php
2
namespace TYPO3\PharStreamWrapper\Interceptor;
3
4
/*
5
 * This file is part of the TYPO3 project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under the terms
8
 * of the MIT License (MIT). For the full copyright and license information,
9
 * please read the LICENSE file that was distributed with this source code.
10
 *
11
 * The TYPO3 project - inspiring people to share!
12
 */
13
14
use TYPO3\PharStreamWrapper\Assertable;
15
use TYPO3\PharStreamWrapper\Exception;
16
use TYPO3\PharStreamWrapper\Manager;
17
use TYPO3\PharStreamWrapper\Phar\DeserializationException;
18
use TYPO3\PharStreamWrapper\Phar\Reader;
19
20
/**
21
 * @internal Experimental implementation of checking against serialized objects in Phar meta-data
22
 * @internal This functionality has not been 100% pentested...
23
 */
24
class PharMetaDataInterceptor implements Assertable
25
{
26
    /**
27
     * Determines whether the according Phar archive contains
28
     * (potential insecure) serialized objects.
29
     *
30
     * @param string $path
31
     * @param string $command
32
     * @return bool
33
     * @throws Exception
34
     */
35
    public function assert($path, $command)
36
    {
37
        if ($this->baseFileDoesNotHaveMetaDataIssues($path)) {
38
            return true;
39
        }
40
        throw new Exception(
41
            sprintf(
42
                'Problematic meta-data in "%s"',
43
                $path
44
            ),
45
            1539632368
46
        );
47
    }
48
49
    /**
50
     * @param string $path
51
     * @return bool
52
     */
53
    private function baseFileDoesNotHaveMetaDataIssues($path)
54
    {
55
        $invocation = Manager::instance()->resolve($path);
56
        if ($invocation === null) {
57
            return false;
58
        }
59
60
        try {
61
            $reader = new Reader($invocation->getBaseName());
62
            $reader->resolveContainer()->getManifest()->deserializeMetaData();
63
        } catch (DeserializationException $exception) {
64
            return false;
65
        }
66
        return true;
67
    }
68
}
69