EasyAudit as a repo
·
2 commits
to main
since this release
Added
- SpecificClassInjection —
statefulBuilderInjectionrule: flags direct constructor injection of stateful Magento framework builders (Magento\Framework\Api\FilterBuilder,Magento\Framework\Api\Search\FilterGroupBuilder,Magento\Framework\Api\SortOrderBuilder). Recommends the matching*Factory+create()per-method pattern.SearchCriteriaBuilderis intentionally excluded as the canonical public API. Severity: note. - Glossary system (
data/{lang}/glossary.json+src/Core/Glossary/GlossaryLoader): language-indexed concept definitions (term, Magento-contextualizedshortDefinition, optional links). Shipsenonly — unavailable languages fall back toen(GlossaryLoader::FALLBACK_LANGUAGE);LanguageNotAvailableExceptionis only thrown when the fallback itself is missing. The free repo emitsconceptsannotations on rule output but does not consume them in any reporter; sponsor reporters (MD, glossary HTML) pick them up via upstream sync. - Per-rule concept annotations on processors:
AbstractProcessorexposes aCONCEPTSconstant projected into the defaultgetReport().AroundPlugins,CountOnCollection,ProxyForHeavyClasses, andSpecificClassInjectionare annotated. Multi-rule processors emit per-rule slugs (viaRULE_CONFIGSentries or a per-ruleIdmap).tests/Unit/Core/Glossary/GlossaryIntegrityTestwalks every processor by reflection and asserts that every referenced slug exists indata/en/glossary.json. - Reporter configuration (
config/easyaudit.json+src/Service/Config.php): runtime registry mapping output format → reporter FQCN, plus adefaultFormatkey.Config::load()validates that each FQCN implementsReporterInterfaceand caches the result. PHAR build now bundles theconfig/directory (box.json). HtmlReporter::renderLongDescription(string $escapedText, array $rule): string: no-op extension hook that sponsor'sGlossaryHtmlReporteroverrides to inject autolinked concept tooltips into already-escaped paragraph text. The escape-then-inject ordering is mandatory.FixerInterface(src/Service/FixerInterface.php): backend abstraction for the fix pipeline.Apinow implements it;FixApplydepends on the interface instead of the concrete class.getRemainingCredits()may returnnullto signal that the active backend does not track credits —FixApplythen skips credit prompts, balance display, and the post-run cost summary. Enables local/offline fixers to plug in without touchingFixApply.- Configurable command registry and fixer in
bin/easyaudit: command list and fixer FQCN are now read fromConfig::load()(commandsandfixerkeys), with the same built-in defaults as before. Sponsor overlays can register additional commands or swap the fixer backend without forking the entry point. - Composer-aware autoloader in
bin/easyaudit: prefersvendor/autoload.phpwhen installed as a Composer dependency (vendor/crealoz/easyaudit-cli/bin/easyaudit) or from a source checkout. Falls back to the hand-rolled PSR-4 loader for the PHAR build, where Composer'svendor/is not bundled. Combined with thecomposer.jsonchanges, this allows installing the CLI ascomposer require crealoz/easyaudit-cli. Scanner::getMode()/Scanner::setMode(?string): scan-mode signal that commands set before callingScanner::run(). Processors can read it to tune behavior for a specific feature (e.g. amplifying severity on checkout-critical files in acheckout-auditrun).nullis the default, general-purpose scan.Paths::cacheDir(string $subdir = ''): XDG_CACHE_HOME-aware cache directory helper. Resolves to$XDG_CACHE_HOME/easyaudit(falling back to$HOME/.cache/easyaudit, then the system temp dir), creates the optional sub-directory on first use with mode0700, and throwsRuntimeExceptionon failure.- SARIF multi-location findings:
SarifReporternow splits a finding whosefilefield contains comma-separatedpath:linesegments into one SARIF location per segment. The outerstartLineis0in that case and each segment carries its own line. Used byAroundPlugins::deepPluginStackso SARIF consumers see one location per plugin di.xml declaration. AbstractPreparer::getMappedRule(): reintroduced as aprotectedhelper returning the mapped rule name for a given ruleId. Was removed in 1.2.0 as unused; now used by the fixer code path.
Changed
Scancommand — reporter dispatch is now config-driven: the hardcodedmatch($format)overJsonReporter|SarifReporter|HtmlReporteris replaced bynew $class()against theconfig/easyaudit.jsonmap. Allowed--formatvalues, the default format, and--helptext are all derived from the loaded config. Adding a new reporter is now a one-line edit toconfig/easyaudit.json— no change toScan.phpor any other core file is required. This is also the extension point sponsor builds use to swap inGlossaryHtmlReporter/ registerMdReporterwithout forkingScan.php.composer.json— package metadata for distribution:typechanged fromprojecttolibrary,licensechanged fromproprietaryto MIT, and abinentry (bin/easyaudit) was added. The CLI can now be installed as a Composer dependency and exposes theeasyauditexecutable viavendor/bin/easyaudit.AroundPlugins::deepPluginStack— per-plugin di.xml locations with line numbers: previously the finding pointed at the first di.xml file withline: 1. It now emits the full list of di.xml declarations that participate in the stack — every<plugin>node on the target across global/frontend/adminhtml scopes — encoded as comma-separateddiFile:lineNosegments. The message format also tightened from… — plugins: …to… Plugins: ….PluginRegistry— DOM-based parsing: rewritten fromSimpleXMLElementtoDOMDocument/DOMXPathso each<plugin>entry now carries its sourceline(getLineNo()). The plugin entry shape gained a requiredline: intfield. Only direct<plugin>children of each<type>are collected (xpath was already constrained, but the DOM walk makes it explicit).FixApply— credit-aware UX is now optional:$creditsRemainingis nullable; when the active fixer returnsnullfromgetRemainingCredits(), credit prompts, the "Credits remaining" line, and the real-cost summary are all suppressed.checkCreditsAndConfirm()return type is nowint|false|null. ThetotalFilescount is computed beforecalculateCost()so cost estimation sees the correct total.HtmlReporter— line column for multi-location findings: whenstartLineis0(multi-location finding such asdeepPluginStack), the Line cell now renders—instead of a misleading0. Long-description rendering also receives the rule array so therenderLongDescriptionextension hook has the concept slugs.Api::getRemainingCredits()return type tightened: now declared?arrayto match theFixerInterfacecontract. Docblocks onrequestFilefix,getRemainingCredits, andgetAllowedTypewere aligned with the interface'sarray{…}shapes.docs/processors.md: rule count updated from 37 to 38;SpecificClassInjectionseverity row gainsNotefor the new builder rule.psalm.xmlissue handlers:UnusedClasssuppression extended tosrc/Core/Report/andsrc/Core/Glossary/(reporter and glossary classes are resolved by FQCN strings);PossiblyUnusedMethodsuppression extended tosrc/Core/Report/,src/Service/Config.php, andsrc/Service/Paths.php.
Full Changelog: v1.2.0...v1.3.0