Issues (85)

Security Analysis    no request data  

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

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/XML/saml/AuthzDecisionStatement.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML2\Assert\Assert as SAMLAssert;
10
use SimpleSAML\SAML2\Constants as C;
11
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
12
use SimpleSAML\SAML2\XML\Decision;
13
use SimpleSAML\XML\Exception\InvalidDOMElementException;
14
use SimpleSAML\XML\Exception\MissingElementException;
15
use SimpleSAML\XML\Exception\SchemaViolationException;
16
use SimpleSAML\XML\Exception\TooManyElementsException;
17
use SimpleSAML\XML\SchemaValidatableElementInterface;
18
use SimpleSAML\XML\SchemaValidatableElementTrait;
19
use ValueError;
20
21
use function array_pop;
22
use function sprintf;
23
24
/**
25
 * Class representing a SAML2 AuthzDecisionStatement
26
 *
27
 * @package simplesamlphp/saml2
28
 */
29
final class AuthzDecisionStatement extends AbstractStatementType implements SchemaValidatableElementInterface
30
{
31
    use SchemaValidatableElementTrait;
32
33
    /**
34
     * Initialize an AuthzDecisionStatement.
35
     *
36
     * @param string $resource
37
     * @param \SimpleSAML\SAML2\XML\Decision $decision
38
     * @param \SimpleSAML\SAML2\XML\saml\Action[] $action
39
     * @param \SimpleSAML\SAML2\XML\saml\Evidence|null $evidence
40
     */
41
    public function __construct(
42
        protected string $resource,
43
        protected Decision $decision,
44
        protected array $action,
45
        protected ?Evidence $evidence = null,
46
    ) {
47
        SAMLAssert::validURI($resource);
48
        Assert::maxCount($action, C::UNBOUNDED_LIMIT);
49
        Assert::allIsInstanceOf($action, Action::class, SchemaViolationException::class);
50
    }
51
52
53
    /**
54
     * Collect the value of the resource-property
55
     *
56
     * @return string
57
     */
58
    public function getResource(): string
59
    {
60
        return $this->resource;
61
    }
62
63
64
    /**
65
     * Collect the value of the decision-property
66
     *
67
     * @return \SimpleSAML\SAML2\XML\Decision
68
     */
69
    public function getDecision(): Decision
70
    {
71
        return $this->decision;
72
    }
73
74
75
    /**
76
     * Collect the value of the action-property
77
     *
78
     * @return array
79
     */
80
    public function getAction(): array
81
    {
82
        return $this->action;
83
    }
84
85
86
    /**
87
     * Collect the value of the evidence-property
88
     *
89
     * @return \SimpleSAML\SAML2\XML\saml\Evidence|null
90
     */
91
    public function getEvidence(): ?Evidence
92
    {
93
        return $this->evidence;
94
    }
95
96
97
    /**
98
     * Convert XML into an AuthzDecisionStatement
99
     *
100
     * @param \DOMElement $xml The XML element we should load
101
     *
102
     * @return static
103
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
104
     *   if the qualified name of the supplied element is wrong
105
     * @throws \SimpleSAML\XML\Exception\MissingElementException
106
     *   if one of the mandatory child-elements is missing
107
     * @throws \Exception if the authentication instant is not a valid timestamp.
108
     */
109
    public static function fromXML(DOMElement $xml): static
110
    {
111
        Assert::same($xml->localName, 'AuthzDecisionStatement', InvalidDOMElementException::class);
112
        Assert::same($xml->namespaceURI, AuthzDecisionStatement::NS, InvalidDOMElementException::class);
113
114
        $action = Action::getChildrenOfClass($xml);
115
        Assert::minCount(
116
            $action,
117
            1,
118
            'Missing <saml:Action> in <saml:AuthzDecisionStatement>',
119
            MissingElementException::class,
120
        );
121
122
        $evidence = Evidence::getChildrenOfClass($xml);
123
        Assert::maxCount(
124
            $evidence,
125
            1,
126
            'Too many <saml:Evidence> in <saml:AuthzDecisionStatement>',
127
            TooManyElementsException::class,
128
        );
129
130
        $decision = self::getAttribute($xml, 'Decision');
131
        try {
132
            $decision = Decision::from($decision);
133
        } catch (ValueError) {
134
            throw new ProtocolViolationException(sprintf('Unknown value \'%s\' for Decision attribute.', $decision));
0 ignored issues
show
$decision of type SimpleSAML\SAML2\XML\Decision is incompatible with the type double|integer|string expected by parameter $values of sprintf(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

134
            throw new ProtocolViolationException(sprintf('Unknown value \'%s\' for Decision attribute.', /** @scrutinizer ignore-type */ $decision));
Loading history...
135
        }
136
137
        return new static(
138
            self::getAttribute($xml, 'Resource'),
139
            $decision,
140
            $action,
141
            array_pop($evidence),
142
        );
143
    }
144
145
146
    /**
147
     * Convert this AuthzDecisionStatement to XML.
148
     *
149
     * @param \DOMElement|null $parent The element we should append this AuthzDecisionStatement to.
150
     * @return \DOMElement
151
     */
152
    public function toXML(?DOMElement $parent = null): DOMElement
153
    {
154
        $e = $this->instantiateParentElement($parent);
155
156
        $e->setAttribute('Resource', $this->getResource());
157
        $e->setAttribute('Decision', $this->getDecision()->value);
158
159
        foreach ($this->getAction() as $action) {
160
            $action->toXML($e);
161
        }
162
163
        if ($this->getEvidence() !== null && !$this->getEvidence()->isEmptyElement()) {
164
            $this->getEvidence()->toXML($e);
165
        }
166
167
        return $e;
168
    }
169
}
170