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/defs.php (2 issues)

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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 22 and the first side effect is on line 87.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/**
4
 * @file
5
 * Defines.
6
 */
7
8
namespace Itafroma\Zork;
9
10
use Itafroma\Zork\Struc\Adv;
11
use Itafroma\Zork\Struc\Object;
12
use Itafroma\Zork\Struc\Room;
13
use Itafroma\Zork\Struc\StrucInterface;
14
use Itafroma\Zork\Struc\Syntax;
15
use \InvalidArgumentException;
16
use function Itafroma\Zork\flagword;
17
use function Itafroma\Zork\make_slot;
18
use function Itafroma\Zork\setg;
19
20
// Generalized oflags tester
21
22
function trnn(Object $obj, $bit) {
23 1
    return ($bit & $obj->oflags) !== 0;
24
}
25
26
function rtrnn(Room $rm, $bit) {
27 1
    return ($bit & $rm->rbits) !== 0;
28
}
29
30
function gtrnn(Room $rm, $bit) {
31 1
    return ($bit & $rm->rglobal) !== 0;
0 ignored issues
show
The property rglobal does not seem to exist in Itafroma\Zork\Struc\Room.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
32
}
33
34
function rtrz(Room $rm, $bit) {
35 1
    $rm->rbits &= ($bit ^ -1);
36
37 1
    return $rm->rbits;
38
}
39
40
function trc(Object $obj, $bit) {
41 1
    $obj->oflags ^= $bit;
42
43 1
    return $obj->oflags;
44
}
45
46
function trz(Object $obj, $bit) {
47 1
    $obj->oflags &= ($bit ^ -1);
48
49 1
    return $obj->oflags;
50
}
51
52
function tro(Object $obj, $bit) {
53 1
    $obj->oflags |= $bit;
54
55 1
    return $obj->oflags;
56
}
57
58
function rtro(Room $rm, $bit) {
59 1
    $rm->rbits |= $bit;
60
61 1
    return $rm->rbits;
62
}
63
64
function rtrc(Room $rm, $bit) {
65 1
    $rm->rbits ^= $bit;
66
67 1
    return $rm->rbits;
68
}
69
70
function atrnn(Adv $adv, $bit) {
71 1
    return ($bit & $adv->aflags) !== 0;
72
}
73
74
function atrz(Adv $adv, $bit) {
75 1
    $adv->aflags &= ($bit ^ -1);
76
77 1
    return $adv->aflags;
78
}
79
80
function atro(Adv $adv, $bit) {
81 1
    $adv->aflags |= $bit;
82
83 1
    return $adv->aflags;
84
}
85
86
// Slots for room
87
make_slot('RVAL', 0);
88
89
// Value for entering
90
make_slot('RGLOBAL', gval('STAR_BITS'));
91
92
// Globals for room
93
flagword(...[
94
    'RSEENBIT',   // Visited?
95
    'RLIGHTBIT',  // Endogenous light source?
96
    'RLANDBIT',   // On land
97
    'RWATERBIT',  // Water room
98
    'RAIRBIT',    // Mid-air room
99
    'RSACREDBIT', // Thief not allowed
100
    'RFILLBIT',   // Can fill bottle here
101
    'RMUNGBIT',   // Room has been munged
102
    'RBUCKBIT',   // This room is a bucket
103
    'RHOUSEBIT',  // This room is part of the house
104
    'RENDGAME',   // This room is in the end game
105
    'RNWALLBIT',  // This room doesn't have walls
106
]);
107
108
// SFLAGs of a SYNTAX
109
flagword(...[
110
    'SFLIP', // T -- Flip args (for verbs like PICK)
111
    'SDRIVER', // T -- Default syntax for gwimming (sic) and orphanery
112
]);
113
114
/**
115
 * Test a bit in the SFLAGs slot of a SYNTAX
116
 *
117
 * @param Itafroma\Zork\Struc\Syntax $s   The syntax to test
118
 * @param int                       $bit The bit to test
119
 * @return boolean FALSE if bit is set, TRUE otherwise
120
 */
121
function strnn(Syntax $s, $bit) {
122 1
    return ($bit & $s->sflags) !== 0;
123
}
124
125
/**
126
 * Retrieves an object property.
127
 *
128
 * @param Itafroma\Zork\Struc\StrucInterface $o The object to access.
129
 * @param mixed                              $p The property to retrieve.
130
 * @return mixed The property value.
131
 */
132
function oget(StrucInterface $o, $p) {
133 3
    if (!($o instanceof Object || $o instanceof Room)) {
134 1
        throw new InvalidArgumentException('$o must be of type Itafroma\Zork\Struc\Object or Itafroma\Zorks\Struc\Room');
135
    }
136
137 2
    $v = ($o instanceof Object) ? $o->oprops : $o->rprops;
138
139 2
    if (empty($v)) {
140 1
        return null;
141
    }
142
143 1
    return isset($v[$p]) ? $v[$p] : null;
144
}
145
146
/**
147
 * Sets an object property.
148
 *
149
 * @param Itafroma\Zork\Struc\StrucInterface $o The object to modify.
150
 * @param mixed                              $p The property to modify.
151
 * @param mixed                              $x The value to set.
152
 */
153
function oput(StrucInterface $o, $p, $x, $add = true) {
154 4
    if (!($o instanceof Object || $o instanceof Room)) {
155 1
        throw new InvalidArgumentException('$o must be of type Itafroma\Zork\Struc\Object or Itafroma\Zork\Struc\Room');
156
    }
157
158 3
    $v = ($o instanceof Object) ? $o->oprops : $o->rprops;
159
160 3
    if ((empty($v) && $add) || isset($v[$p])) {
161 2
        if ($o instanceof Object) {
162 1
            $o->oprops[$p] = $x;
163 1
        }
164
        else {
165 1
            $o->rprops[$p] = $x;
166
        }
167 2
    }
168
169 3
    return $o;
170
}
171
172
setg('ROOMS', []);
173
174
setg('OBJECTS', []);
175
176
setg('ACTORS', []);
177