Skip to content

Commit c8c6b17

Browse files
committed
AC-3483:: SVC false-positive: modifying system.xml file from another module
1 parent 0b32238 commit c8c6b17

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/Analyzer/SystemXml/Analyzer.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,34 @@ private function inspectObject($object)
161161
*/
162162
private function isDuplicateNode($node, $existingNode)
163163
{
164-
// Access the 'id' properties using possible getter methods
165-
//Testing file
164+
// Get node data excluding 'id' and 'parent' for comparison
165+
$nodeData = $this->getNodeData($node);
166+
$existingNodeData = $this->getNodeData($existingNode);
166167

167-
$nodeId = $this->getPrivateProperty($node, 'id');
168-
$existingNodeId = $this->getPrivateProperty($existingNode, 'id');
168+
// Compare the remaining parts of the nodes
169+
return $nodeData == $existingNodeData;
170+
}
171+
172+
private function getNodeData($node)
173+
{
174+
$data = [];
169175

170-
// Access 'parent' properties if needed, depending on your logic
171-
$nodeParent = $this->getPrivateProperty($node, 'parent');
172-
$existingNodeParent = $this->getPrivateProperty($existingNode, 'parent');
176+
// Use reflection to get accessible properties
177+
$reflection = new \ReflectionClass($node);
178+
foreach ($reflection->getMethods() as $method) {
179+
// Skip 'getId' and 'getParent' methods for comparison
180+
if ($method->getName() === 'getId' || $method->getName() === 'getParent') {
181+
continue;
182+
}
183+
184+
// Dynamically call the getter methods
185+
if (strpos($method->getName(), 'get') === 0) {
186+
$propertyName = lcfirst(str_replace('get', '', $method->getName()));
187+
$data[$propertyName] = $method->invoke($node);
188+
}
189+
}
173190

174-
// Compare the nodes after ignoring 'id'
175-
return $nodeParent == $existingNodeParent;
191+
return $data;
176192
}
177193

178194
/**

0 commit comments

Comments
 (0)