diff --git a/README.md b/README.md index f7d7f12983..d29af33f9c 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,6 @@ The layer can check on a recipe-level or on an image-level. | oelint | Bitbake recipe linter | https://github.com/priv-kweihmann/oelint-adv | | | x | x | | | | | | | | | | | | | | x | | | x | | perl | Perl warnings check | | | | | x | | | | | | | | | | | | | | x | | x | | | perlcritic | Perl linter | https://metacpan.org/pod/perlcritic | | | | x | | | | | | | | | | | | | | x | | x | | -| phpcodefixer | Find deprecated PHP functions | https://github.com/wapmorgan/PhpCodeFixer | meta-oe, manual enable | x | | x | | | | | | x | | | | | | | | | | x | | | phpcodesniffer | PHP Js and CSS linter | https://github.com/squizlabs/PHP_CodeSniffer | meta-oe, manual enable | x | | x | | | | | | x | | | | | | | | | | | | | phpmd | PHP Linter | https://github.com/phpmd/phpmd | meta-oe, manual enable | x | | x | | | | | | x | | | | | | | | | | x | x | | phpsecaudit | Find vulnerabilities in PHP code | https://github.com/FloeDesignTechnologies/phpcs-security-audit | meta-oe, manual enable | x | | x | | | | | | x | | | | | | | | | x | | | @@ -313,7 +312,6 @@ each tool does have it's own benefits and flaws so don't be mad if you have 10k+ - [oelint](docs/conf/module/oelint.md) - [perl](docs/conf/module/perl.md) - [perlcritic](docs/conf/module/perlcritic.md) - - [phpcodefixer](docs/conf/module/phpcodefixer.md) - [phpcodesniffer](docs/conf/module/phpcodesniffer.md) - [phpmd](docs/conf/module/phpmd.md) - [phpsecaudit](docs/conf/module/phpsecaudit.md) diff --git a/classes/sca-blacklist.bbclass b/classes/sca-blacklist.bbclass index 9f06f8e248..6a60db0d59 100644 --- a/classes/sca-blacklist.bbclass +++ b/classes/sca-blacklist.bbclass @@ -40,7 +40,6 @@ SCA_BLACKLIST_mypy ?= "linux-.*" SCA_BLACKLIST_nixauditor ?= "" SCA_BLACKLIST_oclint ?= "linux-.*" SCA_BLACKLIST_oelint ?= "" -SCA_BLACKLIST_phpcodefixer ?= "" SCA_BLACKLIST_phpcodesniffer ?= "" SCA_BLACKLIST_phpmd ?= "" SCA_BLACKLIST_phpsecaudit ?= "" diff --git a/classes/sca-global.bbclass b/classes/sca-global.bbclass index f7e213ed99..9a155cd796 100644 --- a/classes/sca-global.bbclass +++ b/classes/sca-global.bbclass @@ -151,7 +151,6 @@ SCA_AVAILABLE_MODULES ?= "\ " # additional layer requirements SCA_AVAILABLE_MODULES[inspec] = "openembedded-layer rubygems" -SCA_AVAILABLE_MODULES[phpcodefixer] = "openembedded-layer" SCA_AVAILABLE_MODULES[phpcodesniffer] = "openembedded-layer" SCA_AVAILABLE_MODULES[phpmd] = "openembedded-layer" SCA_AVAILABLE_MODULES[phpsecaudit] = "openembedded-layer" diff --git a/classes/sca-on-recipe.bbclass b/classes/sca-on-recipe.bbclass index cd88afdf39..c831b85dec 100755 --- a/classes/sca-on-recipe.bbclass +++ b/classes/sca-on-recipe.bbclass @@ -43,7 +43,6 @@ SCA_ENABLED_MODULES_RECIPE ?= "\ oelint \ perl \ perlcritic \ - phpcodefixer \ phpcodesniffer \ phpmd \ phpsecaudit \ diff --git a/classes/sca-phpcodefixer.bbclass b/classes/sca-phpcodefixer.bbclass deleted file mode 100755 index 95c4104548..0000000000 --- a/classes/sca-phpcodefixer.bbclass +++ /dev/null @@ -1,103 +0,0 @@ -## SPDX-License-Identifier: BSD-2-Clause -## Copyright (c) 2019, Konrad Weihmann - -## Add ids to suppress on a recipe level -SCA_PHPCODEFIXER_EXTRA_SUPPRESS ?= "" -## Add ids to lead to a fatal on a recipe level -SCA_PHPCODEFIXER_EXTRA_FATAL ?= "" -SCA_PHPCODEFIXER_FILE_FILTER ?= ".php" -## Set explicit php-version to be checked against, default auto pick -SCA_PHPCODEFIXER_PHP_VERSION ?= "" - -SCA_RAW_RESULT_FILE[phpcodefixer] = "json" - -inherit sca-conv-to-export -inherit sca-datamodel -inherit sca-global -inherit sca-helper -inherit sca-suppress -inherit sca-image-backtrack -inherit sca-tracefiles - -def do_sca_conv_phpcodefixer(d): - import os - import json - - package_name = d.getVar("PN") - buildpath = d.getVar("SCA_SOURCES_DIR") - - _findings = [] - _suppress = sca_suppress_init(d, "SCA_PHPCODEFIXER_EXTRA_SUPPRESS", - d.expand("${STAGING_DATADIR_NATIVE}/phpcodefixer-${SCA_MODE}-suppress")) - - if os.path.exists(sca_raw_result_file(d, "phpcodefixer")): - content = [] - with open(sca_raw_result_file(d, "phpcodefixer"), "r") as f: - try: - content = json.load(f) - except json.JSONDecodeError: - content = {"problems": []} - for m in content["problems"]: - try: - g = sca_get_model_class(d, - PackageName=package_name, - BuildPath=buildpath, - Tool="phpcodefixer", - File=os.path.join(m["path"], m["file"]), - Line=str(m["line"]), - Message="{}: {} since PHP version {}".format(m["type"], m["category"], m["version"]), - ID=m["checker"], - Severity="error") - if _suppress.Suppressed(g): - continue - if g.Scope not in clean_split(d, "SCA_SCOPE_FILTER"): - continue - if g.Severity in sca_allowed_warning_level(d): - _findings += sca_backtrack_findings(d, g) - except Exception as exp: - sca_log_note(d, str(exp)) - - sca_add_model_class_list(d, _findings) - return sca_save_model_to_string(d) - -python do_sca_phpcodefixer() { - import os - import subprocess - - ## Run - _args = [os.path.join(d.getVar("STAGING_BINDIR_NATIVE"), "phpcodefixer/vendor/bin/phpdd")] - _args += ["--max-size=1000mb"] - _args += ["--output-json=-"] - _args += ["--ansi"] - if d.getVar("SCA_PHPCODEFIXER_PHP_VERSION"): - _args += ["--target={}".format(d.getVar("SCA_PHPCODEFIXER_PHP_VERSION"))] - _args += ["-n"] - - _files = get_files_by_extention_or_shebang(d, d.getVar("SCA_SOURCES_DIR"), ".*php", [".php"], \ - sca_filter_files(d, d.getVar("SCA_SOURCES_DIR"), clean_split(d, "SCA_FILE_FILTER_EXTRA"))) - - cmd_output = exec_wrap_check_output(d, _args, _files, combine=exec_wrap_combine_json_subarray, key="problems", - default_val={"problems": []}) - - with open(sca_raw_result_file(d, "phpcodefixer"), "w") as o: - o.write(cmd_output) -} - -python do_sca_phpcodefixer_report() { - import os - ## Create data model - d.setVar("SCA_DATAMODEL_STORAGE", "{}/phpcodefixer.dm".format(d.getVar("T"))) - dm_output = do_sca_conv_phpcodefixer(d) - with open(d.getVar("SCA_DATAMODEL_STORAGE"), "w") as o: - o.write(dm_output) - - sca_task_aftermath(d, "phpcodefixer", get_fatal_entries(d, "SCA_PHPCODEFIXER_EXTRA_FATAL", - d.expand("${STAGING_DATADIR_NATIVE}/phpcodefixer-${SCA_MODE}-fatal"))) -} - -do_sca_phpcodefixer[doc] = "Lint php scripts with phpcodefixer in workspace" -do_sca_phpcodefixer_report[doc] = "Report findings of do_sca_phpcodefixer" -addtask do_sca_phpcodefixer after do_configure before do_sca_tracefiles -addtask do_sca_phpcodefixer_report after do_sca_tracefiles before do_sca_deploy - -DEPENDS += "phpcodefixer-native sca-recipe-phpcodefixer-rules-native" diff --git a/docs/conf/module/phpcodefixer.md b/docs/conf/module/phpcodefixer.md deleted file mode 100644 index 005cc9f2e3..0000000000 --- a/docs/conf/module/phpcodefixer.md +++ /dev/null @@ -1,62 +0,0 @@ -# Configuration for phpcodefixer - -## Supported environments/languages - -* PHP - -## Configuration - -| var | purpose | type | default | -| ------------- |:-------------:| -----:| -----: -| SCA_BLACKLIST_phpcodefixer | Blacklist filter for this tool | space-separated-list | "" -| SCA_PHPCODEFIXER_EXTRA_FATAL | Extra error-IDs leading to build termination when found | space-separated-list | "": -| SCA_PHPCODEFIXER_EXTRA_SUPPRESS | Extra error-IDs to be suppressed | space-separated-list | "" -| SCA_PHPCODEFIXER_FILE_FILTER | File extensions to check | space-separated-list | ".php" -| SCA_PHPCODEFIXER_PHP_VERSION | Explicitly set a PHP version to check against. Leave empty for auto-detect | version string in format x.y or empty | "" - -## Supports - -* [x] suppression of IDs -* [x] terminate build on fatal -* [x] run on recipe -* [ ] run on image -* [ ] run with SCA-layer default settings (see SCA_AVAILABLE_MODULES) - -## Requires - -* [x] requires online access - -## Known error-IDs - -__tbd__ - -## Checking scope - -* [x] security -* [ ] functional defects -* [ ] compliance -* [ ] style issues - -## Statistics - -* ⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜ 04/10 Build Speed -* ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ 10/10 Execution Speed -* ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜ 09/10 Quality - -## Score mapping - -### Error considered as security relevant - -* phpcodefixer.phpcodefixer.* - -### Error considered as functional defect - -* n.a. - -### Error consired as compliance issue - -* n.a. - -### Error considered as style issue - -* n.a. diff --git a/files/module_list.csv b/files/module_list.csv index 16c163fcd0..8ee0be10bb 100644 --- a/files/module_list.csv +++ b/files/module_list.csv @@ -39,7 +39,6 @@ nixauditor,Auditing tool for images,https://github.com/XalfiE/Nix-Auditor,,,x,,, oelint,Bitbake recipe linter,https://github.com/priv-kweihmann/oelint-adv,,,x,x,,,,,,,,,,,,,,x,,,x perl,Perl warnings check,,,,,x,,,,,,,,,,,,,,x,,x, perlcritic,Perl linter,https://metacpan.org/pod/perlcritic,,,,x,,,,,,,,,,,,,,x,,x, -phpcodefixer,Find deprecated PHP functions,https://github.com/wapmorgan/PhpCodeFixer,"meta-oe, manual enable",x,,x,,,,,,x,,,,,,,,,,x, phpcodesniffer,PHP Js and CSS linter,https://github.com/squizlabs/PHP_CodeSniffer,"meta-oe, manual enable",x,,x,,,,,,x,,,,,,,,,,, phpmd,PHP Linter,https://github.com/phpmd/phpmd,"meta-oe, manual enable",x,,x,,,,,,x,,,,,,,,,,x,x phpsecaudit,Find vulnerabilities in PHP code,https://github.com/FloeDesignTechnologies/phpcs-security-audit,"meta-oe, manual enable",x,,x,,,,,,x,,,,,,,,,x,, diff --git a/recipes-sca-rules/sca-recipe-phpcodefixer-rules-native/files/fatal b/recipes-sca-rules/sca-recipe-phpcodefixer-rules-native/files/fatal deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-phpcodefixer-rules-native/files/suppress b/recipes-sca-rules/sca-recipe-phpcodefixer-rules-native/files/suppress deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-phpcodefixer-rules-native/sca-recipe-phpcodefixer-rules-native_1.0.bb b/recipes-sca-rules/sca-recipe-phpcodefixer-rules-native/sca-recipe-phpcodefixer-rules-native_1.0.bb deleted file mode 100755 index 1a66547eed..0000000000 --- a/recipes-sca-rules/sca-recipe-phpcodefixer-rules-native/sca-recipe-phpcodefixer-rules-native_1.0.bb +++ /dev/null @@ -1,19 +0,0 @@ -SUMMARY = "SCA ruleset for phpcodefixer at recipes" -DESCRIPTION = "Rules to configure how phpcodefixer is affecting the build" - -DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}" -LICENSE = "BSD-2-Clause" -LIC_FILES_CHKSUM = "file://${SCA_LAYERDIR}/LICENSE;md5=a4a2bbea1db029f21b3a328c7a059172" - -SRC_URI = "file://suppress \ - file://fatal" - -inherit native - -do_install() { - install -d "${D}${datadir}" - install "${WORKDIR}/fatal" "${D}${datadir}/phpcodefixer-recipe-fatal" - install "${WORKDIR}/suppress" "${D}${datadir}/phpcodefixer-recipe-suppress" -} - -FILES:${PN} = "${datadir}" diff --git a/recipes-sca/phpcodefixer-native/files/phpcodefixer.sca.description b/recipes-sca/phpcodefixer-native/files/phpcodefixer.sca.description deleted file mode 100644 index eb81ab19f8..0000000000 --- a/recipes-sca/phpcodefixer-native/files/phpcodefixer.sca.description +++ /dev/null @@ -1,27 +0,0 @@ -{ - "buildspeed": 4, - "execspeed": 10, - "languages": [ - "php" - ], - "uses": [ - "@php" - ], - "quality": 9, - "scope": [ - "security" - ], - "score": { - "security": [ - "phpcodefixer.phpcodefixer..*" - ] - }, - "test": { - "findings": [ - "bad-php" - ], - "no-findings": [ - "busybox" - ] - } -} \ No newline at end of file diff --git a/recipes-sca/phpcodefixer-native/phpcodefixer-native_2.0.26.bb b/recipes-sca/phpcodefixer-native/phpcodefixer-native_2.0.26.bb deleted file mode 100755 index eef4ccf5bc..0000000000 --- a/recipes-sca/phpcodefixer-native/phpcodefixer-native_2.0.26.bb +++ /dev/null @@ -1,25 +0,0 @@ -SUMMARY = "PHP code analyzer" -DESCRIPTION = "Analyzer of PHP code to search issues with deprecated functionality in newer interpreter versions" -HOMEPAGE = "https://github.com/wapmorgan/PhpCodeFixer" - -DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}" -LICENSE = "BSD-3-Clause" -LIC_FILES_CHKSUM = "file://LICENSE;md5=c98596cdc7ad2b3b9a3a84255a83cb9f" - -SRC_URI = "git://github.com/wapmorgan/PhpCodeFixer.git;branch=master;protocol=https" -SRCREV = "7120d33f0ffe7a4bb140aaf454b6b4b9c1dddc98" -PHPCOMPOSER_PKGS_NAME = "wapmorgan/php-code-fixer:${PV}" - -S = "${WORKDIR}/git" - -inherit phpcomposer -inherit sca-description -inherit native - -SCA_TOOL_DESCRIPTION = "phpcodefixer" - -do_compile:prepend() { - rm -f ${S}/composer.json ${S}/composer.lock -} - -FILES:${PN} = "${bindir}" diff --git a/test/lang_metaoe.txt b/test/lang_metaoe.txt index d216c1ec7e..0a78dd5c07 100644 --- a/test/lang_metaoe.txt +++ b/test/lang_metaoe.txt @@ -1,4 +1,3 @@ -phpcodefixer phpcodesniffer phpmd phpsecaudit