Skip to content

Update TP: PHP - 83_array_variable_key #39

@felix-20

Description

@felix-20

Testability pattern

83_array_variable_key

Problem statement

The php code for instance 2 and instance 3 is the same.

 <?php
$a = "ttt";
$b = $_GET["p1"];
$c = $_GET["p2"];
$x = array(1,2,$a=>$b);
echo $x[$c];

Proposed changes

One possiblity for changing the code of instance 3 I came up with, was this:

<?php
$b = $_GET["p1"];
$c = $_GET["p2"]; // source
$x = array(1,2,$b=>$c);
echo $x[$b]; // sink

The key and the value in x are now user controlled.
This is of course only one possibility.

Other

Do you have any other ideas? Or is it more useful to delete that instance?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ACK_WAITINGissue to be reviewed and confirmedUPDATE_TPissue is about updating a testability pattern

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions