diff --git a/README.md b/README.md index 6c4b634ffc..36438a3666 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 | | -| phan | PHP linter | https://github.com/phan/phan | meta-oe, manual enable | x | | 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 | @@ -314,7 +313,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) - - [phan](docs/conf/module/phan.md) - [phpcodefixer](docs/conf/module/phpcodefixer.md) - [phpcodesniffer](docs/conf/module/phpcodesniffer.md) - [phpmd](docs/conf/module/phpmd.md) diff --git a/classes/sca-blacklist.bbclass b/classes/sca-blacklist.bbclass index dacdc603e0..9f06f8e248 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_phan ?= "" SCA_BLACKLIST_phpcodefixer ?= "" SCA_BLACKLIST_phpcodesniffer ?= "" SCA_BLACKLIST_phpmd ?= "" diff --git a/classes/sca-global.bbclass b/classes/sca-global.bbclass index 4f645fd864..f7e213ed99 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[phan] = "openembedded-layer" SCA_AVAILABLE_MODULES[phpcodefixer] = "openembedded-layer" SCA_AVAILABLE_MODULES[phpcodesniffer] = "openembedded-layer" SCA_AVAILABLE_MODULES[phpmd] = "openembedded-layer" diff --git a/classes/sca-on-recipe.bbclass b/classes/sca-on-recipe.bbclass index 9d67595ded..cd88afdf39 100755 --- a/classes/sca-on-recipe.bbclass +++ b/classes/sca-on-recipe.bbclass @@ -43,7 +43,6 @@ SCA_ENABLED_MODULES_RECIPE ?= "\ oelint \ perl \ perlcritic \ - phan \ phpcodefixer \ phpcodesniffer \ phpmd \ diff --git a/classes/sca-phan.bbclass b/classes/sca-phan.bbclass deleted file mode 100755 index f1a20caf06..0000000000 --- a/classes/sca-phan.bbclass +++ /dev/null @@ -1,122 +0,0 @@ -## SPDX-License-Identifier: BSD-2-Clause -## Copyright (c) 2019, Konrad Weihmann - -## Add ids to suppress on a recipe level -SCA_PHAN_EXTRA_SUPPRESS ?= "" -## Add ids to lead to a fatal on a recipe level -SCA_PHAN_EXTRA_FATAL ?= "" -SCA_PHAN_FILE_FILTER ?= ".php" - -SCA_RAW_RESULT_FILE[phan] = "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 - -PHP_EXTENSION = "ast" -inherit php-ext - -def do_sca_conv_phan(d): - import os - import json - - package_name = d.getVar("PN") - buildpath = d.getVar("SCA_SOURCES_DIR") - - _findings = [] - _suppress = sca_suppress_init(d, "SCA_PHAN_EXTRA_SUPPRESS", - d.expand("${STAGING_DATADIR_NATIVE}/phan-${SCA_MODE}-suppress")) - - _severity_map = { - "10": "error", - "9": "error", - "8": "error", - "7": "warning", - "6": "warning", - "5": "warning", - "4": "warning", - "3": "info", - "2": "info", - "1": "info", - "0": "info", - } - - if os.path.exists(sca_raw_result_file(d, "phan")): - content = [] - with open(sca_raw_result_file(d, "phan"), "r") as f: - try: - content = json.load(f) - except json.JSONDecodeError: - pass - for m in content: - try: - g = sca_get_model_class(d, - PackageName=package_name, - Tool="phan", - BuildPath=d.getVar("SCA_SOURCES_DIR"), - File=m["location"]["path"], - Line=str(m["location"]["lines"]["begin"]), - Message=m["description"], - ID=m["check_name"], - Severity=_severity_map[str(m["severity"])]) - 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) - -do_sca_phan[vardepsexclude] += "BB_NUMBER_THREADS" -python do_sca_phan() { - import os - import subprocess - - os.makedirs(os.path.join(d.getVar("T"), "phanout"), exist_ok=True) - ## Run - os.environ["PHP_INI_SCAN_DIR"] = os.path.dirname(d.getVar("PHP_INI_FILE")) - _args = [os.path.join(d.getVar("STAGING_BINDIR_NATIVE"), "phan/vendor/bin/phan")] - _args += ["--disable-cache"] - _args += ["-S"] - _args += ["-b"] - _args += ["-j", d.getVar("BB_NUMBER_THREADS")] - _args += ["-m=json"] - _args += ["-t"] - _args += ["-u"] - _args += ["-z"] - - _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, default_val=[]) - - with open(sca_raw_result_file(d, "phan"), "w") as o: - o.write(cmd_output) -} - -python do_sca_phan_report() { - import os - ## Create data model - d.setVar("SCA_DATAMODEL_STORAGE", "{}/phan.dm".format(d.getVar("T"))) - dm_output = do_sca_conv_phan(d) - with open(d.getVar("SCA_DATAMODEL_STORAGE"), "w") as o: - o.write(dm_output) - - sca_task_aftermath(d, "phan", get_fatal_entries(d, "SCA_PHAN_EXTRA_FATAL", - d.expand("${STAGING_DATADIR_NATIVE}/phan-${SCA_MODE}-fatal"))) -} - -do_sca_phan[doc] = "Lint php scripts with phan in workspace" -do_sca_phan_report[doc] = "Report findings of do_sca_phan" -addtask do_sca_phan after do_configure before do_sca_tracefiles -addtask do_sca_phan_report after do_sca_tracefiles before do_sca_deploy - -DEPENDS += "phan-native sca-recipe-phan-rules-native" diff --git a/docs/conf/module/phan.md b/docs/conf/module/phan.md deleted file mode 100644 index a97d21d10e..0000000000 --- a/docs/conf/module/phan.md +++ /dev/null @@ -1,61 +0,0 @@ -# Configuration for phan - -## Supported environments/languages - -* PHP - -## Configuration - -| var | purpose | type | default | -| ------------- |:-------------:| -----:| -----: -| SCA_BLACKLIST_phan | Blacklist filter for this tool | space-separated-list | "" -| SCA_PHAN_EXTRA_FATAL | Extra error-IDs leading to build termination when found | space-separated-list | "": -| SCA_PHAN_EXTRA_SUPPRESS | Extra error-IDs to be suppressed | space-separated-list | "" -| SCA_PHAN_FILE_FILTER | File extensions to check | space-separated-list | ".php" - -## 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 -* [ ] style issues - -## Statistics - -* ⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜ 04/10 Build Speed -* ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ 10/10 Execution Speed -* ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜ 09/10 Quality - -## Score mapping - -### Error considered as security relevant - -* n.a. - -### Error considered as functional defect - -* phan.phan.* - -### 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 a081536327..16c163fcd0 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, -phan,PHP linter,https://github.com/phan/phan,"meta-oe, manual enable",x,,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 diff --git a/recipes-sca-rules/sca-recipe-phan-rules-native/files/fatal b/recipes-sca-rules/sca-recipe-phan-rules-native/files/fatal deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-phan-rules-native/files/suppress b/recipes-sca-rules/sca-recipe-phan-rules-native/files/suppress deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-phan-rules-native/sca-recipe-phan-rules-native_1.0.bb b/recipes-sca-rules/sca-recipe-phan-rules-native/sca-recipe-phan-rules-native_1.0.bb deleted file mode 100755 index 52e98948c4..0000000000 --- a/recipes-sca-rules/sca-recipe-phan-rules-native/sca-recipe-phan-rules-native_1.0.bb +++ /dev/null @@ -1,19 +0,0 @@ -SUMMARY = "SCA ruleset for phan at recipes" -DESCRIPTION = "Rules to configure how phan 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}/phan-recipe-fatal" - install "${WORKDIR}/suppress" "${D}${datadir}/phan-recipe-suppress" -} - -FILES:${PN} = "${datadir}" diff --git a/recipes-sca/phan-native/files/phan.sca.description b/recipes-sca/phan-native/files/phan.sca.description deleted file mode 100644 index 923f431b7a..0000000000 --- a/recipes-sca/phan-native/files/phan.sca.description +++ /dev/null @@ -1,29 +0,0 @@ -{ - "buildspeed": 4, - "execspeed": 10, - "languages": [ - "php" - ], - "uses": [ - "@php" - ], - "quality": 8, - "scope": [ - "security", - "functional", - "style" - ], - "score": { - "style": [ - "phan.phan..*" - ] - }, - "test": { - "findings": [ - "bad-php" - ], - "no-findings": [ - "busybox" - ] - } -} \ No newline at end of file diff --git a/recipes-sca/phan-native/phan-native_5.3.2.bb b/recipes-sca/phan-native/phan-native_5.3.2.bb deleted file mode 100755 index a672c47fd4..0000000000 --- a/recipes-sca/phan-native/phan-native_5.3.2.bb +++ /dev/null @@ -1,28 +0,0 @@ -SUMMARY = "Phan is a static analyzer for PHP" -HOMEPAGE = "https://github.com/phan/phan" - -DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://LICENSE;md5=fbdcd3d0ec03d3c2e54b19846ad2b027" - -DEPENDS += "php-ast-native" - -SRC_URI = "git://github.com/phan/phan.git;protocol=https;branch=v5" -SRCREV = "b7697eb811e912c038f709f8e1c4911c7ada3edc" -PHP_EXTENSION += "ast" -PHPCOMPOSER_PKGS_NAME = "phan/phan:${PV}" - -S = "${WORKDIR}/git" - -inherit phpcomposer -inherit php-ext -inherit sca-description -inherit native - -SCA_TOOL_DESCRIPTION = "phan" - -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 d8914f9458..d216c1ec7e 100644 --- a/test/lang_metaoe.txt +++ b/test/lang_metaoe.txt @@ -1,4 +1,3 @@ -phan phpcodefixer phpcodesniffer phpmd