Skip to content

Commit

Permalink
Preference to not save payload data
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxudo committed Dec 18, 2023
1 parent cbe9260 commit 3d6ebd0
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 72 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ Reports on macOS mobile configuration profile information

Collects information about installed profiles by querying the `/usr/bin/profiles` command

### Profile Payload Data
By default the `profile` module uploads the profile's payload data as a JSON file to the MunkiReport server. In some cases this can result is very large file uploads or a very large `profile` database table.

To prevent the module from uploading the profile's payload, set the `profile_upload_payload` of the `MunkiReport` domain to `FALSE` using either a profile or the below command.

`defaults write /Library/Preferences/MunkiReport.plist profile_upload_payload -bool False`

Table Schema
-----

Expand Down
8 changes: 4 additions & 4 deletions migrations/2021_04_02_000001_profile_more_columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ public function up()
$table->index('profile_verification_state');
$table->index('user');
$table->index('profile_method');

});
}

public function down()
{
$capsule = new Capsule();
$capsule::schema()->table($this->tableName, function (Blueprint $table) {

// Remove nullable
$table->string('profile_uuid')->change();
$table->string('profile_name')->change();
$table->string('profile_removal_allowed')->change();
$table->string('payload_name')->change();
$table->string('payload_display')->change();
$table->text('payload_data')->change();

// Remove new columns
$table->dropColumn('profile_install_date');
$table->dropColumn('profile_organization');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function up()
$table->longText('payload_data')->nullable()->change();
});
}

public function down()
{
$capsule = new Capsule();
Expand Down
10 changes: 5 additions & 5 deletions profile_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function index()
echo "You've loaded the profile module!";
}

/**
/**
* Retrieve data in JSON for widget
*
**/
Expand All @@ -47,9 +47,9 @@ public function get_profile_groups()
}

jsonView($out);
}
}

/**
/**
* Retrieve data for payload data popovers
*
**/
Expand Down Expand Up @@ -81,10 +81,10 @@ public function get_payload_data($serial_number, $profile_uuid, $payload_name)
$json_string = str_replace(array('\\"', '"{', '}"','\''), '', $json_string);
$json_string = str_replace('{}', 'No Payload Data', $json_string);
$json_string = str_replace('null', 'No Payload Data', $json_string);
echo '<div style="white-space: pre-wrap">'. $json_string.'</div>';
echo '<div style="white-space: pre-wrap">'. $json_string.'</div>';
}

/**
/**
* Retrieve data in json format for client tab
*
**/
Expand Down
30 changes: 20 additions & 10 deletions scripts/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ def get_profiles_data(cachedir):
elif payload_item == 'PayloadDisplayName':
profile['payload_display'] = payload[payload_item]
elif payload_item == 'PayloadContent':
try:
profile['payload_data'] = json.dumps(payload[payload_item],indent=2,default=str)
except:
profile['payload_data'] = 'Error Saving Payload Data'
# Check if we are configured to save the payload data
if CFPreferencesCopyAppValue('profile_upload_payload', 'MunkiReport') == False:
profile['payload_data'] = 'No Payload Data'
else:
try:
profile['payload_data'] = json.dumps(payload[payload_item],indent=2,default=str)
except:
profile['payload_data'] = 'Error Saving Payload Data'

# Add profile to profile_data
profile_data.append(profile.copy())
Expand Down Expand Up @@ -153,12 +157,18 @@ def get_profiles_data(cachedir):
# Process profile payload items
for key in localProfilePlist[item]:
profile['payload_name'] = key
try:
profile['payload_data'] = json.dumps(localProfilePlist[item][key],indent=2,default=str)
except:
profile['payload_data'] = 'Error Saving Payload Data'
# Add profile to profile_data
profile_data.append(profile.copy())

# Check if we are configured to save the payload data
if CFPreferencesCopyAppValue('profile_upload_payload', 'MunkiReport') == False:
profile['payload_data'] = 'No Payload Data'
else:
try:
profile['payload_data'] = json.dumps(localProfilePlist[item][key],indent=2,default=str)
except:
profile['payload_data'] = 'Error Saving Payload Data'

# Add profile to profile_data
profile_data.append(profile.copy())

return profile_data

Expand Down
99 changes: 47 additions & 52 deletions views/profile_listing.php
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
<?php $this->view('partials/head'); ?>

<div class="container">
<div class="row">
<div class="col-lg-12">

<h3><span data-i18n="profile.report"></span> <span id="total-count" class='label label-primary'>…</span></h3>

<table class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th data-i18n="listing.computername" data-colname='machine.computer_name'></th>
<th data-i18n="serial" data-colname='reportdata.serial_number'></th>
<th data-i18n="profile.profilename" data-colname='profile.profile_name'></th>
<th data-i18n="profile.uuid" data-colname='profile.profile_uuid'></th>
<th data-i18n="profile.scope" data-colname='profile.user'></th>
<th data-i18n="profile.method" data-colname='profile.profile_method'></th>
<th data-i18n="profile.payload_type" data-colname='profile.payload_name'></th>
<th data-i18n="profile.payloadname" data-colname='profile.payload_display'></th>
<th data-i18n="profile.payload_data" data-colname='profile.timestamp'></th>
<th data-i18n="profile.profile_install_date" data-colname='profile.profile_install_date'></th>
<th data-i18n="profile.profile_organization" data-colname='profile.profile_organization'></th>
<th data-i18n="profile.profile_verification_state" data-colname='profile.profile_verification_state'></th>
<th data-i18n="profile.profile_description" data-colname='profile.profile_description'></th>
</tr>
</thead>

<tbody>
<tr>
<td data-i18n="listing.loading" colspan="13" class="dataTables_empty"></td>
</tr>
</tbody>
</table>
</div> <!-- /span 12 -->
</div> <!-- /row -->
<div class="row">
<div class="col-lg-12">
<h3><span data-i18n="profile.report"></span> <span id="total-count" class='label label-primary'>…</span></h3>
<table class="table table-striped table-condensed table-bordered">
<thead>
<tr>
<th data-i18n="listing.computername" data-colname='machine.computer_name'></th>
<th data-i18n="serial" data-colname='reportdata.serial_number'></th>
<th data-i18n="profile.profilename" data-colname='profile.profile_name'></th>
<th data-i18n="profile.uuid" data-colname='profile.profile_uuid'></th>
<th data-i18n="profile.scope" data-colname='profile.user'></th>
<th data-i18n="profile.method" data-colname='profile.profile_method'></th>
<th data-i18n="profile.payload_type" data-colname='profile.payload_name'></th>
<th data-i18n="profile.payloadname" data-colname='profile.payload_display'></th>
<th data-i18n="profile.payload_data" data-colname='profile.timestamp'></th>
<th data-i18n="profile.profile_install_date" data-colname='profile.profile_install_date'></th>
<th data-i18n="profile.profile_organization" data-colname='profile.profile_organization'></th>
<th data-i18n="profile.profile_verification_state" data-colname='profile.profile_verification_state'></th>
<th data-i18n="profile.profile_description" data-colname='profile.profile_description'></th>
</tr>
</thead>
<tbody>
<tr>
<td data-i18n="listing.loading" colspan="13" class="dataTables_empty"></td>
</tr>
</tbody>
</table>
</div> <!-- /span 12 -->
</div> <!-- /row -->
</div> <!-- /container -->

<script type="text/javascript">

$(document).on('appUpdate', function(e){
$(document).on('appUpdate', function(e){
var oTable = $('.table').DataTable();
oTable.ajax.reload();
return;
});

var oTable = $('.table').DataTable();
oTable.ajax.reload();
return;

});

$(document).on('appReady', function(e, lang) {
$(document).on('appReady', function(e, lang) {

// Get modifiers from data attribute
var mySort = [], // Initial sort
Expand All @@ -69,7 +64,7 @@
col++
});

oTable = $('.table').dataTable( {
oTable = $('.table').dataTable( {
ajax: {
url: appUrl + '/datatables/data',
type: "POST",
Expand All @@ -91,13 +86,13 @@
buttons: mr.dt.buttons,
order: mySort,
columnDefs: columnDefs,
createdRow: function( nRow, aData, iDataIndex ) {
// Update name in first column to link
var name=$('td:eq(0)', nRow).html();
if(name == ''){name = "No Name"};
var sn=$('td:eq(1)', nRow).html();
var link = mr.getClientDetailLink(name, sn, '#tab_profile-tab');
$('td:eq(0)', nRow).html(link);
createdRow: function( nRow, aData, iDataIndex ) {
// Update name in first column to link
var name=$('td:eq(0)', nRow).html();
if(name == ''){name = "No Name"};
var sn=$('td:eq(1)', nRow).html();
var link = mr.getClientDetailLink(name, sn, '#tab_profile-tab');
$('td:eq(0)', nRow).html(link);

// payload_display
var payload_display=$('td:eq(6)', nRow).text();
Expand All @@ -108,7 +103,7 @@
var profile_name=$('td:eq(2)', nRow).text();
var profile_uuid=$('td:eq(3)', nRow).text();
var payload_type=$('td:eq(6)', nRow).text();
$('td:eq(8)', nRow).html('<button onclick="view_payload_data(\''+sn+'\',\''+profile_uuid+'\',\''+payload_type+'\',\''+profile_name+'\')" class="btn btn-info btn-xs" style="min-width: 100px;" >'+i18n.t('profile.view')+'</button>')
$('td:eq(8)', nRow).html('<button onclick="view_payload_data(\''+sn+'\',\''+profile_uuid+'\',\''+payload_type+'\',\''+profile_name+'\')" class="btn btn-info btn-xs" style="min-width: 100px;" >'+i18n.t('profile.view')+'</button>')

// // profile_removal_allowed
// var removal_allowed=$('td:eq(9)', nRow).text();
Expand Down Expand Up @@ -136,9 +131,9 @@
verification_state = verification_state == 'not verified' ? i18n.t('profile.not_verified') :
(verification_state = verification_state == 'unsigned' ? i18n.t('profile.not_verified') : verification_state)
$('td:eq(11)', nRow).text(verification_state)
}
});
});
}
});
});

// Get payload data via API and display in modal
function view_payload_data(serial_number, profile_uuid, payload_type, profile_name){
Expand Down

0 comments on commit 3d6ebd0

Please sign in to comment.