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

baseFileDoesNotHaveMetaDataIssues()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 4
nop 1
dl 0
loc 14
rs 9.9666
c 0
b 0
f 0
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