diff --git a/README.md b/README.md index 8b3962b9e4..77327c54ae 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 | | -| 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 | | | | phpstan | PHP linter | https://github.com/phpstan/phpstan | meta-oe, manual enable | x | | x | | | | | | x | | | | | | | | | | | x | | pkgqaenc | Enhanced package QA | | | | | x | | | | | | | | | | | | | x | | x | | | @@ -311,7 +310,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) - - [phpmd](docs/conf/module/phpmd.md) - [phpsecaudit](docs/conf/module/phpsecaudit.md) - [phpstan](docs/conf/module/phpstan.md) - [pkgqaenc](docs/conf/module/pkgqaenc.md) diff --git a/classes/sca-blacklist.bbclass b/classes/sca-blacklist.bbclass index ced2d86d84..17926006ef 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_phpmd ?= "" SCA_BLACKLIST_phpsecaudit ?= "" SCA_BLACKLIST_phpstan ?= "" SCA_BLACKLIST_proselint ?= "" diff --git a/classes/sca-global.bbclass b/classes/sca-global.bbclass index 58595ce168..2f6d8ffc09 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[phpmd] = "openembedded-layer" SCA_AVAILABLE_MODULES[phpsecaudit] = "openembedded-layer" SCA_AVAILABLE_MODULES[phpstan] = "openembedded-layer" SCA_AVAILABLE_MODULES[pyright] = "openembedded-layer" diff --git a/classes/sca-on-recipe.bbclass b/classes/sca-on-recipe.bbclass index 0ce677410a..34bc82f02e 100755 --- a/classes/sca-on-recipe.bbclass +++ b/classes/sca-on-recipe.bbclass @@ -43,7 +43,6 @@ SCA_ENABLED_MODULES_RECIPE ?= "\ oelint \ perl \ perlcritic \ - phpmd \ phpsecaudit \ phpstan \ pkgqaenc \ diff --git a/classes/sca-phpmd.bbclass b/classes/sca-phpmd.bbclass deleted file mode 100755 index 5ec4f96fbb..0000000000 --- a/classes/sca-phpmd.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_PHPMD_EXTRA_SUPPRESS ?= "" -## Add ids to lead to a fatal on a recipe level -SCA_PHPMD_EXTRA_FATAL ?= "" -SCA_PHPMD_FILE_FILTER ?= ".php .phtml" -SCA_PHPMD_CHECKS ?= "codesize cleancode controversial naming unusedcode design" - -SCA_RAW_RESULT_FILE[phpmd] = "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_phpmd(d): - import os - import json - import hashlib - - package_name = d.getVar("PN") - buildpath = d.getVar("SCA_SOURCES_DIR") - - _findings = [] - _suppress = sca_suppress_init(d, "SCA_PHPMD_EXTRA_SUPPRESS", - d.expand("${STAGING_DATADIR_NATIVE}/phpmd-${SCA_MODE}-suppress")) - - if os.path.exists(sca_raw_result_file(d, "phpmd")): - content = [] - with open(sca_raw_result_file(d, "phpmd"), "r") as f: - try: - content = json.load(f) - except json.JSONDecodeError: - content = {"files": []} - for f in content["files"]: - for m in f["violations"]: - try: - g = sca_get_model_class(d, - PackageName=package_name, - BuildPath=buildpath, - Tool="phpmd", - File=f["file"], - Line=str(m["beginLine"]), - Message=m["description"], - ID=m["rule"], - Severity="warning") - 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_phpmd() { - import os - import subprocess - - ## Run - _args = [os.path.join(d.getVar("STAGING_BINDIR_NATIVE"), "phpmd/vendor/bin/phpmd")] - - _files = get_files_by_extention_or_shebang(d, d.getVar("SCA_SOURCES_DIR"), ".*php", d.getVar("SCA_PHPMD_FILE_FILTER"), \ - sca_filter_files(d, d.getVar("SCA_SOURCES_DIR"), clean_split(d, "SCA_FILE_FILTER_EXTRA"))) - - _args += [",".join(_files)] - _args += ["json"] - _args += [",".join(clean_split(d, "SCA_PHPMD_CHECKS"))] - _args += ["--suffixes", ",".join([x.lstrip(".") for x in clean_split(d, "SCA_PHPMD_FILE_FILTER")])] - - cmd_output = exec_wrap_check_output(d, _args, _files, combine=exec_wrap_combine_json_subarray, key="files", - default_val={"files": []}) - - with open(sca_raw_result_file(d, "phpmd"), "w") as o: - o.write(cmd_output) -} - -python do_sca_phpmd_report() { - import os - ## Create data model - d.setVar("SCA_DATAMODEL_STORAGE", "{}/phpmd.dm".format(d.getVar("T"))) - dm_output = do_sca_conv_phpmd(d) - with open(d.getVar("SCA_DATAMODEL_STORAGE"), "w") as o: - o.write(dm_output) - - sca_task_aftermath(d, "phpmd", get_fatal_entries(d, "SCA_PHPMD_EXTRA_FATAL", - d.expand("${STAGING_DATADIR_NATIVE}/phpmd-${SCA_MODE}-fatal"))) -} - -do_sca_phpmd[doc] = "Lint php scripts with phpmd in workspace" -do_sca_phpmd_report[doc] = "Report findings of do_sca_phpmd" -addtask do_sca_phpmd after do_configure before do_sca_tracefiles -addtask do_sca_phpmd_report after do_sca_tracefiles before do_sca_deploy - -DEPENDS += "phpmd-native sca-recipe-phpmd-rules-native" diff --git a/docs/conf/module/phpmd.md b/docs/conf/module/phpmd.md deleted file mode 100644 index 36cbe5344f..0000000000 --- a/docs/conf/module/phpmd.md +++ /dev/null @@ -1,62 +0,0 @@ -# Configuration for phpmd - -## Supported environments/languages - -* PHP - -## Configuration - -| var | purpose | type | default | -| ------------- |:-------------:| -----:| -----: -| SCA_BLACKLIST_phpmd | Blacklist filter for this tool | space-separated-list | "" -| SCA_PHPMD_EXTRA_FATAL | Extra error-IDs leading to build termination when found | space-separated-list | "": -| SCA_PHPMD_EXTRA_SUPPRESS | Extra error-IDs to be suppressed | space-separated-list | "" -| SCA_PHPMD_FILE_FILTER | File extensions to check | space-separated-list | ".php .phtml" -| SCA_PHPMD_CHECKS | Checks to perform | space-separated-list | "codesize cleancode controversial naming unusedcode design" - -## 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 - -* [ ] security -* [x] functional defects -* [ ] compliance -* [x] style issues - -## Statistics - -* ⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜ 04/10 Build Speed -* ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜ 09/10 Execution Speed -* ⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜ 06/10 Quality - -## Score mapping - -### Error considered as security relevant - -* n.a. - -### Error considered as functional defect - -* phpmd.phpmd.* - -### 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 d1389b677d..c86e0cd2d4 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, -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,, phpstan,PHP linter,https://github.com/phpstan/phpstan,"meta-oe, manual enable",x,,x,,,,,,x,,,,,,,,,,,x pkgqaenc,Enhanced package QA,,,,,x,,,,,,,,,,,,,x,,x,, diff --git a/recipes-sca-rules/sca-recipe-phpmd-rules-native/files/fatal b/recipes-sca-rules/sca-recipe-phpmd-rules-native/files/fatal deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-phpmd-rules-native/files/suppress b/recipes-sca-rules/sca-recipe-phpmd-rules-native/files/suppress deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-phpmd-rules-native/sca-recipe-phpmd-rules-native_1.0.bb b/recipes-sca-rules/sca-recipe-phpmd-rules-native/sca-recipe-phpmd-rules-native_1.0.bb deleted file mode 100755 index 3d7e01b132..0000000000 --- a/recipes-sca-rules/sca-recipe-phpmd-rules-native/sca-recipe-phpmd-rules-native_1.0.bb +++ /dev/null @@ -1,19 +0,0 @@ -SUMMARY = "SCA ruleset for phpmd at recipes" -DESCRIPTION = "Rules to configure how phpmd 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}/phpmd-recipe-fatal" - install "${WORKDIR}/suppress" "${D}${datadir}/phpmd-recipe-suppress" -} - -FILES:${PN} = "${datadir}" diff --git a/recipes-sca/phpmd-native/files/phpmd.sca.description b/recipes-sca/phpmd-native/files/phpmd.sca.description deleted file mode 100644 index 5d95050545..0000000000 --- a/recipes-sca/phpmd-native/files/phpmd.sca.description +++ /dev/null @@ -1,28 +0,0 @@ -{ - "buildspeed": 4, - "execspeed": 9, - "languages": [ - "php" - ], - "uses": [ - "@php" - ], - "quality": 6, - "scope": [ - "functional", - "style" - ], - "score": { - "functional": [ - "phpmd.phpmd..*" - ] - }, - "test": { - "findings": [ - "bad-php" - ], - "no-findings": [ - "busybox" - ] - } -} \ No newline at end of file diff --git a/recipes-sca/phpmd-native/phpmd-native_2.12.0.bb b/recipes-sca/phpmd-native/phpmd-native_2.12.0.bb deleted file mode 100755 index 5210d93608..0000000000 --- a/recipes-sca/phpmd-native/phpmd-native_2.12.0.bb +++ /dev/null @@ -1,25 +0,0 @@ -SUMMARY = "PHP code metrics" -DESCRIPTION = "PHPMD can be seen as an user friendly frontend application for the raw metrics stream measured by PHP Depend" -HOMEPAGE = "https://github.com/phpmd/phpmd" - -DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}" -LICENSE = "BSD-3-Clause" -LIC_FILES_CHKSUM = "file://LICENSE;md5=102189a3104d17e4cdd01198fef36372" - -SRC_URI = "git://github.com/phpmd/phpmd.git;branch=master;protocol=https" -SRCREV = "c0b678ba71902f539c27c14332aa0ddcf14388ec" -PHPCOMPOSER_PKGS_NAME = "phpmd/phpmd:${PV}" - -S = "${WORKDIR}/git" - -inherit phpcomposer -inherit sca-description -inherit native - -SCA_TOOL_DESCRIPTION = "phpmd" - -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 62922428c8..0f6f5354ea 100644 --- a/test/lang_metaoe.txt +++ b/test/lang_metaoe.txt @@ -1,4 +1,3 @@ -phpmd phpsecaudit phpstan pyright