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.

Issues (8)

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/CFDI.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 cfdi-xml project.
5
 *
6
 * (c) Kinedu
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 Kinedu\CfdiXML;
13
14
use DOMDocument;
15
use XSLTProcessor;
16
use Kinedu\CfdiXML\Common\Node;
17
use Kinedu\CfdiXML\Node\Comprobante;
18
19
class CFDI
20
{
21
    /** @var string */
22
    const XSL_ENDPOINT = 'http://www.sat.gob.mx/sitio_internet/cfd/3/cadenaoriginal_3_3/cadenaoriginal_3_3.xslt';
23
24
    /** @var string */
25
    protected $version = '3.3';
26
27
    /** @var string */
28
    protected $key;
29
30
    /** @var string */
31
    protected $cer;
32
33
    /** @var \Kinedu\CfdiXML\Node\Comprobante */
34
    protected $comprobante;
35
36
    /**
37
     * Create a new cfdi instance.
38
     *
39
     * @param array $data
40
     * @param string $key
41
     * @param string $cer
42
     */
43
    public function __construct(array $data, string $key, string $cer)
44
    {
45
        $this->comprobante = new Comprobante($data, $this->version);
46
47
        $this->key = $key;
48
        $this->cer = $cer;
49
    }
50
51
    /**
52
     * Add new node to comprobante instance.
53
     *
54
     * @param \Kinedu\CfdiXML\Common\Node $node
55
     *
56
     * @return void
57
     */
58
    public function add(Node $node)
59
    {
60
        $this->comprobante->add($node);
61
    }
62
63
    /**
64
     * Gets the original string.
65
     *
66
     * @return string
67
     */
68
    public function getCadenaOriginal(): string
69
    {
70
        $xsl = new DOMDocument();
71
        $xsl->load($this->getXSL());
72
73
        $xslt = new XSLTProcessor();
74
        @$xslt->importStyleSheet($xsl);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
75
76
        $xml = new DOMDocument();
77
        $xml->loadXML($this->comprobante->getDocument()->saveXML());
78
79
        return (string) $xslt->transformToXml($xml);
80
    }
81
82
    /**
83
     * Get sello.
84
     *
85
     * @return string
86
     */
87
    public function getSello(): string
88
    {
89
        $pkey = openssl_get_privatekey($this->key);
90
        openssl_sign(@$this->getCadenaOriginal(), $signature, $pkey, OPENSSL_ALGO_SHA256);
91
        openssl_free_key($pkey);
92
        return base64_encode($signature);
93
    }
94
95
    /**
96
     * Put sello.
97
     *
98
     * @return void
99
     */
100
    protected function putSello()
101
    {
102
        $this->comprobante->setAttr(
103
            $this->comprobante->getElement(),
104
            [
105
                'Sello' => $this->getSello(),
106
            ]
107
        );
108
    }
109
110
    /**
111
     * Get certificado.
112
     *
113
     * @return string
114
     */
115
    public function getCertificado(): string
116
    {
117
        $cer = preg_replace('/(-+[^-]+-+)/', '', $this->cer);
118
        $cer = preg_replace('/\s+/', '', $cer);
119
        return $cer;
120
    }
121
122
    /**
123
     * Put certificado.
124
     *
125
     * @return void
126
     */
127
    protected function putCertificado()
128
    {
129
        $this->comprobante->setAttr(
130
            $this->comprobante->getElement(),
131
            [
132
                'Certificado' => $this->getCertificado(),
133
            ]
134
        );
135
    }
136
137
    /**
138
     * Returns the xml with the stamp and certificate attributes.
139
     *
140
     * @return DOMDocument
141
     */
142
    protected function xml(): DOMDocument
143
    {
144
        $this->putSello();
145
        $this->putCertificado();
146
        return $this->comprobante->getDocument();
147
    }
148
149
    /**
150
     * Get the xml.
151
     *
152
     * @return string
153
     */
154
    public function getXML(): string
155
    {
156
        return $this->xml()->saveXML();
157
    }
158
159
    /**
160
     * @param string $filename
161
     */
162
    public function save(string $filename)
163
    {
164
        return $this->xml()->save($filename);
165
    }
166
167
    /**
168
     * @return string
169
     */
170
    public function getXSL()
171
    {
172
        return static::XSL_ENDPOINT;
173
    }
174
}
175