Skip to content

Commit

Permalink
Merge pull request #13667 from snipe/bug/sc-23771
Browse files Browse the repository at this point in the history
Fixed #13658 for asset history with encrypted fields
  • Loading branch information
snipe authored Sep 28, 2023
2 parents 048ad57 + ee72c92 commit cc4cb14
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions app/Http/Transformers/ActionlogsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ private function clean_field($value)
public function transformActionlog (Actionlog $actionlog, $settings = null)
{
$icon = $actionlog->present()->icon();
$custom_field = CustomField::all();
$custom_fields = CustomField::all();

if ($actionlog->filename!='') {
$icon = e(\App\Helpers\Helper::filetype_icon($actionlog->filename));
$icon = Helper::filetype_icon($actionlog->filename);
}

// This is necessary since we can't escape special characters within a JSON object
Expand All @@ -55,17 +56,29 @@ public function transformActionlog (Actionlog $actionlog, $settings = null)
$clean_meta = [];

if ($meta_array) {

foreach ($meta_array as $fieldname => $fieldata) {
if( str_starts_with($fieldname, '_snipeit_')){
if( $custom_field->where('db_column', '=', $fieldname)->where('field_encrypted', true)){
$clean_meta[$fieldname]['old'] = "encrypted";
$clean_meta[$fieldname]['new'] = "encrypted";

$clean_meta[$fieldname]['old'] = $this->clean_field($fieldata->old);
$clean_meta[$fieldname]['new'] = $this->clean_field($fieldata->new);

// this is a custom field
if (str_starts_with($fieldname, '_snipeit_')) {

foreach ($custom_fields as $custom_field) {

if ($custom_field->db_column == $fieldname) {

if ($custom_field->field_encrypted == '1') {
$clean_meta[$fieldname]['old'] = "************";
$clean_meta[$fieldname]['new'] = "************";
}

}

}
}
else {
$clean_meta[$fieldname]['old'] = $this->clean_field($fieldata->old);
$clean_meta[$fieldname]['new'] = $this->clean_field($fieldata->new);
}

}

}
Expand Down

0 comments on commit cc4cb14

Please sign in to comment.