exakat.1.6.6 Review
exakat 1.6.6出生于迈阿密,在阳光下,在阳光PHP 19.会议非常精力充沛,并且在与会者的帮助下,它为一些有趣的更新提供了灵感:PHP支持带有逻辑运营商的字符串(适用于安全性); Exakat评论Typehint并检查它们是否足够了。 Avast,Me Hearties,到Exakat 1.6.6评论!
不足的类型不足
typehint是用于参数的配置:它指定了传入数据的类型,以便其方法和属性在代码中提前已知。例如 :
<?php interface i { function foo() ; } class x implements i { function foo() { return 1;} function bar() { return 2;} } function foobar(i $x) { echo $x->foo(); } ?>
As you can read above, $x
is now an object whose class implements the i
interface : in the script above, this means that the method foo
is implemented. This way, it is possible to check that the incoming argument $x
has the pre-requisite to be used in the function foobar
.
Typehinting是改进代码的键入策略的一部分,仅检查是否已实现正确的接口。它没有’t检查实际使用的方法,因为它不是强制性的。它也没有’t check that any other
method is used, as is illustrated below, based on the previous script.
<?php interface i { function foo() ; } class x implements i { function foo() { return 1;} function bar() { return 2;} } function foobar(i $x) { echo $x->foo(); echo $x->bar(); // This is a new call } ?>
The call to the method bar
was added to the foobar
function, and if the object is an x
object, then bar
is indeed a method of this object. Yet, the typehint only requires the interface i
to be displayed. As such, an implementation of i
without bar
would end the application on a fatal error.
exakat中的当前分析检查是否真实定义了与参数使用的方法。目前跳过未定义的接口。这应该有助于发现尝试在一些额外的方法中潜行的代码拨打电话:其他类被使用的维护日将是痛苦的一天。
感谢Brandon Savage为灵感!
带有字符串的按位运算符
Bitwise operators are &
, |
, ^
和 ~
. They work on data as a bit field, and return a integer, while their close cousin &&
, ||
, 和
, or
, xor
make logical combinations, and return a boolean.
较少所知道的是按位运算符也使用字符串。当两个操作数是字符串时,PHP将字符转换为数字,应用转换,然后将结果转回字符串。看看 脚本生活 上 3v4l.org. ;
<?php echo 'a' ^ 'Z', PHP_EOL; echo 'a', ord('a'), PHP_EOL; echo 'Z', ord('Z'), PHP_EOL; echo '90 ^ 97', 90 ^ 97, PHP_EOL; echo ';', ord(';'), PHP_EOL; ?>
The semicolon (ASCII 59) is the result of the xor applied on a
(ASCII 90) and Z
(ASCII 97).
这不是常见的用法,但此PHP功能是混淆代码的好方法,以及隐藏可能包含敏感名称的字符串。像这样 :
<?php $_="`{{{" ^ "?<>/"; ${$_} ?>
The xor
上 the first two strings produces the string _GET
, which, in turn, may be used as a base to access PHP superglobals.
请注意,上面的线不会’t contain any alphabetical characters, leading to hard to grep code. Yet, it works its way to produce a reference to $_GET
, and from there, open access to injections.
感谢Chris Cornutt指出这个脚本。这导致升级exakat引擎,使得按位运算符现在可以正确处理字符串,在处理整数的顶部。我们将使用这些新工具升级安全性分析。
PHP 7.3.2. 错误修复
上周, PHP 7.3.2. 和 PHP 7.2.15 were released.
当您想知道PHP补丁版本可能对代码产生影响,运行审核,并打开大使报告。在该部分‘Audit log’,有一个名为的条目‘Bugfixes’。它报告了审计代码中找到的函数和扩展,并修复。

这为PHP补丁对代码上的任何潜在影响提供了精确的审查。有时候,你必须在臭虫上工作来使它工作,并且是从这个暴政中释放的好消息。
每周审计:2019,周#08
exakat包括A.‘weekly’报告:此报告采用五项分析为构建。这意味着短暂的审计报告,几乎没有问题审查。读取它们并不是很多,并在代码中查看它们。 PHP社区中的每个人都可以专注于一个经典的编码问题并解决它。谈谈周围的每周审计:你’LL找到面临同样挑战的程序员。
获得‘weekly’审核,运行审计,请求‘Weekly’ report.
# Init the project (skip when it is already done)
php exakat.phar init -p <yourproject> -R //github.com/Seldaek/monolog.git -git
# Run the project (skip when it is already done)
php exakat.phar project -p <yourproject>
# Export the weekly project (every monday)
php exakat.phar report -p <yourproject> -format Weekly
# Open projects/<yourproject>/weekly/index.html in your browser
每周,您可以在此找到5个新分析,以便在您的代码中审查。事实上,当您的代码干净时,您也可以快速查看即将到来的
每周 recommendations for PHP code review : 2018, week 2019-07
- 未解决的instanceof. :instanceof运算符不会’T确认是否存在比较类。
- 带有奇怪空间的字符串 :不可见的空间可能会误认为是正常空间。
- list()可以省略变量 :只需省略列表()调用中的任何未使用的变量。
- 与concat的回声 : Optimize your
echo
‘s by not concatenating atecho
time, but serving all argument separated. - 不变的课程 :仅由常数组成的类或界面。
快乐的PHP代码评论
所有356个分析仪都介绍在文档中,包括不可避免的: 避免可选属性:避免可选属性,以防止使用存在检查乱丢代码。
它是代码中常见的过度劳累来源:74%的应用程序正在为此误导的代码落下。
您可以查看图库中的所有exakat报告: exakat画廊.
下载exakat.io,安装它 Docker. ,升级它‘exakat.phar升级-u’ and like us on GitHub. .