check_id = $check_id; $this->status = $status; $this->detected_at = AOWPCS_Plugin::now(); } /** * Stable identity of the problem across scans (rule + affected subject) */ public function fingerprint() { return sha1($this->check_id . ':' . $this->subject); } /** * Hash of what was observed; an accepted risk is reopened when this changes */ public function evidence_hash() { return sha1(wp_json_encode(array($this->severity, $this->detected, $this->evidence))); } /** * Data stored with the finding (secrets removed) */ public function data() { return array( 'summary' => AOWPCS_Redactor::text($this->summary), 'detected' => is_array($this->detected) ? AOWPCS_Redactor::evidence($this->detected) : AOWPCS_Redactor::text((string) $this->detected), 'expected' => is_array($this->expected) ? AOWPCS_Redactor::evidence($this->expected) : AOWPCS_Redactor::text((string) $this->expected), 'evidence' => AOWPCS_Redactor::evidence($this->evidence), 'steps' => array_map(array('AOWPCS_Redactor', 'text'), (array) $this->steps), 'meta' => AOWPCS_Redactor::evidence($this->meta), 'detected_at' => $this->detected_at, ); } public function to_array() { return array_merge(array( 'check_id' => $this->check_id, 'category' => $this->category, 'status' => $this->status, 'severity' => $this->severity, 'kind' => $this->kind, 'confidence' => $this->confidence, 'subject' => $this->subject, 'title' => $this->title, 'fingerprint' => $this->fingerprint(), ), $this->data()); } }