Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions deploy/conf/nw.local.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ server {
#add_header X-Frame-Options SAMEORIGIN;
add_header Content-Security-Policy "default-src * blob: filesystem: about: ws: wss: 'unsafe-eval' 'unsafe-inline'; script-src 'self' https://localhost:8765/ https://www.gstatic.com https://www.google.com https://www.recaptcha.net https://ajax.googleapis.com https://api.github.com https://ws-na.amazon-adsystem.com http://pagead2.googlesyndication.com https://tpc.googlesyndication.com https://www.googleadservices.com https://kit.fontawesome.com https://js.sentry-cdn.com/ https://browser.sentry-cdn.com/ 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * 'self' https://localhost:* https://localhost:8765 http://www.ninjawars.net http://ninjawars.net https://www.ninjawars.net; style-src 'self' https://kit.fontawesome.com https://fonts.gstatic.com https://fonts.googleapis.com data: blob: 'unsafe-inline'; font-src 'self' https://kit.fontawesome.com https://ka-f.fontawesome.com https://fonts.gstatic.com https://fonts.googleapis.com data: blob: 'unsafe-inline'; worker-src 'self' https://localhost:8765/ data: blob: 'unsafe-inline';";
fastcgi_param PHP_VALUE "session.cookie_domain= \n date.timezone=America/New_York \n default_charset=UTF-8 \n session.gc_maxlifetime=144000 \n display_errors=On \n";
# Check session via: php-fpm8.2 -i | grep session.gc
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
# Check session via: php-fpm8.3 -i | grep session.gc
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root/front-controller.php;
include fastcgi_params;
}
Expand All @@ -108,7 +108,7 @@ server {
add_header Content-Security-Policy "default-src * blob: filesystem: about: ws: wss: 'unsafe-eval' 'unsafe-inline'; script-src 'self' https://localhost:8765/ https://www.gstatic.com https://www.google.com https://www.recaptcha.net https://ajax.googleapis.com https://api.github.com https://ws-na.amazon-adsystem.com http://pagead2.googlesyndication.com https://tpc.googlesyndication.com https://www.googleadservices.com https://kit.fontawesome.com https://js.sentry-cdn.com/ https://browser.sentry-cdn.com/ 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * 'self' https://localhost:* https://localhost:8765 http://www.ninjawars.net http://ninjawars.net https://www.ninjawars.net; style-src 'self' https://kit.fontawesome.com https://fonts.gstatic.com https://fonts.googleapis.com data: blob: 'unsafe-inline'; font-src 'self' https://kit.fontawesome.com https://ka-f.fontawesome.com https://fonts.gstatic.com https://fonts.googleapis.com data: blob: 'unsafe-inline'; worker-src 'self' https://localhost:8765/ data: blob: 'unsafe-inline';";
# Check session via: php-fpm8.2 -i | grep session.gc
fastcgi_param PHP_VALUE "session.cookie_domain= \n date.timezone=America/New_York \n default_charset=UTF-8 \n session.gc_maxlifetime=144000 \n display_errors=On \n";
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root/front-controller.php;
include fastcgi_params;
}
Expand Down
5 changes: 4 additions & 1 deletion deploy/lib/control/NpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,14 @@ public function attack(Container $p_dependencies)
'guard' => 'attackGuard',
];

$npco = $victim ? (new NpcFactory())->create($victim) : null;

$method = null;

if ($player && $player->turns > 0 && !empty($victim)) {
// Strip stealth when attacking special NPCs
if ($player->hasStatus(STEALTH) && in_array(strtolower($victim), self::$STEALTH_REMOVING_NPCS)) {
if ($player->hasStatus(STEALTH) &&
(in_array(strtolower($victim), self::$STEALTH_REMOVING_NPCS) || ($npco && $npco->hasTrait('stealth_removing')))) {
Comment on lines +328 to +329
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential undefined constant usage in stealth status check

The code uses STEALTH as a constant in the condition $player->hasStatus(STEALTH), but there is no visible declaration of this constant in the provided code. If this constant is undefined, it will be interpreted as a string literal 'STEALTH', which might cause the hasStatus check to fail silently, allowing players to maintain stealth status incorrectly when attacking NPCs that should remove it.

Impact

This could lead to gameplay imbalance where players can attack certain NPCs while maintaining stealth when they shouldn't be allowed to. This breaks game mechanics and could potentially be exploited by players.

References

Recommendation

Either define the STEALTH constant if it's missing, or use a string literal if that's the intended behavior. If the constant is defined elsewhere in the codebase, consider importing it or using a class constant instead for better maintainability.

if ($player->hasStatus(Player::STEALTH) && 
    (in_array(strtolower($victim), self::$STEALTH_REMOVING_NPCS) || ($npco && $npco->hasTrait('stealth_removing')))) {
📝 Suggested fix

‼️ IMPORTANT
Please review this suggestion carefully before applying:

  • Verify it matches your codebase standards
  • Ensure it doesn't introduce new issues
  • Test thoroughly after applying
Suggested change
if ($player->hasStatus(STEALTH) &&
(in_array(strtolower($victim), self::$STEALTH_REMOVING_NPCS) || ($npco && $npco->hasTrait('stealth_removing')))) {
if ($player->hasStatus(Player::STEALTH) &&
(in_array(strtolower($victim), self::$STEALTH_REMOVING_NPCS) || ($npco && $npco->hasTrait('stealth_removing')))) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I think this is the old “defined globally” constant problem.

$player->subtractStatus(STEALTH);
}

Expand Down
26 changes: 23 additions & 3 deletions deploy/npc-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@
'stamina' => 10,
'speed' => 30,
'ki' => 20,
'short' => 'a horned demon',
'short' => 'is a horned demon',
'img' => 'attacking_wandering_oni.jpg',
'race' => 'oni',
'inventory' => [
Expand All @@ -570,21 +570,41 @@
'stealthy',
'slowing',
'energy_vampire',
'horned'
'horned',
'stealth_removing'
],
],
'toad' => [
'name' => 'Toad',
'strength' => 1,
'stamina' => 3,
'speed' => 15,
'short' => 'a slimy toad',
'short' => 'is a slimy large beast',
'img' => 'matsuoto-hoji-toad.jpg',
'race' => 'animal',
'inventory' => [],
'traits' => [
'amphibious',
],
],
'samurai22' => [
'name' => 'Samurai',
'short' => 'is an armored warrior',
'race' => 'human',
'strength' => 70,
'stamina' => 30,
'speed' => 12,
'ki' => 1,
'damage' => 20,
'gold' => 100,
'img' => 'samurai.png',
'inventory' => [
'ginsengroot' => '.11',
],
'traits' => [
'partial_match_strength',
'stealth_removing'
],
],
]
);
15 changes: 0 additions & 15 deletions deploy/sql/fixtures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,6 @@ COPY public.levelling_log (id, killpoints, levelling, killsdate, _player_id) FRO
\.


--
-- Data for Name: login_attempts; Type: TABLE DATA; Schema: public; Owner: developers
--

COPY public.login_attempts (attempt_id, username, ua_string, ip, successful, additional_info, attempt_date) FROM stdin;
\.


--
-- Data for Name: messages; Type: TABLE DATA; Schema: public; Owner: developers
--
Expand Down Expand Up @@ -561,13 +553,6 @@ SELECT pg_catalog.setval('public.item_item_id_seq', 40, true);
SELECT pg_catalog.setval('public.levelling_log_id_seq', 4471970, true);


--
-- Name: login_attempts_attempt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: developers
--

SELECT pg_catalog.setval('public.login_attempts_attempt_id_seq', 1, false);


--
-- Name: messages_message_id_seq; Type: SEQUENCE SET; Schema: public; Owner: developers
--
Expand Down
6 changes: 3 additions & 3 deletions deploy/templates/npc.abstract.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
The {$race|escape} seems stronger than you!
{/if}

<p>
<p class='npc-combat-area'>
{if $attack_damage > 0}
{if $npco->hasTrait('horned')}
<p>The {$display_name|escape}'s horns gore you.</p>
Expand All @@ -40,7 +40,7 @@
{/if}
</p>

<p>
<p class='pc-npc-combat-area'>
You
{if $ninja_damage > 0}
<span class='damage {$ninja_damage_class}'>{$ninja_damage_class} the {$display_name|escape}</span>
Expand All @@ -67,7 +67,7 @@
<p class='ninja-notice target-escape'>The {$display_name|escape} flees from you and escapes!</p>
{else}
{if $much_stronger}
<p class='you-escape' title='They had {$enemy_strength|escape} strength'>You are unable to end the {$display_name|escape}, so you escape instead!</p>
<p class='you-escape' title='They had {$enemy_strength|escape} strength'>You are unable to defeat the {$display_name|escape}, so you escape instead!</p>
{else}
<p title='They had {$npc_health} health'>You fight to a standstill and neither wins.</p>
{/if}
Expand Down
Loading