Issues (7)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/FfprobeReader.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the Meta Reader package.
5
 *
6
 * (c) Stephan Wentz <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Temp\MetaReader;
13
14
use FFMpeg\FFProbe;
15
use FFMpeg\FFProbe\DataMapping\Stream;
16
use Temp\MetaReader\Value\MetaValue;
17
use Temp\MetaReader\Value\ValueBag;
18
19
/**
20
 * Ffprobe reader.
21
 *
22
 * @author Stephan Wentz <[email protected]>
23
 */
24
class FfprobeReader implements ReaderInterface
25
{
26
    /**
27
     * @var FFProbe
28
     */
29
    private $ffprobe;
30
31
    /**
32
     * @param FFProbe $ffprobe
33
     */
34
    public function __construct(FFProbe $ffprobe)
35
    {
36
        $this->ffprobe = $ffprobe;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function available()
43
    {
44
        return true;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function supports($filename)
51
    {
52
        try {
53
            $streams = $this->ffprobe->streams($filename);
54
        } catch (\Exception $e) {
55
            return false;
56
        }
57
58
        foreach ($streams as $stream) {
59
            if (!$stream->has('codec_type') || !in_array($stream->get('codec_type'), ['audio', 'video'])) {
60
                return false;
61
            }
62
        }
63
64
        return true;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function read($filename)
71
    {
72
        $meta = new ValueBag();
73
74
        try {
75
            $format = $this->ffprobe->format($filename);
76
77
            if ($format->has('format_name')) {
78
                $meta->set('media.format_name', new MetaValue($format->get('format_name')));
79
            }
80
            if ($format->has('format_long_name')) {
81
                $meta->set('media.format_long_name', new MetaValue($format->get('format_long_name')));
82
            }
83
            if ($format->has('duration')) {
84
                $meta->set('media.duration', new MetaValue($format->get('duration')));
85
            }
86
            if ($format->has('bit_rate')) {
87
                $meta->set('media.bit_rate', new MetaValue($format->get('bit_rate')));
88
            }
89
            if ($format->has('width')) {
90
                $meta->set('media.width', new MetaValue($format->get('width')));
91
            }
92
            if ($format->has('height')) {
93
                $meta->set('media.height', new MetaValue($format->get('height')));
94
            }
95
            if ($format->has('nb_streams')) {
96
                $meta->set('media.number_of_streams', new MetaValue($format->get('nb_streams')));
97
            }
98
99
            $streams = $this->ffprobe->streams($filename);
100
101
            foreach ($streams as $stream) {
102
                $index = $stream->get('index');
103
                $prefix = 'stream_'.$index;
104
105
                $type = 'media';
106
                if ($stream->isVideo()) {
107
                    $type = 'video';
108
                } elseif ($stream->isAudio()) {
109
                    $type = 'audio';
110
                }
111
112
                if ($stream->has('codec_type')) {
113
                    $meta->set("$type.$prefix.codec_type", new MetaValue($stream->get('codec_type')));
114
                }
115
                if ($stream->has('codec_name')) {
116
                    $meta->set("$type.$prefix.codec_name", new MetaValue($stream->get('codec_name')));
117
                }
118
                if ($stream->has('codec_long_name')) {
119
                    $meta->set("$type.$prefix.codec_long_name", new MetaValue($stream->get('codec_long_name')));
120
                }
121
                if ($stream->has('codec_time_base')) {
122
                    $meta->set("$type.$prefix.codec_time_base", new MetaValue($stream->get('codec_time_base')));
123
                }
124
                if ($stream->has('codec_tag_string')) {
125
                    $meta->set("$type.$prefix.codec_tag", new MetaValue($stream->get('codec_tag_string')));
126
                }
127
                if ($stream->has('bit_rate')) {
128
                    $meta->set("$type.$prefix.bit_rate", new MetaValue($stream->get('bit_rate')));
129
                }
130
                if ($stream->has('display_aspect_ration')) {
131
                    $meta->set("$type.$prefix.aspect_ratio", new MetaValue($stream->get('display_aspect_ratio')));
132
                }
133
                if ($stream->has('avg_frame_rate')) {
134
                    $meta->set("$type.$prefix.frame_rate", new MetaValue($stream->get('avg_frame_rate')));
135
                }
136
                if ($stream->has('bits_per_sample')) {
137
                    $meta->set("$type.$prefix.bits_per_sample", new MetaValue($stream->get('bits_per_sample')));
138
                }
139
                if ($stream->has('channels')) {
140
                    $meta->set("$type.$prefix.channels", new MetaValue($stream->get('channels')));
141
                }
142
            }
143
        } catch (\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by Stephan Wentz
Consider adding a comment why this CATCH block is empty.
Loading history...
144
        }
145
146
        return $meta;
147
    }
148
}
149