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
Push — master ( 6c4153...d181b6 )
by François
03:10
created

TlsAuth::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 *  Copyright (C) 2016 SURFnet.
4
 *
5
 *  This program is free software: you can redistribute it and/or modify
6
 *  it under the terms of the GNU Affero General Public License as
7
 *  published by the Free Software Foundation, either version 3 of the
8
 *  License, or (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU Affero General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU Affero General Public License
16
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace SURFnet\VPN\Server;
20
21
use SURFnet\VPN\Common\FileIO;
22
use RuntimeException;
23
24
class TlsAuth
25
{
26
    /** @var string */
27
    private $dataDir;
28
29
    public function __construct($dataDir)
30
    {
31
        $this->dataDir = $dataDir;
32
    }
33
34
    public function init()
35
    {
36
        $taFile = sprintf('%s/ta.key', $this->dataDir);
37
38
        // generate the TA file if it does not exist
39
        if (!@file_exists($taFile)) {
40
            $this->execOpenVpn(['--genkey', '--secret', $taFile]);
41
        }
42
    }
43
44
    public function get()
45
    {
46
        $taFile = sprintf('%s/ta.key', $this->dataDir);
47
48
        return FileIO::readFile($taFile);
49
    }
50
51 View Code Duplication
    private function execOpenVpn(array $argv)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $command = sprintf(
54
            '/usr/sbin/openvpn %s >/dev/null 2>/dev/null',
55
            implode(' ', $argv)
56
        );
57
58
        exec(
59
            $command,
60
            $commandOutput,
61
            $returnValue
62
        );
63
64
        if (0 !== $returnValue) {
65
            throw new RuntimeException(
66
                sprintf('command "%s" did not complete successfully: "%s"', $command, $commandOutput)
67
            );
68
        }
69
    }
70
}
71