Page MenuHomePhabricator

Implicit conversion from float 1.2 to int loses precision
Closed, ResolvedPublic

Description

https://gerrit.wikimedia.org/r/c/css-sanitizer/+/786398/
https://integration.wikimedia.org/ci/job/composer-package-php81-docker/36/console

/src/vendor/mediawiki/phan-taint-check-plugin/src/Taintedness.php:472 [8192] Implicit conversion from float 1.2 to int loses precision
14:27:23 (Phan 5.2.0 crashed when parsing/analyzing 'tests/Objects/CSSObjectListTest.php')
14:27:23 More details:
14:27:23 #2: SecurityCheckPlugin\Taintedness->getTaintednessForOffsetOrWhole() called at [/src/vendor/mediawiki/phan-taint-check-plugin/src/TaintednessVisitor.php:703] Args: [1.2]
14:27:23 #3: SecurityCheckPlugin\TaintednessVisitor->visitDim() called at [/src/vendor/phan/phan/src/Phan/Plugin/ConfigPluginSet.php:1297] Args: [ast\Node({"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}})]
14:27:23 #4: SecurityCheckPlugin\MWVisitor::Phan\Plugin\{closure}() called at [/src/vendor/phan/phan/src/Phan/Plugin/ConfigPluginSet.php:323] Args: [Phan\CodeBase({}), Phan\Language\Context(tests/Objects/CSSObjectListTest.php:290), ast\Node({"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}), [ast\Node({"kind":132,"flags":0,"lineno":1,"children":[{"kind":542,"flags":0,"lineno":7,"children":{"name":"Wikimedia\\CSS\\Objects","stmts":null}},{"kind":143,"flags":1,"lineno":9,"children":[{"kind":543,"flags":0,"lineno":9,"children":{"name":"InvalidArgumentException","alias":null}}]},{"kind":143,"flags":1,"lineno":10,"children":[{"kind":543,"flags":0,"lineno":10,"children":{"name":"OutOfBoundsException","alias":null}}]},{"kind":143,"flags":1,"lineno":11,"children":[{"kind":543,"flags":0,"lineno":11,"children":{"name":"PHPUnit\\Framework\\TestCase","alias":null}}]},{"kind":143,"flags":1,"lineno":12,"children":[{"kind":5...
14:27:23 #5: Phan\Plugin\ConfigPluginSet->postAnalyzeNode() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:3216] Args: [Phan\CodeBase({}), Phan\Language\Context(tests/Objects/CSSObjectListTest.php:290), ast\Node({"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}), [ast\Node({"kind":132,"flags":0,"lineno":1,"children":[{"kind":542,"flags":0,"lineno":7,"children":{"name":"Wikimedia\\CSS\\Objects","stmts":null}},{"kind":143,"flags":1,"lineno":9,"children":[{"kind":543,"flags":0,"lineno":9,"children":{"name":"InvalidArgumentException","alias":null}}]},{"kind":143,"flags":1,"lineno":10,"children":[{"kind":543,"flags":0,"lineno":10,"children":{"name":"OutOfBoundsException","alias":null}}]},{"kind":143,"flags":1,"lineno":11,"children":[{"kind":543,"flags":0,"lineno":11,"children":{"name":"PHPUnit\\Framework\\TestCase","alias":null}}]},{"kind":143,"flags":1,"lineno":12,"children":[{"kind":543,"flags...
14:27:23 #6: Phan\BlockAnalysisVisitor->postOrderAnalyze() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:600] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:290), ast\Node({"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}})]
14:27:23 #7: Phan\BlockAnalysisVisitor->visit() called at [/src/vendor/phan/phan/src/Phan/AST/Visitor/KindVisitorImplementation.php:191] Args: [ast\Node({"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}})]
14:27:23 #8: Phan\AST\Visitor\KindVisitorImplementation->visitDim() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:628] Args: [ast\Node({"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}})]
14:27:23 #9: Phan\BlockAnalysisVisitor->analyzeAndGetUpdatedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:597] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:290), ast\Node({"kind":518,"flags":0,"lineno":290,"children":{"var":{"kind":256,"flags":1879048192,"lineno":290,"children":{"name":"dummy"},"taint":{}},"expr":{"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}}}), ast\Node({"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}})]
14:27:23 #10: Phan\BlockAnalysisVisitor->visit() called at [/src/vendor/phan/phan/src/Phan/AST/Visitor/KindVisitorImplementation.php:70] Args: [ast\Node({"kind":518,"flags":0,"lineno":290,"children":{"var":{"kind":256,"flags":1879048192,"lineno":290,"children":{"name":"dummy"},"taint":{}},"expr":{"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}}})]
14:27:23 #11: Phan\AST\Visitor\KindVisitorImplementation->visitAssign() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:628] Args: [ast\Node({"kind":518,"flags":0,"lineno":290,"children":{"var":{"kind":256,"flags":1879048192,"lineno":290,"children":{"name":"dummy"},"taint":{}},"expr":{"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}}})]
14:27:23 #12: Phan\BlockAnalysisVisitor->analyzeAndGetUpdatedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:240] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:290), ast\Node({"kind":132,"flags":0,"lineno":289,"children":[{"kind":518,"flags":0,"lineno":290,"children":{"var":{"kind":256,"flags":1879048192,"lineno":290,"children":{"name":"dummy"},"taint":{}},"expr":{"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}}},{"kind":768,"flags":0,"lineno":291,"children":{"expr":{"kind":256,"flags":0,"lineno":291,"children":{"name":"this"}},"method":"fail","args":{"kind":128,"flags":0,"lineno":291,"children":["Expected exception not thrown"]}}}]}), ast\Node({"kind":518,"flags":0,"lineno":290,"children":{"var":{"kind":256,"flags":1879048192,"lineno":290,"children":{"name":"dummy"},"taint":{}},"expr":{"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"l...
14:27:23 #13: Phan\BlockAnalysisVisitor->visitStmtList() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:628] Args: [ast\Node({"kind":132,"flags":0,"lineno":289,"children":[{"kind":518,"flags":0,"lineno":290,"children":{"var":{"kind":256,"flags":1879048192,"lineno":290,"children":{"name":"dummy"},"taint":{}},"expr":{"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}}},{"kind":768,"flags":0,"lineno":291,"children":{"expr":{"kind":256,"flags":0,"lineno":291,"children":{"name":"this"}},"method":"fail","args":{"kind":128,"flags":0,"lineno":291,"children":["Expected exception not thrown"]}}}]})]
14:27:23 #14: Phan\BlockAnalysisVisitor->analyzeAndGetUpdatedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:2498] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:290), ast\Node({"kind":772,"flags":0,"lineno":289,"children":{"try":{"kind":132,"flags":0,"lineno":289,"children":[{"kind":518,"flags":0,"lineno":290,"children":{"var":{"kind":256,"flags":1879048192,"lineno":290,"children":{"name":"dummy"},"taint":{}},"expr":{"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}}},{"kind":768,"flags":0,"lineno":291,"children":{"expr":{"kind":256,"flags":0,"lineno":291,"children":{"name":"this"}},"method":"fail","args":{"kind":128,"flags":0,"lineno":291,"children":["Expected exception not thrown"]}}}]},"catches":{"kind":135,"flags":0,"lineno":292,"children":[{"kind":773,"flags":0,"lineno":292,"children":{"class":{"kind":141,"flags":0,"lineno":292,"children":[{"kind":2048,"flags"...
14:27:23 #15: Phan\BlockAnalysisVisitor->visitTry() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:628] Args: [ast\Node({"kind":772,"flags":0,"lineno":289,"children":{"try":{"kind":132,"flags":0,"lineno":289,"children":[{"kind":518,"flags":0,"lineno":290,"children":{"var":{"kind":256,"flags":1879048192,"lineno":290,"children":{"name":"dummy"},"taint":{}},"expr":{"kind":512,"flags":0,"lineno":290,"children":{"expr":{"kind":256,"flags":0,"lineno":290,"children":{"name":"list"},"taint":{}},"dim":1.2}}}},{"kind":768,"flags":0,"lineno":291,"children":{"expr":{"kind":256,"flags":0,"lineno":291,"children":{"name":"this"}},"method":"fail","args":{"kind":128,"flags":0,"lineno":291,"children":["Expected exception not thrown"]}}}]},"catches":{"kind":135,"flags":0,"lineno":292,"children":[{"kind":773,"flags":0,"lineno":292,"children":{"class":{"kind":141,"flags":0,"lineno":292,"children":[{"kind":2048,"flags":1,"lineno":292,"children":{"name":"InvalidArgumentException"}}]},"var":{"kind":256,...
14:27:23 #16: Phan\BlockAnalysisVisitor->analyzeAndGetUpdatedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:240] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:289), ast\Node({"kind":132,"flags":0,"lineno":251,"children":[{"kind":518,"flags":0,"lineno":252,"children":{"var":{"kind":256,"flags":1879048192,"lineno":252,"children":{"name":"value1"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":252,"children":{"class":{"kind":2048,"flags":1,"lineno":252,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":252,"children":[1],"hash":null}},"taint":{},"hash":null}},"taint":{}},{"kind":518,"flags":0,"lineno":253,"children":{"var":{"kind":256,"flags":1879048192,"lineno":253,"children":{"name":"value2"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":253,"children":{"class":{"kind":2048,"flags":1,"lineno":253,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags"...
14:27:23 #17: Phan\BlockAnalysisVisitor->visitStmtList() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:628] Args: [ast\Node({"kind":132,"flags":0,"lineno":251,"children":[{"kind":518,"flags":0,"lineno":252,"children":{"var":{"kind":256,"flags":1879048192,"lineno":252,"children":{"name":"value1"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":252,"children":{"class":{"kind":2048,"flags":1,"lineno":252,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":252,"children":[1],"hash":null}},"taint":{},"hash":null}},"taint":{}},{"kind":518,"flags":0,"lineno":253,"children":{"var":{"kind":256,"flags":1879048192,"lineno":253,"children":{"name":"value2"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":253,"children":{"class":{"kind":2048,"flags":1,"lineno":253,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":253,"children":[2],"hash":null}},"taint":{},"hash":null}},"taint":...
14:27:23 #18: Phan\BlockAnalysisVisitor->analyzeAndGetUpdatedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:3097] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:271), ast\Node({"kind":69,"flags":1,"lineno":251,"children":{"name":"testArrayAccess","docComment":null,"params":{"kind":136,"flags":0,"lineno":251,"children":[]},"stmts":{"kind":132,"flags":0,"lineno":251,"children":[{"kind":518,"flags":0,"lineno":252,"children":{"var":{"kind":256,"flags":1879048192,"lineno":252,"children":{"name":"value1"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":252,"children":{"class":{"kind":2048,"flags":1,"lineno":252,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":252,"children":[1],"hash":null}},"taint":{},"hash":null}},"taint":{}},{"kind":518,"flags":0,"lineno":253,"children":{"var":{"kind":256,"flags":1879048192,"lineno":253,"children":{"name":"value2"},"taint":{},"hash":null},"expr":{"kind":527,"flag...
14:27:23 #19: Phan\BlockAnalysisVisitor->visitMethod() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:628] Args: [ast\Node({"kind":69,"flags":1,"lineno":251,"children":{"name":"testArrayAccess","docComment":null,"params":{"kind":136,"flags":0,"lineno":251,"children":[]},"stmts":{"kind":132,"flags":0,"lineno":251,"children":[{"kind":518,"flags":0,"lineno":252,"children":{"var":{"kind":256,"flags":1879048192,"lineno":252,"children":{"name":"value1"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":252,"children":{"class":{"kind":2048,"flags":1,"lineno":252,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":252,"children":[1],"hash":null}},"taint":{},"hash":null}},"taint":{}},{"kind":518,"flags":0,"lineno":253,"children":{"var":{"kind":256,"flags":1879048192,"lineno":253,"children":{"name":"value2"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":253,"children":{"class":{"kind":2048,"flags":1,"lineno":253,"childr...
14:27:23 #20: Phan\BlockAnalysisVisitor->analyzeAndGetUpdatedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:240] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:251), ast\Node({"kind":132,"flags":0,"lineno":17,"children":[{"kind":69,"flags":1,"lineno":19,"children":{"name":"testException","docComment":null,"params":{"kind":136,"flags":0,"lineno":19,"children":[]},"stmts":{"kind":132,"flags":0,"lineno":19,"children":[{"kind":518,"flags":0,"lineno":20,"children":{"var":{"kind":256,"flags":1879048192,"lineno":20,"children":{"name":"item"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":20,"children":{"class":{"kind":2048,"flags":1,"lineno":20,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":20,"children":[1],"hash":null}},"taint":{},"hash":null}},"taint":{},"hash":null},{"kind":768,"flags":0,"lineno":21,"children":{"expr":{"kind":256,"flags":0,"lineno":21,"children":{"name":"this"},"taint":{},"has...
14:27:23 #21: Phan\BlockAnalysisVisitor->visitStmtList() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:628] Args: [ast\Node({"kind":132,"flags":0,"lineno":17,"children":[{"kind":69,"flags":1,"lineno":19,"children":{"name":"testException","docComment":null,"params":{"kind":136,"flags":0,"lineno":19,"children":[]},"stmts":{"kind":132,"flags":0,"lineno":19,"children":[{"kind":518,"flags":0,"lineno":20,"children":{"var":{"kind":256,"flags":1879048192,"lineno":20,"children":{"name":"item"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":20,"children":{"class":{"kind":2048,"flags":1,"lineno":20,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":20,"children":[1],"hash":null}},"taint":{},"hash":null}},"taint":{},"hash":null},{"kind":768,"flags":0,"lineno":21,"children":{"expr":{"kind":256,"flags":0,"lineno":21,"children":{"name":"this"},"taint":{},"hash":null},"method":"expectException","args":{"kind":128,"flags":0,"lineno":21,"...
14:27:23 #22: Phan\BlockAnalysisVisitor->analyzeAndGetUpdatedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:1537] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:251), ast\Node({"kind":70,"flags":0,"lineno":17,"children":{"name":"CSSObjectListTest","docComment":"/**\n * @covers \\Wikimedia\\CSS\\Objects\\CSSObjectList\n */","extends":{"kind":2048,"flags":1,"lineno":17,"children":{"name":"TestCase"}},"implements":null,"stmts":{"kind":132,"flags":0,"lineno":17,"children":[{"kind":69,"flags":1,"lineno":19,"children":{"name":"testException","docComment":null,"params":{"kind":136,"flags":0,"lineno":19,"children":[]},"stmts":{"kind":132,"flags":0,"lineno":19,"children":[{"kind":518,"flags":0,"lineno":20,"children":{"var":{"kind":256,"flags":1879048192,"lineno":20,"children":{"name":"item"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":20,"children":{"class":{"kind":2048,"flags":1,"lineno":20,"children":{"name":"TestCSSObjectListItem"},"hash":n...
14:27:23 #23: Phan\BlockAnalysisVisitor->visitClosedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:3065] Args: [ast\Node({"kind":70,"flags":0,"lineno":17,"children":{"name":"CSSObjectListTest","docComment":"/**\n * @covers \\Wikimedia\\CSS\\Objects\\CSSObjectList\n */","extends":{"kind":2048,"flags":1,"lineno":17,"children":{"name":"TestCase"}},"implements":null,"stmts":{"kind":132,"flags":0,"lineno":17,"children":[{"kind":69,"flags":1,"lineno":19,"children":{"name":"testException","docComment":null,"params":{"kind":136,"flags":0,"lineno":19,"children":[]},"stmts":{"kind":132,"flags":0,"lineno":19,"children":[{"kind":518,"flags":0,"lineno":20,"children":{"var":{"kind":256,"flags":1879048192,"lineno":20,"children":{"name":"item"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":20,"children":{"class":{"kind":2048,"flags":1,"lineno":20,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":20,"children":[1],"hash":null}...
14:27:23 #24: Phan\BlockAnalysisVisitor->visitClass() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:628] Args: [ast\Node({"kind":70,"flags":0,"lineno":17,"children":{"name":"CSSObjectListTest","docComment":"/**\n * @covers \\Wikimedia\\CSS\\Objects\\CSSObjectList\n */","extends":{"kind":2048,"flags":1,"lineno":17,"children":{"name":"TestCase"}},"implements":null,"stmts":{"kind":132,"flags":0,"lineno":17,"children":[{"kind":69,"flags":1,"lineno":19,"children":{"name":"testException","docComment":null,"params":{"kind":136,"flags":0,"lineno":19,"children":[]},"stmts":{"kind":132,"flags":0,"lineno":19,"children":[{"kind":518,"flags":0,"lineno":20,"children":{"var":{"kind":256,"flags":1879048192,"lineno":20,"children":{"name":"item"},"taint":{},"hash":null},"expr":{"kind":527,"flags":0,"lineno":20,"children":{"class":{"kind":2048,"flags":1,"lineno":20,"children":{"name":"TestCSSObjectListItem"},"hash":null},"args":{"kind":128,"flags":0,"lineno":20,"children":[1],"hash":null}},"taint"...
14:27:23 #25: Phan\BlockAnalysisVisitor->analyzeAndGetUpdatedContext() called at [/src/vendor/phan/phan/src/Phan/BlockAnalysisVisitor.php:240] Args: [Phan\Language\Context(tests/Objects/CSSObjectListTest.php:17), ast\Node({"kind":132,"flags":0,"lineno":1,"children":[{"kind":542,"flags":0,"lineno":7,"children":{"name":"Wikimedia\\CSS\\Objects","stmts":null}},{"kind":143,"flags":1,"lineno":9,"children":[{"kind":543,"flags":0,"lineno":9,"children":{"name":"InvalidArgumentException","alias":null}}]},{"kind":143,"flags":1,"lineno":10,"children":[{"kind":543,"flags":0,"lineno":10,"children":{"name":"OutOfBoundsException","alias":null}}]},{"kind":143,"flags":1,"lineno":11,"children":[{"kind":543,"flags":0,"lineno":11,"children":{"name":"PHPUnit\\Framework\\TestCase","alias":null}}]},{"kind":143,"flags":1,"lineno":12,"children":[{"kind":543,"flags":0,"lineno":12,"children":{"name":"Wikimedia\\CSS\\Util","alias":null}}]},{"kind":70,"flags":0,"lineno":17,"children":{"name":"CSSObjectListTest","docComment":"/*...
14:27:23 #26: Phan\BlockAnalysisVisitor->visitStmtList() called at [/src/vendor/phan/phan/src/Phan/AST/Visitor/KindVisitorImplementation.php:35] Args: [ast\Node({"kind":132,"flags":0,"lineno":1,"children":[{"kind":542,"flags":0,"lineno":7,"children":{"name":"Wikimedia\\CSS\\Objects","stmts":null}},{"kind":143,"flags":1,"lineno":9,"children":[{"kind":543,"flags":0,"lineno":9,"children":{"name":"InvalidArgumentException","alias":null}}]},{"kind":143,"flags":1,"lineno":10,"children":[{"kind":543,"flags":0,"lineno":10,"children":{"name":"OutOfBoundsException","alias":null}}]},{"kind":143,"flags":1,"lineno":11,"children":[{"kind":543,"flags":0,"lineno":11,"children":{"name":"PHPUnit\\Framework\\TestCase","alias":null}}]},{"kind":143,"flags":1,"lineno":12,"children":[{"kind":543,"flags":0,"lineno":12,"children":{"name":"Wikimedia\\CSS\\Util","alias":null}}]},{"kind":70,"flags":0,"lineno":17,"children":{"name":"CSSObjectListTest","docComment":"/**\n * @covers \\Wikimedia\\CSS\\Objects\\CSSObjectList\n */",...
14:27:23 #27: Phan\AST\Visitor\KindVisitorImplementation->__invoke() called at [/src/vendor/phan/phan/src/Phan/Analysis.php:578] Args: [ast\Node({"kind":132,"flags":0,"lineno":1,"children":[{"kind":542,"flags":0,"lineno":7,"children":{"name":"Wikimedia\\CSS\\Objects","stmts":null}},{"kind":143,"flags":1,"lineno":9,"children":[{"kind":543,"flags":0,"lineno":9,"children":{"name":"InvalidArgumentException","alias":null}}]},{"kind":143,"flags":1,"lineno":10,"children":[{"kind":543,"flags":0,"lineno":10,"children":{"name":"OutOfBoundsException","alias":null}}]},{"kind":143,"flags":1,"lineno":11,"children":[{"kind":543,"flags":0,"lineno":11,"children":{"name":"PHPUnit\\Framework\\TestCase","alias":null}}]},{"kind":143,"flags":1,"lineno":12,"children":[{"kind":543,"flags":0,"lineno":12,"children":{"name":"Wikimedia\\CSS\\Util","alias":null}}]},{"kind":70,"flags":0,"lineno":17,"children":{"name":"CSSObjectListTest","docComment":"/**\n * @covers \\Wikimedia\\CSS\\Objects\\CSSObjectList\n */","extends":{"kind...
14:27:23 #28: Phan\Analysis::analyzeFile() called at [/src/vendor/phan/phan/src/Phan/Phan.php:535] Args: [Phan\CodeBase({}), "tests/Objects/CSSObjectListTest.php", null, null]
14:27:23 #29: Phan\Phan::Phan\{closure}() called at [/src/vendor/phan/phan/src/Phan/Phan.php:592] Args: [69, "tests/Objects/CSSObjectListTest.php", 121]
14:27:23 #30: Phan\Phan::finishAnalyzingRemainingStatements() called at [/src/vendor/phan/phan/src/Phan/Phan.php:384] Args: [Phan\CodeBase({}), null, ["src/Grammar/Matcher.php", "src/Grammar/Alternative.php", "src/Grammar/AnythingMatcher.php", "src/Grammar/BlockMatcher.php", "src/Grammar/CheckedMatcher.php", "src/Grammar/DelimMatcher.php", "src/Grammar/FunctionMatcher.php", "src/Grammar/Juxtaposition.php", "src/Grammar/KeywordMatcher.php", "src/Grammar/NoWhitespace.php", ... 111 more element(s)], []]
14:27:23 #31: Phan\Phan::analyzeFileList() called at [/src/vendor/phan/phan/src/phan.php:38] Args: [Phan\CodeBase({}), Closure]
14:27:23 #32: require_once() called at [/src/vendor/phan/phan/phan:10] Args: ["/src/vendor/phan/phan/src/phan.php"]
14:27:23 #33: include() called at [/src/vendor/bin/phan:117] Args: ["/src/vendor/phan/phan/phan"]

Event Timeline

It is a test, with the following code

CSSObjectListTest.php
		try {
			$dummy = $list[1.2];
			$this->fail( 'Expected exception not thrown' );
		} catch ( InvalidArgumentException $ex ) {
			$this->assertSame( 'Offset must be an integer.', $ex->getMessage() );
		}

		try {
			$list[1.2] = $value6;
			$this->fail( 'Expected exception not thrown' );
		} catch ( InvalidArgumentException $ex ) {
			$this->assertSame( 'Offset must be an integer.', $ex->getMessage() );
		}

php only supports int and string as array index, the 1.2 makes a problem here. taint is using the raw value as offset. It checks is_scalar, but ...

Not sure if the exception is the same under php8.1 and the test fails after phan would pass.

Taint check itself has a similar test which is failing

https://gerrit.wikimedia.org/r/c/mediawiki/tools/phan/SecurityCheckPlugin/+/789297
https://integration.wikimedia.org/ci/job/composer-package-php81-docker/119/consoleFull

23:53:05 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░/src/src/Taintedness.php:406 [8192] Implicit conversion from float 3.5 to int loses precision
23:53:05 (Phan 5.3.2 crashed when parsing/analyzing 'src/207_invalid_offset.php')
23:53:05 More details:
23:53:05 #2: SecurityCheckPlugin\Taintedness->getTaintednessForOffsetOrWhole() called at [/src/src/TaintednessVisitor.php:490] Args: [3.5]
23:53:05 #3: SecurityCheckPlugin\TaintednessVisitor->visitDim() called at [/src/vendor/phan/phan/src/Phan/Plugin/ConfigPluginSet.php:1308] Args: [ast\Node({"kind":512,"flags":0,"lineno":6,"children":{"expr":{"kind":256,"flags":0,"lineno":6,"children":{"name":"arr"},"taint":{}},"dim":3.5}})]
23:53:05 #4: SecurityCheckPlugin\MWVisitor::Phan\Plugin\{closure}() called at [/src/vendor/phan/phan/src/Phan/Plugin/ConfigPluginSet.php:323] Args: [Phan\CodeBase({}), Phan\Language\Context(src/207_invalid_offset.php:6), ast\Node({"kind":512,"flags":0,"lineno":6,"children":{"expr":{"kind":256,"flags":0,"lineno":6,"children":{"name":"arr"},"taint":{}},"dim":3.5}}), [ast\Node({"kind":132,"flags":0,"lineno":1,"children":[{"kind":518,"flags":0,"lineno":3,"children":{"var":{"kind":256,"flags":1879048192,"lineno":3,"children":{"name":"arr"},"taint":{},"hash":null},"expr":{"kind":129,"flags":3,"lineno":3,"children":[{"kind":526,"flags":0,"lineno":3,"children":{"value":"z","key":"string"},"hash":null},{"kind":526,"flags":0,"lineno":3,"children":{"value":"x","key":""},"hash":null},{"kind":526,"flags":0,"lineno":3,"children":{"value":{"kind":129,"flags":3,"lineno":3,"children":[],"taint":{},"hash":null},"key":0},"hash":null}],"taint":{},"hash":null}},"taint":{}},{"kind":67,"flags":0,"lineno":4,"children":{"n...

Alright... Indeed, taint-check doesn't do any check on the type of the offset (except for ensuring that it's scalar). PHP is definitely weird when it comes to internal casts for array offsets (e.g. numeric strings automagically becoming integers), and we just don't care. Since taint-check just uses the same index used by the application, the assumption is that whatever weirdness happens in taint-check, it also happens in the application, and so the result will be consistent. This also means that if taint-check crashes due to a PHP warning, the same warning will be raised when running the application (except perhaps it won't crash, since I assume not many applications, especially not MediaWiki, have an aggressive error handler). Obviously, this does not mean that crashing is a good thing, especially since we're talking about a tool (phan) that is also supposed to help you with ensuring that your application is compatible with newer PHP versions.

Now, about the fix. One thing we could do is guard all index accesses with an is_float and cast the index to int. This is not ideal though, because these potentially invalid offsets can be accessed in many places. Instead, we could just add that check to resolveOffset(), making sure that it's always used when determining what an index is going to be (i.e., make sure that nothing is using resolveValue()). Since we're at it, I think the is_resource check should be moved there, too.

I also considered silencing the error with @ where it may happen, but this has two disadvantages. First, once again, we'd have to silence potentially many expressions all around the place. Second, I just benchmarked @ to see if the anecdotal story of it being slow (due to unsetting and restoring the error handler) is true; well, it is! Those 470ms vs 16ms and 923ms vs 24ms are frightening and not something we can tolerate. For reference, with PHP 8.0 the current unsafe and unsilenced version is roughly 10% faster than the is_float one, but this is probably acceptable.

Change 789987 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/tools/phan/SecurityCheckPlugin@master] Avoid using floats as array keys for PHP 8.1 compatibility

https://gerrit.wikimedia.org/r/789987

Change 789987 merged by jenkins-bot:

[mediawiki/tools/phan/SecurityCheckPlugin@master] Avoid using floats as array keys for PHP 8.1 compatibility

https://gerrit.wikimedia.org/r/789987

Change 842841 had a related patch set uploaded (by Jforrester; author: Jforrester):

[integration/config@master] Zuul: Use more canonical way to disable php81 jobs from libraries

https://gerrit.wikimedia.org/r/842841

Tgr subscribed.

It is a test, with the following code

CSSObjectListTest.php
		try {
			$dummy = $list[1.2];
			$this->fail( 'Expected exception not thrown' );
		} catch ( InvalidArgumentException $ex ) {
			$this->assertSame( 'Offset must be an integer.', $ex->getMessage() );
		}

		try {
			$list[1.2] = $value6;
			$this->fail( 'Expected exception not thrown' );
		} catch ( InvalidArgumentException $ex ) {
			$this->assertSame( 'Offset must be an integer.', $ex->getMessage() );
		}

php only supports int and string as array index, the 1.2 makes a problem here. taint is using the raw value as offset. It checks is_scalar, but ...

$list is a CSSObjectList instance, which implements ArrayAccess. CSSObjectList happens to require integer offsets, but ArrayAccess in general does not (it doesn't even need to be scalar, and for example SplObjectStorage uses non-scalar indexes).

So the real issue here seems to be that SecurityCheckPlugin assumes array access syntax means the variable is an array.

Also, the fix here apparently didn't work: T324207: Phan crashes on css-sanitizer on PHP 8.1

While testing with the above example I have found also an issue upstream - https://github.com/phan/phan/issues/4749

Umherirrender removed a project: Patch-For-Review.

While testing with the above example I have found also an issue upstream - https://github.com/phan/phan/issues/4749

According to a fresh run on css-sanitizer for php8.1 that is also the current failure
So this task in the phan-taint-check-plugin is resolved and waiting for upstream in the other task: T324207

I don't see how an upstream fix for float conversion would solve the problem that Taintedness uses an array internally to represent an array-like object in the source code. Array-like objects can have non-scalar keys, arrays can't.

I don't see how an upstream fix for float conversion would solve the problem that Taintedness uses an array internally to represent an array-like object in the source code. Array-like objects can have non-scalar keys, arrays can't.

The fix to taint-plugin converts floats to int and that is valid to store in array. Not sure if that is the best way to do, but at least my tests does not show a fatal error in taint. Maybe there is a better to way to store that key and make taint-checks better when it seens similiar keys and avoid false positives for keys converted from float to int. If that should be part of this task, feel free to open and adjust the description. The underlying fatal is fixed (and I have understand the bug only to avoid the fatal)

Change #1169726 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] Fix EventFactory not using country code when provided without address

https://gerrit.wikimedia.org/r/1169726