webshell-analyzer 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- webshell_analyzer/__init__.py +0 -0
- webshell_analyzer/cli/__init__.py +0 -0
- webshell_analyzer/cli/cli.py +151 -0
- webshell_analyzer/extractor/ast_extraction/composer.json +5 -0
- webshell_analyzer/extractor/ast_extraction/composer.lock +77 -0
- webshell_analyzer/extractor/ast_extraction/src/NodeVisitor.php +85 -0
- webshell_analyzer/extractor/ast_extraction/src/astBuilder.php +50 -0
- webshell_analyzer/extractor/ast_extraction/src/astExtractor.php +50 -0
- webshell_analyzer/extractor/ast_extraction/src/featuresDeclare.php +36 -0
- webshell_analyzer/extractor/ast_extraction/vendor/autoload.php +25 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/ClassLoader.php +579 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/InstalledVersions.php +378 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/autoload_classmap.php +10 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/autoload_namespaces.php +9 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/autoload_psr4.php +10 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/autoload_real.php +38 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/autoload_static.php +36 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/installed.json +67 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/installed.php +32 -0
- webshell_analyzer/extractor/ast_extraction/vendor/composer/platform_check.php +26 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +150 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Class_.php +151 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +50 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +86 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +116 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +73 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Function_.php +67 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +94 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Method.php +147 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +45 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php +171 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php +223 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +65 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +145 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +83 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder/Use_.php +49 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Builder.php +12 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/BuilderFactory.php +375 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +338 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Comment/Doc.php +6 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Comment.php +209 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluationException.php +6 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +237 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Error.php +173 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +43 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +17 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/ErrorHandler.php +12 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php +31 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Internal/Differ.php +178 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +71 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php +237 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +282 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/JsonDecoder.php +108 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +230 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php +93 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +49 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +26 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +45 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +60 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +19 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +60 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/PipeOperatorEmulator.php +45 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/PropertyTokenEmulator.php +19 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php +31 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +31 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +30 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/VoidCastEmulator.php +98 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer.php +116 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Modifiers.php +85 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NameContext.php +284 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Arg.php +44 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/ArrayItem.php +43 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Attribute.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +27 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/ClosureUse.php +36 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +13 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Const_.php +36 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/DeclareItem.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +34 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +84 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pipe.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +60 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +16 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Void_.php +11 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +25 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +36 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +86 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +30 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +30 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +38 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +38 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +35 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +34 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +32 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +45 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +40 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +45 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +35 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +35 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +30 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +45 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +36 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php +8 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +40 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Identifier.php +85 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/InterpolatedStringPart.php +32 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php +27 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +49 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +49 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Name.php +278 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/NullableType.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Param.php +123 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/PropertyHook.php +105 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/PropertyItem.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +17 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Float_.php +78 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/Int_.php +82 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/InterpolatedString.php +34 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Property.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +27 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +161 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar.php +6 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/StaticVar.php +39 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Block.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +40 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +77 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +109 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +154 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +94 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +17 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +34 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +36 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +44 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +32 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +47 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +50 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +81 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +30 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +41 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +46 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +40 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +30 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +16 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +121 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +17 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +15 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +30 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +12 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +34 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +37 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +29 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +17 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +47 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +33 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt.php +8 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/UnionType.php +27 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/UseItem.php +55 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php +16 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +27 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Node.php +150 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php +181 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php +299 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php +90 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php +287 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +26 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +19 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php +82 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +47 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +49 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +269 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +73 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +51 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor.php +124 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +24 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php +2919 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Parser/Php8.php +2917 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Parser.php +24 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php +1335 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/ParserFactory.php +42 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/PhpVersion.php +175 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +1232 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter.php +51 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +1706 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Token.php +18 -0
- webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/compatibility_tokens.php +71 -0
- webshell_analyzer/extractor/extractor.py +73 -0
- webshell_analyzer/extractor/lexical_extraction/lexicalExtractor.py +31 -0
- webshell_analyzer/extractor/statistical_extraction/statisticalExtractor.py +60 -0
- webshell_analyzer/model/features_selected.json +1 -0
- webshell_analyzer/model/model_loader.py +19 -0
- webshell_analyzer/model/rf_webshell_model.joblib +0 -0
- webshell_analyzer/modules/__init__.py +0 -0
- webshell_analyzer/modules/detector.py +174 -0
- webshell_analyzer/modules/scanner.py +68 -0
- webshell_analyzer-1.0.0.dist-info/METADATA +105 -0
- webshell_analyzer-1.0.0.dist-info/RECORD +304 -0
- webshell_analyzer-1.0.0.dist-info/WHEEL +5 -0
- webshell_analyzer-1.0.0.dist-info/entry_points.txt +2 -0
- webshell_analyzer-1.0.0.dist-info/licenses/LICENSE +21 -0
- webshell_analyzer-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Internal;
|
|
4
|
+
|
|
5
|
+
use PhpParser\Token;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Provides operations on token streams, for use by pretty printer.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
class TokenStream {
|
|
13
|
+
/** @var Token[] Tokens (in PhpToken::tokenize() format) */
|
|
14
|
+
private array $tokens;
|
|
15
|
+
/** @var int[] Map from position to indentation */
|
|
16
|
+
private array $indentMap;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create token stream instance.
|
|
20
|
+
*
|
|
21
|
+
* @param Token[] $tokens Tokens in PhpToken::tokenize() format
|
|
22
|
+
*/
|
|
23
|
+
public function __construct(array $tokens, int $tabWidth) {
|
|
24
|
+
$this->tokens = $tokens;
|
|
25
|
+
$this->indentMap = $this->calcIndentMap($tabWidth);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether the given position is immediately surrounded by parenthesis.
|
|
30
|
+
*
|
|
31
|
+
* @param int $startPos Start position
|
|
32
|
+
* @param int $endPos End position
|
|
33
|
+
*/
|
|
34
|
+
public function haveParens(int $startPos, int $endPos): bool {
|
|
35
|
+
return $this->haveTokenImmediatelyBefore($startPos, '(')
|
|
36
|
+
&& $this->haveTokenImmediatelyAfter($endPos, ')');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether the given position is immediately surrounded by braces.
|
|
41
|
+
*
|
|
42
|
+
* @param int $startPos Start position
|
|
43
|
+
* @param int $endPos End position
|
|
44
|
+
*/
|
|
45
|
+
public function haveBraces(int $startPos, int $endPos): bool {
|
|
46
|
+
return ($this->haveTokenImmediatelyBefore($startPos, '{')
|
|
47
|
+
|| $this->haveTokenImmediatelyBefore($startPos, T_CURLY_OPEN))
|
|
48
|
+
&& $this->haveTokenImmediatelyAfter($endPos, '}');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Check whether the position is directly preceded by a certain token type.
|
|
53
|
+
*
|
|
54
|
+
* During this check whitespace and comments are skipped.
|
|
55
|
+
*
|
|
56
|
+
* @param int $pos Position before which the token should occur
|
|
57
|
+
* @param int|string $expectedTokenType Token to check for
|
|
58
|
+
*
|
|
59
|
+
* @return bool Whether the expected token was found
|
|
60
|
+
*/
|
|
61
|
+
public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType): bool {
|
|
62
|
+
$tokens = $this->tokens;
|
|
63
|
+
$pos--;
|
|
64
|
+
for (; $pos >= 0; $pos--) {
|
|
65
|
+
$token = $tokens[$pos];
|
|
66
|
+
if ($token->is($expectedTokenType)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (!$token->isIgnorable()) {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check whether the position is directly followed by a certain token type.
|
|
78
|
+
*
|
|
79
|
+
* During this check whitespace and comments are skipped.
|
|
80
|
+
*
|
|
81
|
+
* @param int $pos Position after which the token should occur
|
|
82
|
+
* @param int|string $expectedTokenType Token to check for
|
|
83
|
+
*
|
|
84
|
+
* @return bool Whether the expected token was found
|
|
85
|
+
*/
|
|
86
|
+
public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType): bool {
|
|
87
|
+
$tokens = $this->tokens;
|
|
88
|
+
$pos++;
|
|
89
|
+
for ($c = \count($tokens); $pos < $c; $pos++) {
|
|
90
|
+
$token = $tokens[$pos];
|
|
91
|
+
if ($token->is($expectedTokenType)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
if (!$token->isIgnorable()) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** @param int|string|(int|string)[] $skipTokenType */
|
|
102
|
+
public function skipLeft(int $pos, $skipTokenType): int {
|
|
103
|
+
$tokens = $this->tokens;
|
|
104
|
+
|
|
105
|
+
$pos = $this->skipLeftWhitespace($pos);
|
|
106
|
+
if ($skipTokenType === \T_WHITESPACE) {
|
|
107
|
+
return $pos;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!$tokens[$pos]->is($skipTokenType)) {
|
|
111
|
+
// Shouldn't happen. The skip token MUST be there
|
|
112
|
+
throw new \Exception('Encountered unexpected token');
|
|
113
|
+
}
|
|
114
|
+
$pos--;
|
|
115
|
+
|
|
116
|
+
return $this->skipLeftWhitespace($pos);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** @param int|string|(int|string)[] $skipTokenType */
|
|
120
|
+
public function skipRight(int $pos, $skipTokenType): int {
|
|
121
|
+
$tokens = $this->tokens;
|
|
122
|
+
|
|
123
|
+
$pos = $this->skipRightWhitespace($pos);
|
|
124
|
+
if ($skipTokenType === \T_WHITESPACE) {
|
|
125
|
+
return $pos;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!$tokens[$pos]->is($skipTokenType)) {
|
|
129
|
+
// Shouldn't happen. The skip token MUST be there
|
|
130
|
+
throw new \Exception('Encountered unexpected token');
|
|
131
|
+
}
|
|
132
|
+
$pos++;
|
|
133
|
+
|
|
134
|
+
return $this->skipRightWhitespace($pos);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Return first non-whitespace token position smaller or equal to passed position.
|
|
139
|
+
*
|
|
140
|
+
* @param int $pos Token position
|
|
141
|
+
* @return int Non-whitespace token position
|
|
142
|
+
*/
|
|
143
|
+
public function skipLeftWhitespace(int $pos): int {
|
|
144
|
+
$tokens = $this->tokens;
|
|
145
|
+
for (; $pos >= 0; $pos--) {
|
|
146
|
+
if (!$tokens[$pos]->isIgnorable()) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return $pos;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Return first non-whitespace position greater or equal to passed position.
|
|
155
|
+
*
|
|
156
|
+
* @param int $pos Token position
|
|
157
|
+
* @return int Non-whitespace token position
|
|
158
|
+
*/
|
|
159
|
+
public function skipRightWhitespace(int $pos): int {
|
|
160
|
+
$tokens = $this->tokens;
|
|
161
|
+
for ($count = \count($tokens); $pos < $count; $pos++) {
|
|
162
|
+
if (!$tokens[$pos]->isIgnorable()) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return $pos;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** @param int|string|(int|string)[] $findTokenType */
|
|
170
|
+
public function findRight(int $pos, $findTokenType): int {
|
|
171
|
+
$tokens = $this->tokens;
|
|
172
|
+
for ($count = \count($tokens); $pos < $count; $pos++) {
|
|
173
|
+
if ($tokens[$pos]->is($findTokenType)) {
|
|
174
|
+
return $pos;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return -1;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Whether the given position range contains a certain token type.
|
|
182
|
+
*
|
|
183
|
+
* @param int $startPos Starting position (inclusive)
|
|
184
|
+
* @param int $endPos Ending position (exclusive)
|
|
185
|
+
* @param int|string $tokenType Token type to look for
|
|
186
|
+
* @return bool Whether the token occurs in the given range
|
|
187
|
+
*/
|
|
188
|
+
public function haveTokenInRange(int $startPos, int $endPos, $tokenType): bool {
|
|
189
|
+
$tokens = $this->tokens;
|
|
190
|
+
for ($pos = $startPos; $pos < $endPos; $pos++) {
|
|
191
|
+
if ($tokens[$pos]->is($tokenType)) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public function haveTagInRange(int $startPos, int $endPos): bool {
|
|
199
|
+
return $this->haveTokenInRange($startPos, $endPos, \T_OPEN_TAG)
|
|
200
|
+
|| $this->haveTokenInRange($startPos, $endPos, \T_CLOSE_TAG);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Get indentation before token position.
|
|
205
|
+
*
|
|
206
|
+
* @param int $pos Token position
|
|
207
|
+
*
|
|
208
|
+
* @return int Indentation depth (in spaces)
|
|
209
|
+
*/
|
|
210
|
+
public function getIndentationBefore(int $pos): int {
|
|
211
|
+
return $this->indentMap[$pos];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Get the code corresponding to a token offset range, optionally adjusted for indentation.
|
|
216
|
+
*
|
|
217
|
+
* @param int $from Token start position (inclusive)
|
|
218
|
+
* @param int $to Token end position (exclusive)
|
|
219
|
+
* @param int $indent By how much the code should be indented (can be negative as well)
|
|
220
|
+
*
|
|
221
|
+
* @return string Code corresponding to token range, adjusted for indentation
|
|
222
|
+
*/
|
|
223
|
+
public function getTokenCode(int $from, int $to, int $indent): string {
|
|
224
|
+
$tokens = $this->tokens;
|
|
225
|
+
$result = '';
|
|
226
|
+
for ($pos = $from; $pos < $to; $pos++) {
|
|
227
|
+
$token = $tokens[$pos];
|
|
228
|
+
$id = $token->id;
|
|
229
|
+
$text = $token->text;
|
|
230
|
+
if ($id === \T_CONSTANT_ENCAPSED_STRING || $id === \T_ENCAPSED_AND_WHITESPACE) {
|
|
231
|
+
$result .= $text;
|
|
232
|
+
} else {
|
|
233
|
+
// TODO Handle non-space indentation
|
|
234
|
+
if ($indent < 0) {
|
|
235
|
+
$result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $text);
|
|
236
|
+
} elseif ($indent > 0) {
|
|
237
|
+
$result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $text);
|
|
238
|
+
} else {
|
|
239
|
+
$result .= $text;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return $result;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Precalculate the indentation at every token position.
|
|
248
|
+
*
|
|
249
|
+
* @return int[] Token position to indentation map
|
|
250
|
+
*/
|
|
251
|
+
private function calcIndentMap(int $tabWidth): array {
|
|
252
|
+
$indentMap = [];
|
|
253
|
+
$indent = 0;
|
|
254
|
+
foreach ($this->tokens as $i => $token) {
|
|
255
|
+
$indentMap[] = $indent;
|
|
256
|
+
|
|
257
|
+
if ($token->id === \T_WHITESPACE) {
|
|
258
|
+
$content = $token->text;
|
|
259
|
+
$newlinePos = \strrpos($content, "\n");
|
|
260
|
+
if (false !== $newlinePos) {
|
|
261
|
+
$indent = $this->getIndent(\substr($content, $newlinePos + 1), $tabWidth);
|
|
262
|
+
} elseif ($i === 1 && $this->tokens[0]->id === \T_OPEN_TAG &&
|
|
263
|
+
$this->tokens[0]->text[\strlen($this->tokens[0]->text) - 1] === "\n") {
|
|
264
|
+
// Special case: Newline at the end of opening tag followed by whitespace.
|
|
265
|
+
$indent = $this->getIndent($content, $tabWidth);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Add a sentinel for one past end of the file
|
|
271
|
+
$indentMap[] = $indent;
|
|
272
|
+
|
|
273
|
+
return $indentMap;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private function getIndent(string $ws, int $tabWidth): int {
|
|
277
|
+
$spaces = \substr_count($ws, " ");
|
|
278
|
+
$tabs = \substr_count($ws, "\t");
|
|
279
|
+
assert(\strlen($ws) === $spaces + $tabs);
|
|
280
|
+
return $spaces + $tabs * $tabWidth;
|
|
281
|
+
}
|
|
282
|
+
}
|
webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/JsonDecoder.php
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser;
|
|
4
|
+
|
|
5
|
+
class JsonDecoder {
|
|
6
|
+
/** @var \ReflectionClass<Node>[] Node type to reflection class map */
|
|
7
|
+
private array $reflectionClassCache;
|
|
8
|
+
|
|
9
|
+
/** @return mixed */
|
|
10
|
+
public function decode(string $json) {
|
|
11
|
+
$value = json_decode($json, true);
|
|
12
|
+
if (json_last_error()) {
|
|
13
|
+
throw new \RuntimeException('JSON decoding error: ' . json_last_error_msg());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return $this->decodeRecursive($value);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param mixed $value
|
|
21
|
+
* @return mixed
|
|
22
|
+
*/
|
|
23
|
+
private function decodeRecursive($value) {
|
|
24
|
+
if (\is_array($value)) {
|
|
25
|
+
if (isset($value['nodeType'])) {
|
|
26
|
+
if ($value['nodeType'] === 'Comment' || $value['nodeType'] === 'Comment_Doc') {
|
|
27
|
+
return $this->decodeComment($value);
|
|
28
|
+
}
|
|
29
|
+
return $this->decodeNode($value);
|
|
30
|
+
}
|
|
31
|
+
return $this->decodeArray($value);
|
|
32
|
+
}
|
|
33
|
+
return $value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private function decodeArray(array $array): array {
|
|
37
|
+
$decodedArray = [];
|
|
38
|
+
foreach ($array as $key => $value) {
|
|
39
|
+
$decodedArray[$key] = $this->decodeRecursive($value);
|
|
40
|
+
}
|
|
41
|
+
return $decodedArray;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private function decodeNode(array $value): Node {
|
|
45
|
+
$nodeType = $value['nodeType'];
|
|
46
|
+
if (!\is_string($nodeType)) {
|
|
47
|
+
throw new \RuntimeException('Node type must be a string');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
$reflectionClass = $this->reflectionClassFromNodeType($nodeType);
|
|
51
|
+
$node = $reflectionClass->newInstanceWithoutConstructor();
|
|
52
|
+
|
|
53
|
+
if (isset($value['attributes'])) {
|
|
54
|
+
if (!\is_array($value['attributes'])) {
|
|
55
|
+
throw new \RuntimeException('Attributes must be an array');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
$node->setAttributes($this->decodeArray($value['attributes']));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
foreach ($value as $name => $subNode) {
|
|
62
|
+
if ($name === 'nodeType' || $name === 'attributes') {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
$node->$name = $this->decodeRecursive($subNode);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return $node;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private function decodeComment(array $value): Comment {
|
|
73
|
+
$className = $value['nodeType'] === 'Comment' ? Comment::class : Comment\Doc::class;
|
|
74
|
+
if (!isset($value['text'])) {
|
|
75
|
+
throw new \RuntimeException('Comment must have text');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return new $className(
|
|
79
|
+
$value['text'],
|
|
80
|
+
$value['line'] ?? -1, $value['filePos'] ?? -1, $value['tokenPos'] ?? -1,
|
|
81
|
+
$value['endLine'] ?? -1, $value['endFilePos'] ?? -1, $value['endTokenPos'] ?? -1
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** @return \ReflectionClass<Node> */
|
|
86
|
+
private function reflectionClassFromNodeType(string $nodeType): \ReflectionClass {
|
|
87
|
+
if (!isset($this->reflectionClassCache[$nodeType])) {
|
|
88
|
+
$className = $this->classNameFromNodeType($nodeType);
|
|
89
|
+
$this->reflectionClassCache[$nodeType] = new \ReflectionClass($className);
|
|
90
|
+
}
|
|
91
|
+
return $this->reflectionClassCache[$nodeType];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** @return class-string<Node> */
|
|
95
|
+
private function classNameFromNodeType(string $nodeType): string {
|
|
96
|
+
$className = 'PhpParser\\Node\\' . strtr($nodeType, '_', '\\');
|
|
97
|
+
if (class_exists($className)) {
|
|
98
|
+
return $className;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
$className .= '_';
|
|
102
|
+
if (class_exists($className)) {
|
|
103
|
+
return $className;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
throw new \RuntimeException("Unknown node type \"$nodeType\"");
|
|
107
|
+
}
|
|
108
|
+
}
|
webshell_analyzer/extractor/ast_extraction/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
namespace PhpParser\Lexer;
|
|
4
|
+
|
|
5
|
+
use PhpParser\Error;
|
|
6
|
+
use PhpParser\ErrorHandler;
|
|
7
|
+
use PhpParser\Lexer;
|
|
8
|
+
use PhpParser\Lexer\TokenEmulator\AsymmetricVisibilityTokenEmulator;
|
|
9
|
+
use PhpParser\Lexer\TokenEmulator\AttributeEmulator;
|
|
10
|
+
use PhpParser\Lexer\TokenEmulator\EnumTokenEmulator;
|
|
11
|
+
use PhpParser\Lexer\TokenEmulator\ExplicitOctalEmulator;
|
|
12
|
+
use PhpParser\Lexer\TokenEmulator\MatchTokenEmulator;
|
|
13
|
+
use PhpParser\Lexer\TokenEmulator\NullsafeTokenEmulator;
|
|
14
|
+
use PhpParser\Lexer\TokenEmulator\PipeOperatorEmulator;
|
|
15
|
+
use PhpParser\Lexer\TokenEmulator\PropertyTokenEmulator;
|
|
16
|
+
use PhpParser\Lexer\TokenEmulator\ReadonlyFunctionTokenEmulator;
|
|
17
|
+
use PhpParser\Lexer\TokenEmulator\ReadonlyTokenEmulator;
|
|
18
|
+
use PhpParser\Lexer\TokenEmulator\ReverseEmulator;
|
|
19
|
+
use PhpParser\Lexer\TokenEmulator\TokenEmulator;
|
|
20
|
+
use PhpParser\Lexer\TokenEmulator\VoidCastEmulator;
|
|
21
|
+
use PhpParser\PhpVersion;
|
|
22
|
+
use PhpParser\Token;
|
|
23
|
+
|
|
24
|
+
class Emulative extends Lexer {
|
|
25
|
+
/** @var array{int, string, string}[] Patches used to reverse changes introduced in the code */
|
|
26
|
+
private array $patches = [];
|
|
27
|
+
|
|
28
|
+
/** @var list<TokenEmulator> */
|
|
29
|
+
private array $emulators = [];
|
|
30
|
+
|
|
31
|
+
private PhpVersion $targetPhpVersion;
|
|
32
|
+
|
|
33
|
+
private PhpVersion $hostPhpVersion;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param PhpVersion|null $phpVersion PHP version to emulate. Defaults to newest supported.
|
|
37
|
+
*/
|
|
38
|
+
public function __construct(?PhpVersion $phpVersion = null) {
|
|
39
|
+
$this->targetPhpVersion = $phpVersion ?? PhpVersion::getNewestSupported();
|
|
40
|
+
$this->hostPhpVersion = PhpVersion::getHostVersion();
|
|
41
|
+
|
|
42
|
+
$emulators = [
|
|
43
|
+
new MatchTokenEmulator(),
|
|
44
|
+
new NullsafeTokenEmulator(),
|
|
45
|
+
new AttributeEmulator(),
|
|
46
|
+
new EnumTokenEmulator(),
|
|
47
|
+
new ReadonlyTokenEmulator(),
|
|
48
|
+
new ExplicitOctalEmulator(),
|
|
49
|
+
new ReadonlyFunctionTokenEmulator(),
|
|
50
|
+
new PropertyTokenEmulator(),
|
|
51
|
+
new AsymmetricVisibilityTokenEmulator(),
|
|
52
|
+
new PipeOperatorEmulator(),
|
|
53
|
+
new VoidCastEmulator(),
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
// Collect emulators that are relevant for the PHP version we're running
|
|
57
|
+
// and the PHP version we're targeting for emulation.
|
|
58
|
+
foreach ($emulators as $emulator) {
|
|
59
|
+
$emulatorPhpVersion = $emulator->getPhpVersion();
|
|
60
|
+
if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) {
|
|
61
|
+
$this->emulators[] = $emulator;
|
|
62
|
+
} elseif ($this->isReverseEmulationNeeded($emulatorPhpVersion)) {
|
|
63
|
+
$this->emulators[] = new ReverseEmulator($emulator);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public function tokenize(string $code, ?ErrorHandler $errorHandler = null): array {
|
|
69
|
+
$emulators = array_filter($this->emulators, function ($emulator) use ($code) {
|
|
70
|
+
return $emulator->isEmulationNeeded($code);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (empty($emulators)) {
|
|
74
|
+
// Nothing to emulate, yay
|
|
75
|
+
return parent::tokenize($code, $errorHandler);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if ($errorHandler === null) {
|
|
79
|
+
$errorHandler = new ErrorHandler\Throwing();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
$this->patches = [];
|
|
83
|
+
foreach ($emulators as $emulator) {
|
|
84
|
+
$code = $emulator->preprocessCode($code, $this->patches);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
$collector = new ErrorHandler\Collecting();
|
|
88
|
+
$tokens = parent::tokenize($code, $collector);
|
|
89
|
+
$this->sortPatches();
|
|
90
|
+
$tokens = $this->fixupTokens($tokens);
|
|
91
|
+
|
|
92
|
+
$errors = $collector->getErrors();
|
|
93
|
+
if (!empty($errors)) {
|
|
94
|
+
$this->fixupErrors($errors);
|
|
95
|
+
foreach ($errors as $error) {
|
|
96
|
+
$errorHandler->handleError($error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
foreach ($emulators as $emulator) {
|
|
101
|
+
$tokens = $emulator->emulate($code, $tokens);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return $tokens;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private function isForwardEmulationNeeded(PhpVersion $emulatorPhpVersion): bool {
|
|
108
|
+
return $this->hostPhpVersion->older($emulatorPhpVersion)
|
|
109
|
+
&& $this->targetPhpVersion->newerOrEqual($emulatorPhpVersion);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private function isReverseEmulationNeeded(PhpVersion $emulatorPhpVersion): bool {
|
|
113
|
+
return $this->hostPhpVersion->newerOrEqual($emulatorPhpVersion)
|
|
114
|
+
&& $this->targetPhpVersion->older($emulatorPhpVersion);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private function sortPatches(): void {
|
|
118
|
+
// Patches may be contributed by different emulators.
|
|
119
|
+
// Make sure they are sorted by increasing patch position.
|
|
120
|
+
usort($this->patches, function ($p1, $p2) {
|
|
121
|
+
return $p1[0] <=> $p2[0];
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param list<Token> $tokens
|
|
127
|
+
* @return list<Token>
|
|
128
|
+
*/
|
|
129
|
+
private function fixupTokens(array $tokens): array {
|
|
130
|
+
if (\count($this->patches) === 0) {
|
|
131
|
+
return $tokens;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Load first patch
|
|
135
|
+
$patchIdx = 0;
|
|
136
|
+
list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
|
|
137
|
+
|
|
138
|
+
// We use a manual loop over the tokens, because we modify the array on the fly
|
|
139
|
+
$posDelta = 0;
|
|
140
|
+
$lineDelta = 0;
|
|
141
|
+
for ($i = 0, $c = \count($tokens); $i < $c; $i++) {
|
|
142
|
+
$token = $tokens[$i];
|
|
143
|
+
$pos = $token->pos;
|
|
144
|
+
$token->pos += $posDelta;
|
|
145
|
+
$token->line += $lineDelta;
|
|
146
|
+
$localPosDelta = 0;
|
|
147
|
+
$len = \strlen($token->text);
|
|
148
|
+
while ($patchPos >= $pos && $patchPos < $pos + $len) {
|
|
149
|
+
$patchTextLen = \strlen($patchText);
|
|
150
|
+
if ($patchType === 'remove') {
|
|
151
|
+
if ($patchPos === $pos && $patchTextLen === $len) {
|
|
152
|
+
// Remove token entirely
|
|
153
|
+
array_splice($tokens, $i, 1, []);
|
|
154
|
+
$i--;
|
|
155
|
+
$c--;
|
|
156
|
+
} else {
|
|
157
|
+
// Remove from token string
|
|
158
|
+
$token->text = substr_replace(
|
|
159
|
+
$token->text, '', $patchPos - $pos + $localPosDelta, $patchTextLen
|
|
160
|
+
);
|
|
161
|
+
$localPosDelta -= $patchTextLen;
|
|
162
|
+
}
|
|
163
|
+
$lineDelta -= \substr_count($patchText, "\n");
|
|
164
|
+
} elseif ($patchType === 'add') {
|
|
165
|
+
// Insert into the token string
|
|
166
|
+
$token->text = substr_replace(
|
|
167
|
+
$token->text, $patchText, $patchPos - $pos + $localPosDelta, 0
|
|
168
|
+
);
|
|
169
|
+
$localPosDelta += $patchTextLen;
|
|
170
|
+
$lineDelta += \substr_count($patchText, "\n");
|
|
171
|
+
} elseif ($patchType === 'replace') {
|
|
172
|
+
// Replace inside the token string
|
|
173
|
+
$token->text = substr_replace(
|
|
174
|
+
$token->text, $patchText, $patchPos - $pos + $localPosDelta, $patchTextLen
|
|
175
|
+
);
|
|
176
|
+
} else {
|
|
177
|
+
assert(false);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Fetch the next patch
|
|
181
|
+
$patchIdx++;
|
|
182
|
+
if ($patchIdx >= \count($this->patches)) {
|
|
183
|
+
// No more patches. However, we still need to adjust position.
|
|
184
|
+
$patchPos = \PHP_INT_MAX;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
$posDelta += $localPosDelta;
|
|
192
|
+
}
|
|
193
|
+
return $tokens;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Fixup line and position information in errors.
|
|
198
|
+
*
|
|
199
|
+
* @param Error[] $errors
|
|
200
|
+
*/
|
|
201
|
+
private function fixupErrors(array $errors): void {
|
|
202
|
+
foreach ($errors as $error) {
|
|
203
|
+
$attrs = $error->getAttributes();
|
|
204
|
+
|
|
205
|
+
$posDelta = 0;
|
|
206
|
+
$lineDelta = 0;
|
|
207
|
+
foreach ($this->patches as $patch) {
|
|
208
|
+
list($patchPos, $patchType, $patchText) = $patch;
|
|
209
|
+
if ($patchPos >= $attrs['startFilePos']) {
|
|
210
|
+
// No longer relevant
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if ($patchType === 'add') {
|
|
215
|
+
$posDelta += strlen($patchText);
|
|
216
|
+
$lineDelta += substr_count($patchText, "\n");
|
|
217
|
+
} elseif ($patchType === 'remove') {
|
|
218
|
+
$posDelta -= strlen($patchText);
|
|
219
|
+
$lineDelta -= substr_count($patchText, "\n");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
$attrs['startFilePos'] += $posDelta;
|
|
224
|
+
$attrs['endFilePos'] += $posDelta;
|
|
225
|
+
$attrs['startLine'] += $lineDelta;
|
|
226
|
+
$attrs['endLine'] += $lineDelta;
|
|
227
|
+
$error->setAttributes($attrs);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|