Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Added check for isDevMode in the security plugin #144

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
* text=auto
*.php text eol=lf

tests/ export-ignore
build/ export-ignore
.github/ export-ignore
tests/ export-ignore
build/ export-ignore
.github/ export-ignore

.mergify.yml export-ignore
.php_cs export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
codecov.yml export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
infection.json.dist export-ignore
CONTRIBUTING.md export-ignore
README.md export-ignore
.changelog export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.mergify.yml export-ignore
.nvmrc export-ignore
.php_cs export-ignore
.phpunit.xdebug.filter export-ignore
.textlintrc export-ignore
.travis.yml export-ignore
appveyor.yml export-ignore
CONTRIBUTING.md export-ignore
infection.json.dist export-ignore
package.json export-ignore
package-lock.json export-ignore
phpstan.neon export-ignore
phpunit.xml.dist export-ignore
psalm.xml export-ignore
7 changes: 4 additions & 3 deletions .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: 7.2
- run: composer global require narrowspark/coding-standard:3.1.0 --no-interaction --prefer-dist --no-progress --profile --no-suggest --optimize-autoloader
php-version: 7.3
extension-csv: mbstring, xml, ctype, iconv, zip, dom, fileinfo
- run: composer global require narrowspark/automatic-composer-prefetcher:dev-master narrowspark/coding-standard:3.2.0 --no-interaction --no-progress --profile --no-suggest --optimize-autoloader
- name: 'lint php code'
run: |
cd $GITHUB_WORKSPACE
/home/runner/.composer/vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation
/home/runner/.composer/vendor/bin/php-cs-fixer fix --config=$GITHUB_WORKSPACE/.php_cs -v --dry-run --stop-on-violation
23 changes: 23 additions & 0 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Mutation testing'

on:
push:
paths:
- '**.php'
pull_request:
paths:
- '**.php'

jobs:
php-cs-fixer:
name: 'Infection'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: 7.2
- run: composer install
- name: 'mutation tests'
run: ulimit -n 4096 && phpdbg -qrr ./vendor/bin/infection -vvv --min-msi=40 --min-covered-msi=60
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: 'Static analyzing with phpstan'
name: 'Static analyzing'

on: [push, pull_request]
on:
push:
paths:
- '**.php'
pull_request:
paths:
- '**.php'

jobs:
php-cs-fixer:
Expand Down
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $config = new Config($header, [
],
'comment_to_phpdoc' => false,
'final_class' => false,
'heredoc_indentation' => false,
'PhpCsFixerCustomFixers/no_commented_out_code' => false,
]);

Expand Down
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ jobs:
# script:
# - composer psalm

- stage: Mutation
php: 7.2
env: REMOVE_XDEBUG=true SETUP=high COMPOSER_VERSION=1.9.0
script:
- ulimit -n 4096 && phpdbg -qrr ./vendor/bin/infection -vvv --min-msi=40 --min-covered-msi=60

- stage: Coverage
php: 7.2
env: REMOVE_XDEBUG=false SETUP=high COMPOSER_VERSION=1.9.0
Expand Down
24 changes: 12 additions & 12 deletions build/update-mirror-classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@

$fs = new Filesystem();

foreach (MirrorSettings::OUTPUT_LIST as $path => $namspace) {
$fs->remove($rootDir . \DIRECTORY_SEPARATOR . $path);
}

$comment = MirrorSettings::COMMENT_STRING;

$regex = '/namespace ([a-zA-z]*)/s';
$aliasList = [];

foreach (MirrorSettings::MIRROR_LIST as $path => $settings) {
foreach (MirrorSettings::OUTPUT_LIST as $outputPath => $namespace) {
foreach (MirrorSettings::MIRROR_LIST as $list) {
$outputSettings = $list['output'];

// remove output folder before creating new files.
$fs->remove($rootDir . \DIRECTORY_SEPARATOR . $outputSettings['path']);

$preparedOutputPath = \str_replace("/{$settings['path']}/", '/' . $outputPath.$settings['path'] . '/', $path);
foreach ($list['mirror_list'] as $path => $settings) {
$preparedOutputPath = \str_replace("/{$settings['path']}/", '/' . $outputSettings['path'].$settings['path'] . '/', $path);

$fs->copy($path, $preparedOutputPath, true);

$content = \file_get_contents($preparedOutputPath);
$content = \str_replace(["\nclass", "\nabstract class", "\ninterface"], ["\n{$comment}\nclass", "\n{$comment}\nabstract class", "\n{$comment}\ninterface"], $content);

$mirrorContent = \str_replace($settings['namespace'], $namespace, $content);
$mirrorContent = \str_replace($settings['namespace'], $outputSettings['namespace'], $content);

\preg_match($regex, $content, $matches, \PREG_OFFSET_CAPTURE, 0);
\preg_match($regex, $mirrorContent, $mirrorMatches, \PREG_OFFSET_CAPTURE, 0);
\preg_match('/(abstract class |final class |class |interface |trait )([A-z]*)/s', $content, $classMatches, \PREG_OFFSET_CAPTURE, 0);

if (! array_key_exists($outputPath, $aliasList)) {
$aliasList[$outputPath] = [];
if (! array_key_exists($outputSettings['path'], $aliasList)) {
$aliasList[$outputSettings['path']] = [];
}

$aliasList[$outputPath][] = '\class_alias(' . $mirrorMatches[1][0] . '\\' . $classMatches[2][0] . '::class, ' . $matches[1][0] . '\\' . $classMatches[2][0] . '::class);' . "\n";
$aliasList[$outputSettings['path']][] = 'class_alias(' . $mirrorMatches[1][0] . '\\' . $classMatches[2][0] . '::class, ' . $matches[1][0] . '\\' . $classMatches[2][0] . '::class);' . "\n";

$fs->dumpFile($preparedOutputPath, $mirrorContent);

Expand All @@ -73,7 +73,7 @@
foreach ($aliasList as $output => $aliases) {
$preparedOutputPath = 'src/'.rtrim($output, '/').'/alias.php';

$fs->dumpFile($rootDir . DIRECTORY_SEPARATOR . $preparedOutputPath, "<?php\n\ndeclare(strict_types=1);\n\n" . $header . "\n\n" . implode('', $aliases));
$fs->dumpFile($rootDir . DIRECTORY_SEPARATOR . $preparedOutputPath, "<?php\n\ndeclare(strict_types=1);\n\n" . $header . "\n\nuse function class_alias;" . "\n\n" . implode('', $aliases));

echo "Dumped {$preparedOutputPath}.\n";
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"nyholm/nsa": "^1.1.0",
"phpunit/phpunit": "^8.4.1",
"ocramius/package-versions": "^1.4.0 || ^1.5.0",
"narrowspark/coding-standard": "^3.1.0",
"narrowspark/coding-standard": "^3.2.0",
"infection/infection": "^0.13.6",
"slam/phpstan-extensions": "^3.6.1"
},
Expand Down
117 changes: 85 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@textlint-rule/textlint-rule-no-invalid-control-character": "^1.2.0",
"@textlint-rule/textlint-rule-no-unmatched-pair": "^1.0.7",
"@textlint-rule/textlint-rule-preset-google": "^0.1.2",
"textlint": "^11.4.0",
"textlint": "^11.5.0",
"textlint-rule-abbr-within-parentheses": "^1.0.2",
"textlint-rule-alex": "^1.3.1",
"textlint-rule-apostrophe": "^1.0.0",
Expand Down
2 changes: 2 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
<directory>./vendor</directory>
<directory>./tests</directory>
<directory>./src/Prefetcher/Common/</directory>
<directory>./src/Security/Common/</directory>
<file>./src/Prefetcher/alias.php</file>
<file>./src/Security/alias.php</file>
<file>./build/update-mirror-classes.php</file>
</exclude>
</whitelist>
Expand Down
Loading