pw-module-filevalidator
Use when deploying discrete file validation architectures inside ProcessWire assessing security and normalization workflows via FileValidator.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when deploying discrete file validation architectures inside ProcessWire assessing security and normalization workflows via FileValidator.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when building, structuring, or refactoring native backend modules for ProcessWire using PHP 8.4 and strict typing.
Use when designing, structuring, or rendering HTML for ProcessWire Admin interfaces, custom Process modules, or Inputfields.
Use when brainstorming or designing ProcessWire modules, templates, field schemas, or hooks to resolve ambiguity and validate architecture before implementation.
Use when creating, executing, or managing Pest tests within ProcessWire or ProcessWire modules, including Test-Driven Development (TDD) tasks.
Use when encountering any bug, test failure, blank screen of death, or unexpected behavior in ProcessWire before proposing fixes.
Use when creating or updating module documentation, package READMEs, architecture guides, or CLI command references for ProcessWire projects.
| name | pw-module-filevalidator |
| description | Use when deploying discrete file validation architectures inside ProcessWire assessing security and normalization workflows via FileValidator. |
| risk | safe |
| source | processwire-boost |
| date_added | 2026-04-08 |
ProcessWire 3.x explicitly enables security filtering extending entirely separate validation architectures bound to file upload protocols called FileValidators. When any admin or form uploads an asset into InputfieldFile / InputfieldImage classes, a series of linked validation classes sequentially processes the raw files rejecting improper MIME types, checking dimensional scales, validating extension properties, and forcefully mitigating payload injection vulnerabilities directly at the source.
Audit the configuration variables verifying system validation logic mapping structurally against these constraints:
public function isValid().WireException classes securely informing the admin layer of specific failure points efficiently?A core validator maps immediately into the functional layer intercepting the process payload via the native FileValidator structure (often extending standard WireData mapping Module requirements explicitly).
<?php
declare(strict_types=1);
namespace ProcessWire;
/**
* File Validator protecting internal resources mapping explicit CSV properties structurally against specific syntax integrity failures.
*/
class FileValidatorCSV extends WireData implements Module
{
public static function getModuleInfo(): array
{
return [
'title' => 'FileValidator: CSV Security Scanner',
'version' => 101,
'summary' => 'Scans CSV files during upload executing validations guarding against potential embedded payload commands blocking explicitly malicious executions natively.',
'requires' => [
'ProcessWire>=3.0.0',
'PHP>=8.4.0'
]
];
}
/**
* Automated Hook Deployment intercepting universally configuring active upload parameters logically.
*/
public function init(): void
{
$this->addHookAfter('InputfieldFile::fileAdded', $this, 'hookValidateCSV');
}
/**
* Processes execution assessing physical file states blocking vulnerabilities successfully.
*
* @param HookEvent $event Resolving active event dispatch arrays.
*/
protected function hookValidateCSV(HookEvent $event): void
{
$pagefile = $event->arguments(0);
// Escape immediately ignoring configurations unrelated to target extensions
if (strtolower($pagefile->ext()) !== 'csv') {
return;
}
$filename = $pagefile->filename();
// Execute operational file checks independently generating validations
if (!$this->isValid($filename)) {
// Unlink explicitly deleting compromised items ensuring zero persistence inherently
@unlink($filename);
// Abort upload processes mapping explicit failures natively
$event->replace = true;
$event->return = false;
// Log issues mapping specific vulnerabilities targeting isolated investigations
$this->wire()->log->error("Blocked compromised CSV payload upload operation targeting file: " . $pagefile->name());
throw new WireException($this->_('Upload Rejected: The CSV file violates specific internal macro constraints. Payload operation aborted safely.'));
}
}
/**
* Executes discrete specific macro validation matrices mapping functional checks automatically.
*
* @param string $filename Native temporary path mapping active upload evaluation context securely.
* @return bool
*/
public function isValid(string $filename): bool
{
if (!file_exists($filename)) {
return false;
}
$content = file_get_contents($filename);
// Inspecting commonly abused spreadsheet formula vectors preventing code executions natively
if (preg_match('/^[\=\+\-\@]/m', $content)) {
return false;
}
return true;
}
}
Certain explicit capabilities provided internally by ProcessWire bypass basic Hooks explicitly configuring direct assignments dynamically resolving module evaluations against distinct UI frameworks securely evaluating explicit configurations natively relying internally upon explicitly provided array validations directly.
Modifying behaviors exclusively inside defined modules limits broad global scope interruptions dynamically configuring specific elements safely. Avoid attaching universally triggering Hooks against InputfieldFile indiscriminately unless specifically demanded; apply evaluations isolated actively depending upon distinct requirements directly mapping localized executions securely.
$pagefile->filename() elements definitively testing against localized disk persistence environments.WireException mapping exact errors resolving clearly onto localized active form notifications natively.(Pass these direct prompts to the agent to initiate workflows instantly)
[Deploy Operational Sanitizing Logic Scanner]
"Build an encapsulated module designated
FileValidatorPDFAttributesactively configuring functionalInputfieldFile::fileAddedprocesses enforcing hook interceptions securely isolating specificWireException."
CRITICAL RULE FOR ALL AI AGENTS: When you need to understand, use, or hook into a ProcessWire core class or module, you MUST NEVER guess or hallucinate the API methods.
.agents/docs/index.md..agents/docs/core/Page.md), and use your file reading tools to read its methods, parameters, and hookable (🪝) events before writing any code.