Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
35 / 35
100.00% covered (success)
100.00%
21 / 21
CRAP
100.00% covered (success)
100.00%
1 / 1
TaintednessAccessorsTrait
100.00% covered (success)
100.00%
35 / 35
100.00% covered (success)
100.00%
21 / 21
27
100.00% covered (success)
100.00%
1 / 1
 getTaintednessRaw
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTaintednessRaw
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 getCausedByRaw
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCausedByRef
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFuncCausedByRaw
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setCausedByRaw
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 setCausedByRef
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setFuncCausedByRaw
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMethodLinks
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setMethodLinks
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 getMethodLinksRef
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVarLinks
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 ensureVarLinksForArgExist
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getTaintednessRef
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTaintednessRef
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 clearRefData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFuncTaint
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 doSetFuncTaint
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRetObjs
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 addRetObjs
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 initRetObjs
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php declare( strict_types=1 );
2
3namespace SecurityCheckPlugin;
4
5use Phan\Language\Element\FunctionInterface;
6use Phan\Language\Element\PassByReferenceVariable;
7use Phan\Language\Element\TypedElementInterface;
8
9/**
10 * Accessors to read and write taintedness props stored inside phan objects. This trait exists to avoid duplicating
11 * dynamic property names, to have better type inference, to enable phan checks for undeclared props on the other
12 * files, to keep track of props usage etc.
13 * @phan-file-suppress PhanUndeclaredProperty
14 */
15trait TaintednessAccessorsTrait {
16    /**
17     * @param TypedElementInterface $element
18     * @return Taintedness|null
19     */
20    protected static function getTaintednessRaw( TypedElementInterface $element ): ?Taintedness {
21        return $element->taintedness ?? null;
22    }
23
24    /**
25     * @param TypedElementInterface $element
26     * @param Taintedness $taintedness
27     */
28    protected static function setTaintednessRaw( TypedElementInterface $element, Taintedness $taintedness ): void {
29        $element->taintedness = $taintedness;
30        if ( $element instanceof PassByReferenceVariable ) {
31            self::setTaintednessRef( $element->getElement(), $taintedness );
32        }
33    }
34
35    /**
36     * @param TypedElementInterface $element
37     * @return CausedByLines|null
38     */
39    protected static function getCausedByRaw( TypedElementInterface $element ): ?CausedByLines {
40        return $element->taintedOriginalError ?? null;
41    }
42
43    /**
44     * @param TypedElementInterface $element
45     * @return CausedByLines|null
46     */
47    protected static function getCausedByRef( TypedElementInterface $element ): ?CausedByLines {
48        return $element->taintedOriginalErrorRef ?? null;
49    }
50
51    /**
52     * @param FunctionInterface $func
53     * @return FunctionCausedByLines|null
54     */
55    protected static function getFuncCausedByRaw( FunctionInterface $func ): ?FunctionCausedByLines {
56        return $func->funcTaintedOriginalError ?? null;
57    }
58
59    /**
60     * @param TypedElementInterface $element
61     * @param CausedByLines $lines
62     */
63    protected static function setCausedByRaw( TypedElementInterface $element, CausedByLines $lines ): void {
64        $element->taintedOriginalError = $lines;
65        if ( $element instanceof PassByReferenceVariable ) {
66            self::setCausedByRef( $element->getElement(), $lines );
67        }
68    }
69
70    /**
71     * @param TypedElementInterface $element
72     * @param CausedByLines $lines
73     */
74    protected static function setCausedByRef( TypedElementInterface $element, CausedByLines $lines ): void {
75        $element->taintedOriginalErrorRef = $lines;
76    }
77
78    /**
79     * @param FunctionInterface $func
80     * @param FunctionCausedByLines $lines
81     */
82    protected static function setFuncCausedByRaw( FunctionInterface $func, FunctionCausedByLines $lines ): void {
83        $func->funcTaintedOriginalError = $lines;
84    }
85
86    /**
87     * @param TypedElementInterface $element
88     * @return MethodLinks|null
89     */
90    protected static function getMethodLinks( TypedElementInterface $element ): ?MethodLinks {
91        return $element->taintedMethodLinks ?? null;
92    }
93
94    /**
95     * @param TypedElementInterface $element
96     * @param MethodLinks $links
97     */
98    protected static function setMethodLinks( TypedElementInterface $element, MethodLinks $links ): void {
99        $element->taintedMethodLinks = $links;