Search This Blog

2018/02/03

IE/Edge only show # because XSS filter(X-XSS-Protection)

If a cross-site scripting attack is detected, the IE will sanitize the page and only show a "#" as default header.

X-XSS-Protection: 0

Disables XSS filtering.

X-XSS-Protection: 1

Enables XSS filtering(usually default in browsers), sanitize the page.

X-XSS-Protection: 1; mode=block

Enables XSS filtering, prevent rendering of the page if an attack is detected.

X-XSS-Protection: 1; report=<reporting-uri>

Enables XSS filtering, sanitize the page and report the violation. This uses the functionality of the CSP report-uri directive to send a report.

In PHP

header("X-XSS-Protection: 1; mode=block");

By .htaccess

<IfModule mod_headers.c>
  Header set X-XSS-Protection "1; mode=block"
</IfModule>

Controlling the XSS Filter(Microsoft)
X-XSS-Protection(MDN)

2018/01/19

how to use phpdocument使用方法

環境準備Prepare
By yum
$ sudo yum -y install php-pear php-xml
$ sudo pear channel-discover pear.phpdoc.org
$ sudo pear install -a phpdoc/phpDocumentor
$ sudo yum install php-intl
$ sudo yum install graphviz (option)
By composer
$ sudo php composer.phar require phpdocumentor/phpdocumentor


php.ini設定
date.timezone = 'Asia/Tokyo'

生成
cd /path/to/root/of/project
phpdoc -c app/phpdoc.xml --template="clean"
phpdoc -d /path/to/source/folder
phpdoc -t /path/to/file

-c: 設定ファイルを利用すること
default config: phpdoc.dist.xml

phpdoc template:list
* abstract
* checkstyle
* clean
* new-black
* old-ocean
* responsive
* responsive-twig
* xml
* zend

Sample of phpdoc.xml

2018/01/13

blogspot: data for title

site name + post title
<data:blog.pageTitle/>

post title
<data:view.title.escaped/>

2018/01/06

Mock assert function | PHPUnit

mixed is ...

メソッド 意味
assertNull($var) $varがNULLである
assertEquals($val1, $val2) $val1が$val2と等しい
assertSame($val1, $val2) $val1と$val2が型も含めて等しい
assertInternalType($type, $val) $valの型名が$typeである

number is ...

メソッド 意味
assertGreaterThan($expect, $var) $expect < $var が成立する
assertGreaterThanOrEqual($expect, $var) $expect <= $var が成立する
assertLessThan($expect, $var) $expect > $var が成立する
assertLessThanOrEqual($expect, $var) $expect >= $var が成立する

string is ...

メソッド 意味
assertJsonStringEqualsJsonString($str1, $str2) $str1と$str2がjsonとして等しい
assertRegExp($ptn, $str) $strが正規表現$ptnにマッチする

boolean is ...

メソッド 意味
assertTrue($var) $varがTRUEである
assertFalse($var) $varがFALSEである

array is ...

メソッド 意味
assertArrayHasKey($key, $array) 配列$arrayにキー$keyが存在する
assertContains($val, $array) 配列$arrayに値$valが存在する
assertContainsOnly($type, $array) 配列$arrayの値の型がすべて$typeである
assertCount($count, $array) 配列$arrayの値の数が$countである
assertEmpty($array) 配列$arrayが空である

object/class is ...

メソッド 意味
assertObjectHasAttribute($attr, $object) オブジェクト$objectにプロパティ変数$attrが存在する
assertClassHasAttribute($attr, $class) クラス名$classにプロパティ変数$attrが存在する
assertClassHasStaticAttribute($attr, $class) クラス名$classに静的プロパティ変数$attrが存在する
assertInstanceOf($class, $instance) $instanceがクラス名$classのインスタンスである

file is ...

メソッド 意味
assertFileExists($file) $fileが存在する
assertFileEquals($file1, $file2) $file1と$file2の内容が等しい
assertJsonFileEqualsJsonFile($file1, $file2) $file1と$file2の内容がjsonとして等しい
assertJsonStringEqualsJsonFile($file1, $json) $file1の内容と$jsonがjsonとして等しい

2017/12/04

Vagrant:不要なboxを削除

boxを確認する
vagrant box list
vagrant global-status

例:
centos/7 (virtualbox, 1705.01)
centos/7 (virtualbox, 1707.01)
centos/7 (virtualbox, 1710.01)

1705.01のバージョンを削除する
vagrant box remove centos/7 --box-version 1705.01

強制的に、下記のオプションを付ける
-f / --force

全部削除
vagrant box isremove centos/7 --all